etui/widgets/list

Types

Scroll and selection state for a list. Kept external so state persists across renders.

pub type ListState {
  ListState(selected: Int, offset: Int)
}

Constructors

  • ListState(selected: Int, offset: Int)

Scrollable list of styled items with selection highlight.

pub type ListWidget {
  ListWidget(
    items: List(span.Line),
    fg: style.Color,
    bg: style.Color,
    highlight_style: style.Style,
    blink_period: Int,
  )
}

Constructors

Values

pub fn clamp_state(
  state: ListState,
  item_count: Int,
) -> ListState

Clamp selected to [0, item_count - 1]. Call after replacing the item list to avoid a stale selection index.

pub fn effective_offset(state: ListState, height: Int) -> Int
pub fn list_new(items: List(String)) -> ListWidget

New list from plain strings. Default colors, reverse-video selection.

pub fn list_new_styled(items: List(span.Line)) -> ListWidget

New list from styled span.Line items.

list.list_new_styled([
  span.line_new([span.span_styled("ERROR", style.bold_style()), span.span_plain(" file")]),
  span.line_plain("normal item"),
])
pub fn render_animated(
  buf: buffer.Buffer,
  area: geometry.Rect,
  l: ListWidget,
  state: ListState,
  frame: Int,
) -> buffer.Buffer
pub fn render_stateful(
  buf: buffer.Buffer,
  area: geometry.Rect,
  l: ListWidget,
  state: ListState,
) -> buffer.Buffer
pub fn select(state: ListState, idx: Int) -> ListState
pub fn select_next(
  state: ListState,
  item_count: Int,
) -> ListState
pub fn select_prev(state: ListState) -> ListState
pub fn state_new() -> ListState
pub fn with_blink(l: ListWidget, period: Int) -> ListWidget

Blink period in frames. 0 = steady (no blink). Use with render_animated.

pub fn with_colors(
  l: ListWidget,
  fg: style.Color,
  bg: style.Color,
) -> ListWidget
pub fn with_highlight_style(
  l: ListWidget,
  s: style.Style,
) -> ListWidget
Search Document