diff --git a/Cargo.toml b/Cargo.toml index 195586f..9ac83ff 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,8 +6,10 @@ edition = "2021" [dependencies] poppler-rs = { version = "0.23.0", features = ["v21_5"] } cairo-rs = { version = "0.19.4", features = ["png"] } +# 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 = { path = "./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 Box. 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", features = ["rustix", "vb64"], default-features = false } # ratatui-image = { path = "./ratatui-image", features = ["rustix", "vb64"], default-features = false } crossterm = { version = "0.27.0", features = ["event-stream"] } diff --git a/README.md b/README.md new file mode 100644 index 0000000..7820a91 --- /dev/null +++ b/README.md @@ -0,0 +1,32 @@ +# `tdf` + +A terminal-based PDF viewer. + +Designed to be performant, very responsive, and work well with even very large PDFs. Built with [`ratatui`](https://github.com/ratatui-org/ratatui). + +![What it looks like](./example_scrt.png) + +## Features: +- Asynchronous Rendering +- Searching +- Responsive details about rendering/search progress +- Reactive layout + +## To Build +First, you need to install the system dependencies. This includes packages such as (but not limited to) `cairo`, `gtk`, and `poppler`. If you're on linux, these will probably show up in your package manager as something like `libcairo-devel` or `cairo-dev`. + +If it turns out that you're missing one of these, it will fail to compile and tell you what library you're missing. Find the development package for that library in your package manager, install it, and try to build again. Now, the important steps: + +1. Get the rust toolchain from [rustup.rs](https://rustup.rs) +2. Clone the repo and `cd` into it +3. Run `cargo build --release` + +Alternatively, if you'd like to squeeze the most performance out of this tool, you'll want to run `bash ./build_most_optimized.sh` and pull the resulting binary from `./target/$target/tdf`. + +## Why in the world would you use this? + +I dunno. Just for fun, mostly. + +## Can I contribute? + +Yeah, sure. Please do. diff --git a/build_most_optimized.sh b/build_most_optimized.sh index caea15f..cd9f867 100644 --- a/build_most_optimized.sh +++ b/build_most_optimized.sh @@ -1 +1 @@ -RUSTFLAGS="-Cpanic=abort -Ccodegen-units=1 -Cembed-bitcode=yes -Zdylib-lto -Copt-level=z -Zlocation-detail=none -Cstrip=symbols -Ctarget-cpu=native" cargo -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort build --profile production --target "$(rustc +nightly -Z unstable-options --print target-spec-json | jq -r '."llvm-target"')" +RUSTFLAGS="-Cpanic=abort -Ccodegen-units=1 -Cembed-bitcode=yes -Zdylib-lto -Copt-level=s -Zlocation-detail=none -Cstrip=symbols -Ctarget-cpu=native" cargo -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort build --profile production --target "$(rustc +nightly -Z unstable-options --print target-spec-json | jq -r '."llvm-target"')" diff --git a/example_scrt.png b/example_scrt.png new file mode 100644 index 0000000..905053a Binary files /dev/null and b/example_scrt.png differ diff --git a/src/renderer.rs b/src/renderer.rs index 8b4bb5c..952829f 100644 --- a/src/renderer.rs +++ b/src/renderer.rs @@ -208,7 +208,12 @@ pub fn start_rendering( Ok(None) => (), // If that fn returned Some, that means it needed to be re-rendered for some // reason or another, so we're sending it here - Ok(Some(img)) => sender.blocking_send(Ok(RenderInfo::Page(img))).unwrap(), + Ok(Some(img)) => { + // But we first need to store if we already rendered it correctly so that + // the next time we iterate through, it might see that we're already good + rendered.contained_term = Some(img.search_results > 0); + sender.blocking_send(Ok(RenderInfo::Page(img))).unwrap() + }, // And if we got an error, then obviously we need to propagate that Err(e) => sender.blocking_send(Err(RenderError::Render(e))).unwrap() }