Skip to content

Commit

Permalink
v0.3.2 backportapalooza (#170)
Browse files Browse the repository at this point in the history
* Some clean ups, fixes, config flag (#91)

* Refactor: Remove unneccesary CLI branching

* Refactor: Refactor configuration load function

* Feat: Add '--config' flag

* Refactor: Reduce passing of args and configuration

* Fix: Fix cli parsing of page width

* Clean: use 'display()' instead of debug print for path

* Clean: use Default for Keybindings

* Refactor: Use Keybindings in tests

* Doc: Fix 'page width' to 'page_width'

* Refactor: use interpolation style

* Refactor: Remove inline on Keybindings::new

* Refactor: Extract Keybindings Default implementation

* Refactor: Destructure Config and Args in opts

* Support bare relative links (#103)

* Attempt to reregister file watcher on file "removal" (#106)

* Add a test for all CLI options (#116)

* Add repology badge for package manager installation (#109)

* Make correct location of `inlyne.toml` file clearer (#122)

* Make correct location of `inlyne.toml` file clearer

* Fix missing backtick

* Interpreter testing (#132)

* Interpreter test tweaks (#138)

* Cleanup existing custom debug impls

* Add custom debug impls for `Element::Image(_)`

* Add a snapshot test for complex image elements

* More robust file watching (#147)

* The watcher should attempt to re-register on name changes

* Re-register watcher after longer delays

* Add a reminder for fixing watching after file changes

* Move file watcher into its own file

* Make file watcher testable

* Watcher follows file changes

* Test the file watcher

* Final test tweaks

* Swap back to the old delays

* Final final test tweaks

* Use a slightly longer delay

* Shorter poll interval for file watcher

* Follow through with rename

* Make file reloading less panic happy (#145)

* Rework panic happy file reloading

* Tweak logs

* The watcher should attempt to re-register on name changes

* Re-register watcher after longer delays

* Improve syntax highlighting (#150)

* Add failing test

* Use extended syntax definitions

* Add failing test

* Allow for comma as an info string delimiter

* Retry watcher test with increased delays (#155)

* Fix-up nested lists (#154)

* Add failing tests

* Handle nesting of lists

* Cleanup list prefix handling

* Dogfood new `smart-debug` crate (#156)

* Dont ignore locked mutex in debug impl (#166)

* fix: add missing `fontdb` feature flag (#169)

This solves an issue with the NixOS build where fonts are required at
runtime for inlyne to start. With the `fontconfig` feature flag inlyne
will use font-config to determine a font.

Partially resolves #164

* Add relevant keywords to `Cargo.toml` (#171)

* Use `human-panic` for a custom panic hook (#172)

* Use `human-panic` for a custom panic hook

* Indicate that the version is a "git release"

* `cargo upgragde`

* Update `two-face`

* `cargo update`

* Update simple dependencies

* Update `smart-debug`

* Update `resvg` & co.

* Update `rust-version` to v1.70.0

* Bump version to v0.3.2

---------

Co-authored-by: Gijs Burghoorn <g.burghoorn@gmail.com>
Co-authored-by: Nico Burns <nico@nicoburns.com>
Co-authored-by: AlphaKeks <85143381+AlphaKeks@users.noreply.github.com>
  • Loading branch information
4 people committed Nov 23, 2023
1 parent 8f55507 commit 32b71c1
Show file tree
Hide file tree
Showing 30 changed files with 3,349 additions and 1,163 deletions.
2,467 changes: 1,648 additions & 819 deletions Cargo.lock

Large diffs are not rendered by default.

63 changes: 36 additions & 27 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,54 +1,63 @@
[package]
name = "inlyne"
version = "0.3.1"
version = "0.3.2"
description = "Introducing Inlyne, a GPU powered yet browserless tool to help you quickly view markdown files in the blink of an eye."
edition = "2021"
authors = ["trimental"]
license = "MIT"
readme = "README.md"
repository = "https://github.com/trimental/inlyne"
homepage = "https://github.com/trimental/inlyne"
rust-version = "1.70"
keywords = ["markdown", "viewer", "gpu"]

[dependencies]
wgpu_glyph = "0.20"
winit = "0.28.5"
wgpu = "0.16"
bytemuck = "1.13.1"
wgpu_glyph = "0.21"
winit = "0.28.7"
wgpu = "0.17"
bytemuck = "1.14.0"
lyon = "1.0.1"
comrak = { version = "0.18.0", default-features = false, features = ["syntect"] }
open = "4.1.0"
comrak = { version = "0.19.0", default-features = false, features = ["syntect"] }
open = "5.0.1"
html5ever = "0.26.0"
image = "0.24.6"
clap = { version = "4.2.7", features = ["cargo"] }
copypasta = "0.8.2"
resvg = "0.32.0"
usvg = "0.32.0"
tiny-skia = "0.9.0"
anyhow = "1.0.71"
image = "0.24.7"
clap = { version = "4.3.24", features = ["cargo"] }
copypasta = "0.10.0"
resvg = "0.36"
usvg = "0.36"
tiny-skia = "0.11"
anyhow = "1.0.75"
dirs = "5.0.1"
serde = { version = "1.0.162", features = ["derive"] }
toml = "0.7.3"
reqwest = { version = "0.11.17", features = ["blocking", "json", "stream"] }
serde = { version = "1.0.193", features = ["derive"] }
toml = "0.7.6"
reqwest = { version = "0.11.22", features = ["blocking", "json", "stream"] }
font-kit = "0.11.0"
memmap2 = "0.5.10"
log = "0.4.17"
env_logger = "0.10.0"
notify = "5.1.0"
clap_complete = "4.2.1"
memmap2 = "0.9.0"
log = "0.4.20"
env_logger = "0.10.1"
notify = "6.1.1"
clap_complete = "4.3.2"
dark-light = "1.0.0"
# We only decompress our own compressed data, so disable `safe-decode` and
# `checked-decode`
lz4_flex = { version = "0.10.0", default-features = false, features = ["frame", "safe-encode", "std"] }
lz4_flex = { version = "0.11.1", default-features = false, features = ["frame", "safe-encode", "std"] }
pollster = "0.3.0"
smart-debug = "0.0.3"
syntect = "5.1.0"
two-face = "0.3.0"

# Uncomment for profiling
# [profile.release]
# debug = true
# Required for WGPU to work properly with Vulkan
fontdb = { version = "0.16.0", features = ["fontconfig"] }
human-panic = "1.2.2"

[profile.release-lto]
inherits = "release"
strip = true
lto = true

[dev-dependencies]
pretty_assertions = "1.3.0"
filetime = "0.2.22"
insta = "1.34.0"
pretty_assertions = "1.4.0"
tempfile = "3.8.1"
wiremock = "0.5.21"
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ view markdown files in the blink of an eye.
## Install

To install just use `cargo install inlyne`, everything comes pre-bundled.
Alternatively you can install through various package managers.

[![Packaging status](https://repology.org/badge/vertical-allrepos/inlyne.svg)](https://repology.org/project/inlyne/versions)

## Features

Expand Down Expand Up @@ -90,7 +93,13 @@ You weren't supposed to see this!

## Configuration

Use `inlyne --help` to see all the command line options. Some of which can be set permentantly by placing an `inlyne.toml` file into the default [dirs](https://crates.io/crates/dirs) configuration folder for your respective OS. Checkout `inlyne.toml.sample` for an example configuration.
Use `inlyne --help` to see all the command line options. Some of which can be set permentantly by placing an `inlyne.toml` file into a directory called `inlyne` within the default [dirs](https://crates.io/crates/dirs) configuration folder for your respective OS:

- Linux: `/home/alice/.config/inlyne/inlyne.toml`
- Windows: `C:\Users\Alice\AppData\Roaming\inlyne\inlyne.toml`
- Mac: `/Users/Alice/Library/Application Support/inlyne/inlyne.toml`

Checkout `inlyne.toml.sample` for an example configuration.

## FAQ

Expand Down
176 changes: 176 additions & 0 deletions src/debug_impls.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
//! A whole load of custom debug impls to keep the output more succinct
//!
//! Mostly to reduce noise for snapshot tests, but also good in general

use std::fmt;

use crate::{positioner::Spacer, text::Text};

pub struct DebugInlineMaybeF32Color<'a>(pub &'a Option<[f32; 4]>);

impl fmt::Debug for DebugInlineMaybeF32Color<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self.0 {
None => f.write_str("None"),
Some(rgba) => f.write_fmt(format_args!("Some({:?})", DebugF32Color(*rgba))),
}
}
}

pub struct DebugF32Color(pub [f32; 4]);

impl fmt::Debug for DebugF32Color {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if self.0 == [0.0, 0.0, 0.0, 1.0] {
f.write_str("Color(BLACK)")
} else {
let Self([r, g, b, a]) = self;

if *a == 1.0 {
f.write_fmt(format_args!("Color {{ r: {r:.2}, g: {g:.2}, b: {b:.2} }}"))
} else {
f.write_fmt(format_args!(
"Color {{ r: {r:.2}, g: {g:.2}, b: {b:.2}, a: {a:.2} }}"
))
}
}
}
}

pub struct DebugInline<'inner, T>(pub &'inner T);

impl<T: fmt::Debug> fmt::Debug for DebugInline<'_, T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_fmt(format_args!("{:?}", self.0))
}
}

fn debug_inline_some<T: fmt::Debug>(
debug: &mut fmt::DebugStruct<'_, '_>,
name: &'static str,
maybe_t: &Option<T>,
) {
if maybe_t.is_some() {
debug.field(name, &DebugInline(maybe_t));
}
}

pub struct DebugBytesPrefix<'a>(pub &'a [u8]);

impl<'a> fmt::Debug for DebugBytesPrefix<'a> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self.0 {
[x, y, z, _, ..] => {
let len = self.0.len();
f.write_fmt(format_args!("{{ len: {len}, data: [{x}, {y}, {z}, ..] }}"))
}
three_or_less => f.write_fmt(format_args!("{three_or_less:?}")),
}
}
}

pub fn text(text: &Text, f: &mut fmt::Formatter<'_>) -> fmt::Result {
#[derive(Copy, Clone)]
struct StyleWrapper {
is_bold: bool,
is_italic: bool,
is_underlined: bool,
is_striked: bool,
}

impl StyleWrapper {
fn is_regular(self) -> bool {
let Self {
is_bold,
is_italic,
is_underlined,
is_striked,
} = self;

![is_bold, is_italic, is_underlined, is_striked].contains(&true)
}
}

impl fmt::Debug for StyleWrapper {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let Self {
is_bold,
is_italic,
is_underlined,
is_striked,
} = *self;

if self.is_regular() {
f.write_str("REGULAR")?;
} else {
if is_bold {
f.write_str("BOLD ")?;
}
if is_italic {
f.write_str("ITALIC ")?;
}
if is_underlined {
f.write_str("UNDERLINED ")?;
}
if is_striked {
f.write_str("STRIKED ")?;
}
}

Ok(())
}
}

let Text {
text,
size,
color,
link,
is_bold,
is_italic,
is_underlined,
is_striked,
font: _,
// Globally consistent so avoid displaying as noise
hidpi_scale: _,
default_color,
} = text;

let mut debug = f.debug_struct("Text");

// Fields that we will always display
debug.field("text", text);

// Fields that we only display when set to unique values
if *size != 16.0 {
debug.field("size", size);
}
if color.is_none() {
debug.field("default_color", &DebugF32Color(*default_color));
} else {
let color = color.map(DebugF32Color);
debug.field("color", &DebugInline(&color));
}
let style = StyleWrapper {
is_bold: *is_bold,
is_italic: *is_italic,
is_underlined: *is_underlined,
is_striked: *is_striked,
};
if !style.is_regular() {
debug.field("style", &style);
}
debug_inline_some(&mut debug, "link", link);

debug.finish_non_exhaustive()
}

pub fn spacer(spacer: &Spacer, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let Spacer { space, visible } = spacer;

if *visible {
f.write_fmt(format_args!("VisibleSpacer({space})"))
} else {
f.write_fmt(format_args!("InvisibleSpacer({space})"))
}
}
Loading

0 comments on commit 32b71c1

Please sign in to comment.