Skip to main content

ScrollableContentState

Struct ScrollableContentState 

Source
pub struct ScrollableContentState { /* private fields */ }
Expand description

State for the ScrollableContent component

Implementations§

Source§

impl ScrollableContentState

Source

pub fn new(lines: Vec<String>) -> Self

Create a new state with the given content lines

Source

pub fn empty() -> Self

Create an empty state

Source

pub fn set_lines(&mut self, lines: Vec<String>)

Set the content lines

Source

pub fn lines(&self) -> &[String]

Get the content lines

Source

pub fn push_line(&mut self, line: impl Into<String>)

Push a line to the content

Source

pub fn clear(&mut self)

Clear all content

Source

pub fn line_count(&self) -> usize

Get the number of lines

Source

pub fn scroll_offset(&self) -> usize

Get the current scroll offset

Source

pub fn set_scroll_offset(&mut self, offset: usize)

Set the scroll offset

Source

pub fn is_focused(&self) -> bool

Check if focused

Source

pub fn set_focused(&mut self, focused: bool)

Set focus state

Source

pub fn is_fullscreen(&self) -> bool

Check if in fullscreen mode

Source

pub fn set_fullscreen(&mut self, fullscreen: bool)

Set fullscreen mode

Source

pub fn toggle_fullscreen(&mut self) -> bool

Toggle fullscreen mode

Source

pub fn set_title(&mut self, title: impl Into<String>)

Set the title

Source

pub fn title(&self) -> Option<&str>

Get the title

Source

pub fn scroll_up(&mut self, lines: usize)

Scroll up by the given number of lines

Source

pub fn scroll_down(&mut self, lines: usize, visible_height: usize)

Scroll down by the given number of lines

Source

pub fn scroll_to_top(&mut self)

Scroll to the top

Source

pub fn scroll_to_bottom(&mut self, visible_height: usize)

Scroll to the bottom

Source

pub fn page_up(&mut self, visible_height: usize)

Page up

Source

pub fn page_down(&mut self, visible_height: usize)

Page down

Source

pub fn visible_lines(&self, height: usize) -> &[String]

Get a slice of visible lines based on current scroll position and height

Source

pub fn is_at_top(&self) -> bool

Check if scrolled to top

Source

pub fn is_at_bottom(&self, visible_height: usize) -> bool

Check if scrolled to bottom (given visible height)

Source

pub fn content_as_string(&self) -> String

Get the content as a single string (for clipboard copy)

Trait Implementations§

Source§

impl Clone for ScrollableContentState

Source§

fn clone(&self) -> ScrollableContentState

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ScrollableContentState

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ScrollableContentState

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.