mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
29 lines
542 B
Rust
29 lines
542 B
Rust
use ratatui::{buffer::Buffer, widgets::Widget};
|
|
use yazi_config::LAYOUT;
|
|
|
|
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, _: ratatui::layout::Rect, buf: &mut Buffer) {
|
|
let Some(lock) = &self.cx.active().preview.lock else {
|
|
return;
|
|
};
|
|
|
|
if *lock.area != LAYOUT.get().preview {
|
|
return;
|
|
}
|
|
|
|
for w in &lock.data {
|
|
w.clone().render(buf, |p| self.cx.mgr.area(p));
|
|
}
|
|
}
|
|
}
|