Update deps and do some code simplifications

This commit is contained in:
itsjunetime
2025-03-23 12:57:38 -06:00
parent 595f23de6f
commit 69d5f96375
3 changed files with 60 additions and 89 deletions
Generated
+45 -62
View File
@@ -349,9 +349,9 @@ dependencies = [
[[package]] [[package]]
name = "cc" name = "cc"
version = "1.2.16" version = "1.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "be714c154be609ec7f5dad223a33bf1482fff90472de28f7362806e6d4832b8c" checksum = "1fcb57c740ae1daf453ae85f16e37396f672b039e00d9d866e07ddb24e328e3a"
dependencies = [ dependencies = [
"jobserver", "jobserver",
"libc", "libc",
@@ -383,12 +383,6 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "cfg_aliases"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e"
[[package]] [[package]]
name = "cfg_aliases" name = "cfg_aliases"
version = "0.2.1" version = "0.2.1"
@@ -759,9 +753,9 @@ checksum = "5729f5117e208430e437df2f4843f5e5952997175992d1414f94c57d61e270b4"
[[package]] [[package]]
name = "deranged" name = "deranged"
version = "0.3.11" version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" checksum = "9c9e6a11ca8224451684bc0d7d5a7adbf8f2fd6887261a1cfc3c0432f9d4068e"
dependencies = [ dependencies = [
"powerfmt", "powerfmt",
] ]
@@ -1108,14 +1102,14 @@ dependencies = [
[[package]] [[package]]
name = "getrandom" name = "getrandom"
version = "0.3.1" version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43a49c392881ce6d5c3b8cb70f98717b7c07aabbdff06687b9030dbfbe2725f8" checksum = "73fea8450eea4bac3940448fb7ae50d91f034f941199fcd9d909a5a07aa455f0"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"libc", "libc",
"wasi 0.13.3+wasi-0.2.2", "r-efi",
"windows-targets 0.52.6", "wasi 0.14.2+wasi-0.2.4",
] ]
[[package]] [[package]]
@@ -1548,9 +1542,9 @@ dependencies = [
[[package]] [[package]]
name = "libmimalloc-sys" name = "libmimalloc-sys"
version = "0.1.39" version = "0.1.40"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23aa6811d3bd4deb8a84dde645f943476d13b248d818edcf8ce0b2f37f036b44" checksum = "07d0e07885d6a754b9c7993f2625187ad694ee985d60f23355ff0e7077261502"
dependencies = [ dependencies = [
"cc", "cc",
"libc", "libc",
@@ -1622,7 +1616,7 @@ version = "1.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0aeb26bf5e836cc1c341c8106051b573f1766dfa05aa87f0b98be5e51b02303" checksum = "c0aeb26bf5e836cc1c341c8106051b573f1766dfa05aa87f0b98be5e51b02303"
dependencies = [ dependencies = [
"nix 0.29.0", "nix",
"winapi", "winapi",
] ]
@@ -1674,9 +1668,9 @@ dependencies = [
[[package]] [[package]]
name = "mimalloc" name = "mimalloc"
version = "0.1.43" version = "0.1.44"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68914350ae34959d83f732418d51e2427a794055d0b9529f48259ac07af65633" checksum = "99585191385958383e13f6b822e6b6d8d9cf928e7d286ceb092da92b43c87bc1"
dependencies = [ dependencies = [
"libmimalloc-sys", "libmimalloc-sys",
] ]
@@ -1718,7 +1712,7 @@ dependencies = [
[[package]] [[package]]
name = "mupdf" name = "mupdf"
version = "0.4.4" version = "0.4.4"
source = "git+https://github.com/itsjunetime/mupdf-rs?branch=june%2Fmupdf_1_25#9dab2e5deff2a018fe2bc001e7d97b8ace08c4d7" source = "git+https://github.com/itsjunetime/mupdf-rs?branch=june%2Fmupdf_1_25#4a1d0740da26db0036cce5dd170e1274a92fd0e8"
dependencies = [ dependencies = [
"bitflags 2.9.0", "bitflags 2.9.0",
"font-kit", "font-kit",
@@ -1731,7 +1725,7 @@ dependencies = [
[[package]] [[package]]
name = "mupdf-sys" name = "mupdf-sys"
version = "0.4.4" version = "0.4.4"
source = "git+https://github.com/itsjunetime/mupdf-rs?branch=june%2Fmupdf_1_25#9dab2e5deff2a018fe2bc001e7d97b8ace08c4d7" source = "git+https://github.com/itsjunetime/mupdf-rs?branch=june%2Fmupdf_1_25#4a1d0740da26db0036cce5dd170e1274a92fd0e8"
dependencies = [ dependencies = [
"bindgen", "bindgen",
"cc", "cc",
@@ -1746,18 +1740,6 @@ version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086"
[[package]]
name = "nix"
version = "0.28.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab2156c4fce2f8df6c499cc1c763e4394b7482525bf2a9701c9d79d215f519e4"
dependencies = [
"bitflags 2.9.0",
"cfg-if",
"cfg_aliases 0.1.1",
"libc",
]
[[package]] [[package]]
name = "nix" name = "nix"
version = "0.29.0" version = "0.29.0"
@@ -1766,7 +1748,7 @@ checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46"
dependencies = [ dependencies = [
"bitflags 2.9.0", "bitflags 2.9.0",
"cfg-if", "cfg-if",
"cfg_aliases 0.2.1", "cfg_aliases",
"libc", "libc",
"memoffset", "memoffset",
] ]
@@ -1977,7 +1959,7 @@ dependencies = [
[[package]] [[package]]
name = "pathfinder_simd" name = "pathfinder_simd"
version = "0.5.4" version = "0.5.4"
source = "git+https://github.com/itsjunetime/pathfinder.git#7fd835fabc1192ed9c83c31a61f5bb89af24238d" source = "git+https://github.com/servo/pathfinder.git#8ccf6f7c2dd91f8e143998f91e55d1d24a4709bd"
dependencies = [ dependencies = [
"rustc_version", "rustc_version",
] ]
@@ -2082,7 +2064,7 @@ version = "0.11.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "67eabc2ef2a60eb7faa00097bd1ffdb5bd28e62bf39990626a582201b7a754e5" checksum = "67eabc2ef2a60eb7faa00097bd1ffdb5bd28e62bf39990626a582201b7a754e5"
dependencies = [ dependencies = [
"siphasher 1.0.1", "siphasher",
] ]
[[package]] [[package]]
@@ -2263,6 +2245,12 @@ dependencies = [
"proc-macro2", "proc-macro2",
] ]
[[package]]
name = "r-efi"
version = "5.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5"
[[package]] [[package]]
name = "rand" name = "rand"
version = "0.8.5" version = "0.8.5"
@@ -2705,12 +2693,6 @@ dependencies = [
"quote", "quote",
] ]
[[package]]
name = "siphasher"
version = "0.3.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d"
[[package]] [[package]]
name = "siphasher" name = "siphasher"
version = "1.0.1" version = "1.0.1"
@@ -2846,7 +2828,7 @@ dependencies = [
"itertools 0.14.0", "itertools 0.14.0",
"mimalloc", "mimalloc",
"mupdf", "mupdf",
"nix 0.29.0", "nix",
"notify", "notify",
"ratatui", "ratatui",
"ratatui-image", "ratatui-image",
@@ -2878,12 +2860,12 @@ dependencies = [
[[package]] [[package]]
name = "termwiz" name = "termwiz"
version = "0.23.0" version = "0.23.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed32af792ae81937cb8640b03eaef737408e5c8feee47b35e8b80c49bcb64524" checksum = "4676b37242ccbd1aabf56edb093a4827dc49086c0ffd764a5705899e0f35f8f7"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"base64 0.21.7", "base64 0.22.1",
"bitflags 2.9.0", "bitflags 2.9.0",
"fancy-regex", "fancy-regex",
"filedescriptor", "filedescriptor",
@@ -2894,7 +2876,7 @@ dependencies = [
"libc", "libc",
"log", "log",
"memmem", "memmem",
"nix 0.28.0", "nix",
"num-derive", "num-derive",
"num-traits", "num-traits",
"ordered-float", "ordered-float",
@@ -2903,7 +2885,7 @@ dependencies = [
"phf", "phf",
"sha2", "sha2",
"signal-hook", "signal-hook",
"siphasher 0.3.11", "siphasher",
"terminfo", "terminfo",
"termios", "termios",
"thiserror 1.0.69", "thiserror 1.0.69",
@@ -2970,9 +2952,9 @@ dependencies = [
[[package]] [[package]]
name = "time" name = "time"
version = "0.3.39" version = "0.3.40"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dad298b01a40a23aac4580b67e3dbedb7cc8402f3592d7f49469de2ea4aecdd8" checksum = "9d9c75b47bdff86fa3334a3db91356b8d7d86a9b839dab7d0bdc5c3d3a077618"
dependencies = [ dependencies = [
"deranged", "deranged",
"libc", "libc",
@@ -2985,9 +2967,9 @@ dependencies = [
[[package]] [[package]]
name = "time-core" name = "time-core"
version = "0.1.3" version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "765c97a5b985b7c11d7bc27fa927dc4fe6af3a6dfb021d28deb60d3bf51e76ef" checksum = "c9e9a38711f559d9e3ce1cdb06dd7c5b8ea546bc90052da6d06bb76da74bb07c"
[[package]] [[package]]
name = "tinytemplate" name = "tinytemplate"
@@ -3268,7 +3250,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "458f7a779bf54acc9f347480ac654f68407d3aab21269a6e3c9f922acd9e2da9" checksum = "458f7a779bf54acc9f347480ac654f68407d3aab21269a6e3c9f922acd9e2da9"
dependencies = [ dependencies = [
"atomic", "atomic",
"getrandom 0.3.1", "getrandom 0.3.2",
] ]
[[package]] [[package]]
@@ -3341,9 +3323,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]] [[package]]
name = "wasi" name = "wasi"
version = "0.13.3+wasi-0.2.2" version = "0.14.2+wasi-0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26816d2e1a4a36a2940b96c5296ce403917633dff8f3440e9b236ed6f6bacad2" checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3"
dependencies = [ dependencies = [
"wit-bindgen-rt", "wit-bindgen-rt",
] ]
@@ -3432,7 +3414,7 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "692daff6d93d94e29e4114544ef6d5c942a7ed998b37abdc19b17136ea428eb7" checksum = "692daff6d93d94e29e4114544ef6d5c942a7ed998b37abdc19b17136ea428eb7"
dependencies = [ dependencies = [
"getrandom 0.3.1", "getrandom 0.3.2",
"mac_address", "mac_address",
"sha2", "sha2",
"thiserror 1.0.69", "thiserror 1.0.69",
@@ -3484,6 +3466,7 @@ dependencies = [
"bitflags 1.3.2", "bitflags 1.3.2",
"euclid", "euclid",
"lazy_static", "lazy_static",
"serde",
"wezterm-dynamic", "wezterm-dynamic",
] ]
@@ -3750,9 +3733,9 @@ dependencies = [
[[package]] [[package]]
name = "wit-bindgen-rt" name = "wit-bindgen-rt"
version = "0.33.0" version = "0.39.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3268f3d866458b787f390cf61f4bbb563b922d091359f9608842999eaee3943c" checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1"
dependencies = [ dependencies = [
"bitflags 2.9.0", "bitflags 2.9.0",
] ]
@@ -3785,18 +3768,18 @@ dependencies = [
[[package]] [[package]]
name = "zerocopy" name = "zerocopy"
version = "0.8.23" version = "0.8.24"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd97444d05a4328b90e75e503a34bad781f14e28a823ad3557f0750df1ebcbc6" checksum = "2586fea28e186957ef732a5f8b3be2da217d65c5969d4b1e17f973ebbe876879"
dependencies = [ dependencies = [
"zerocopy-derive", "zerocopy-derive",
] ]
[[package]] [[package]]
name = "zerocopy-derive" name = "zerocopy-derive"
version = "0.8.23" version = "0.8.24"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6352c01d0edd5db859a63e2605f4ea3183ddbd15e2c4a9e7d32184df75e4f154" checksum = "a996a8f63c5c4448cd959ac1bab0aaa3306ccfd060472f85943ee0750f0169be"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
+1 -1
View File
@@ -158,4 +158,4 @@ used_underscore_items = "warn"
zero_sized_map_values = "warn" zero_sized_map_values = "warn"
[patch.crates-io] [patch.crates-io]
pathfinder_simd = { git = "https://github.com/itsjunetime/pathfinder.git" } pathfinder_simd = { git = "https://github.com/servo/pathfinder.git" }
+14 -26
View File
@@ -22,7 +22,10 @@ use ratatui::{
}; };
use ratatui_image::{Image, protocol::Protocol}; use ratatui_image::{Image, protocol::Protocol};
use crate::{renderer::RenderError, skip::Skip}; use crate::{
renderer::{RenderError, fill_default},
skip::Skip
};
pub struct Tui { pub struct Tui {
name: String, name: String,
@@ -239,9 +242,8 @@ impl Tui {
let mut test_area_w = img_area.width; let mut test_area_w = img_area.width;
// go through our pages, starting at the first one we want to view // go through our pages, starting at the first one we want to view
let mut page_widths = self.rendered[self.page..] let mut page_widths = self.rendered[self.page..]
.iter() .iter_mut()
// and get their indices (I know it's offset, we fix it down below when we actually // and get this to represent a count of how many we're looking at so far to render
// render each page)
.enumerate() .enumerate()
// and only take as many as are ready to be rendered // and only take as many as are ready to be rendered
.take_while(|(idx, page)| { .take_while(|(idx, page)| {
@@ -252,9 +254,9 @@ impl Tui {
take take
}) })
// and map it to their width (in cells on the terminal, not pixels) // and map it to their width (in cells on the terminal, not pixels)
.filter_map(|(idx, page)| page.img.as_ref().map(|img| (idx, img.rect().width))) .filter_map(|(_, page)| page.img.as_mut().map(|img| (img.rect().width, img)))
// and then take them as long as they won't overflow the available area. // and then take them as long as they won't overflow the available area.
.take_while(|(_, width)| match test_area_w.checked_sub(*width) { .take_while(|(width, _)| match test_area_w.checked_sub(*width) {
Some(new_val) => { Some(new_val) => {
test_area_w = new_val; test_area_w = new_val;
true true
@@ -273,7 +275,7 @@ impl Tui {
} else { } else {
execute!(stdout(), BeginSynchronizedUpdate).unwrap(); execute!(stdout(), BeginSynchronizedUpdate).unwrap();
let total_width = page_widths.iter().map(|(_, w)| w).sum::<u16>(); let total_width = page_widths.iter().map(|(w, _)| w).sum::<u16>();
self.last_render.pages_shown = page_widths.len(); self.last_render.pages_shown = page_widths.len();
@@ -281,17 +283,8 @@ impl Tui {
self.last_render.unused_width = unused_width; self.last_render.unused_width = unused_width;
img_area.x += unused_width / 2; img_area.x += unused_width / 2;
for (page_idx, width) in page_widths { for (width, img) in page_widths {
// now, theoretically, when we call this, this page should *not* be None, but we do Self::render_single_page(frame, img, Rect { width, ..img_area });
// have to account for that possibility since we can't `borrow` the image from self
// when passing it in to `render_single_page` since that would be a mutable
// reference + an immutable reference (and also we need to potentially temporarily
// remove it from the array of rendered pages to replace it with a text-rendered
// image)
self.render_single_page(frame, page_idx + self.page, Rect {
width,
..img_area
});
img_area.x += width; img_area.x += width;
} }
@@ -302,11 +295,8 @@ impl Tui {
} }
} }
fn render_single_page(&mut self, frame: &mut Frame<'_>, page_idx: usize, img_area: Rect) { fn render_single_page(frame: &mut Frame<'_>, page_img: &mut Protocol, img_area: Rect) {
match self.rendered[page_idx].img { frame.render_widget(Image::new(page_img), img_area);
Some(ref mut page_img) => frame.render_widget(Image::new(page_img), img_area),
None => Self::render_loading_in(frame, img_area)
};
} }
fn render_loading_in(frame: &mut Frame<'_>, area: Rect) { fn render_loading_in(frame: &mut Frame<'_>, area: Rect) {
@@ -350,9 +340,7 @@ impl Tui {
} }
pub fn set_n_pages(&mut self, n_pages: usize) { pub fn set_n_pages(&mut self, n_pages: usize) {
self.rendered = std::iter::from_fn(|| Some(RenderedInfo::default())) fill_default(&mut self.rendered, n_pages);
.take(n_pages)
.collect();
self.page = self.page.min(n_pages - 1); self.page = self.page.min(n_pages - 1);
} }