mirror of
https://github.com/itsjunetime/tdf.git
synced 2026-06-02 08:01:47 -04:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2a03294557 | |||
| 7c2c6484a6 | |||
| e65472e571 | |||
| 4fd2237b69 | |||
| 69fd8ec7e8 |
@@ -1,5 +1,14 @@
|
||||
# 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))
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "tdf-viewer"
|
||||
version = "0.3.0"
|
||||
version = "0.4.2"
|
||||
authors = ["June Welker <junewelker@gmail.com>"]
|
||||
edition = "2024"
|
||||
description = "A terminal viewer for PDFs"
|
||||
|
||||
@@ -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 build --release`
|
||||
3. Run `cargo +nightly build --release`
|
||||
|
||||
The binary should then be found at `./target/release/tdf`.
|
||||
|
||||
|
||||
+5
-6
@@ -139,14 +139,13 @@ pub async fn run_conversion_loop(
|
||||
let rn = SystemTime::now()
|
||||
.duration_since(UNIX_EPOCH)
|
||||
.unwrap_or_default()
|
||||
.as_nanos();
|
||||
.as_millis() % 1_000_000;
|
||||
|
||||
let mut img = if shms_work {
|
||||
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}")))?
|
||||
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}"))
|
||||
})?
|
||||
} else {
|
||||
kittage::image::Image::from(dyn_img)
|
||||
};
|
||||
|
||||
+1
-2
@@ -78,8 +78,7 @@ 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_kittage_test_{pid}"))
|
||||
else {
|
||||
let Ok(mut k_img) = kittage::image::Image::shm_from(img, &format!("tdf_test_{pid}")) else {
|
||||
return false;
|
||||
};
|
||||
|
||||
|
||||
+15
-3
@@ -74,12 +74,24 @@ 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
|
||||
required file: PathBuf
|
||||
optional file: PathBuf
|
||||
};
|
||||
|
||||
let path = flags
|
||||
.file
|
||||
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
|
||||
.canonicalize()
|
||||
.map_err(|e| WrappedErr(format!("Cannot canonicalize provided file: {e}").into()))?;
|
||||
|
||||
|
||||
+19
-13
@@ -18,8 +18,8 @@ use ratatui::{
|
||||
layout::{Constraint, Flex, Layout, Position, Rect},
|
||||
style::{Color, Style},
|
||||
symbols::border,
|
||||
text::{Span, Text},
|
||||
widgets::{Block, Borders, Clear, Padding}
|
||||
text::Span,
|
||||
widgets::{Block, Borders, Clear, Padding, Paragraph, Wrap}
|
||||
};
|
||||
use ratatui_image::{FontSize, Image};
|
||||
|
||||
@@ -830,7 +830,7 @@ impl Tui {
|
||||
.border_set(border::ROUNDED)
|
||||
.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
|
||||
.lines()
|
||||
@@ -863,25 +863,31 @@ 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
|
||||
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:
|
||||
Suspend & background tdf \
|
||||
Suspend & background tdf \
|
||||
";
|
||||
|
||||
pub enum InputAction {
|
||||
|
||||
Reference in New Issue
Block a user