mirror of
https://github.com/itsjunetime/tdf.git
synced 2026-06-27 08:04:29 -04:00
Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8abebc99e5 | |||
| d6aee778e0 | |||
| 04d4efaf12 | |||
| 5c380a8713 | |||
| eaeed4730b | |||
| 032fad1f9b | |||
| 91b923f593 | |||
| d5abc4bae5 | |||
| 06f737b1fe | |||
| 95c24206ca | |||
| 5e4fbff9cd | |||
| 421401c7a7 | |||
| 7448fc73c5 | |||
| 1ed03e94fb | |||
| cf9d295d95 |
@@ -58,7 +58,7 @@ jobs:
|
|||||||
- name: Clippy
|
- name: Clippy
|
||||||
run: cargo clippy --locked -- -D warnings
|
run: cargo clippy --locked -- -D warnings
|
||||||
- name: Tests
|
- name: Tests
|
||||||
run: cargo test --locked
|
run: cargo test --verbose --locked
|
||||||
- name: Check fmt
|
- name: Check fmt
|
||||||
run: cargo fmt -- --check
|
run: cargo fmt -- --check
|
||||||
- name: Run benchmarks as tests
|
- name: Run benchmarks as tests
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
- Added windows support! (thank you to [@jarjk](https://github.com/jarjk) for helping out!)
|
- Added windows support! (thank you to [@jarjk](https://github.com/jarjk) for helping out!)
|
||||||
- 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)!)
|
- 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)!)
|
||||||
|
- Fixed issue with images clearing/flashing after displaying a certain number on kitty
|
||||||
- (Internal) decreased runtime footprint of tokio runtime
|
- (Internal) decreased runtime footprint of tokio runtime
|
||||||
|
|
||||||
# v0.5.0
|
# v0.5.0
|
||||||
|
|||||||
Generated
+568
-328
File diff suppressed because it is too large
Load Diff
+6
-10
@@ -11,7 +11,7 @@ license = "AGPL-3.0-only"
|
|||||||
keywords = ["pdf", "tui", "cli", "terminal"]
|
keywords = ["pdf", "tui", "cli", "terminal"]
|
||||||
categories = ["command-line-utilities", "text-processing", "visualization"]
|
categories = ["command-line-utilities", "text-processing", "visualization"]
|
||||||
default-run = "tdf"
|
default-run = "tdf"
|
||||||
rust-version = "1.86"
|
rust-version = "1.95"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "tdf"
|
name = "tdf"
|
||||||
@@ -22,29 +22,25 @@ path = "src/main.rs"
|
|||||||
name = "tdf"
|
name = "tdf"
|
||||||
|
|
||||||
[dependencies]
|
[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 = { version = "^0.30.1", default-features = false, features = [ "crossterm", "layout-cache" ] }
|
||||||
ratatui = { git = "https://github.com/itsjunetime/ratatui.git", rev = "720ac2d0cad1ac6424364fea74856fec9c100cb1", default-features = false, features = [ "crossterm", "layout-cache" ] }
|
ratatui-image = { version = "11.0", default-features = false }
|
||||||
# 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", rev = "a276a87cb8e2976442c6cc59db831db81551da89", default-features = false }
|
|
||||||
# ratatui-image = { path = "./ratatui-image", default-features = false }
|
|
||||||
crossterm = { version = "0.29.0", features = ["event-stream"] }
|
crossterm = { version = "0.29.0", features = ["event-stream"] }
|
||||||
# crossterm = { path = "../crossterm", features = ["event-stream"] }
|
|
||||||
image = { version = "0.25.1", features = ["pnm", "rayon", "png"], default-features = false }
|
image = { version = "0.25.1", features = ["pnm", "rayon", "png"], default-features = false }
|
||||||
notify = { version = "8.0.0", features = ["crossbeam-channel"] }
|
notify = { version = "8.0.0", features = ["crossbeam-channel"] }
|
||||||
tokio = { version = "1.37.0", features = ["rt-multi-thread", "macros"] }
|
tokio = { version = "1.37.0", features = ["rt-multi-thread", "macros"] }
|
||||||
futures-util = { version = "0.3.30", default-features = false }
|
futures-util = { version = "0.3.30", default-features = false }
|
||||||
flume = { version = "0.12.0", default-features = false, features = ["async"] }
|
flume = { version = "0.12.0", default-features = false, features = ["async"] }
|
||||||
xflags = "0.4.0-pre.2"
|
xflags = "0.4.0-pre.2"
|
||||||
mimalloc = "0.1.43"
|
mimalloc = { git = "https://github.com/itsjunetime/mimalloc_rust.git", rev = "3b0dda87caa5fbf4df1f60063a32b1462ddb5a85", features = [ "debug_in_debug" ] }
|
||||||
nix = { version = "0.31.0", features = ["signal"] }
|
nix = { version = "0.31.0", features = ["signal"] }
|
||||||
mupdf = { git = "https://github.com/messense/mupdf-rs.git", rev = "d7441b9998c92135e329559c0aa71d9dc92cf4de", default-features = false, features = ["svg", "system-fonts", "img"] }
|
mupdf = { git = "https://github.com/messense/mupdf-rs.git", rev = "d7441b9998c92135e329559c0aa71d9dc92cf4de", default-features = false, features = ["svg", "system-fonts", "img"] }
|
||||||
rayon = { version = "1", default-features = false }
|
rayon = { version = "1", default-features = false }
|
||||||
# kittage = { path = "../kittage/", features = ["crossterm-tokio", "image-crate", "log"] }
|
# kittage = { path = "../kittage/", features = ["crossterm-tokio", "image-crate", "log"] }
|
||||||
kittage = { version = "0.3.4", features = ["crossterm-tokio", "image-crate", "log"] }
|
kittage = { version = "0.4.0", features = ["crossterm-tokio", "image-crate", "log"] }
|
||||||
memmap2 = "0"
|
memmap2 = "0"
|
||||||
csscolorparser = { version = "0.8.0", default-features = false }
|
csscolorparser = { version = "0.8.0", default-features = false }
|
||||||
debounce = "0.2.2"
|
debounce = "0.2.2"
|
||||||
|
smallvec = "1"
|
||||||
|
|
||||||
# logging
|
# logging
|
||||||
log = "0.4.27"
|
log = "0.4.27"
|
||||||
|
|||||||
+10
-4
@@ -4,7 +4,10 @@ use crossterm::terminal::WindowSize;
|
|||||||
use flume::{Sender, r#async::RecvStream, unbounded};
|
use flume::{Sender, r#async::RecvStream, unbounded};
|
||||||
use futures_util::stream::StreamExt as _;
|
use futures_util::stream::StreamExt as _;
|
||||||
use ratatui::layout::Rect;
|
use ratatui::layout::Rect;
|
||||||
use ratatui_image::picker::{Picker, ProtocolType};
|
use ratatui_image::{
|
||||||
|
FontSize,
|
||||||
|
picker::{Picker, ProtocolType}
|
||||||
|
};
|
||||||
use tdf::{
|
use tdf::{
|
||||||
converter::{ConvertedPage, ConverterMsg, run_conversion_loop},
|
converter::{ConvertedPage, ConverterMsg, run_conversion_loop},
|
||||||
renderer::{RenderError, RenderInfo, RenderNotif, fill_default, start_rendering}
|
renderer::{RenderError, RenderInfo, RenderNotif, fill_default, start_rendering}
|
||||||
@@ -54,7 +57,10 @@ pub struct RenderState {
|
|||||||
pub to_render_tx: Sender<RenderNotif>
|
pub to_render_tx: Sender<RenderNotif>
|
||||||
}
|
}
|
||||||
|
|
||||||
const FONT_SIZE: (u16, u16) = (8, 14);
|
const FONT_SIZE: FontSize = FontSize {
|
||||||
|
width: 8,
|
||||||
|
height: 14
|
||||||
|
};
|
||||||
|
|
||||||
pub fn start_rendering_loop(
|
pub fn start_rendering_loop(
|
||||||
path: impl AsRef<Path>,
|
path: impl AsRef<Path>,
|
||||||
@@ -74,8 +80,8 @@ pub fn start_rendering_loop(
|
|||||||
let size = WindowSize {
|
let size = WindowSize {
|
||||||
columns,
|
columns,
|
||||||
rows,
|
rows,
|
||||||
height: rows * FONT_SIZE.1,
|
height: rows * FONT_SIZE.height,
|
||||||
width: columns * FONT_SIZE.0
|
width: columns * FONT_SIZE.width
|
||||||
};
|
};
|
||||||
|
|
||||||
let main_area = Rect {
|
let main_area = Rect {
|
||||||
|
|||||||
+1
-1
Submodule ratatui-image updated: a276a87cb8...8ad154a219
+29
-24
@@ -1,13 +1,14 @@
|
|||||||
use std::{
|
use std::{
|
||||||
num::NonZeroUsize,
|
io::Cursor,
|
||||||
|
num::{NonZeroU32, NonZeroUsize},
|
||||||
time::{SystemTime, UNIX_EPOCH}
|
time::{SystemTime, UNIX_EPOCH}
|
||||||
};
|
};
|
||||||
|
|
||||||
use flume::{Receiver, SendError, Sender, TryRecvError};
|
use flume::{Receiver, SendError, Sender, TryRecvError};
|
||||||
use futures_util::stream::StreamExt as _;
|
use futures_util::stream::StreamExt as _;
|
||||||
use image::DynamicImage;
|
use image::{DynamicImage, codecs::pnm::PnmDecoder};
|
||||||
use kittage::{NumberOrId, action::NONZERO_ONE};
|
use kittage::NumberOrId;
|
||||||
use ratatui::layout::Rect;
|
use ratatui::prelude::Size;
|
||||||
use ratatui_image::{
|
use ratatui_image::{
|
||||||
Resize,
|
Resize,
|
||||||
picker::{Picker, ProtocolType},
|
picker::{Picker, ProtocolType},
|
||||||
@@ -26,7 +27,7 @@ pub enum MaybeTransferred {
|
|||||||
Transferred(kittage::ImageId)
|
Transferred(kittage::ImageId)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
// #[derive(Debug)]
|
||||||
pub enum ConvertedImage {
|
pub enum ConvertedImage {
|
||||||
Generic(Protocol),
|
Generic(Protocol),
|
||||||
Kitty {
|
Kitty {
|
||||||
@@ -41,8 +42,8 @@ impl ConvertedImage {
|
|||||||
pub fn w_h(&self) -> (u16, u16) {
|
pub fn w_h(&self) -> (u16, u16) {
|
||||||
match self {
|
match self {
|
||||||
Self::Generic(prot) => {
|
Self::Generic(prot) => {
|
||||||
let a = prot.area();
|
let Size { width, height } = prot.size();
|
||||||
(a.width, a.height)
|
(width, height)
|
||||||
}
|
}
|
||||||
Self::Kitty {
|
Self::Kitty {
|
||||||
img: _,
|
img: _,
|
||||||
@@ -71,7 +72,7 @@ pub async fn run_conversion_loop(
|
|||||||
picker: Picker,
|
picker: Picker,
|
||||||
prerender: usize,
|
prerender: usize,
|
||||||
shms_work: bool
|
shms_work: bool
|
||||||
) -> Result<(), SendError<Result<ConvertedPage, RenderError>>> {
|
) -> Result<(), Box<SendError<Result<ConvertedPage, RenderError>>>> {
|
||||||
let mut images = vec![];
|
let mut images = vec![];
|
||||||
let mut page: usize = 0;
|
let mut page: usize = 0;
|
||||||
let pid = std::process::id();
|
let pid = std::process::id();
|
||||||
@@ -111,31 +112,35 @@ pub async fn run_conversion_loop(
|
|||||||
return Ok(None);
|
return Ok(None);
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut dyn_img = image::load_from_memory_with_format(
|
let decoder = PnmDecoder::new(Cursor::new(&page_info.img_data.pixels)).map_err(|e| {
|
||||||
&page_info.img_data.pixels,
|
RenderError::Converting(format!(
|
||||||
image::ImageFormat::Pnm
|
"The image data provided from mupdf was not in pnm format ({e}); don't know how to convert"
|
||||||
)
|
))
|
||||||
.map_err(|e| RenderError::Converting(format!("Can't load image: {e}")))?;
|
})?;
|
||||||
|
|
||||||
|
// The image we get should always already be `ImageRgb8`, so this `into` shouldn't do any
|
||||||
|
// conversions or anything, but just in case some underlying detail of mupdf or image
|
||||||
|
// changes, we do the `into` instead of just `match + unreachable!()` to avoid panicking
|
||||||
|
let mut dyn_img = DynamicImage::from_decoder(decoder)
|
||||||
|
.map_err(|e| RenderError::Converting(format!("Can't load image: {e}")))?
|
||||||
|
.into_rgb8();
|
||||||
|
|
||||||
match dyn_img {
|
|
||||||
DynamicImage::ImageRgb8(ref mut img) =>
|
|
||||||
for quad in &*page_info.result_rects {
|
for quad in &*page_info.result_rects {
|
||||||
img.par_enumerate_pixels_mut()
|
dyn_img
|
||||||
|
.par_enumerate_pixels_mut()
|
||||||
.filter(|(x, y, _)| {
|
.filter(|(x, y, _)| {
|
||||||
*x > quad.ul_x && *x < quad.lr_x && *y > quad.ul_y && *y < quad.lr_y
|
*x > quad.ul_x && *x < quad.lr_x && *y > quad.ul_y && *y < quad.lr_y
|
||||||
})
|
})
|
||||||
.for_each(|(_, _, px)| px.0[2] = px.0[2].saturating_sub(u8::MAX / 2));
|
.for_each(|(_, _, px)| px.0[2] = px.0[2].saturating_sub(u8::MAX / 2));
|
||||||
},
|
|
||||||
_ => unreachable!()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let img_area = Rect {
|
let img_size = Size {
|
||||||
width: page_info.img_data.cell_w,
|
width: page_info.img_data.cell_w,
|
||||||
height: page_info.img_data.cell_h,
|
height: page_info.img_data.cell_h
|
||||||
x: 0,
|
|
||||||
y: 0
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let dyn_img = DynamicImage::ImageRgb8(dyn_img);
|
||||||
|
|
||||||
let txt_img = match picker.protocol_type() {
|
let txt_img = match picker.protocol_type() {
|
||||||
ProtocolType::Kitty => {
|
ProtocolType::Kitty => {
|
||||||
let rn = SystemTime::now()
|
let rn = SystemTime::now()
|
||||||
@@ -157,7 +162,7 @@ pub async fn run_conversion_loop(
|
|||||||
};
|
};
|
||||||
|
|
||||||
// if ur pdf has 4 billion pages then you deserve to suffer
|
// if ur pdf has 4 billion pages then you deserve to suffer
|
||||||
img.num_or_id = NumberOrId::Id(NONZERO_ONE.saturating_add(page_num as u32));
|
img.num_or_id = NumberOrId::Id(NonZeroU32::MIN.saturating_add(page_num as u32));
|
||||||
|
|
||||||
ConvertedImage::Kitty {
|
ConvertedImage::Kitty {
|
||||||
img: MaybeTransferred::NotYet(img),
|
img: MaybeTransferred::NotYet(img),
|
||||||
@@ -167,7 +172,7 @@ pub async fn run_conversion_loop(
|
|||||||
}
|
}
|
||||||
_ => ConvertedImage::Generic(
|
_ => ConvertedImage::Generic(
|
||||||
picker
|
picker
|
||||||
.new_protocol(dyn_img, img_area, Resize::None)
|
.new_protocol(dyn_img, img_size, Resize::Crop(None))
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
RenderError::Converting(format!(
|
RenderError::Converting(format!(
|
||||||
"Couldn't convert DynamicImage to ratatui image: {e}"
|
"Couldn't convert DynamicImage to ratatui image: {e}"
|
||||||
|
|||||||
+86
-38
@@ -1,3 +1,4 @@
|
|||||||
|
use core::fmt::Display;
|
||||||
use std::{io::Write, num::NonZeroU32};
|
use std::{io::Write, num::NonZeroU32};
|
||||||
|
|
||||||
use crossterm::{
|
use crossterm::{
|
||||||
@@ -17,6 +18,7 @@ use kittage::{
|
|||||||
medium::Medium
|
medium::Medium
|
||||||
};
|
};
|
||||||
use ratatui::layout::Position;
|
use ratatui::layout::Position;
|
||||||
|
use smallvec::SmallVec;
|
||||||
|
|
||||||
use crate::converter::MaybeTransferred;
|
use crate::converter::MaybeTransferred;
|
||||||
|
|
||||||
@@ -63,7 +65,7 @@ impl<W: Write> Write for DbgWriter<W> {
|
|||||||
pub async fn run_action<'es>(
|
pub async fn run_action<'es>(
|
||||||
action: Action<'_, '_>,
|
action: Action<'_, '_>,
|
||||||
ev_stream: &'es mut EventStream
|
ev_stream: &'es mut EventStream
|
||||||
) -> Result<ImageId, TransmitError<<&'es mut EventStream as AsyncInputReader>::Error>> {
|
) -> Result<Option<ImageId>, TransmitError<<&'es mut EventStream as AsyncInputReader>::Error>> {
|
||||||
let writer = DbgWriter {
|
let writer = DbgWriter {
|
||||||
w: std::io::stdout().lock(),
|
w: std::io::stdout().lock(),
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
@@ -99,21 +101,51 @@ pub async fn do_shms_work(ev_stream: &mut EventStream) -> bool {
|
|||||||
res.is_ok()
|
res.is_ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ESTransErr<'es> = TransmitError<<&'es mut EventStream as AsyncInputReader>::Error>;
|
||||||
|
|
||||||
|
pub struct DisplayErr<'es> {
|
||||||
|
pub failed_pages: SmallVec<[usize; 2]>,
|
||||||
|
pub user_facing_err: &'static str,
|
||||||
|
pub source: DisplayErrSource<'es>
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'es> DisplayErr<'es> {
|
||||||
|
fn empty(user_facing_err: &'static str, source: ESTransErr<'es>) -> Self {
|
||||||
|
Self {
|
||||||
|
failed_pages: SmallVec::new(),
|
||||||
|
user_facing_err,
|
||||||
|
source: DisplayErrSource::Transmission(source)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub enum DisplayErrSource<'es> {
|
||||||
|
KittageReturnedNoId,
|
||||||
|
Transmission(ESTransErr<'es>)
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Display for DisplayErrSource<'_> {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
match self {
|
||||||
|
Self::KittageReturnedNoId => write!(
|
||||||
|
f,
|
||||||
|
"Kittage returned no ID when we asked it to display an image. This is a bug in kittage, please report it."
|
||||||
|
),
|
||||||
|
Self::Transmission(t) => write!(f, "Error with talking to the terminal: {t}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn display_kitty_images<'es>(
|
pub async fn display_kitty_images<'es>(
|
||||||
display: KittyDisplay<'_>,
|
display: KittyDisplay<'_>,
|
||||||
ev_stream: &'es mut EventStream
|
ev_stream: &'es mut EventStream,
|
||||||
) -> Result<
|
last_z_index: &mut i32
|
||||||
(),
|
) -> Result<(), DisplayErr<'es>> {
|
||||||
(
|
|
||||||
Vec<usize>,
|
|
||||||
&'static str,
|
|
||||||
TransmitError<<&'es mut EventStream as AsyncInputReader>::Error>
|
|
||||||
)
|
|
||||||
> {
|
|
||||||
let images = match display {
|
let images = match display {
|
||||||
KittyDisplay::NoChange => return Ok(()),
|
KittyDisplay::NoChange => return Ok(()),
|
||||||
KittyDisplay::DisplayImages(_) | KittyDisplay::ClearImages => {
|
KittyDisplay::ClearImages =>
|
||||||
run_action(
|
return run_action(
|
||||||
Action::Delete(DeleteConfig {
|
Action::Delete(DeleteConfig {
|
||||||
effect: ClearOrDelete::Clear,
|
effect: ClearOrDelete::Clear,
|
||||||
which: WhichToDelete::All
|
which: WhichToDelete::All
|
||||||
@@ -121,24 +153,23 @@ pub async fn display_kitty_images<'es>(
|
|||||||
ev_stream
|
ev_stream
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| (vec![], "Couldn't clear previous images", e))?;
|
.map_err(|e| DisplayErr::empty("Couldn't clear previous images", e))
|
||||||
|
.map(|_: Option<ImageId>| ()),
|
||||||
let KittyDisplay::DisplayImages(images) = display else {
|
KittyDisplay::DisplayImages(imgs) => imgs
|
||||||
return Ok(());
|
|
||||||
};
|
};
|
||||||
|
|
||||||
images
|
let new_z_index = last_z_index.wrapping_add_unsigned(1);
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let mut err = None;
|
let mut err = Ok::<(), (SmallVec<[usize; 2]>, DisplayErrSource<'es>)>(());
|
||||||
for KittyReadyToDisplay {
|
for KittyReadyToDisplay {
|
||||||
img,
|
img,
|
||||||
page_num,
|
page_num,
|
||||||
pos,
|
pos,
|
||||||
display_loc
|
mut display_loc
|
||||||
} in images
|
} in images
|
||||||
{
|
{
|
||||||
|
display_loc.z_index = new_z_index;
|
||||||
|
|
||||||
let config = DisplayConfig {
|
let config = DisplayConfig {
|
||||||
location: display_loc,
|
location: display_loc,
|
||||||
cursor_movement: CursorMovementPolicy::DontMove,
|
cursor_movement: CursorMovementPolicy::DontMove,
|
||||||
@@ -168,7 +199,7 @@ pub async fn display_kitty_images<'es>(
|
|||||||
};
|
};
|
||||||
std::mem::swap(image, &mut fake_image);
|
std::mem::swap(image, &mut fake_image);
|
||||||
|
|
||||||
let res = run_action(
|
run_action(
|
||||||
Action::TransmitAndDisplay {
|
Action::TransmitAndDisplay {
|
||||||
image: fake_image,
|
image: fake_image,
|
||||||
config,
|
config,
|
||||||
@@ -176,15 +207,13 @@ pub async fn display_kitty_images<'es>(
|
|||||||
},
|
},
|
||||||
ev_stream
|
ev_stream
|
||||||
)
|
)
|
||||||
.await;
|
.await
|
||||||
|
.map_err(DisplayErrSource::Transmission)
|
||||||
match res {
|
.and_then(|img_id| {
|
||||||
Ok(img_id) => {
|
img_id
|
||||||
*img = MaybeTransferred::Transferred(img_id);
|
.map(|id| *img = MaybeTransferred::Transferred(id))
|
||||||
Ok(())
|
.ok_or(DisplayErrSource::KittageReturnedNoId)
|
||||||
}
|
})
|
||||||
Err(e) => Err((page_num, e))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
MaybeTransferred::Transferred(image_id) => run_action(
|
MaybeTransferred::Transferred(image_id) => run_action(
|
||||||
Action::Display {
|
Action::Display {
|
||||||
@@ -195,20 +224,39 @@ pub async fn display_kitty_images<'es>(
|
|||||||
ev_stream
|
ev_stream
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.map(|_| ())
|
// don't need the return id 'cause we already know it
|
||||||
.map_err(|e| (page_num, e))
|
.map(|_: Option<ImageId>| ())
|
||||||
|
.map_err(DisplayErrSource::Transmission)
|
||||||
};
|
};
|
||||||
|
|
||||||
log::debug!("this_err is {this_err:#?}");
|
log::debug!("this_err is {this_err:#?}");
|
||||||
|
|
||||||
if let Err((id, e)) = this_err {
|
if let Err(e) = this_err {
|
||||||
let e = err.get_or_insert_with(|| (vec![], e));
|
match err.as_mut() {
|
||||||
e.0.push(id);
|
Ok(()) => err = Err((SmallVec::from([page_num].as_slice()), e)),
|
||||||
|
Err((v, _)) => v.push(page_num)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let z_idxes_to_remove = *last_z_index;
|
||||||
|
*last_z_index = new_z_index;
|
||||||
|
|
||||||
match err {
|
match err {
|
||||||
Some((replace, e)) => Err((replace, "Couldn't transfer image to the terminal", e)),
|
Err((failed_pages, source)) => Err(DisplayErr {
|
||||||
None => Ok(())
|
failed_pages,
|
||||||
|
user_facing_err: "Couldn't transfer image to the terminal",
|
||||||
|
source
|
||||||
|
}),
|
||||||
|
Ok(()) => run_action(
|
||||||
|
Action::Delete(DeleteConfig {
|
||||||
|
effect: ClearOrDelete::Clear,
|
||||||
|
which: WhichToDelete::PlacementsWithZIndex(z_idxes_to_remove)
|
||||||
|
}),
|
||||||
|
ev_stream
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.map_err(|e| DisplayErr::empty("Couldn't clear previously-sent images", e))
|
||||||
|
.map(|_| ())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+21
-9
@@ -38,7 +38,9 @@ use ratatui_image::{
|
|||||||
use tdf::{
|
use tdf::{
|
||||||
PrerenderLimit,
|
PrerenderLimit,
|
||||||
converter::{ConvertedPage, ConverterMsg, run_conversion_loop},
|
converter::{ConvertedPage, ConverterMsg, run_conversion_loop},
|
||||||
kitty::{KittyDisplay, display_kitty_images, do_shms_work, run_action},
|
kitty::{
|
||||||
|
DisplayErr, DisplayErrSource, KittyDisplay, display_kitty_images, do_shms_work, run_action
|
||||||
|
},
|
||||||
renderer::{self, MUPDF_BLACK, MUPDF_WHITE, RenderError, RenderInfo, RenderNotif},
|
renderer::{self, MUPDF_BLACK, MUPDF_WHITE, RenderError, RenderInfo, RenderNotif},
|
||||||
tui::{BottomMessage, InputAction, MessageSetting, Tui}
|
tui::{BottomMessage, InputAction, MessageSetting, Tui}
|
||||||
};
|
};
|
||||||
@@ -258,7 +260,7 @@ async fn inner_main() -> Result<(), WrappedErr> {
|
|||||||
// the 'equivalent' that is suggested instead is not the same. We need to keep
|
// the 'equivalent' that is suggested instead is not the same. We need to keep
|
||||||
// calling this.
|
// calling this.
|
||||||
#[expect(deprecated)]
|
#[expect(deprecated)]
|
||||||
Ok(Picker::from_fontsize((cell_width_px, cell_height_px)))
|
Ok(Picker::from_fontsize(FontSize { width: cell_width_px, height: cell_height_px }))
|
||||||
},
|
},
|
||||||
ratatui_image::errors::Errors::NoFontSize => Err(WrappedErr(
|
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()
|
"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()
|
||||||
@@ -313,7 +315,7 @@ async fn inner_main() -> Result<(), WrappedErr> {
|
|||||||
let mut term = Terminal::new(backend).map_err(|e| {
|
let mut term = Terminal::new(backend).map_err(|e| {
|
||||||
WrappedErr(format!("Couldn't set up crossterm's terminal backend: {e}").into())
|
WrappedErr(format!("Couldn't set up crossterm's terminal backend: {e}").into())
|
||||||
})?;
|
})?;
|
||||||
term.skip_diff(true);
|
// term.skip_diff(true);
|
||||||
|
|
||||||
enable_raw_mode().map_err(|e| {
|
enable_raw_mode().map_err(|e| {
|
||||||
WrappedErr(
|
WrappedErr(
|
||||||
@@ -388,6 +390,8 @@ async fn enter_redraw_loop(
|
|||||||
mut main_area: tdf::tui::RenderLayout,
|
mut main_area: tdf::tui::RenderLayout,
|
||||||
font_size: FontSize
|
font_size: FontSize
|
||||||
) -> Result<(), Box<dyn Error>> {
|
) -> Result<(), Box<dyn Error>> {
|
||||||
|
let mut kitty_z_idx = i32::MIN;
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
let mut needs_redraw = true;
|
let mut needs_redraw = true;
|
||||||
let next_ev = ev_stream.next().fuse();
|
let next_ev = ev_stream.next().fuse();
|
||||||
@@ -460,10 +464,16 @@ async fn enter_redraw_loop(
|
|||||||
to_display = tui.render(f, &main_area, font_size);
|
to_display = tui.render(f, &main_area, font_size);
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
let maybe_err = display_kitty_images(to_display, &mut ev_stream).await;
|
let maybe_err =
|
||||||
|
display_kitty_images(to_display, &mut ev_stream, &mut kitty_z_idx).await;
|
||||||
|
|
||||||
if let Err((to_replace, err_desc, enum_err)) = maybe_err {
|
if let Err(DisplayErr {
|
||||||
match enum_err {
|
failed_pages,
|
||||||
|
user_facing_err,
|
||||||
|
source
|
||||||
|
}) = maybe_err
|
||||||
|
{
|
||||||
|
match source {
|
||||||
// This is the error that kitty & ghostty provide us when they delete an
|
// This is the error that kitty & ghostty provide us when they delete an
|
||||||
// image due to memory constraints, so if we get it, we just fix it by
|
// image due to memory constraints, so if we get it, we just fix it by
|
||||||
// re-rendering so it don't display it to the user
|
// re-rendering so it don't display it to the user
|
||||||
@@ -471,13 +481,15 @@ async fn enter_redraw_loop(
|
|||||||
// [TODO] maybe when we detect that an image was deleted, we probe the
|
// [TODO] maybe when we detect that an image was deleted, we probe the
|
||||||
// terminal for the pages around it to see if they were deleted too and if
|
// terminal for the pages around it to see if they were deleted too and if
|
||||||
// they were, we re-render them? idk
|
// they were, we re-render them? idk
|
||||||
TransmitError::Terminal(TerminalError::NoEntity(_)) => (),
|
DisplayErrSource::Transmission(TransmitError::Terminal(
|
||||||
|
TerminalError::NoEntity(_)
|
||||||
|
)) => (),
|
||||||
_ => tui.set_msg(MessageSetting::Some(BottomMessage::Error(format!(
|
_ => tui.set_msg(MessageSetting::Some(BottomMessage::Error(format!(
|
||||||
"{err_desc}: {enum_err}"
|
"{user_facing_err}: {source}"
|
||||||
))))
|
))))
|
||||||
}
|
}
|
||||||
|
|
||||||
for page_num in to_replace {
|
for page_num in failed_pages {
|
||||||
tui.page_failed_display(page_num);
|
tui.page_failed_display(page_num);
|
||||||
// So that they get re-rendered and sent over again
|
// So that they get re-rendered and sent over again
|
||||||
to_renderer.send(RenderNotif::PageNeedsReRender(page_num))?;
|
to_renderer.send(RenderNotif::PageNeedsReRender(page_num))?;
|
||||||
|
|||||||
+3
-12
@@ -1,23 +1,14 @@
|
|||||||
use std::num::NonZeroUsize;
|
use std::num::NonZeroUsize;
|
||||||
|
|
||||||
use ratatui::widgets::Widget;
|
use ratatui::{prelude::buffer::CellDiffOption, widgets::Widget};
|
||||||
|
|
||||||
pub struct Skip {
|
pub struct Skip;
|
||||||
skip: bool
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Skip {
|
|
||||||
#[must_use]
|
|
||||||
pub fn new(skip: bool) -> Self {
|
|
||||||
Self { skip }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Widget for Skip {
|
impl Widget for Skip {
|
||||||
fn render(self, area: ratatui::prelude::Rect, buf: &mut ratatui::prelude::Buffer) {
|
fn render(self, area: ratatui::prelude::Rect, buf: &mut ratatui::prelude::Buffer) {
|
||||||
for x in area.x..(area.x + area.width) {
|
for x in area.x..(area.x + area.width) {
|
||||||
for y in area.y..(area.y + area.height) {
|
for y in area.y..(area.y + area.height) {
|
||||||
buf[(x, y)].skip = self.skip;
|
buf[(x, y)].diff_option = CellDiffOption::Skip;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+80
-65
@@ -72,7 +72,7 @@ struct PageConstraints {
|
|||||||
r_to_l: bool
|
r_to_l: bool
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default, Debug)]
|
#[derive(Default, Debug, Clone, Copy)]
|
||||||
struct Zoom {
|
struct Zoom {
|
||||||
// just how much 'zoom' you have. 0 means it fills the screen (instead of fits), such
|
// just how much 'zoom' you have. 0 means it fills the screen (instead of fits), such
|
||||||
// that one axis is fully on-screen
|
// that one axis is fully on-screen
|
||||||
@@ -86,7 +86,7 @@ struct Zoom {
|
|||||||
}
|
}
|
||||||
impl Zoom {
|
impl Zoom {
|
||||||
/// Returns the zoom factor, where 1 is the default and means fill-screen
|
/// Returns the zoom factor, where 1 is the default and means fill-screen
|
||||||
fn factor(&self) -> f32 {
|
fn factor(self) -> f32 {
|
||||||
// TODO: Make these configurable once we have a good way to set options after startup
|
// TODO: Make these configurable once we have a good way to set options after startup
|
||||||
const ZOOM_RATE: f32 = 1.1;
|
const ZOOM_RATE: f32 = 1.1;
|
||||||
const ZOOM_RATE_GRANULAR: f32 = 1.05;
|
const ZOOM_RATE_GRANULAR: f32 = 1.05;
|
||||||
@@ -262,7 +262,7 @@ impl Tui {
|
|||||||
let img_page_w_ratio = img_section_w / initial_page_w;
|
let img_page_w_ratio = img_section_w / initial_page_w;
|
||||||
let img_page_h_ratio = img_section_h / initial_page_h;
|
let img_page_h_ratio = img_section_h / initial_page_h;
|
||||||
|
|
||||||
let shrink_move_page = |dim: &mut u16, pos: &mut u16, axis_zoom_factor: f32| {
|
fn shrink_move_page(dim: &mut u16, pos: &mut u16, axis_zoom_factor: f32) {
|
||||||
let old_dim = *dim;
|
let old_dim = *dim;
|
||||||
// The axis zoom factor tells us what portion of the axis
|
// The axis zoom factor tells us what portion of the axis
|
||||||
// we need to show.
|
// we need to show.
|
||||||
@@ -272,26 +272,56 @@ impl Tui {
|
|||||||
.checked_sub(*dim)
|
.checked_sub(*dim)
|
||||||
.expect("zooming out should shrink the image")
|
.expect("zooming out should shrink the image")
|
||||||
/ 2;
|
/ 2;
|
||||||
};
|
|
||||||
|
|
||||||
// TODO: Detect max zoom-out in zoom levels
|
|
||||||
if img_page_w_ratio < img_page_h_ratio {
|
|
||||||
// vertical scroll / tall image. zooming out means decreasing the width of the page area
|
|
||||||
shrink_move_page(
|
|
||||||
&mut img_area.width,
|
|
||||||
&mut img_area.x,
|
|
||||||
// disallow zooming out past fit-screen
|
|
||||||
zoom_factor.max(1.0 / img_page_h_ratio)
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
// horizontal scroll / wide image. zooming out means decreasing the width of the page area
|
|
||||||
shrink_move_page(
|
|
||||||
&mut img_area.height,
|
|
||||||
&mut img_area.y,
|
|
||||||
// disallow zooming out past fit-screen
|
|
||||||
zoom_factor.max(1.0 / img_page_w_ratio)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn shrink_move_two_pass(
|
||||||
|
zoom: &mut Zoom,
|
||||||
|
dim: &mut u16,
|
||||||
|
pos: &mut u16,
|
||||||
|
zoom_factor: f32,
|
||||||
|
axis_zoom_factor: f32
|
||||||
|
) {
|
||||||
|
// To detect if we're already at fit-screen, we perform a first
|
||||||
|
// pass on `img_area` that emulates the last call to
|
||||||
|
// `render_zoomed` by subtracting from the `zoom`'s level. This
|
||||||
|
// holds because the `img_area` that gets passed is always the
|
||||||
|
// same.
|
||||||
|
let mut first_pass_dim = *dim;
|
||||||
|
let mut first_pass_pos = *pos;
|
||||||
|
let mut first_pass_zoom = *zoom;
|
||||||
|
|
||||||
|
if first_pass_zoom.level.is_negative() {
|
||||||
|
first_pass_zoom.step_in();
|
||||||
|
}
|
||||||
|
let first_pass_zoom_factor = first_pass_zoom.factor();
|
||||||
|
shrink_move_page(
|
||||||
|
&mut first_pass_dim,
|
||||||
|
&mut first_pass_pos,
|
||||||
|
first_pass_zoom_factor.max(1.0 / axis_zoom_factor)
|
||||||
|
);
|
||||||
|
|
||||||
|
log::debug!("first_pass_dim: {first_pass_dim}, first_pass_pos: {first_pass_pos}");
|
||||||
|
// vertical scroll / tall image. zooming out means decreasing
|
||||||
|
// the width of the page area
|
||||||
|
// use `max` to disallow zooming out past fit-screen
|
||||||
|
shrink_move_page(dim, pos, zoom_factor.max(1.0 / axis_zoom_factor));
|
||||||
|
|
||||||
|
log::debug!("new dim: {dim}, new pos: {pos}");
|
||||||
|
// The moment the image area is left unmodified, we've hit
|
||||||
|
// fit-screen and the zoom level ought be normalized.
|
||||||
|
if first_pass_dim == *dim && first_pass_pos == *pos {
|
||||||
|
zoom.step_in();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let (dim, pos, axis_zoom_factor) = if img_page_w_ratio < img_page_h_ratio {
|
||||||
|
(&mut img_area.width, &mut img_area.x, img_page_h_ratio)
|
||||||
|
} else {
|
||||||
|
// horizontal scroll / wide image. zooming out means decreasing
|
||||||
|
// the height of the page area
|
||||||
|
(&mut img_area.height, &mut img_area.y, img_page_w_ratio)
|
||||||
|
};
|
||||||
|
shrink_move_two_pass(zoom, dim, pos, zoom_factor, axis_zoom_factor);
|
||||||
}
|
}
|
||||||
log::debug!("after adjustment, page area is {img_area:#?}");
|
log::debug!("after adjustment, page area is {img_area:#?}");
|
||||||
|
|
||||||
@@ -319,8 +349,8 @@ impl Tui {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let width = (img_section_w * f32::from(font_size.0)) as u32;
|
let width = (img_section_w * f32::from(font_size.width)) as u32;
|
||||||
let height = (img_section_h * f32::from(font_size.1)) as u32;
|
let height = (img_section_h * f32::from(font_size.height)) as u32;
|
||||||
|
|
||||||
zoom.cell_pan_from_left = zoom
|
zoom.cell_pan_from_left = zoom
|
||||||
.cell_pan_from_left
|
.cell_pan_from_left
|
||||||
@@ -337,8 +367,8 @@ impl Tui {
|
|||||||
y: img_area.y
|
y: img_area.y
|
||||||
},
|
},
|
||||||
display_loc: DisplayLocation {
|
display_loc: DisplayLocation {
|
||||||
x: u32::from(zoom.cell_pan_from_left) * u32::from(font_size.0),
|
x: u32::from(zoom.cell_pan_from_left) * u32::from(font_size.width),
|
||||||
y: u32::from(zoom.cell_pan_from_top) * u32::from(font_size.1),
|
y: u32::from(zoom.cell_pan_from_top) * u32::from(font_size.height),
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
columns: img_area.width,
|
columns: img_area.width,
|
||||||
@@ -379,7 +409,7 @@ impl Tui {
|
|||||||
// resize this time), then go through every element in the buffer where any Image would
|
// resize this time), then go through every element in the buffer where any Image would
|
||||||
// be written and set to skip it so that ratatui doesn't spend a lot of time diffing it
|
// be written and set to skip it so that ratatui doesn't spend a lot of time diffing it
|
||||||
// each re-render
|
// each re-render
|
||||||
frame.render_widget(Skip::new(true), img_area);
|
frame.render_widget(Skip, img_area);
|
||||||
return KittyDisplay::NoChange;
|
return KittyDisplay::NoChange;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -701,31 +731,28 @@ impl Tui {
|
|||||||
match ev {
|
match ev {
|
||||||
Event::Key(key) => {
|
Event::Key(key) => {
|
||||||
match key.code {
|
match key.code {
|
||||||
KeyCode::Char(c) => {
|
KeyCode::Char(c)
|
||||||
// TODO: refactor back to `if let` arm guards when those are stabilized
|
|
||||||
if let BottomMessage::Input(InputCommand::Search(ref mut term)) =
|
if let BottomMessage::Input(InputCommand::Search(ref mut term)) =
|
||||||
self.bottom_msg
|
self.bottom_msg =>
|
||||||
{
|
{
|
||||||
term.push(c);
|
term.push(c);
|
||||||
return Some(InputAction::Redraw);
|
InputAction::Redraw.into()
|
||||||
}
|
}
|
||||||
|
KeyCode::Char(c)
|
||||||
if let BottomMessage::Input(InputCommand::GoToPage(ref mut page)) =
|
if let BottomMessage::Input(InputCommand::GoToPage(ref mut page)) =
|
||||||
self.bottom_msg
|
self.bottom_msg && matches!(c, 'g' if self.is_kitty) =>
|
||||||
{
|
c.to_digit(10).map(|input_num| {
|
||||||
if c == 'g' && self.is_kitty {
|
|
||||||
self.update_zoom(Zoom::pan_bottom);
|
|
||||||
self.set_msg(MessageSetting::Pop);
|
|
||||||
return Some(InputAction::Redraw);
|
|
||||||
}
|
|
||||||
|
|
||||||
return c.to_digit(10).map(|input_num| {
|
|
||||||
*page = (*page * 10) + input_num as usize;
|
*page = (*page * 10) + input_num as usize;
|
||||||
InputAction::Redraw
|
InputAction::Redraw
|
||||||
});
|
}),
|
||||||
|
KeyCode::Char(_)
|
||||||
|
if let BottomMessage::Input(InputCommand::GoToPage(_)) =
|
||||||
|
self.bottom_msg =>
|
||||||
|
{
|
||||||
|
self.set_msg(MessageSetting::Pop);
|
||||||
|
self.update_zoom(Zoom::pan_bottom)
|
||||||
}
|
}
|
||||||
|
KeyCode::Char(c) => match c {
|
||||||
match c {
|
|
||||||
'l' => self.change_page(PageChange::Next, ChangeAmount::Single),
|
'l' => self.change_page(PageChange::Next, ChangeAmount::Single),
|
||||||
'j' => self.change_page(PageChange::Next, ChangeAmount::WholeScreen),
|
'j' => self.change_page(PageChange::Next, ChangeAmount::WholeScreen),
|
||||||
'h' => self.change_page(PageChange::Prev, ChangeAmount::Single),
|
'h' => self.change_page(PageChange::Prev, ChangeAmount::Single),
|
||||||
@@ -749,10 +776,10 @@ impl Tui {
|
|||||||
Some(InputAction::Redraw)
|
Some(InputAction::Redraw)
|
||||||
}
|
}
|
||||||
'f' => Some(InputAction::Fullscreen),
|
'f' => Some(InputAction::Fullscreen),
|
||||||
'n' if self.page < self.rendered.len() - 1 => {
|
|
||||||
// TODO: If we can't find one, then maybe like block until we've verified
|
// TODO: If we can't find one, then maybe like block until we've verified
|
||||||
// all the pages have been checked?
|
// all the pages have been checked?
|
||||||
self.rendered[(self.page + 1)..]
|
'n' if self.page < self.rendered.len() - 1 => self.rendered
|
||||||
|
[(self.page + 1)..]
|
||||||
.iter()
|
.iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.find_map(|(idx, p)| {
|
.find_map(|(idx, p)| {
|
||||||
@@ -761,13 +788,8 @@ impl Tui {
|
|||||||
.then_some(self.page + 1 + idx)
|
.then_some(self.page + 1 + idx)
|
||||||
})
|
})
|
||||||
.map(|next_page| {
|
.map(|next_page| {
|
||||||
jump_to_page(
|
jump_to_page(&mut self.page, &mut self.last_render.rect, next_page)
|
||||||
&mut self.page,
|
}),
|
||||||
&mut self.last_render.rect,
|
|
||||||
next_page
|
|
||||||
)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
'N' if self.page > 0 => self.rendered[..(self.page)]
|
'N' if self.page > 0 => self.rendered[..(self.page)]
|
||||||
.iter()
|
.iter()
|
||||||
.rev()
|
.rev()
|
||||||
@@ -778,11 +800,7 @@ impl Tui {
|
|||||||
.then_some(self.page - (idx + 1))
|
.then_some(self.page - (idx + 1))
|
||||||
})
|
})
|
||||||
.map(|prev_page| {
|
.map(|prev_page| {
|
||||||
jump_to_page(
|
jump_to_page(&mut self.page, &mut self.last_render.rect, prev_page)
|
||||||
&mut self.page,
|
|
||||||
&mut self.last_render.rect,
|
|
||||||
prev_page
|
|
||||||
)
|
|
||||||
}),
|
}),
|
||||||
'z' if key.modifiers.contains(KeyModifiers::CONTROL) => {
|
'z' if key.modifiers.contains(KeyModifiers::CONTROL) => {
|
||||||
// [todo] better error handling here?
|
// [todo] better error handling here?
|
||||||
@@ -841,16 +859,13 @@ impl Tui {
|
|||||||
'$' if can_zoom => self.update_zoom(Zoom::pan_right),
|
'$' if can_zoom => self.update_zoom(Zoom::pan_right),
|
||||||
'r' => Some(InputAction::Rotate),
|
'r' => Some(InputAction::Rotate),
|
||||||
_ => None
|
_ => None
|
||||||
}
|
},
|
||||||
}
|
KeyCode::Backspace
|
||||||
KeyCode::Backspace => {
|
|
||||||
if let BottomMessage::Input(InputCommand::Search(ref mut term)) =
|
if let BottomMessage::Input(InputCommand::Search(ref mut term)) =
|
||||||
self.bottom_msg
|
self.bottom_msg =>
|
||||||
{
|
{
|
||||||
term.pop();
|
term.pop();
|
||||||
return Some(InputAction::Redraw);
|
InputAction::Redraw.into()
|
||||||
}
|
|
||||||
None
|
|
||||||
}
|
}
|
||||||
KeyCode::Right => self.change_page(PageChange::Next, ChangeAmount::Single),
|
KeyCode::Right => self.change_page(PageChange::Next, ChangeAmount::Single),
|
||||||
KeyCode::Down | KeyCode::PageDown =>
|
KeyCode::Down | KeyCode::PageDown =>
|
||||||
|
|||||||
Reference in New Issue
Block a user