ElixirOpentui.Widgets.ScrollHelper (ElixirOpentui v0.2.0)

Copy Markdown View Source

Shared scroll key handling for scrollable display widgets.

Centralizes the :up/:down/:page_up/:page_down/:home/:end key dispatch that is common to Code, Diff, and Markdown widgets. Accepts keyword opts to keep call sites self-documenting.

Options

  • :offset (required) — current scroll offset
  • :total (required) — total number of lines
  • :visible (optional) — number of visible lines; used for page step and max offset clamping. When nil, page step defaults to 10 and max offset allows scrolling to the last line.

Summary

Functions

handle_scroll_key(event, opts)

@spec handle_scroll_key(
  map(),
  keyword()
) :: {:handled, non_neg_integer()} | :unhandled