tui menu for viewers
Command Type
built-in
Signature
> tui menu {flags} (items)
Flags
--id {string}: Widget id.--focus: Start with this widget focused.
Parameters
items: Bar entries: strings or {name, items?, action?} records.
Input/output types:
| input | output |
|---|---|
| nothing | tui |
| tui | tui |
| any | tui |
Examples
A plain bar; Enter submits the item name
> tui label --title "Editor" | tui menu ["&File" "&Edit" "&View"] | tui table | tui debug --keys "alt+e,enter" | get selectedDropdowns with actions that reload the table, and a Quit entry that submits
> ls | tui menu [{name: "&File", items: [{name: "&Reload", action: {|| ls }} "&Quit"]} {name: "&View", items: [{name: "&Sizes", action: {|| ls | sort-by size }}]}] | tui table | tui runNotes
Each entry is a string, or a record {name, items?, action?}. items is a list of the same shape and opens as a dropdown; action is a hook closure.
Mnemonics: & before a letter in a name picks it ("&File" shows as File with F underlined); otherwise the first letter is used. Alt+letter opens that bar item from anywhere except a text field. Inside an open dropdown, the letter alone picks the item. Left/Right (or h/l) move along the bar, Down/Enter open a dropdown, Up/Down move inside it, Esc closes it.
Activating an item with an action runs it as a hook: it receives the state record, a returned value replaces the data list, {action: submit|quit} ends the TUI, and an error goes to the status bar. Activating an item without an action submits it: selected is {menu: "File", item: "Open", row: <highlighted row>} for a dropdown entry, or the bar item's name.
The menu is top-level chrome and cannot be nested in tui split or tui box.