Skip to main content

Scrollbar

Struct Scrollbar 

Source
pub struct Scrollbar<'a> { /* private fields */ }
Expand description

Scrollbar widget for altui-core library.

This widget can be used to display a scrollbar in a terminal user interface. The following components of the scrollbar are customizable in symbol and style.

<--▮------->
^  ^   ^   ^
│  │   │   └ end
│  │   └──── track
│  └──────── thumb
└─────────── begin

Implementations§

Source§

impl<'a> Scrollbar<'a>

Source

pub fn new(orientation: ScrollbarOrientation) -> Self

Source

pub fn orientation(self, orientation: ScrollbarOrientation) -> Self

Sets the orientation of the scrollbar. Resets the symbols to DOUBLE_VERTICAL or DOUBLE_HORIZONTAL based on orientation

Source

pub fn show_orientation(&self) -> ScrollbarOrientation

Shows scrollbar orientation

Source

pub fn orientation_and_symbol( self, orientation: ScrollbarOrientation, set: Set, ) -> Self

Sets the orientation and symbols for the scrollbar from a [Set].

Source

pub fn thumb_symbol(self, thumb_symbol: &'a str) -> Self

Sets the symbol that represents the thumb of the scrollbar.

Source

pub fn thumb_style(self, thumb_style: Style) -> Self

Sets the style that represents the thumb of the scrollbar.

Source

pub fn track_symbol(self, track_symbol: &'a str) -> Self

Sets the symbol that represents the track of the scrollbar.

Source

pub fn track_style(self, track_style: Style) -> Self

Sets the style that is used for the track of the scrollbar.

Source

pub fn begin_symbol(self, begin_symbol: Option<&'a str>) -> Self

Sets the symbol that represents the beginning of the scrollbar.

Source

pub fn begin_style(self, begin_style: Style) -> Self

Sets the style that is used for the beginning of the scrollbar.

Source

pub fn end_symbol(self, end_symbol: Option<&'a str>) -> Self

Sets the symbol that represents the end of the scrollbar.

Source

pub fn end_style(self, end_style: Style) -> Self

Sets the style that is used for the end of the scrollbar.

Source

pub fn symbols(self, symbol: Set) -> Self

Sets the symbols used for the various parts of the scrollbar from a [Set].

<--▮------->
^  ^   ^   ^
│  │   │   └ end
│  │   └──── track
│  └──────── thumb
└─────────── begin

Only sets begin_symbol and end_symbol if they already contain a value. If begin_symbol and/or end_symbol were set to None explicitly, this function will respect that choice.

Source

pub fn style(self, style: Style) -> Self

Sets the style used for the various parts of the scrollbar from a Style.

<--▮------->
^  ^   ^   ^
│  │   │   └ end
│  │   └──── track
│  └──────── thumb
└─────────── begin
Source

pub fn offset(&mut self, offset: u16)

Sets the scroll position of the scrollbar and returns the modified ScrollbarState.

Source

pub fn position(&mut self, position: u16)

Sets the scroll position of the scrollbar and returns the modified ScrollbarState.

Source

pub fn content_length(&mut self, content_length: u16)

Sets the length of the scrollable content and returns the modified ScrollbarState.

Source

pub fn viewport_content_length(&mut self, viewport_content_length: u16)

Sets the length of the viewport content and returns the modified ScrollbarState.

Source

pub fn prev(&mut self)

Decrements the scroll position by one, ensuring it doesn’t go below zero.

Source

pub fn next(&mut self)

Increments the scroll position by one, ensuring it doesn’t exceed the length of the content.

Source

pub fn first(&mut self)

Sets the scroll position to the start of the scrollable content.

Source

pub fn last(&mut self)

Sets the scroll position to the end of the scrollable content.

Source

pub fn scroll(&mut self, direction: ScrollDirection)

Changes the scroll position based on the provided ScrollDirection.

Trait Implementations§

Source§

impl<'a> Clone for Scrollbar<'a>

Source§

fn clone(&self) -> Scrollbar<'a>

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<'a> Debug for Scrollbar<'a>

Source§

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

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

impl<'a> Default for Scrollbar<'a>

Source§

fn default() -> Self

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

impl<'a> Widget for Scrollbar<'a>

Source§

fn render(&mut self, area: Rect, buf: &mut Buffer)

Draws the current state of the widget in the given buffer. That is the only method required to implement a custom widget.

Auto Trait Implementations§

§

impl<'a> Freeze for Scrollbar<'a>

§

impl<'a> RefUnwindSafe for Scrollbar<'a>

§

impl<'a> Send for Scrollbar<'a>

§

impl<'a> Sync for Scrollbar<'a>

§

impl<'a> Unpin for Scrollbar<'a>

§

impl<'a> UnsafeUnpin for Scrollbar<'a>

§

impl<'a> UnwindSafe for Scrollbar<'a>

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> 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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more