Compare commits

..

7 Commits

Author SHA1 Message Date
itsjunetime a3d88f40f0 Update ratatuis 2026-02-08 18:38:27 -06:00
June f2be5e39fb Update deps (#134)
* Pin ratatui and ratatui-image deps

* Update deps
2026-01-31 17:32:25 -06:00
itsjunetime 2d40444273 Add mention of new keybindings to help text and changelog 2026-01-27 23:01:56 -06:00
Ishan Deshpande 580af3668f Add support for panning all the way left/right (#131) 2026-01-27 22:50:01 -06:00
Max Dexheimer 577141e201 Fix TODOs
Fixes non UTF8 filenames by not converting to `String` for no reason.

Also removes TODO for the fill-page feature, which already exists.
2026-01-22 15:33:29 +01:00
Max Dexheimer 828db8aed3 Ignore .envrc and .direnv 2026-01-22 15:24:58 +01:00
June 39a4bdafb6 small cleanups (#129)
- don't parse color strings for defaults
- fix comment misstating type of vec
- impl size_hint and ExactSizeIterator for PopOnNext
2026-01-09 20:53:25 -05:00
10 changed files with 436 additions and 778 deletions
+2
View File
@@ -1,2 +1,4 @@
/target
debug.log
/.envrc
/.direnv/
+2
View File
@@ -1,5 +1,7 @@
# Unreleased
- Added keybindings (`0`/`$`) to scroll to left or right side of zoomed-in image ([#131](https://github.com/itsjunetime/tdf/pull/131), thank you [@IshDeshpa](https://github.com/IshDeshpa)!)
# v0.5.0
- Switched simd base64 crate for one that works on stable (from `vb64` to `base64_simd`)
Generated
+402 -759
View File
File diff suppressed because it is too large Load Diff
+6 -6
View File
@@ -23,10 +23,10 @@ name = "tdf"
[dependencies]
# we're using this branch because it has significant performance fixes that I'm waiting on responses from the upstream devs to get upstreamed. See https://github.com/ratatui-org/ratatui/issues/1116
ratatui = { git = "https://github.com/itsjunetime/ratatui.git" }
ratatui = { git = "https://github.com/itsjunetime/ratatui.git", rev = "720ac2d0cad1ac6424364fea74856fec9c100cb1", default-features = false, features = [ "crossterm", "layout-cache" ] }
# ratatui = { path = "./ratatui/ratatui/" }
# We're using this to have the vb64 feature (for faster base64 encoding, since that does take up a good bit of time when converting images to the `Protocol`. It also just includes a few more features that I'm waiting on main to upstream
ratatui-image = { git = "https://github.com/itsjunetime/ratatui-image.git", branch = "vb64_on_personal", default-features = false }
ratatui-image = { git = "https://github.com/itsjunetime/ratatui-image.git", rev = "a276a87cb8e2976442c6cc59db831db81551da89", default-features = false }
# ratatui-image = { path = "./ratatui-image", default-features = false }
crossterm = { version = "0.29.0", features = ["event-stream"] }
# crossterm = { path = "../crossterm", features = ["event-stream"] }
@@ -34,16 +34,17 @@ image = { version = "0.25.1", features = ["pnm", "rayon", "png"], default-featur
notify = { version = "8.0.0", features = ["crossbeam-channel"] }
tokio = { version = "1.37.0", features = ["rt-multi-thread", "macros"] }
futures-util = { version = "0.3.30", default-features = false }
flume = { version = "0.11.0", default-features = false, features = ["async"] }
flume = { version = "0.12.0", default-features = false, features = ["async"] }
xflags = "0.4.0-pre.2"
mimalloc = "0.1.43"
nix = { version = "0.30.0", features = ["signal"] }
nix = { version = "0.31.0", features = ["signal"] }
mupdf = { git = "https://github.com/messense/mupdf-rs.git", rev = "2e0fae910fac8048c7008211fc4d3b9f5d227a07", default-features = false, features = ["svg", "system-fonts", "img"] }
rayon = { version = "1", default-features = false }
# kittage = { path = "../kittage/", features = ["crossterm-tokio", "image-crate", "log"] }
kittage = { version = "0.1.1", features = ["crossterm-tokio", "image-crate", "log"] }
memmap2 = "0"
csscolorparser = { version = "0.8.0", default-features = false }
debounce = "0.2.2"
# logging
log = "0.4.27"
@@ -51,7 +52,6 @@ flexi_logger = "0.31"
# for tracing with tokio-console
console-subscriber = { version = "0.5.0", optional = true }
debounce = "0.2.2"
[profile.production]
inherits = "release"
@@ -64,7 +64,7 @@ epub = ["mupdf/epub"]
cbz = ["mupdf/cbz"]
[dev-dependencies]
criterion = { version = "0.7.0", features = ["async_tokio"] }
criterion = { version = "0.8.0", features = ["async_tokio"] }
cpuprofiler = "0.0.4"
[[bench]]
+2 -2
View File
@@ -65,7 +65,6 @@ pub fn start_rendering_loop(
Sender<RenderNotif>
) {
let pathbuf = path.as_ref().canonicalize().unwrap();
let str_path = pathbuf.into_os_string().to_string_lossy().to_string();
let (to_render_tx, from_main_rx) = unbounded();
let (to_main_tx, from_render_rx) = unbounded();
@@ -91,7 +90,7 @@ pub fn start_rendering_loop(
let cell_width_px = size.width / size.columns;
std::thread::spawn(move || {
start_rendering(
&str_path,
&pathbuf,
to_main_tx,
from_main_rx,
cell_height_px,
@@ -117,6 +116,7 @@ pub fn start_converting_loop(
let (to_converter_tx, from_main_rx) = unbounded();
let (to_main_tx, from_converter_rx) = unbounded();
#[expect(deprecated)]
let mut picker = Picker::from_fontsize(FONT_SIZE);
picker.set_protocol_type(proto);
+1 -1
Submodule ratatui updated: 6a0b8ddf76...720ac2d0ca
+8 -6
View File
@@ -209,10 +209,6 @@ async fn inner_main() -> Result<(), WrappedErr> {
)
.map_err(|e| WrappedErr(format!("Can't watch the provided file: {e}").into()))?;
// TODO: Handle non-utf8 file names? Maybe by constructing a CString and passing that in to the
// mupdf stuff instead of a rust string?
let file_path = path.clone().into_os_string().to_string_lossy().to_string();
let mut window_size = window_size().map_err(|e| {
WrappedErr(format!("Can't get your current terminal window size: {e}").into())
})?;
@@ -250,8 +246,13 @@ async fn inner_main() -> Result<(), WrappedErr> {
window_size.width != 0
&& window_size.height != 0
&& window_size.columns != 0
&& window_size.rows != 0
=> Ok(Picker::from_fontsize((cell_width_px, cell_height_px))),
&& window_size.rows != 0 =>
{
// the 'equivalent' that is suggested instead is not the same. We need to keep
// calling this.
#[expect(deprecated)]
Ok(Picker::from_fontsize((cell_width_px, cell_height_px)))
},
ratatui_image::errors::Errors::NoFontSize => Err(WrappedErr(
"Unable to detect your terminal's font size; this is an issue with your terminal emulator.\nPlease use a different terminal emulator or report this bug to tdf.".into()
)),
@@ -266,6 +267,7 @@ async fn inner_main() -> Result<(), WrappedErr> {
.and_then(NonZeroUsize::new)
.map_or(PrerenderLimit::All, PrerenderLimit::Limited);
let file_path = path.clone();
std::thread::spawn(move || {
renderer::start_rendering(
&file_path,
+2 -2
View File
@@ -1,4 +1,4 @@
use std::{collections::VecDeque, num::NonZeroUsize, thread::sleep, time::Duration};
use std::{collections::VecDeque, num::NonZeroUsize, path::Path, thread::sleep, time::Duration};
use flume::{Receiver, SendError, Sender, TryRecvError};
use mupdf::{
@@ -80,7 +80,7 @@ pub fn fill_default<T: Default>(vec: &mut Vec<T>, size: usize) {
// probably be more performant if accessed by-value instead of through a reference. Probably.
#[expect(clippy::needless_pass_by_value, clippy::too_many_arguments)]
pub fn start_rendering(
path: &str,
path: &Path,
sender: Sender<Result<RenderInfo, RenderError>>,
receiver: Receiver<RenderNotif>,
col_h: u16,
+10 -1
View File
@@ -136,6 +136,12 @@ impl Zoom {
fn pan_top(&mut self) {
self.cell_pan_from_top = u16::MAX;
}
fn pan_left(&mut self) {
self.cell_pan_from_left = 0;
}
fn pan_right(&mut self) {
self.cell_pan_from_left = u16::MAX;
}
}
#[derive(Clone, Copy, Debug)]
enum Direction {
@@ -346,7 +352,6 @@ impl Tui {
}])
}
// TODO: Make a way to fill the width of the screen with one page and scroll down to view it
#[must_use]
pub fn render<'s>(
&'s mut self,
@@ -829,6 +834,8 @@ impl Tui {
'J' if can_zoom => self.update_zoom(|z| z.pan(Direction::Down)),
'K' if can_zoom => self.update_zoom(|z| z.pan(Direction::Up)),
'G' if can_zoom => self.update_zoom(Zoom::pan_top),
'0' if can_zoom => self.update_zoom(Zoom::pan_left),
'$' if can_zoom => self.update_zoom(Zoom::pan_right),
_ => None
}
}
@@ -1098,6 +1105,8 @@ gg/G (when on fill-screen):
Scroll to top/bottom of page
H, J, K, L (when zoomed in):
Pan direction around page
0/$ (when on fill-screen):
Scroll to left/right side of page
";
pub enum InputAction {