Skip to main content

CustomScrollbar

Struct CustomScrollbar 

Source
pub struct CustomScrollbar<'a> { /* private fields */ }
Available on crate feature markdown-preview only.
Expand description

Custom scrollbar widget for markdown navigation.

Shows scroll position using block characters with accurate tracking. Supports click-to-scroll and drag interactions.

This is a UI-only widget that receives &ScrollState for state access. State mutations happen through ScrollState methods, not here.

§Example

use ratatui_toolkit::markdown_widget::state::scroll::ScrollState;

let scroll_state = ScrollState::default();
let scrollbar = CustomScrollbar::new(&scroll_state)
    .config(ScrollbarConfig::default())
    .show_percentage(true);

Implementations§

Source§

impl<'a> CustomScrollbar<'a>

Constructor methods for CustomScrollbar.

Source

pub fn new(scroll_state: &'a ScrollState) -> CustomScrollbar<'a>

Create a new CustomScrollbar with the given scroll state.

§Arguments
  • scroll_state - Reference to the scroll state to track.
§Example
let scrollbar = CustomScrollbar::new(&scroll_state);
Source

pub fn config(self, config: ScrollbarConfig) -> CustomScrollbar<'a>

Set the scrollbar configuration.

§Arguments
  • config - The configuration to use.
§Returns

Self for method chaining.

Source

pub fn show_percentage(self, show: bool) -> CustomScrollbar<'a>

Enable or disable the percentage indicator.

§Arguments
  • show - Whether to show the percentage.
§Returns

Self for method chaining.

Source§

impl<'a> CustomScrollbar<'a>

This impl block contains no items.

Render the scrollbar thumb (scrollable indicator).

Source§

impl<'a> CustomScrollbar<'a>

This impl block contains no items.

Render the scrollbar track (background).

Trait Implementations§

Source§

impl<'a> Debug for CustomScrollbar<'a>

Source§

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

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

impl<'a> Widget for CustomScrollbar<'a>

Source§

fn render(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 CustomScrollbar<'a>

§

impl<'a> RefUnwindSafe for CustomScrollbar<'a>

§

impl<'a> Send for CustomScrollbar<'a>

§

impl<'a> Sync for CustomScrollbar<'a>

§

impl<'a> Unpin for CustomScrollbar<'a>

§

impl<'a> UnsafeUnpin for CustomScrollbar<'a>

§

impl<'a> UnwindSafe for CustomScrollbar<'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> 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> 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, 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