list (cellium v0.1.0)

View Source

List widget module for rendering scrollable lists of items.

This module provides an interactive list widget that handles keyboard events for selection and scrolling.

Usage

Basic list:

{list, [{id, my_list}, {items, ["Item 1", "Item 2", "Item 3"]}]}

Properties

  • items (list of strings): The items to display in the list.
  • selected_index (integer): The index of the currently selected item.
  • scroll_offset (integer): The index of the first item to display.
  • focusable (boolean): Always true for lists.
  • focused (boolean): Set by focus manager when the list has focus.

Summary

Functions

Handles keyboard events for the list.

Creates a new list widget with no items.

Creates a new list widget with the specified items.

Renders the list widget.

Functions

calculate_scroll_offset(SelectedIndex, CurrentOffset, Height)

handle_event/2

-spec handle_event(term(), map()) -> map().

Handles keyboard events for the list.

Processes arrow keys for selection and scrolling.

new(Id)

-spec new(term()) -> map().

Creates a new list widget with no items.

new(Id, Items)

-spec new(term(), [string()]) -> map().

Creates a new list widget with the specified items.

render(Widget, Buffer)

-spec render(map(), map()) -> map().

Renders the list widget.

render_focused(Widget, Buffer)

-spec render_focused(map(), map()) -> map().