class

TUI::Scroller

Inherits Reference < Object

Constants

WHEEL_STEP = 3

Rows moved per mouse wheel tick — one shared default so widgets don't each redeclare an identical constant.

Constructors

new(offset : Int32 = 0)
Source

Instance methods

clamp(total : Int32, visible : Int32) : Nil

Recompute a valid offset against current content/viewport sizes. Call every render — self-heals when content shrinks (filter, toggle) or the widget resizes, without every mutation site needing to remember to reset/clamp separately.

Source
down(by : Int32 = 1, total : Int32 = Int32::MAX, visible : Int32 = 0) : Nil
Source
fraction(total : Int32, visible : Int32) : Float64 | Nil

0.0..1.0 position of the viewport within the content, or nil if the content fits entirely (no scrollbar needed).

Source
offset

First visible content row, 0-based. Kept in range by #clamp — call that every render rather than trusting this to stay valid on its own after content or viewport size changes.

Source
reset
Source
reveal(index : Int32, visible : Int32) : Nil

Ensure index is within the visible window — scrolls minimally.

Source
up(by : Int32 = 1) : Nil
Source
wheel_down(by : Int32 = WHEEL_STEP, total : Int32 = Int32::MAX, visible : Int32 = 0) : Nil
Source
wheel_up(by : Int32 = WHEEL_STEP) : Nil

Wheel-tick convenience over #up/#down — same semantics, just names the common case and supplies the shared step default. #up/#down remain the primitives (used by PageUp/PageDown/arrow keys).

Source