mirror of
https://github.com/itsjunetime/tdf.git
synced 2026-06-02 08:01:47 -04:00
Prevent page clear/show flash on kitty when pages have been cleared from memory. (#148)
* wip; start working on making it not flash when transferring new images * don't delete the images, just clear them * add changelog entry * fmt
This commit is contained in:
@@ -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
+7
-8
@@ -1573,9 +1573,9 @@ checksum = "7a79a3332a6609480d7d0c9eab957bca6b455b91bb84e66d19f5ff66294b85b8"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libc"
|
name = "libc"
|
||||||
version = "0.2.185"
|
version = "0.2.186"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "52ff2c0fe9bc6cb6b14a0592c2ff4fa9ceb83eea9db979b0487cd054946a2b8f"
|
checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libfuzzer-sys"
|
name = "libfuzzer-sys"
|
||||||
@@ -1605,12 +1605,11 @@ checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libmimalloc-sys"
|
name = "libmimalloc-sys"
|
||||||
version = "0.1.44"
|
version = "0.1.47"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "667f4fec20f29dfc6bc7357c582d91796c169ad7e2fce709468aefeb2c099870"
|
checksum = "2d1eacfa31c33ec25e873c136ba5669f00f9866d0688bea7be4d3f7e43067df6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cc",
|
"cc",
|
||||||
"libc",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1727,9 +1726,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mimalloc"
|
name = "mimalloc"
|
||||||
version = "0.1.48"
|
version = "0.1.50"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e1ee66a4b64c74f4ef288bcbb9192ad9c3feaad75193129ac8509af543894fd8"
|
checksum = "b3627c4272df786b9260cabaa46aec1d59c93ede723d4c3ef646c503816b0640"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libmimalloc-sys",
|
"libmimalloc-sys",
|
||||||
]
|
]
|
||||||
@@ -2081,7 +2080,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "pathfinder_simd"
|
name = "pathfinder_simd"
|
||||||
version = "0.5.5"
|
version = "0.5.5"
|
||||||
source = "git+https://github.com/itsjunetime/pathfinder.git?branch=fix_nightly_arm_simd#814671e162a1829e074521446317b915311d3d4d"
|
source = "git+https://github.com/itsjunetime/pathfinder.git?rev=814671e162a1829e074521446317b915311d3d4d#814671e162a1829e074521446317b915311d3d4d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"rustc_version",
|
"rustc_version",
|
||||||
]
|
]
|
||||||
|
|||||||
+1
-1
@@ -55,7 +55,7 @@ flexi_logger = "0.31"
|
|||||||
console-subscriber = { version = "0.5.0", optional = true }
|
console-subscriber = { version = "0.5.0", optional = true }
|
||||||
|
|
||||||
[patch.crates-io]
|
[patch.crates-io]
|
||||||
pathfinder_simd = { git = "https://github.com/itsjunetime/pathfinder.git", branch = "fix_nightly_arm_simd" }
|
pathfinder_simd = { git = "https://github.com/itsjunetime/pathfinder.git", rev = "814671e162a1829e074521446317b915311d3d4d" }
|
||||||
|
|
||||||
[profile.production]
|
[profile.production]
|
||||||
inherits = "release"
|
inherits = "release"
|
||||||
|
|||||||
+44
-32
@@ -139,12 +139,13 @@ impl Display for DisplayErrSource<'_> {
|
|||||||
|
|
||||||
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,
|
||||||
|
last_z_index: &mut i32
|
||||||
) -> Result<(), DisplayErr<'es>> {
|
) -> Result<(), DisplayErr<'es>> {
|
||||||
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
|
||||||
@@ -152,24 +153,23 @@ pub async fn display_kitty_images<'es>(
|
|||||||
ev_stream
|
ev_stream
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| DisplayErr::empty("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 = Ok::<(), (SmallVec<[usize; 2]>, DisplayErrSource<'es>)>(());
|
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,
|
||||||
@@ -199,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,
|
||||||
@@ -207,16 +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(Some(img_id)) => {
|
img_id
|
||||||
*img = MaybeTransferred::Transferred(img_id);
|
.map(|id| *img = MaybeTransferred::Transferred(id))
|
||||||
Ok(())
|
.ok_or(DisplayErrSource::KittageReturnedNoId)
|
||||||
}
|
})
|
||||||
Ok(None) => Err((page_num, DisplayErrSource::KittageReturnedNoId)),
|
|
||||||
Err(e) => Err((page_num, DisplayErrSource::Transmission(e)))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
MaybeTransferred::Transferred(image_id) => run_action(
|
MaybeTransferred::Transferred(image_id) => run_action(
|
||||||
Action::Display {
|
Action::Display {
|
||||||
@@ -229,22 +226,37 @@ pub async fn display_kitty_images<'es>(
|
|||||||
.await
|
.await
|
||||||
// don't need the return id 'cause we already know it
|
// don't need the return id 'cause we already know it
|
||||||
.map(|_: Option<ImageId>| ())
|
.map(|_: Option<ImageId>| ())
|
||||||
.map_err(|e| (page_num, DisplayErrSource::Transmission(e)))
|
.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 {
|
||||||
match err.as_mut() {
|
match err.as_mut() {
|
||||||
Ok(()) => err = Err((SmallVec::from([id].as_slice()), e)),
|
Ok(()) => err = Err((SmallVec::from([page_num].as_slice()), e)),
|
||||||
Err((v, _)) => v.push(id)
|
Err((v, _)) => v.push(page_num)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err.map_err(|(failed_pages, source)| DisplayErr {
|
let z_idxes_to_remove = *last_z_index;
|
||||||
failed_pages,
|
*last_z_index = new_z_index;
|
||||||
user_facing_err: "Couldn't transfer image to the terminal",
|
|
||||||
source
|
match err {
|
||||||
})
|
Err((failed_pages, source)) => Err(DisplayErr {
|
||||||
|
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(|_| ())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-1
@@ -390,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();
|
||||||
@@ -462,7 +464,8 @@ 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(DisplayErr {
|
if let Err(DisplayErr {
|
||||||
failed_pages,
|
failed_pages,
|
||||||
|
|||||||
Reference in New Issue
Block a user