pub enum PreviewContent {
Empty,
Loading,
Text(Vec<String>),
Highlighted(Vec<HighlightedLine>),
Binary(Vec<String>),
Image(ImagePreview),
Directory {
file_count: usize,
dir_count: usize,
hidden_count: usize,
entries: Vec<String>,
},
}Expand description
The renderable content for the preview pane.
Each variant carries the data needed by ui/preview_panel.rs to draw
the pane without any further I/O.
Variants§
Empty
A placeholder shown before any entry is selected or while loading.
Loading
A placeholder shown while an async worker result is in flight.
Displayed while workers/highlight.rs, workers/image_decode.rs, or
the binary metadata worker are running.
Text(Vec<String>)
Plain-text preview with pre-formatted lines.
Each element is a formatted string (e.g. " 1 first line of file").
Used for small text files where syntect highlighting is not available
(e.g. unknown syntax) and as the async-deferred fallback on error.
Highlighted(Vec<HighlightedLine>)
Syntax-highlighted text preview (Phase 5).
Each outer element is a line; each inner element is a styled span. Line numbers are prepended as an unstyled span by the render code.
Binary(Vec<String>)
Binary file metadata (Phase 5).
Each string is one line of formatted metadata (size, type, modified timestamp, etc.).
Image(ImagePreview)
Pixel image preview drawn through a terminal graphics protocol.
Produced by workers/image_decode.rs once the image has been decoded
off-thread. Carries its own encoder state, so the render path needs no
further I/O.
Directory
Directory preview: a summary block followed by entry names.
Implementations§
Source§impl PreviewContent
impl PreviewContent
Sourcepub fn scrollable_len(&self) -> Option<usize>
pub fn scrollable_len(&self) -> Option<usize>
Number of logical lines this content occupies, or None when it does
not scroll.
None covers the placeholders and Image: an image is drawn as pixels
into the whole pane, so a line offset is meaningless, and returning
None for Loading is what stops a deferred re-preview of the same
file from resetting a scroll position that is about to be valid again.
Sourcepub fn display_rows(&self, index: usize, width: u16) -> usize
pub fn display_rows(&self, index: usize, width: u16) -> usize
Number of terminal rows logical line index occupies in a pane width
columns wide.
The text, binary and highlighted previews word-wrap, so a line longer than the pane spills onto further rows; this measures it with the same wrapper the renderer draws with, which is what keeps the scroll limit and the position footer honest. The directory listing does not wrap, so each of its lines is one row.
Never returns less than 1: an empty line still takes a row. A width
of zero (no frame drawn yet) and an out-of-range index also count as
one row, so callers can treat the result as a plain line count.
Trait Implementations§
Source§impl Clone for PreviewContent
impl Clone for PreviewContent
Source§impl Debug for PreviewContent
impl Debug for PreviewContent
Auto Trait Implementations§
impl !RefUnwindSafe for PreviewContent
impl !UnwindSafe for PreviewContent
impl Freeze for PreviewContent
impl Send for PreviewContent
impl Sync for PreviewContent
impl Unpin for PreviewContent
impl UnsafeUnpin for PreviewContent
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().