pub struct PanelWrap { /* private fields */ }Expand description
Cached line/wrap structure for one panel’s text, rebuilt only when its
content or width actually changes (see PanelWrap::rebuild_if_needed).
Implementations§
Source§impl PanelWrap
impl PanelWrap
Sourcepub fn build(source: Arc<str>, width: usize) -> Self
pub fn build(source: Arc<str>, width: usize) -> Self
Build fresh from source at width columns. O(source length) —
call only when content/width has actually changed (see
rebuild_if_needed), never unconditionally on every frame.
Sourcepub fn rebuild_if_needed(
cache: &mut Option<PanelWrap>,
source: &Arc<str>,
width: usize,
)
pub fn rebuild_if_needed( cache: &mut Option<PanelWrap>, source: &Arc<str>, width: usize, )
Rebuild only if source’s identity (by pointer — a new response/edit
always produces a fresh allocation) or width differ from what’s
cached; otherwise this is a no-op, keeping repeated frames (drags,
idle redraws) cheap regardless of how large the content is.
pub fn line_count(&self) -> usize
Sourcepub fn source(&self) -> &str
pub fn source(&self) -> &str
The exact, unmodified text this cache was built from — every line, with its original line endings, not just what’s currently scrolled into view. Used for “copy the whole panel” (no selection needed).
pub fn line_text(&self, idx: usize) -> &str
pub fn line_char_len(&self, idx: usize) -> usize
pub fn total_rows(&self) -> u32
Sourcepub fn visible_window(&self, scroll: u16, height: u16) -> Vec<Line<'static>>
pub fn visible_window(&self, scroll: u16, height: u16) -> Vec<Line<'static>>
The exact wrapped rows visible in a height-row window starting at
absolute wrapped-row scroll — the only rows actually wrapped, and
only the portion of each raw line that window actually covers
(wrap_line_window), regardless of the total content size or how
long any single raw line is. Repeated calls with the same
(scroll, height) (the common case across idle/unchanged frames)
hit last_window and do no wrapping work at all.
Sourcepub fn textpos_to_row_col(&self, pos: TextPos) -> (u32, usize)
pub fn textpos_to_row_col(&self, pos: TextPos) -> (u32, usize)
Convert a logical TextPos into its absolute wrapped-row index and
column-within-that-row — the reverse of Self::row_col_to_textpos,
used to project a (resize-invariant) selection back onto the current
frame’s screen space for highlighting or scroll-into-view.
Sourcepub fn row_col_to_textpos(&self, row: u32, col: usize) -> TextPos
pub fn row_col_to_textpos(&self, row: u32, col: usize) -> TextPos
Convert an absolute wrapped-row index + column-in-row (screen space)
into the logical TextPos it corresponds to — the reverse of
Self::textpos_to_row_col, used to map a mouse click/drag onto
real content.
Auto Trait Implementations§
impl !Freeze for PanelWrap
impl !RefUnwindSafe for PanelWrap
impl !Sync for PanelWrap
impl Send for PanelWrap
impl Unpin for PanelWrap
impl UnsafeUnpin for PanelWrap
impl UnwindSafe for PanelWrap
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
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 more