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>)
pub fn set_hex_mode(&mut self, on: bool)
pub fn set_prompt(&mut self, prompt: Option<ParsedPrompt>)
pub fn set_preprocess_failure(&mut self, msg: Option<String>)
pub fn set_file_index(&mut self, current: usize, total: usize)
pub fn set_source_label(&mut self, label: String)
pub fn source_label_clone(&self) -> String
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_grep(&mut self, grep: Option<GrepPredicate>)
pub fn grep_active(&self) -> bool
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 (line mode only;
records mode rebuilds from scratch each call).
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 set_format_label(&mut self, label: Option<String>)
pub fn set_format_label(&mut self, label: Option<String>)
Active –format name shown in
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).
pub fn scroll_lines( &mut self, delta: i64, src: &dyn Source, idx: &mut LineIndex, )
pub fn page_down(&mut self, src: &dyn Source, idx: &mut LineIndex)
pub fn page_up(&mut self, src: &dyn Source, idx: &mut LineIndex)
pub fn half_page_down(&mut self, src: &dyn Source, idx: &mut LineIndex)
pub fn half_page_up(&mut self, src: &dyn Source, idx: &mut LineIndex)
pub fn goto_top(&mut self)
pub fn goto_bottom(&mut self, src: &dyn Source, idx: &mut LineIndex)
Sourcepub fn goto_line(&mut self, n: usize, src: &dyn Source, idx: &mut LineIndex)
pub fn goto_line(&mut self, n: usize, src: &dyn Source, idx: &mut LineIndex)
Position the viewport so line n (0-indexed) is the top visible line.
Sourcepub fn goto_record(&mut self, n: usize, src: &dyn Source, idx: &mut LineIndex)
pub fn goto_record(&mut self, n: usize, src: &dyn Source, idx: &mut LineIndex)
Position the viewport at the start of record n (0-indexed).
Sourcepub fn goto_percent(&mut self, p: u8, src: &dyn Source, idx: &mut LineIndex)
pub fn goto_percent(&mut self, p: u8, src: &dyn Source, idx: &mut LineIndex)
Position the viewport at p percent through the file by bytes.
p is clamped to 0..=100. p=100 lands at the last line.
pub fn resize(&mut self, cols: u16, rows: u16)
pub fn toggle_line_numbers(&mut self)
pub fn toggle_chop(&mut self)
Sourcepub fn visible_lines(&self) -> &[usize]
pub fn visible_lines(&self) -> &[usize]
Return the current set of visible (matched) line indices. Non-empty only in hide mode (filter or grep active without –dim). Stable public accessor so integration tests and external tooling can inspect filter results.