pub struct Viewport {
pub opts: RenderOpts,
pub show_line_numbers: bool,
pub source_label: String,
/* private fields */
}Fields§
§opts: RenderOpts§show_line_numbers: bool§source_label: StringImplementations§
Source§impl Viewport
impl Viewport
pub fn new(cols: u16, rows: u16, source_label: String) -> Self
pub fn set_display(&mut self, renderer: Option<DisplayRenderer>)
Sourcepub fn set_search(
&mut self,
raw: String,
direction: SearchDirection,
) -> Result<(), String>
pub fn set_search( &mut self, raw: String, direction: SearchDirection, ) -> Result<(), String>
Compile and store a search pattern. Returns the parse error from the regex crate if the pattern is invalid; the previous search (if any) is preserved on error.
pub fn clear_search(&mut self)
pub fn search_active(&self) -> bool
pub fn search_direction(&self) -> SearchDirection
Sourcepub fn search_repeat(
&mut self,
src: &dyn Source,
idx: &mut LineIndex,
reverse: bool,
) -> bool
pub fn search_repeat( &mut self, src: &dyn Source, idx: &mut LineIndex, reverse: bool, ) -> bool
Jump to the next match of the active search, in direction (or its
reverse if reverse is true). Wraps at the end of the source.
Returns true iff a match was found and the viewport moved.
pub fn set_filter(&mut self, filter: Option<CompiledFilter>)
pub fn set_dim_mode(&mut self, on: bool)
pub fn filter_active(&self) -> bool
pub fn dim_mode(&self) -> bool
Sourcepub fn extend_visible_lines(&mut self, idx: &LineIndex, src: &dyn Source)
pub fn extend_visible_lines(&mut self, idx: &LineIndex, src: &dyn Source)
Walk any newly indexed logical lines and append matching ones to
visible_lines if we’re in hide mode. No-op otherwise. Cheap to call
every loop tick — keeps a visible_scanned cursor.
pub fn body_rows(&self) -> u16
pub fn follow_mode(&self) -> bool
pub fn set_follow_mode(&mut self, on: bool)
pub fn toggle_follow(&mut self)
pub fn live_mode(&self) -> bool
pub fn set_live_mode(&mut self, on: bool)
Sourcepub fn set_prettify_label(&mut self, label: Option<String>)
pub fn set_prettify_label(&mut self, label: Option<String>)
Status-line label for active pretty-print state, e.g. "json" or
"json:err". None means no indicator is shown.
Sourcepub fn invalidate_filter_cache(&mut self)
pub fn invalidate_filter_cache(&mut self)
Drop the per-line filter-membership cache without disturbing the filter
itself or scroll position. Used after a --live rebuild: line numbering
may have changed, so cached visible_lines is stale, but we want to
keep the same filter applied and let the user stay where they were.
Sourcepub fn clamp_top_line(&mut self, line_count: usize)
pub fn clamp_top_line(&mut self, line_count: usize)
Clamp top_line so it doesn’t fall past the new end of the source.
Pairs with invalidate_filter_cache after a content rewrite.
Sourcepub fn is_at_bottom(&self, idx: &LineIndex) -> bool
pub fn is_at_bottom(&self, idx: &LineIndex) -> bool
True when the viewport’s body window already covers the last line of the source. New content added past this point should auto-scroll if follow mode is on.
pub fn frame(&self, src: &dyn Source, idx: &mut LineIndex) -> Frame
Sourcepub fn scroll_logical_lines(
&mut self,
delta: i64,
src: &dyn Source,
idx: &mut LineIndex,
)
pub fn scroll_logical_lines( &mut self, delta: i64, src: &dyn Source, idx: &mut LineIndex, )
Jump by whole logical lines, regardless of wrap rows. top_row is
reset to 0 so the start of the destination line is at the top of
the viewport. In hide mode this is equivalent to scroll_lines
(which already moves by visible/logical lines).