Skip to main content

Viewport

Struct Viewport 

Source
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: String

Implementations§

Source§

impl Viewport

Source

pub fn new(cols: u16, rows: u16, source_label: String) -> Self

Source

pub fn set_display(&mut self, renderer: Option<DisplayRenderer>)

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.

Source

pub fn search_active(&self) -> bool

Source

pub fn search_direction(&self) -> SearchDirection

Source

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.

Source

pub fn set_filter(&mut self, filter: Option<CompiledFilter>)

Source

pub fn set_grep(&mut self, grep: Option<GrepPredicate>)

Source

pub fn grep_active(&self) -> bool

Source

pub fn set_dim_mode(&mut self, on: bool)

Source

pub fn filter_active(&self) -> bool

Source

pub fn dim_mode(&self) -> bool

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).

Source

pub fn body_rows(&self) -> u16

Source

pub fn follow_mode(&self) -> bool

Source

pub fn set_follow_mode(&mut self, on: bool)

Source

pub fn toggle_follow(&mut self)

Source

pub fn live_mode(&self) -> bool

Source

pub fn set_live_mode(&mut self, on: bool)

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn frame(&self, src: &dyn Source, idx: &mut LineIndex) -> Frame

Source

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).

Source

pub fn scroll_lines( &mut self, delta: i64, src: &dyn Source, idx: &mut LineIndex, )

Source

pub fn page_down(&mut self, src: &dyn Source, idx: &mut LineIndex)

Source

pub fn page_up(&mut self, src: &dyn Source, idx: &mut LineIndex)

Source

pub fn half_page_down(&mut self, src: &dyn Source, idx: &mut LineIndex)

Source

pub fn half_page_up(&mut self, src: &dyn Source, idx: &mut LineIndex)

Source

pub fn goto_top(&mut self)

Source

pub fn goto_bottom(&mut self, src: &dyn Source, idx: &mut LineIndex)

Source

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.

Source

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).

Source

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.

Source

pub fn top_line(&self) -> usize

Get the currently top-displayed physical line index.

Source

pub fn resize(&mut self, cols: u16, rows: u16)

Source

pub fn toggle_line_numbers(&mut self)

Source

pub fn toggle_chop(&mut self)

Source

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.