pub struct ScrollState {
pub scroll_offset: usize,
pub viewport_height: usize,
pub total_lines: usize,
pub current_line: usize,
pub filter: Option<String>,
pub filter_mode: bool,
}Expand description
Scroll state for markdown rendering.
Manages scroll position, viewport dimensions, and current line for navigation.
Fields§
§scroll_offset: usizeCurrent scroll offset (0-indexed, first visible line index).
viewport_height: usizeHeight of viewport (number of visible lines).
total_lines: usizeTotal number of lines in document.
current_line: usizeCurrently selected line (1-indexed, for highlighting).
filter: Option<String>Current filter text (when in filter mode).
filter_mode: boolWhether filter mode is currently active.
Implementations§
Source§impl ScrollState
impl ScrollState
Source§impl ScrollState
impl ScrollState
Sourcepub fn adjust_scroll_for_current_line(&mut self)
pub fn adjust_scroll_for_current_line(&mut self)
Adjust scroll offset to ensure current_line is visible with a margin. Scrolls when the cursor gets within 3 lines of the top/bottom edge.
Source§impl ScrollState
impl ScrollState
Sourcepub fn filter_line_down(&mut self, _filter_text: String)
pub fn filter_line_down(&mut self, _filter_text: String)
Move to the next line that matches the filter text.
§Arguments
filter_text- The text to match against (case-insensitive)
This method is used in filter mode to navigate through matching lines.
It updates both current_line and scroll_offset to show the next match.
Sourcepub fn filter_line_up(&mut self, _filter_text: String)
pub fn filter_line_up(&mut self, _filter_text: String)
Move to the previous line that matches the filter text.
§Arguments
filter_text- The text to match against (case-insensitive)
This method is used in filter mode to navigate through matching lines.
It updates both current_line and scroll_offset to show the previous match.
Source§impl ScrollState
impl ScrollState
Sourcepub fn is_current_line_visible(&self) -> bool
pub fn is_current_line_visible(&self) -> bool
Check if current line is visible in the viewport.
§Returns
true if the current line is within the visible viewport.
Source§impl ScrollState
impl ScrollState
Source§impl ScrollState
impl ScrollState
Source§impl ScrollState
impl ScrollState
Sourcepub fn max_scroll_offset(&self) -> usize
pub fn max_scroll_offset(&self) -> usize
Source§impl ScrollState
impl ScrollState
Sourcepub fn scroll_down(&mut self, amount: usize)
pub fn scroll_down(&mut self, amount: usize)
Source§impl ScrollState
impl ScrollState
Sourcepub fn scroll_percentage(&self) -> f64
pub fn scroll_percentage(&self) -> f64
Calculate percentage scrolled (0.0 to 1.0).
§Returns
The scroll position as a percentage of total scrollable content.
Source§impl ScrollState
impl ScrollState
Sourcepub fn scroll_to_bottom(&mut self)
pub fn scroll_to_bottom(&mut self)
Move to bottom of document.
Source§impl ScrollState
impl ScrollState
Sourcepub fn scroll_to_top(&mut self)
pub fn scroll_to_top(&mut self)
Move to top of document.
Source§impl ScrollState
impl ScrollState
Source§impl ScrollState
impl ScrollState
Sourcepub fn set_current_line(&mut self, line: usize)
pub fn set_current_line(&mut self, line: usize)
Set current line and adjust scroll to keep it visible.
§Arguments
line- The line number to set as current (1-indexed).
Source§impl ScrollState
impl ScrollState
Sourcepub fn update_total_lines(&mut self, total: usize)
pub fn update_total_lines(&mut self, total: usize)
Source§impl ScrollState
impl ScrollState
Sourcepub fn update_viewport(&mut self, area: Rect)
pub fn update_viewport(&mut self, area: Rect)
Source§impl ScrollState
impl ScrollState
Sourcepub fn visible_range(&self) -> (usize, usize)
pub fn visible_range(&self) -> (usize, usize)
Get range of currently visible lines (1-indexed, inclusive).
§Returns
A tuple of (start_line, end_line) for visible content.
Trait Implementations§
Source§impl Clone for ScrollState
impl Clone for ScrollState
Source§fn clone(&self) -> ScrollState
fn clone(&self) -> ScrollState
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ScrollState
impl Debug for ScrollState
Auto Trait Implementations§
impl Freeze for ScrollState
impl RefUnwindSafe for ScrollState
impl Send for ScrollState
impl Sync for ScrollState
impl Unpin for ScrollState
impl UnwindSafe for ScrollState
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().