Compare commits

..

9 Commits

Author SHA1 Message Date
itsjunetime 15b1a99d76 Add changelog entry 2025-11-06 19:23:39 -06:00
itsjunetime 170bdd3869 Fix weird cropping when zooming out too much with kitty 2025-11-06 19:22:52 -06:00
June 7551c4dba3 Update deps and fmt (#110) 2025-11-06 18:50:19 -06:00
itsjunetime e61eb9b846 Fix r_to_l argument as well to just be a flag 2025-11-06 18:21:18 -06:00
tatounee 6b37976357 Made flags -f, --fullscreen not taking argument (#109)
Now, its presence alone is enough to activate the full-screen option.
2025-11-06 18:18:57 -06:00
June 3628d21c74 Switch to stable base64 simd library (#105) 2025-09-29 17:00:29 -05:00
itsjunetime f4f3b4f539 Actually update package Cargo.toml ugh 2025-09-15 10:05:20 -05:00
itsjunetime a79c534e97 Actually mark release on CHANGELOG 2025-09-07 20:33:43 -05:00
June 971393892a v0.4.3 release 2025-09-07 20:32:16 -05:00
8 changed files with 462 additions and 575 deletions
+6
View File
@@ -1,5 +1,11 @@
# Unreleased
- Switched simd base64 crate for one that works on stable (from `vb64` to `base64_simd`)
- Allow boolean arguments to function as flags, without a `true` or `false` argument following the flag itself
- Fix cropping issues when zooming out too much while using kitty protocol
# v0.4.3
- Fix issue with some terminals hanging on startup
- Fix issues with some iterm2-backend terminals not displaying anything
- Allow using ctrl+scroll to zoom in/out while zoomed using kitty backend
Generated
+422 -542
View File
File diff suppressed because it is too large Load Diff
+4 -5
View File
@@ -1,6 +1,6 @@
[package]
name = "tdf-viewer"
version = "0.4.2"
version = "0.4.3"
authors = ["June Welker <junewelker@gmail.com>"]
edition = "2024"
description = "A terminal viewer for PDFs"
@@ -49,7 +49,7 @@ log = "0.4.27"
flexi_logger = "0.31"
# for tracing with tokio-console
console-subscriber = { version = "0.4.0", optional = true }
console-subscriber = { version = "0.5.0", optional = true }
csscolorparser = { version = "0.7.0" }
[profile.production]
@@ -57,8 +57,7 @@ inherits = "release"
lto = "fat"
[features]
default = ["nightly"]
nightly = ["ratatui-image/vb64"]
default = []
tracing = ["tokio/tracing", "dep:console-subscriber"]
epub = ["mupdf/epub"]
cbz = ["mupdf/cbz"]
@@ -93,7 +92,7 @@ checked_conversions = "warn"
copy_iterator = "warn"
default_trait_access = "warn"
doc_link_with_quotes = "warn"
empty_enum = "warn"
empty_enums = "warn"
explicit_into_iter_loop = "warn"
explicit_iter_loop = "warn"
filter_map_next = "warn"
+4 -2
View File
@@ -16,7 +16,9 @@ Designed to be performant, very responsive, and work well with even very large P
## Installation
1. Get the rust toolchain from [rustup.rs](https://rustup.rs)
2. Run `rustup install nightly && cargo +nightly install --git https://github.com/itsjunetime/tdf.git`
2. Run `cargo install --git https://github.com/itsjunetime/tdf.git`
If you want to use this with `epub`s or `cbz`s, add `--features epub` or `--features cbz` to the command line (or `--features cbz,epub` for both)
## To Build
First, you need to install the system dependencies. This will generally only include `libfontconfig` and `clang`. If you're on linux, these will probably show up in your package manager as something like `libfontconfig1-devel` or `libfontconfig-dev` and just `clang`.
@@ -25,7 +27,7 @@ If it turns out that you're missing one of these, it will fail to compile and te
1. Get the rust toolchain from [rustup.rs](https://rustup.rs)
2. Clone the repo and `cd` into it
3. Run `cargo +nightly build --release`
3. Run `cargo build --release`
The binary should then be found at `./target/release/tdf`.
+1 -1
Submodule ratatui updated: 47c200fb7f...6a0b8ddf76
+4 -9
View File
@@ -83,11 +83,11 @@ async fn inner_main() -> Result<(), WrappedErr> {
let flags = xflags::parse_or_exit! {
/// Display the pdf with the pages starting at the right hand size and moving left and
/// adjust input keys to match
optional -r,--r-to-l r_to_l: bool
optional -r,--r-to-l
/// The maximum number of pages to display together, horizontally, at a time
optional -m,--max-wide max_wide: NonZeroUsize
/// Fullscreen the pdf (hide document name, page count, etc)
optional -f,--fullscreen fullscreen: bool
optional -f,--fullscreen
/// The number of pages to prerender surrounding the currently-shown page; 0 means no
/// limit. By default, there is no limit.
optional -p,--prerender prerender: usize
@@ -267,12 +267,7 @@ async fn inner_main() -> Result<(), WrappedErr> {
|| "Unknown file".into(),
|n| n.to_string_lossy().to_string()
);
let tui = Tui::new(
file_name,
flags.max_wide,
flags.r_to_l.unwrap_or_default(),
is_kitty
);
let tui = Tui::new(file_name, flags.max_wide, flags.r_to_l, is_kitty);
let backend = CrosstermBackend::new(std::io::stdout());
let mut term = Terminal::new(backend).map_err(|e| {
@@ -300,7 +295,7 @@ async fn inner_main() -> Result<(), WrappedErr> {
})?;
}
let fullscreen = flags.fullscreen.unwrap_or_default();
let fullscreen = flags.fullscreen;
let main_area = Tui::main_layout(&term.get_frame(), fullscreen);
to_renderer
.send(RenderNotif::Area(main_area.page_area))
+20 -15
View File
@@ -205,23 +205,28 @@ impl Tui {
log::debug!("zoom is now {zoom:#?}");
log::debug!("img_area is {img_area:#?}");
log::debug!("img dimensions are {cell_w}x{cell_h}");
if zoom.level < 0 {
img_area = Rect {
width: img_area
.width
.saturating_sub((zoom.level * 2).unsigned_abs())
.max(1),
x: img_area.x + (zoom.level.unsigned_abs().min(img_area.width / 2)),
..img_area
}
}
log::debug!("after adjustment, img_area is {img_area:#?}");
// Ugh I don't like this logic. I wish we could simplify it.
let img_width = f32::from(cell_w);
let img_height = f32::from(cell_h);
let img_aspect_ratio = img_width / img_height;
if zoom.level < 0 {
let old_width = img_area.width;
img_area.width = img_area
.width
.saturating_sub((zoom.level * 2).unsigned_abs())
.max((f32::from(img_area.height) * img_aspect_ratio) as u16);
img_area.x += (old_width - img_area.width) / 2;
log::debug!("after adjustment, img_area is {img_area:#?}");
// TODO: Find a way to detect when we've hit the maximum zoom-out and stop
// more zooming out
}
// Ugh I don't like this logic. I wish we could simplify it.
let img_area_width = f32::from(img_area.width);
let img_area_height = f32::from(img_area.height);
let available_to_real_width_ratio = img_area_width / img_width;
@@ -787,7 +792,7 @@ impl Tui {
}
}
// I want this to always return 0 'cause I just use it to return from `Self::handle_event`]
// I want this to always return an option 'cause I just use it to return from `Self::handle_event`
#[expect(clippy::unnecessary_wraps)]
fn update_zoom(&mut self, f: impl FnOnce(&mut Zoom)) -> Option<InputAction> {
if let Some(z) = &mut self.zoom {