etui/widgets/multi_select

Types

selected is kept sorted ascending and contains unique indices.

pub type MultiSelectState {
  MultiSelectState(cursor: Int, selected: List(Int), offset: Int)
}

Constructors

  • MultiSelectState(cursor: Int, selected: List(Int), offset: Int)
pub type MultiSelectWidget {
  MultiSelectWidget(
    items: List(String),
    cursor_style: style.Style,
    selected_style: style.Style,
    checked_mark: String,
    unchecked_mark: String,
    cursor_mark: String,
    max: Int,
    fg: style.Color,
    bg: style.Color,
  )
}

Constructors

Values

pub fn clear_selection(
  state: MultiSelectState,
) -> MultiSelectState

Drop every check; the cursor stays where it is.

pub fn effective_offset(
  state: MultiSelectState,
  height: Int,
) -> Int

Effective scroll offset for a viewport of height rows.

pub fn is_selected(state: MultiSelectState, idx: Int) -> Bool

Is the item at idx checked?

pub fn multi_select_new(items: List(String)) -> MultiSelectWidget

A checkbox list with reverse-video cursor and [x] marks.

pub fn render(
  buf: buffer.Buffer,
  area: geometry.Rect,
  w: MultiSelectWidget,
  state: MultiSelectState,
) -> buffer.Buffer

Render the visible window of items, scrolling to keep the cursor in view.

pub fn select_next(
  state: MultiSelectState,
  item_count: Int,
) -> MultiSelectState

Move the cursor down, stopping at the last item.

pub fn select_prev(state: MultiSelectState) -> MultiSelectState

Move the cursor up, stopping at the first item.

pub fn selected_indices(state: MultiSelectState) -> List(Int)

Indices of the checked items, sorted ascending.

pub fn selected_values(
  items: List(String),
  state: MultiSelectState,
) -> List(String)

Pull the selected item strings in original order.

pub fn state_new() -> MultiSelectState

Cursor at the first item, nothing checked.

pub fn toggle(
  state: MultiSelectState,
  max: Int,
) -> MultiSelectState

Toggle the cursor item. Respects max from the widget config.

pub fn with_colors(
  w: MultiSelectWidget,
  fg: style.Color,
  bg: style.Color,
) -> MultiSelectWidget

Colors of plain unselected rows.

pub fn with_cursor_mark(
  w: MultiSelectWidget,
  m: String,
) -> MultiSelectWidget

Marker drawn left of the cursor row; other rows get matching blanks.

pub fn with_cursor_style(
  w: MultiSelectWidget,
  s: style.Style,
) -> MultiSelectWidget

Style of the row under the cursor.

pub fn with_marks(
  w: MultiSelectWidget,
  checked: String,
  unchecked: String,
) -> MultiSelectWidget

Replace the [x] / [ ] marks (e.g. "✓ " / " ").

pub fn with_max(
  w: MultiSelectWidget,
  m: Int,
) -> MultiSelectWidget

Cap the number of selected items. 0 = unlimited.

pub fn with_selected_style(
  w: MultiSelectWidget,
  s: style.Style,
) -> MultiSelectWidget

Style applied to checked rows that are not under the cursor.

✨ Search Document