Compare commits

...

5 Commits

Author SHA1 Message Date
itsjunetime 2a03294557 Release version 0.4.2 2025-08-18 10:18:26 -05:00
Per Hurtig 7c2c6484a6 Fix macOS shared memory filename length limit (fixes issue #92) (#93)
* Fix macOS shared memory filename length limit

Shorten shared memory object names from "__tdf_kittage_{pid}_page_{rn}_{page_num}"
to "tdf_{pid}_{rn}_{page_num}" and change timestamp from nanoseconds to
milliseconds % 1M to stay under macOS's 31-character limit for shm names.

Fixes "File name too long (os error 63)" error when rendering PDFs on macOS.

On macOS, SHM_NAME_MAX: 30

* Fix macOS shared memory filename length limit

Shorten shared memory object names from "__tdf_kittage_{pid}_page_{rn}_{page_num}"
to "tdf_{pid}_{rn}_{page_num}" and change timestamp from nanoseconds to
milliseconds % 1M to stay under macOS's 31-character limit for shm names.

Fixes "File name too long (os error 63)" error when rendering PDFs on macOS.

SHM_NAME_MAX: 30
2025-08-18 10:15:19 -05:00
itsjunetime e65472e571 Add --version flag 2025-08-15 09:43:52 -05:00
itsjunetime 4fd2237b69 Specify on README to use nightly when building even though it should be detected by rust-toolchain.toml 2025-08-11 21:26:17 -05:00
itsjunetime 69fd8ec7e8 Add instructions for zooming and such to help page 2025-08-09 15:58:56 -06:00
7 changed files with 51 additions and 26 deletions
+9
View File
@@ -1,5 +1,14 @@
# Unreleased # 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 # 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)) - 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))
+1 -1
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "tdf-viewer" name = "tdf-viewer"
version = "0.3.0" version = "0.4.2"
authors = ["June Welker <junewelker@gmail.com>"] authors = ["June Welker <junewelker@gmail.com>"]
edition = "2024" edition = "2024"
description = "A terminal viewer for PDFs" 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) 1. Get the rust toolchain from [rustup.rs](https://rustup.rs)
2. Clone the repo and `cd` into it 2. Clone the repo and `cd` into it
3. Run `cargo build --release` 3. Run `cargo +nightly build --release`
The binary should then be found at `./target/release/tdf`. The binary should then be found at `./target/release/tdf`.
+5 -6
View File
@@ -139,14 +139,13 @@ pub async fn run_conversion_loop(
let rn = SystemTime::now() let rn = SystemTime::now()
.duration_since(UNIX_EPOCH) .duration_since(UNIX_EPOCH)
.unwrap_or_default() .unwrap_or_default()
.as_nanos(); .as_millis() % 1_000_000;
let mut img = if shms_work { let mut img = if shms_work {
kittage::image::Image::shm_from( kittage::image::Image::shm_from(dyn_img, &format!("tdf_{pid}_{rn}_{page_num}"))
dyn_img, .map_err(|e| {
&format!("__tdf_kittage_{pid}_page_{rn}_{page_num}") RenderError::Converting(format!("Couldn't write to shm: {e}"))
) })?
.map_err(|e| RenderError::Converting(format!("Couldn't write to shm: {e}")))?
} else { } else {
kittage::image::Image::from(dyn_img) kittage::image::Image::from(dyn_img)
}; };
+1 -2
View File
@@ -78,8 +78,7 @@ pub async fn run_action<'image, 'data, 'es>(
pub async fn do_shms_work(ev_stream: &mut EventStream) -> bool { pub async fn do_shms_work(ev_stream: &mut EventStream) -> bool {
let img = DynamicImage::new_rgb8(1, 1); let img = DynamicImage::new_rgb8(1, 1);
let pid = std::process::id(); let pid = std::process::id();
let Ok(mut k_img) = kittage::image::Image::shm_from(img, &format!("__tdf_kittage_test_{pid}")) let Ok(mut k_img) = kittage::image::Image::shm_from(img, &format!("tdf_test_{pid}")) else {
else {
return false; return false;
}; };
+15 -3
View File
@@ -74,12 +74,24 @@ async fn main() -> Result<(), WrappedErr> {
optional -w,--white-color white: String optional -w,--white-color white: String
/// Custom black color, specified in css format (e.g "000000" or "rgb(0, 0, 0)") /// Custom black color, specified in css format (e.g "000000" or "rgb(0, 0, 0)")
optional -b,--black-color black: String optional -b,--black-color black: String
/// Print the version and exit
optional --version
/// PDF file to read /// PDF file to read
required file: PathBuf optional file: PathBuf
}; };
let path = flags if flags.version {
.file 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
.canonicalize() .canonicalize()
.map_err(|e| WrappedErr(format!("Cannot canonicalize provided file: {e}").into()))?; .map_err(|e| WrappedErr(format!("Cannot canonicalize provided file: {e}").into()))?;
+19 -13
View File
@@ -18,8 +18,8 @@ use ratatui::{
layout::{Constraint, Flex, Layout, Position, Rect}, layout::{Constraint, Flex, Layout, Position, Rect},
style::{Color, Style}, style::{Color, Style},
symbols::border, symbols::border,
text::{Span, Text}, text::Span,
widgets::{Block, Borders, Clear, Padding} widgets::{Block, Borders, Clear, Padding, Paragraph, Wrap}
}; };
use ratatui_image::{FontSize, Image}; use ratatui_image::{FontSize, Image};
@@ -830,7 +830,7 @@ impl Tui {
.border_set(border::ROUNDED) .border_set(border::ROUNDED)
.border_style(Color::Blue); .border_style(Color::Blue);
let help_span = Text::raw(HELP_PAGE); let help_span = Paragraph::new(HELP_PAGE).wrap(Wrap { trim: false });
let max_w: u16 = HELP_PAGE let max_w: u16 = HELP_PAGE
.lines() .lines()
@@ -863,25 +863,31 @@ impl Tui {
static HELP_PAGE: &str = "\ static HELP_PAGE: &str = "\
l, h, left, right: l, h, left, right:
Go forward/backwards a single page Go forward/backwards a single page
j, k, down, up: j, k, down, up:
Go forwards/backwards a screen's worth of pages Go forwards/backwards a screen's worth of pages
q, esc: q, esc:
Quit Quit
g: g:
Go to specific page (type numbers after 'g') Go to specific page (type numbers after 'g')
/: /:
Search Search
n, N: n, N:
Next/Previous search result Next/Previous search result
i: i:
Invert colors Invert colors
f: f:
Remove borders/fullscreen 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
?: ?:
Show this page Show this page
ctrl+z: ctrl+z:
Suspend & background tdf \ Suspend & background tdf \
"; ";
pub enum InputAction { pub enum InputAction {