mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-24 08:11:04 +00:00
29 lines
558 B
Rust
29 lines
558 B
Rust
use ratatui::{buffer::Buffer, widgets::Widget};
|
|
|
|
use crate::Ctx;
|
|
|
|
pub(crate) struct Preview<'a> {
|
|
cx: &'a Ctx,
|
|
}
|
|
|
|
impl<'a> Preview<'a> {
|
|
#[inline]
|
|
pub(crate) fn new(cx: &'a Ctx) -> Self { Self { cx } }
|
|
}
|
|
|
|
impl Widget for Preview<'_> {
|
|
fn render(self, area: ratatui::layout::Rect, buf: &mut Buffer) {
|
|
let preview = &self.cx.manager.active().preview;
|
|
let Some(lock) = &preview.lock else {
|
|
return;
|
|
};
|
|
|
|
if (lock.window.rows, lock.window.cols) != (area.height, area.width) {
|
|
return;
|
|
}
|
|
|
|
for w in &lock.data {
|
|
w.clone_render(buf);
|
|
}
|
|
}
|
|
}
|