Raxol. Playground. DemoHelpers
(Raxol v2.6.0)
View Source
Shared helpers for playground demo TEA apps.
Small utilities that eliminate the most common duplication across demos while keeping demos self-contained and readable.
Summary
Functions
Moves a cursor index down (increment), clamped to max_index.
Returns "> " if index matches selected, else " ".
Moves a cursor index up (decrement), clamped to 0.
Cycles an index forward through a list length, wrapping around.
Returns the effective width for a demo element, clamping desired to the
available width injected by the playground app. Falls back to desired when
running outside the playground.
Navigate forward through input history.
Navigate backward through input history.
Functions
@spec cursor_down(non_neg_integer(), non_neg_integer()) :: non_neg_integer()
Moves a cursor index down (increment), clamped to max_index.
@spec cursor_prefix(non_neg_integer(), non_neg_integer()) :: String.t()
Returns "> " if index matches selected, else " ".
@spec cursor_up(non_neg_integer()) :: non_neg_integer()
Moves a cursor index up (decrement), clamped to 0.
@spec cycle_next(non_neg_integer(), non_neg_integer()) :: non_neg_integer()
Cycles an index forward through a list length, wrapping around.
@spec effective_width(map(), pos_integer()) :: pos_integer()
Returns the effective width for a demo element, clamping desired to the
available width injected by the playground app. Falls back to desired when
running outside the playground.
Navigate forward through input history.
Expects the model to have :input_history, :history_index, :input, and :cursor fields.
Navigate backward through input history.
Expects the model to have :input_history, :history_index, :input, and :cursor fields.