[WIP] try to fix freezes (doesn't work)

This commit is contained in:
2024-02-11 08:45:55 +01:00
parent f08fa31887
commit dd4ef915ac

View File

@ -70,16 +70,23 @@ impl OverlappableWidget for EmptyWidget {
#[cfg(feature = "images")]
mod images {
use std::sync::Mutex;
use ratatui_image::picker::Picker;
use super::*;
lazy_static::lazy_static! {
static ref PROTOCOL_PICKER: ratatui_image::picker::Picker = make_protocol_picker();
static ref PROTOCOL_PICKER_LOCK: Mutex<()> = Mutex::new(());
static ref PROTOCOL_PICKER: Picker = make_protocol_picker();
}
fn make_protocol_picker() -> ratatui_image::picker::Picker {
fn make_protocol_picker() -> Picker {
let guard = PROTOCOL_PICKER_LOCK.lock().unwrap();
let mut picker = ratatui_image::picker::Picker::from_termios()
.expect("ratatui_image::picker::Picker::from_termios() failed");
picker.guess_protocol();
drop(guard);
picker
}
@ -96,6 +103,7 @@ mod images {
20 // TODO
}
fn render_overlap(self, area: Rect, buf: &mut Buffer) -> (u16, u16) {
/*
let width = u16::min(100, area.width);
let width_px: u32 = (width as u32) * (PROTOCOL_PICKER.font_size.0 as u32);
let height_px = width_px * self.0.height() / self.0.width();
@ -116,7 +124,8 @@ mod images {
.expect("picker.new_protocol failed");
let widget= ratatui_image::Image::new(protocol.as_ref());
widget.render(area, buf); // TODO: scroll
(area.width, area.height)
*/
(area.width, 20)
}
}
}