Compare commits

..

22 Commits

Author SHA1 Message Date
itsjunetime dcc3dbc958 Small fixes to avoid panic and allow zooming back in after zooming out 2025-08-06 09:28:29 -06:00
itsjunetime 196f7fb589 fmt 2025-08-06 09:22:15 -06:00
itsjunetime 1c797d4653 Switch around list of items on changelog 2025-08-06 09:22:15 -06:00
itsjunetime 16ac61dc8e Update deps 2025-08-06 09:22:15 -06:00
itsjunetime 05bfee148c mmmm maybe it's finally ready to merge... 2025-08-06 09:22:15 -06:00
itsjunetime b368f8d41d yaaaay zooming out once you're already zoomed in and respecting kitty's limits for how big of an image to display 2025-08-06 09:22:15 -06:00
itsjunetime 484d248e26 Add debug logging and fix cursor placement after image display 2025-08-06 09:22:15 -06:00
itsjunetime da8cdd1fbd Only allow zooming in kitty 2025-08-06 09:22:15 -06:00
itsjunetime 02b447a98e clean up top and bottom rendering 2025-08-06 09:22:15 -06:00
itsjunetime 0578fccfa6 yay zooming woohoo 2025-08-06 09:22:15 -06:00
itsjunetime a67ff7996c zooming basically does what you'd expect now 2025-08-06 09:22:15 -06:00
itsjunetime a56fa8c817 Make help page work again 2025-08-06 09:22:15 -06:00
itsjunetime fc063efd42 fall back to stdout if shms don't work 2025-08-06 09:22:15 -06:00
itsjunetime 62c92141e3 Make it work correctly with ghostty image eviction too 2025-08-06 09:22:15 -06:00
itsjunetime 5e6857881b incorporate recovering from deleted images 2025-08-06 09:22:15 -06:00
itsjunetime 7514488441 Remove logging 2025-08-06 09:22:15 -06:00
itsjunetime 6677266010 Uhhhh various improvements from kittage and psx-shm 2025-08-06 09:22:15 -06:00
itsjunetime b791b55b80 Use github kittage 2025-08-06 09:22:15 -06:00
itsjunetime fcea5ac696 yaaayyyy it works 2025-08-06 09:22:15 -06:00
itsjunetime 4bde532d08 it almost basically works 2025-08-06 09:22:15 -06:00
itsjunetime 4d764cd4f9 it's almost working !! 2025-08-06 09:22:15 -06:00
itsjunetime b09ce88d9f Initial attempt at supporting new backend for kitty images 2025-08-06 09:22:15 -06:00
7 changed files with 26 additions and 53 deletions
-11
View File
@@ -1,16 +1,5 @@
# Unreleased
# v0.4.2
- Add `--version` flag
- Fix shms not working on macos ([#93](https://github.com/itsjunetime/tdf/pull/93))
# v0.4.1
- Add instructions for using new zoom/pan features to help page
# v0.4.0
- Update to new `kittage` backend for kitty-protocol-supporting terminals (fixes many issues and improves performance significantly, see [the PR](https://github.com/itsjunetime/tdf/pull/74))
- Use new mupdf search API for slightly better performance
- Update ratatui(-image) dependencies
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "tdf-viewer"
version = "0.4.2"
version = "0.3.0"
authors = ["June Welker <junewelker@gmail.com>"]
edition = "2024"
description = "A terminal viewer for PDFs"
+1 -1
View File
@@ -25,7 +25,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`.
+6 -5
View File
@@ -139,13 +139,14 @@ pub async fn run_conversion_loop(
let rn = SystemTime::now()
.duration_since(UNIX_EPOCH)
.unwrap_or_default()
.as_millis() % 1_000_000;
.as_nanos();
let mut img = if shms_work {
kittage::image::Image::shm_from(dyn_img, &format!("tdf_{pid}_{rn}_{page_num}"))
.map_err(|e| {
RenderError::Converting(format!("Couldn't write to shm: {e}"))
})?
kittage::image::Image::shm_from(
dyn_img,
&format!("__tdf_kittage_{pid}_page_{rn}_{page_num}")
)
.map_err(|e| RenderError::Converting(format!("Couldn't write to shm: {e}")))?
} else {
kittage::image::Image::from(dyn_img)
};
+2 -1
View File
@@ -78,7 +78,8 @@ pub async fn run_action<'image, 'data, 'es>(
pub async fn do_shms_work(ev_stream: &mut EventStream) -> bool {
let img = DynamicImage::new_rgb8(1, 1);
let pid = std::process::id();
let Ok(mut k_img) = kittage::image::Image::shm_from(img, &format!("tdf_test_{pid}")) else {
let Ok(mut k_img) = kittage::image::Image::shm_from(img, &format!("__tdf_kittage_test_{pid}"))
else {
return false;
};
+3 -15
View File
@@ -74,24 +74,12 @@ async fn main() -> Result<(), WrappedErr> {
optional -w,--white-color white: String
/// Custom black color, specified in css format (e.g "000000" or "rgb(0, 0, 0)")
optional -b,--black-color black: String
/// Print the version and exit
optional --version
/// PDF file to read
optional file: PathBuf
required file: PathBuf
};
if flags.version {
println!("{}", env!("CARGO_PKG_VERSION"));
return Ok(());
}
let Some(file) = flags.file else {
return Err(WrappedErr(
"Please specify the file to open, e.g. `tdf ./my_example_pdf.pdf`".into()
));
};
let path = file
let path = flags
.file
.canonicalize()
.map_err(|e| WrappedErr(format!("Cannot canonicalize provided file: {e}").into()))?;
+13 -19
View File
@@ -18,8 +18,8 @@ use ratatui::{
layout::{Constraint, Flex, Layout, Position, Rect},
style::{Color, Style},
symbols::border,
text::Span,
widgets::{Block, Borders, Clear, Padding, Paragraph, Wrap}
text::{Span, Text},
widgets::{Block, Borders, Clear, Padding}
};
use ratatui_image::{FontSize, Image};
@@ -830,7 +830,7 @@ impl Tui {
.border_set(border::ROUNDED)
.border_style(Color::Blue);
let help_span = Paragraph::new(HELP_PAGE).wrap(Wrap { trim: false });
let help_span = Text::raw(HELP_PAGE);
let max_w: u16 = HELP_PAGE
.lines()
@@ -863,31 +863,25 @@ impl Tui {
static HELP_PAGE: &str = "\
l, h, left, right:
Go forward/backwards a single page
Go forward/backwards a single page
j, k, down, up:
Go forwards/backwards a screen's worth of pages
Go forwards/backwards a screen's worth of pages
q, esc:
Quit
Quit
g:
Go to specific page (type numbers after 'g')
Go to specific page (type numbers after 'g')
/:
Search
Search
n, N:
Next/Previous search result
Next/Previous search result
i:
Invert colors
Invert colors
f:
Remove borders/fullscreen
z (when using kitty protocol):
Toggle between fill-screen and fit-screen
o/O (when on fill-screen):
zoom in and out, respectively
H, J, K, L (when zoomed in):
pan direction around page
Remove borders/fullscreen
?:
Show this page
Show this page
ctrl+z:
Suspend & background tdf \
Suspend & background tdf \
";
pub enum InputAction {