TermUI.Widgets.ScrollBar (TermUI v0.2.0)
View SourceStandalone scroll bar widget.
ScrollBar provides a visual indicator and interactive control for scrolling. Can be used independently or integrated with other scrollable widgets.
Usage
ScrollBar.new(
orientation: :vertical,
total: 100,
visible: 20,
position: 0,
length: 20,
on_scroll: fn pos -> handle_scroll(pos) end
)Features
- Vertical and horizontal orientations
- Proportional thumb size based on visible/total ratio
- Track click for page scrolling
- Drag scrolling for smooth navigation
- Customizable appearance
Mouse Interaction
- Click on thumb: Start dragging
- Click on track: Page scroll toward click
- Drag thumb: Smooth scrolling
Summary
Functions
Returns true if scrolling is possible (content exceeds visible).
Gets the scroll fraction (0.0 - 1.0).
Gets the current scroll position.
Creates a simple horizontal scroll bar.
Creates new ScrollBar widget props.
Updates the content dimensions.
Sets scroll by fraction (0.0 - 1.0).
Sets the scroll position.
Creates a simple vertical scroll bar.
Returns the visible fraction (thumb size ratio).
Functions
Returns true if scrolling is possible (content exceeds visible).
Gets the scroll fraction (0.0 - 1.0).
Gets the current scroll position.
Creates a simple horizontal scroll bar.
Creates new ScrollBar widget props.
Options
:orientation- :vertical or :horizontal (default: :vertical):total- Total content size (default: 100):visible- Visible content size (default: 20):position- Current scroll position (default: 0):length- Bar length in characters (default: 20):on_scroll- Callback when position changes:track_char- Character for track (default: "░"):thumb_char- Character for thumb (default: "█"):min_thumb_size- Minimum thumb size (default: 1)
Updates the content dimensions.
Sets scroll by fraction (0.0 - 1.0).
Sets the scroll position.
Creates a simple vertical scroll bar.
Returns the visible fraction (thumb size ratio).