From bd5554db2737ead0d1b7cedbf195556ec535d9c6 Mon Sep 17 00:00:00 2001 From: itsjunetime Date: Fri, 5 Sep 2025 10:34:46 -0500 Subject: [PATCH] Update mupdf to use git dependency so it works on windows --- Cargo.lock | 47 +++++++---------------------------------------- Cargo.toml | 2 +- ratatui-image | 2 +- src/converter.rs | 3 +++ src/renderer.rs | 8 ++++---- src/tui.rs | 2 ++ 6 files changed, 18 insertions(+), 46 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0d487fa..8efacea 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -250,9 +250,9 @@ checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "bindgen" -version = "0.71.1" +version = "0.72.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f58bf3d7db68cfbac37cfc485a8d711e87e064c3d0fe0435b92f7a407f9d6b3" +checksum = "993776b509cfb49c750f11b8f07a46fa23e0a1386ffc01fb1e7d343efc387895" dependencies = [ "bitflags 2.9.4", "cexpr", @@ -1889,13 +1889,11 @@ dependencies = [ [[package]] name = "mupdf" version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a6499267155b9ae03ff8e53c456d0bfff988b2647d62ff1df038f39ebe93a0c" +source = "git+https://github.com/messense/mupdf-rs.git?rev=2e0fae910fac8048c7008211fc4d3b9f5d227a07#2e0fae910fac8048c7008211fc4d3b9f5d227a07" dependencies = [ "bitflags 2.9.4", "font-kit", "mupdf-sys", - "num_enum", "once_cell", "zerocopy", ] @@ -1903,8 +1901,7 @@ dependencies = [ [[package]] name = "mupdf-sys" version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13e9a0d4e844ab50315d43312f3d62f72c77205b07c8ee21cbd4b52bdc2a9910" +source = "git+https://github.com/messense/mupdf-rs.git?rev=2e0fae910fac8048c7008211fc4d3b9f5d227a07#2e0fae910fac8048c7008211fc4d3b9f5d227a07" dependencies = [ "bindgen", "cc", @@ -2050,28 +2047,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "num_enum" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a973b4e44ce6cad84ce69d797acf9a044532e4184c4f267913d1b546a0727b7a" -dependencies = [ - "num_enum_derive", - "rustversion", -] - -[[package]] -name = "num_enum_derive" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77e878c846a8abae00dd069496dbe8751b16ac1c3d6bd2a7283a938e8228f90d" -dependencies = [ - "proc-macro-crate", - "proc-macro2", - "quote", - "syn 2.0.106", -] - [[package]] name = "num_threads" version = "0.1.7" @@ -2367,15 +2342,6 @@ dependencies = [ "zerocopy", ] -[[package]] -name = "proc-macro-crate" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edce586971a4dfaa28950c6f18ed55e0406c1ab88bbce2c6f6293a7aaba73d35" -dependencies = [ - "toml_edit", -] - [[package]] name = "proc-macro2" version = "1.0.101" @@ -2551,6 +2517,7 @@ dependencies = [ [[package]] name = "ratatui-image" version = "8.0.1" +source = "git+https://github.com/itsjunetime/ratatui-image.git?branch=vb64_on_personal#fe3d0b992bcfafa671c5374a94503831baf165ca" dependencies = [ "base64 0.22.1", "icy_sixel", @@ -4044,9 +4011,9 @@ dependencies = [ [[package]] name = "wit-bindgen" -version = "0.45.0" +version = "0.45.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "052283831dbae3d879dc7f51f3d92703a316ca49f91540417d38591826127814" +checksum = "5c573471f125075647d03df72e026074b7203790d41351cd6edc96f46bcccd36" [[package]] name = "xflags" diff --git a/Cargo.toml b/Cargo.toml index 12636f8..7a696d8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,7 +38,7 @@ flume = { version = "0.11.0", default-features = false, features = ["async"] } xflags = "0.4.0-pre.2" mimalloc = "0.1.43" nix = { version = "0.30.0", features = ["signal"] } -mupdf = { version = "0.5.0", default-features = false, features = ["svg", "system-fonts", "img"] } +mupdf = { git = "https://github.com/messense/mupdf-rs.git", rev = "2e0fae910fac8048c7008211fc4d3b9f5d227a07", default-features = false, features = ["svg", "system-fonts", "img"] } rayon = { version = "*", default-features = false } # kittage = { path = "../kittage/", features = ["crossterm-tokio", "image-crate", "log"] } kittage = { git = "https://github.com/itsjunetime/kittage.git", features = ["crossterm-tokio", "image-crate", "log"] } diff --git a/ratatui-image b/ratatui-image index 24087c1..fe3d0b9 160000 --- a/ratatui-image +++ b/ratatui-image @@ -1 +1 @@ -Subproject commit 24087c1e8ea3961dbd1860f5f76c1c350fa503ac +Subproject commit fe3d0b992bcfafa671c5374a94503831baf165ca diff --git a/src/converter.rs b/src/converter.rs index 2170824..4097405 100644 --- a/src/converter.rs +++ b/src/converter.rs @@ -26,6 +26,7 @@ pub enum MaybeTransferred { Transferred(kittage::ImageId) } +#[derive(Debug)] pub enum ConvertedImage { Generic(Protocol), Kitty { @@ -168,6 +169,8 @@ pub async fn run_conversion_loop( ) }; + log::debug!("got converted page for num {} with results {:?}", page_info.page_num, page_info.result_rects); + // update the iteration to the iteration that we stole this image from *iteration = new_iter; diff --git a/src/renderer.rs b/src/renderer.rs index f3a0fb1..9188bc4 100644 --- a/src/renderer.rs +++ b/src/renderer.rs @@ -2,7 +2,7 @@ use std::{collections::VecDeque, num::NonZeroUsize, thread::sleep, time::Duratio use flume::{Receiver, SendError, Sender, TryRecvError}; use mupdf::{ - Colorspace, Document, Matrix, Page, Pixmap, Quad, TextPageOptions, text_page::SearchHitResponse + Colorspace, Document, Matrix, Page, Pixmap, Quad, TextPageFlags, text_page::SearchHitResponse }; use ratatui::layout::Rect; @@ -520,7 +520,7 @@ fn render_single_page_to_ctx( }) } -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct HighlightRect { pub ul_x: u32, pub ul_y: u32, @@ -536,7 +536,7 @@ fn search_page( ) -> Result, mupdf::error::Error> { search_term .map(|term| { - page.to_text_page(TextPageOptions::empty()) + page.to_text_page(TextPageFlags::empty()) .and_then(|page| { let mut v = Vec::with_capacity(trusted_search_results); page.search_cb(term, &mut v, |v, results| { @@ -552,7 +552,7 @@ fn search_page( #[inline] fn count_search_results(page: &Page, search_term: &str) -> Result { - page.to_text_page(TextPageOptions::empty()) + page.to_text_page(TextPageFlags::empty()) .and_then(|page| { let mut count = 0; page.search_cb(search_term, &mut count, |count, results| { diff --git a/src/tui.rs b/src/tui.rs index b08f950..9990752 100644 --- a/src/tui.rs +++ b/src/tui.rs @@ -427,6 +427,8 @@ impl Tui { } } + log::debug!("tui got page {page_num} ready with img {img:#?}"); + // We always just set this here because we handle reloading in the `set_n_pages` function. // If the document was reloaded, then It'll have the `set_n_pages` called to set the new // number of pages, so the vec will already be cleared