mirror of
https://github.com/itsjunetime/tdf.git
synced 2026-06-27 08:04:29 -04:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2329bbbfeb | |||
| a6a9471bef | |||
| bd00c7e913 |
Generated
+209
-458
File diff suppressed because it is too large
Load Diff
+11
-3
@@ -22,16 +22,21 @@ path = "src/main.rs"
|
||||
name = "tdf"
|
||||
|
||||
[dependencies]
|
||||
ratatui = { version = "^0.30.1", default-features = false, features = [ "crossterm", "layout-cache" ] }
|
||||
ratatui-image = { version = "11.0", default-features = false }
|
||||
# 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", rev = "720ac2d0cad1ac6424364fea74856fec9c100cb1", default-features = false, features = [ "crossterm", "layout-cache" ] }
|
||||
# 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 = "8ad154a219c1e4832a378bd07aaf39b3ddff959b", default-features = false }
|
||||
# ratatui-image = { path = "./ratatui-image", default-features = false }
|
||||
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 }
|
||||
notify = { version = "8.0.0", features = ["crossbeam-channel"] }
|
||||
tokio = { version = "1.37.0", features = ["rt-multi-thread", "macros"] }
|
||||
futures-util = { version = "0.3.30", default-features = false }
|
||||
flume = { version = "0.12.0", default-features = false, features = ["async"] }
|
||||
xflags = "0.4.0-pre.2"
|
||||
mimalloc = { version = "0.1.43", features = [ "debug_in_debug" ] }
|
||||
mimalloc = "0.1.43"
|
||||
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"] }
|
||||
rayon = { version = "1", default-features = false }
|
||||
@@ -49,6 +54,9 @@ flexi_logger = "0.31"
|
||||
# for tracing with tokio-console
|
||||
console-subscriber = { version = "0.5.0", optional = true }
|
||||
|
||||
[patch.crates-io]
|
||||
pathfinder_simd = { git = "https://github.com/itsjunetime/pathfinder.git", rev = "814671e162a1829e074521446317b915311d3d4d" }
|
||||
|
||||
[profile.production]
|
||||
inherits = "release"
|
||||
lto = "fat"
|
||||
|
||||
+4
-10
@@ -4,10 +4,7 @@ use crossterm::terminal::WindowSize;
|
||||
use flume::{Sender, r#async::RecvStream, unbounded};
|
||||
use futures_util::stream::StreamExt as _;
|
||||
use ratatui::layout::Rect;
|
||||
use ratatui_image::{
|
||||
FontSize,
|
||||
picker::{Picker, ProtocolType}
|
||||
};
|
||||
use ratatui_image::picker::{Picker, ProtocolType};
|
||||
use tdf::{
|
||||
converter::{ConvertedPage, ConverterMsg, run_conversion_loop},
|
||||
renderer::{RenderError, RenderInfo, RenderNotif, fill_default, start_rendering}
|
||||
@@ -57,10 +54,7 @@ pub struct RenderState {
|
||||
pub to_render_tx: Sender<RenderNotif>
|
||||
}
|
||||
|
||||
const FONT_SIZE: FontSize = FontSize {
|
||||
width: 8,
|
||||
height: 14
|
||||
};
|
||||
const FONT_SIZE: (u16, u16) = (8, 14);
|
||||
|
||||
pub fn start_rendering_loop(
|
||||
path: impl AsRef<Path>,
|
||||
@@ -80,8 +74,8 @@ pub fn start_rendering_loop(
|
||||
let size = WindowSize {
|
||||
columns,
|
||||
rows,
|
||||
height: rows * FONT_SIZE.height,
|
||||
width: columns * FONT_SIZE.width
|
||||
height: rows * FONT_SIZE.1,
|
||||
width: columns * FONT_SIZE.0
|
||||
};
|
||||
|
||||
let main_area = Rect {
|
||||
|
||||
+1
-1
Submodule ratatui updated: 720ac2d0ca...abe7dcf234
+1
-1
Submodule ratatui-image updated: 8ad154a219...f791e0a99c
+10
-8
@@ -8,7 +8,7 @@ use flume::{Receiver, SendError, Sender, TryRecvError};
|
||||
use futures_util::stream::StreamExt as _;
|
||||
use image::{DynamicImage, codecs::pnm::PnmDecoder};
|
||||
use kittage::NumberOrId;
|
||||
use ratatui::prelude::Size;
|
||||
use ratatui::layout::Rect;
|
||||
use ratatui_image::{
|
||||
Resize,
|
||||
picker::{Picker, ProtocolType},
|
||||
@@ -27,7 +27,7 @@ pub enum MaybeTransferred {
|
||||
Transferred(kittage::ImageId)
|
||||
}
|
||||
|
||||
// #[derive(Debug)]
|
||||
#[derive(Debug)]
|
||||
pub enum ConvertedImage {
|
||||
Generic(Protocol),
|
||||
Kitty {
|
||||
@@ -42,8 +42,8 @@ impl ConvertedImage {
|
||||
pub fn w_h(&self) -> (u16, u16) {
|
||||
match self {
|
||||
Self::Generic(prot) => {
|
||||
let Size { width, height } = prot.size();
|
||||
(width, height)
|
||||
let a = prot.area();
|
||||
(a.width, a.height)
|
||||
}
|
||||
Self::Kitty {
|
||||
img: _,
|
||||
@@ -72,7 +72,7 @@ pub async fn run_conversion_loop(
|
||||
picker: Picker,
|
||||
prerender: usize,
|
||||
shms_work: bool
|
||||
) -> Result<(), Box<SendError<Result<ConvertedPage, RenderError>>>> {
|
||||
) -> Result<(), SendError<Result<ConvertedPage, RenderError>>> {
|
||||
let mut images = vec![];
|
||||
let mut page: usize = 0;
|
||||
let pid = std::process::id();
|
||||
@@ -134,9 +134,11 @@ pub async fn run_conversion_loop(
|
||||
.for_each(|(_, _, px)| px.0[2] = px.0[2].saturating_sub(u8::MAX / 2));
|
||||
}
|
||||
|
||||
let img_size = Size {
|
||||
let img_area = Rect {
|
||||
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);
|
||||
@@ -172,7 +174,7 @@ pub async fn run_conversion_loop(
|
||||
}
|
||||
_ => ConvertedImage::Generic(
|
||||
picker
|
||||
.new_protocol(dyn_img, img_size, Resize::Crop(None))
|
||||
.new_protocol(dyn_img, img_area, Resize::None)
|
||||
.map_err(|e| {
|
||||
RenderError::Converting(format!(
|
||||
"Couldn't convert DynamicImage to ratatui image: {e}"
|
||||
|
||||
+55
-7
@@ -1,5 +1,8 @@
|
||||
use core::fmt::Display;
|
||||
use std::{io::Write, num::NonZeroU32};
|
||||
use std::{
|
||||
io::{StdoutLock, Write, stdout},
|
||||
num::NonZeroU32
|
||||
};
|
||||
|
||||
use crossterm::{
|
||||
cursor::MoveTo,
|
||||
@@ -15,7 +18,8 @@ use kittage::{
|
||||
display::{CursorMovementPolicy, DisplayConfig, DisplayLocation},
|
||||
error::TransmitError,
|
||||
image::Image,
|
||||
medium::Medium
|
||||
medium::Medium,
|
||||
tmux::TmuxWriter
|
||||
};
|
||||
use ratatui::layout::Position;
|
||||
use smallvec::SmallVec;
|
||||
@@ -32,7 +36,7 @@ pub struct KittyReadyToDisplay<'tui> {
|
||||
pub enum KittyDisplay<'tui> {
|
||||
NoChange,
|
||||
ClearImages,
|
||||
DisplayImages(Vec<KittyReadyToDisplay<'tui>>)
|
||||
DisplayImages(SmallVec<[KittyReadyToDisplay<'tui>; 1]>)
|
||||
}
|
||||
|
||||
pub struct DbgWriter<W: Write> {
|
||||
@@ -62,22 +66,58 @@ impl<W: Write> Write for DbgWriter<W> {
|
||||
}
|
||||
}
|
||||
|
||||
pub enum MaybeTmuxWriter<W>
|
||||
where
|
||||
W: Write
|
||||
{
|
||||
Tmux(TmuxWriter<W>),
|
||||
Normal(W)
|
||||
}
|
||||
|
||||
impl<W: Write> MaybeTmuxWriter<W> {
|
||||
pub fn new(w: W, is_tmux: bool) -> Self {
|
||||
if is_tmux {
|
||||
Self::Tmux(TmuxWriter::new(w))
|
||||
} else {
|
||||
Self::Normal(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<W: Write> Write for &mut MaybeTmuxWriter<W> {
|
||||
fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
|
||||
match *self {
|
||||
MaybeTmuxWriter::Tmux(t) => t.write(buf),
|
||||
MaybeTmuxWriter::Normal(w) => w.write(buf)
|
||||
}
|
||||
}
|
||||
|
||||
fn flush(&mut self) -> std::io::Result<()> {
|
||||
match *self {
|
||||
MaybeTmuxWriter::Tmux(t) => t.flush(),
|
||||
MaybeTmuxWriter::Normal(w) => w.flush()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn run_action<'es>(
|
||||
action: Action<'_, '_>,
|
||||
writer: &mut MaybeTmuxWriter<StdoutLock<'_>>,
|
||||
ev_stream: &'es mut EventStream
|
||||
) -> Result<Option<ImageId>, TransmitError<<&'es mut EventStream as AsyncInputReader>::Error>> {
|
||||
let writer = DbgWriter {
|
||||
w: std::io::stdout().lock(),
|
||||
w: writer,
|
||||
#[cfg(debug_assertions)]
|
||||
buf: String::new()
|
||||
};
|
||||
|
||||
action
|
||||
.execute_async(writer, ev_stream)
|
||||
.await
|
||||
.map(|(_, i)| i)
|
||||
}
|
||||
|
||||
pub async fn do_shms_work(ev_stream: &mut EventStream) -> bool {
|
||||
pub async fn do_shms_work(is_tmux: bool, ev_stream: &mut EventStream) -> bool {
|
||||
let img = DynamicImage::new_rgb8(1, 1);
|
||||
let pid = std::process::id();
|
||||
let shm_name = format!("tdf_test_{pid}");
|
||||
@@ -94,7 +134,8 @@ pub async fn do_shms_work(ev_stream: &mut EventStream) -> bool {
|
||||
|
||||
enable_raw_mode().unwrap();
|
||||
|
||||
let res = run_action(Action::Query(&k_img), ev_stream).await;
|
||||
let mut writer = MaybeTmuxWriter::new(stdout().lock(), is_tmux);
|
||||
let res = run_action(Action::Query(&k_img), &mut writer, ev_stream).await;
|
||||
|
||||
disable_raw_mode().unwrap();
|
||||
|
||||
@@ -139,9 +180,12 @@ impl Display for DisplayErrSource<'_> {
|
||||
|
||||
pub async fn display_kitty_images<'es>(
|
||||
display: KittyDisplay<'_>,
|
||||
is_tmux: bool,
|
||||
ev_stream: &'es mut EventStream,
|
||||
last_z_index: &mut i32
|
||||
) -> Result<(), DisplayErr<'es>> {
|
||||
let mut writer = MaybeTmuxWriter::new(stdout().lock(), is_tmux);
|
||||
|
||||
let images = match display {
|
||||
KittyDisplay::NoChange => return Ok(()),
|
||||
KittyDisplay::ClearImages =>
|
||||
@@ -150,6 +194,7 @@ pub async fn display_kitty_images<'es>(
|
||||
effect: ClearOrDelete::Clear,
|
||||
which: WhichToDelete::All
|
||||
}),
|
||||
&mut writer,
|
||||
ev_stream
|
||||
)
|
||||
.await
|
||||
@@ -176,7 +221,7 @@ pub async fn display_kitty_images<'es>(
|
||||
..DisplayConfig::default()
|
||||
};
|
||||
|
||||
execute!(std::io::stdout(), MoveTo(pos.x, pos.y)).unwrap();
|
||||
execute!(&mut writer, MoveTo(pos.x, pos.y)).unwrap();
|
||||
|
||||
log::debug!("going to display img {img:#?}");
|
||||
log::debug!("displaying with config {config:#?}");
|
||||
@@ -205,6 +250,7 @@ pub async fn display_kitty_images<'es>(
|
||||
config,
|
||||
placement_id: None
|
||||
},
|
||||
&mut writer,
|
||||
ev_stream
|
||||
)
|
||||
.await
|
||||
@@ -221,6 +267,7 @@ pub async fn display_kitty_images<'es>(
|
||||
placement_id: *image_id,
|
||||
config
|
||||
},
|
||||
&mut writer,
|
||||
ev_stream
|
||||
)
|
||||
.await
|
||||
@@ -253,6 +300,7 @@ pub async fn display_kitty_images<'es>(
|
||||
effect: ClearOrDelete::Clear,
|
||||
which: WhichToDelete::PlacementsWithZIndex(z_idxes_to_remove)
|
||||
}),
|
||||
&mut writer,
|
||||
ev_stream
|
||||
)
|
||||
.await
|
||||
|
||||
+40
-26
@@ -1,7 +1,4 @@
|
||||
use core::{
|
||||
error::Error,
|
||||
num::{NonZeroU32, NonZeroUsize}
|
||||
};
|
||||
use core::{error::Error, num::NonZeroUsize};
|
||||
use std::{
|
||||
borrow::Cow,
|
||||
ffi::OsString,
|
||||
@@ -16,8 +13,8 @@ use crossterm::{
|
||||
event::EventStream,
|
||||
execute,
|
||||
terminal::{
|
||||
EndSynchronizedUpdate, EnterAlternateScreen, LeaveAlternateScreen, disable_raw_mode,
|
||||
enable_raw_mode, window_size
|
||||
EndSynchronizedUpdate, EnterAlternateScreen, LeaveAlternateScreen, WindowSize,
|
||||
disable_raw_mode, enable_raw_mode, window_size
|
||||
}
|
||||
};
|
||||
use debounce::EventDebouncer;
|
||||
@@ -39,7 +36,8 @@ use tdf::{
|
||||
PrerenderLimit,
|
||||
converter::{ConvertedPage, ConverterMsg, run_conversion_loop},
|
||||
kitty::{
|
||||
DisplayErr, DisplayErrSource, KittyDisplay, display_kitty_images, do_shms_work, run_action
|
||||
DisplayErr, DisplayErrSource, KittyDisplay, MaybeTmuxWriter, display_kitty_images,
|
||||
do_shms_work, run_action
|
||||
},
|
||||
renderer::{self, MUPDF_BLACK, MUPDF_WHITE, RenderError, RenderInfo, RenderNotif},
|
||||
tui::{BottomMessage, InputAction, MessageSetting, Tui}
|
||||
@@ -250,22 +248,20 @@ async fn inner_main() -> Result<(), WrappedErr> {
|
||||
// We need to create `picker` on this thread because if we create it on the `renderer` thread,
|
||||
// it messes up something with user input. Input never makes it to the crossterm thing
|
||||
let picker = Picker::from_query_stdio()
|
||||
.or_else(|e| match e {
|
||||
ratatui_image::errors::Errors::NoFontSize if
|
||||
window_size.width != 0
|
||||
&& window_size.height != 0
|
||||
&& window_size.columns != 0
|
||||
&& window_size.rows != 0 =>
|
||||
{
|
||||
.or_else(|e| match (e, window_size) {
|
||||
(
|
||||
ratatui_image::errors::Errors::NoFontSize,
|
||||
WindowSize { width: 1.., height: 1.., columns: 1.., rows: 1.. }
|
||||
) => {
|
||||
// the 'equivalent' that is suggested instead is not the same. We need to keep
|
||||
// calling this.
|
||||
#[expect(deprecated)]
|
||||
Ok(Picker::from_fontsize(FontSize { width: cell_width_px, height: cell_height_px }))
|
||||
Ok(Picker::from_fontsize((cell_width_px, 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()
|
||||
)),
|
||||
e => Err(WrappedErr(format!("Couldn't get the necessary information to set up images: {e}").into()))
|
||||
(e, _) => Err(WrappedErr(format!("Couldn't get the necessary information to set up images: {e}").into()))
|
||||
})?;
|
||||
|
||||
// then we want to spawn off the rendering task
|
||||
@@ -298,8 +294,9 @@ async fn inner_main() -> Result<(), WrappedErr> {
|
||||
let (to_main, from_converter) = flume::unbounded();
|
||||
|
||||
let is_kitty = picker.protocol_type() == ProtocolType::Kitty;
|
||||
let is_tmux = picker.is_tmux();
|
||||
|
||||
let shms_work = is_kitty && do_shms_work(&mut ev_stream).await;
|
||||
let shms_work = is_kitty && do_shms_work(is_tmux, &mut ev_stream).await;
|
||||
|
||||
tokio::spawn(run_conversion_loop(
|
||||
to_main, from_main, picker, 20, shms_work
|
||||
@@ -315,7 +312,7 @@ async fn inner_main() -> Result<(), WrappedErr> {
|
||||
let mut term = Terminal::new(backend).map_err(|e| {
|
||||
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| {
|
||||
WrappedErr(
|
||||
@@ -324,11 +321,13 @@ async fn inner_main() -> Result<(), WrappedErr> {
|
||||
})?;
|
||||
|
||||
if is_kitty {
|
||||
let mut writer = MaybeTmuxWriter::new(stdout().lock(), is_tmux);
|
||||
run_action(
|
||||
Action::Delete(DeleteConfig {
|
||||
effect: ClearOrDelete::Delete,
|
||||
which: WhichToDelete::IdRange(NonZeroU32::new(1).unwrap()..=NonZeroU32::MAX)
|
||||
which: WhichToDelete::All
|
||||
}),
|
||||
&mut writer,
|
||||
&mut ev_stream
|
||||
)
|
||||
.await
|
||||
@@ -350,13 +349,14 @@ async fn inner_main() -> Result<(), WrappedErr> {
|
||||
let tui_rx = tui_rx.into_stream();
|
||||
let from_converter = from_converter.into_stream();
|
||||
|
||||
enter_redraw_loop(
|
||||
ev_stream,
|
||||
let res = enter_redraw_loop(
|
||||
&mut ev_stream,
|
||||
to_renderer,
|
||||
tui_rx,
|
||||
to_converter,
|
||||
from_converter,
|
||||
fullscreen,
|
||||
is_tmux,
|
||||
tui,
|
||||
&mut term,
|
||||
main_area,
|
||||
@@ -370,21 +370,35 @@ async fn inner_main() -> Result<(), WrappedErr> {
|
||||
)
|
||||
.into()
|
||||
)
|
||||
})?;
|
||||
});
|
||||
|
||||
if is_kitty {
|
||||
let mut writer = MaybeTmuxWriter::new(stdout().lock(), is_tmux);
|
||||
_ = run_action(
|
||||
Action::Delete(DeleteConfig {
|
||||
effect: ClearOrDelete::Delete,
|
||||
which: WhichToDelete::All
|
||||
}),
|
||||
&mut writer,
|
||||
&mut ev_stream
|
||||
)
|
||||
.await;
|
||||
}
|
||||
drop(maybe_logger);
|
||||
Ok(())
|
||||
|
||||
res
|
||||
}
|
||||
|
||||
// oh shut up clippy who cares
|
||||
#[expect(clippy::too_many_arguments)]
|
||||
async fn enter_redraw_loop(
|
||||
mut ev_stream: EventStream,
|
||||
ev_stream: &mut EventStream,
|
||||
to_renderer: Sender<RenderNotif>,
|
||||
mut tui_rx: RecvStream<'_, Result<RenderInfo, RenderError>>,
|
||||
to_converter: Sender<ConverterMsg>,
|
||||
mut from_converter: RecvStream<'_, Result<ConvertedPage, RenderError>>,
|
||||
mut fullscreen: bool,
|
||||
is_tmux: bool,
|
||||
mut tui: Tui,
|
||||
term: &mut Terminal<CrosstermBackend<Stdout>>,
|
||||
mut main_area: tdf::tui::RenderLayout,
|
||||
@@ -465,7 +479,7 @@ async fn enter_redraw_loop(
|
||||
})?;
|
||||
|
||||
let maybe_err =
|
||||
display_kitty_images(to_display, &mut ev_stream, &mut kitty_z_idx).await;
|
||||
display_kitty_images(to_display, is_tmux, ev_stream, &mut kitty_z_idx).await;
|
||||
|
||||
if let Err(DisplayErr {
|
||||
failed_pages,
|
||||
|
||||
+12
-3
@@ -1,14 +1,23 @@
|
||||
use std::num::NonZeroUsize;
|
||||
|
||||
use ratatui::{prelude::buffer::CellDiffOption, widgets::Widget};
|
||||
use ratatui::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 {
|
||||
fn render(self, area: ratatui::prelude::Rect, buf: &mut ratatui::prelude::Buffer) {
|
||||
for x in area.x..(area.x + area.width) {
|
||||
for y in area.y..(area.y + area.height) {
|
||||
buf[(x, y)].diff_option = CellDiffOption::Skip;
|
||||
buf[(x, y)].skip = self.skip;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+9
-8
@@ -19,6 +19,7 @@ use ratatui::{
|
||||
widgets::{Block, Borders, Clear, Padding, Paragraph, Wrap}
|
||||
};
|
||||
use ratatui_image::{FontSize, Image};
|
||||
use smallvec::SmallVec;
|
||||
|
||||
use crate::{
|
||||
FitOrFill,
|
||||
@@ -349,8 +350,8 @@ impl Tui {
|
||||
}
|
||||
}
|
||||
|
||||
let width = (img_section_w * f32::from(font_size.width)) as u32;
|
||||
let height = (img_section_h * f32::from(font_size.height)) as u32;
|
||||
let width = (img_section_w * f32::from(font_size.0)) as u32;
|
||||
let height = (img_section_h * f32::from(font_size.1)) as u32;
|
||||
|
||||
zoom.cell_pan_from_left = zoom
|
||||
.cell_pan_from_left
|
||||
@@ -359,7 +360,7 @@ impl Tui {
|
||||
.cell_pan_from_top
|
||||
.min(img_cell_h.saturating_sub(img_section_h.ceil() as u16));
|
||||
|
||||
KittyDisplay::DisplayImages(vec![KittyReadyToDisplay {
|
||||
KittyDisplay::DisplayImages(SmallVec::from([KittyReadyToDisplay {
|
||||
img,
|
||||
page_num,
|
||||
pos: Position {
|
||||
@@ -367,15 +368,15 @@ impl Tui {
|
||||
y: img_area.y
|
||||
},
|
||||
display_loc: DisplayLocation {
|
||||
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.height),
|
||||
x: u32::from(zoom.cell_pan_from_left) * u32::from(font_size.0),
|
||||
y: u32::from(zoom.cell_pan_from_top) * u32::from(font_size.1),
|
||||
width,
|
||||
height,
|
||||
columns: img_area.width,
|
||||
rows: img_area.height,
|
||||
..DisplayLocation::default()
|
||||
}
|
||||
}])
|
||||
}]))
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
@@ -409,7 +410,7 @@ impl Tui {
|
||||
// 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
|
||||
// each re-render
|
||||
frame.render_widget(Skip, img_area);
|
||||
frame.render_widget(Skip::new(true), img_area);
|
||||
return KittyDisplay::NoChange;
|
||||
}
|
||||
|
||||
@@ -517,7 +518,7 @@ impl Tui {
|
||||
display_loc: DisplayLocation::default()
|
||||
})
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
.collect::<SmallVec<_>>();
|
||||
|
||||
// we want to set this at the very end so it doesn't get set somewhere halfway through and
|
||||
// then the whole diffing thing messes it up
|
||||
|
||||
Reference in New Issue
Block a user