term.widgets — Lilush API

←index

← term

Overview

Interactive terminal UI widgets — chooser, file chooser, form, and confirmation dialogs.

Functions

NameSignature
chooserchooser(content, opts) -> selected
confirmconfirm(title, opts) -> confirmed
simple_confirmsimple_confirm(text) -> confirmed
file_chooserfile_chooser(opts) -> path
formform(content, opts) -> results

chooser(content, opts) -> selected

Display an interactive single or multi-select chooser dialog

Opens a bordered dialog on the alternate screen with arrow-key navigation. Set opts.multiple_choice = true for multi-select mode. Returns the chosen string (or table of strings in multi-select mode), or an empty string/table on ESC.

confirm(title, opts) -> confirmed

Display a confirmation dialog and wait for yes/no

Opens a bordered dialog on the alternate screen. Use Left/Right arrows to switch between Yes and No buttons; confirm with Enter, y, or Y; cancel with n, N, or ESC. opts.rss can override widget styling. Returns true if the user confirmed, false otherwise.

simple_confirm(text) -> confirmed

Display a confirmation prompt and wait for y/n

Writes text inline (no dialog box) and waits for a single keypress. Returns true for y or Y, false for anything else.

file_chooser(opts) -> path

Display an interactive file chooser dialog with fuzzy search

Opens a bordered dialog with a search field for browsing and selecting files. When the search field is empty, shows a flat directory listing sorted by recency. When text is entered, recursively scans subdirectories and ranks results by fuzzy match score and recency.

Set opts.multiple_choice = true for multi-file selection. Selected files are pinned at the top of the dialog. Use CTRL+ENTER to confirm selection, ESC to clear search (or exit if search is already empty).

Options: title, start_dir, show_hidden, multiple_choice, max_depth (default 5), max_scan_results (default 1000), rss. Returns full path string, array of paths, or nil on cancel.

form(content, opts) -> results

Display an interactive form dialog with labeled input fields

Opens a bordered dialog with one input field per label in content. The opts.meta table can specify per-field options like w (width) and secret (mask input). Returns a table mapping labels to values.