TermUI.Widget.PickList (TermUI v0.2.0)

View Source

A modal pick-list widget for selecting from a list of items.

PickList displays a centered modal overlay with a scrollable list, keyboard navigation, and type-ahead filtering. Used for provider and model selection dialogs.

Usage

PickList.render(%{
  items: ["Apple", "Banana", "Cherry"],
  title: "Select Fruit",
  on_select: fn item -> IO.puts("Selected: #{item}") end,
  on_cancel: fn -> IO.puts("Cancelled") end
}, state, area)

Props

  • :items - List of items to display (required)
  • :title - Modal title (optional)
  • :on_select - Callback when item selected fn item -> ... end
  • :on_cancel - Callback when cancelled fn -> ... end
  • :width - Modal width (default: 40)
  • :height - Modal height (default: 10)
  • :style - Border/text style options
  • :highlight_style - Style for selected item (default: inverted colors)

Keyboard Controls

  • Up/Down - Navigate items
  • Page Up/Down - Jump 10 items
  • Home/End - Jump to first/last item
  • Enter - Confirm selection
  • Escape - Cancel
  • Typing - Filter items (type-ahead search)
  • Backspace - Remove filter character

Summary

Functions

Handles keyboard events for the pick-list.

Handles messages to the pick-list.

Initializes the pick-list state.

Renders the pick-list modal.

Functions

handle_event(arg1, state)

Handles keyboard events for the pick-list.

handle_info(arg1, state)

Handles messages to the pick-list.

init(props)

Initializes the pick-list state.

render(state, area)

Renders the pick-list modal.