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 case_mode(&self) -> CaseMode
pub fn hilite_search(&self) -> bool
pub fn set_hilite_search(&mut self, on: bool)
pub fn set_quit_at_eof(&mut self, mode: QuitAtEof)
pub fn set_squeeze_blanks(&mut self, on: bool)
pub fn squeeze_blanks(&self) -> bool
pub fn set_header(&mut self, lines: usize, cols: usize)
pub fn header_lines(&self) -> usize
pub fn header_cols(&self) -> usize
pub fn set_page_size(&mut self, n: Option<u16>)
pub fn page_size(&self) -> Option<u16>
Sourcepub fn note_motion_for_eof(
&mut self,
forward: bool,
src: &dyn Source,
idx: &LineIndex,
) -> bool
pub fn note_motion_for_eof( &mut self, forward: bool, src: &dyn Source, idx: &LineIndex, ) -> bool
Notify the EOF state machine of a motion. Returns true when the
caller should quit. forward = true for any motion that could
advance past EOF; false for backward motions (which reset the
hit counter under QuitAtEof::Second).
Sourcepub fn set_case_mode(&mut self, mode: CaseMode)
pub fn set_case_mode(&mut self, mode: CaseMode)
Switch the case-mode policy. Re-compiles any active search so the new policy takes effect on the next frame without the user having to retype the pattern.
pub fn set_status_style(&mut self, style: Style)
pub fn status_style(&self) -> Style
Sourcepub fn flash(&mut self, msg: impl Into<String>, ticks: u32)
pub fn flash(&mut self, msg: impl Into<String>, ticks: u32)
Show msg in the status row for the next ticks calls to the
timeout branch (~250 ms each). Overrides the normal status during
that window.
Sourcepub fn tick_flash(&mut self)
pub fn tick_flash(&mut self)
Decrement the flash countdown by one tick. Clears the flash when it reaches zero.
Sourcepub fn note_growth(&mut self)
pub fn note_growth(&mut self)
Reset the idle counter; the source just produced fresh bytes.
Sourcepub fn tick_idle(&mut self)
pub fn tick_idle(&mut self)
Increment the idle counter. Called in the timeout branch when the line index didn’t grow.
Sourcepub fn is_idle(&self) -> bool
pub fn is_idle(&self) -> bool
True when the source has been quiet long enough to surface
(F idle) instead of (F). Threshold: 20 ticks ≈ 5s.
pub fn set_display(&mut self, renderer: Option<DisplayRenderer>)
pub fn set_hex_mode(&mut self, on: bool)
Sourcepub fn set_hex_group_size(&mut self, bytes_per_group: usize)
pub fn set_hex_group_size(&mut self, bytes_per_group: usize)
Set bytes-per-group for --hex rendering. Accepts 1, 2, 4, 8, or 16.
Invalid values are ignored.
Sourcepub fn hex_group_size(&self) -> usize
pub fn hex_group_size(&self) -> usize
Current bytes-per-group for --hex rendering.
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_tag_active(&mut self, info: Option<(String, usize, usize)>)
pub fn set_ansi_mode(&mut self, mode: AnsiMode)
pub fn ansi_mode(&self) -> AnsiMode
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
Sourcepub fn suspend_follow_if(&mut self, flag: bool)
pub fn suspend_follow_if(&mut self, flag: bool)
Conditionally turn follow mode off. Used by motion handlers when
--follow-suspend-on-motion is in effect — any motion (scroll,
page, goto-line) suspends following until the user re-engages
with Shift-F.
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, src: &dyn Source, idx: &LineIndex) -> bool
pub fn is_at_bottom(&self, src: &dyn Source, 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(&mut 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.