D.A.B.Tv0.0.33 Tutorial API DABT Tools ↗ GitHub ↗

Chrome: commands, modals, dialogs & footer

lib/chrome/tui_cmd.sh, lib/chrome/tui_modal.sh, lib/chrome/tui_dialog.sh, lib/chrome/tui_footer.sh - the command palette, the overlay/modal layer dialogs and toasts are built on, the dialogs themselves, and the <footer/> key-hint bar. ← API index for the full module list and a task-oriented tour with examples.

Functions return 0 unless their entry says otherwise.

Commands and palette

The command bar (default ctrl+p or :) lists registered commands and runs one. DABT’s own commands are registered the same way, from share/defaults/commands.xml.

Function Summary
tui.cmd.add Registers a command in the command palette.
tui.cmd.remove Unregisters a command. A key bound with --key stays bound; remove it with tui.unbind.
tui.cmd.run Runs a command by id. Returns 1 and prints a message on stderr for an unknown id.
tui.cmd.list Prints every command as ID<TAB>GROUP<TAB>TITLE<TAB>ACTION, in registration order.
tui.cmd.load Registers the commands in an XML file, one <cmd id="…" title="…" action="…" [group="…"] [desc="…"] [when="…"] [key="…"]/> per line.
tui.cmd.provider Registers a function that runs every time the palette opens and adds commands that depend on current state.
tui.palette.open Opens the command palette, optionally with the search prefilled. Bound to ctrl+p and : by default.
tui.palette.close Closes the palette if it is open.

tui.cmd.add

tui.cmd.add ID TITLE ACTION [--group G] [--desc TEXT] [--when FN] [--key KEY]

Registers a command in the command palette.

Parameters

  • ID: unique command id. Adding an existing ID replaces it.
  • TITLE: what the palette shows and searches.
  • ACTION: function plus arguments, chained with ; if needed. Same rules as a tui.bind command.

Options

  • --group G: heading the command is listed under.
  • --desc TEXT: second line in the palette.
  • --when FN: the command is listed only while FN returns 0.
  • --key KEY: also binds KEY to the command; the palette shows it as the hint.

Returns: 1 when ID, TITLE or ACTION is missing.

Notes

  • Commands added while a plugin loads are removed when that plugin is disabled, and show the plugin’s name as their hint.

Example

tui.cmd.add export "Export report" on_export --group App --desc "Write report.csv" --key ctrl+e

tui.cmd.remove

tui.cmd.remove ID

Unregisters a command. A key bound with --key stays bound; remove it with tui.unbind.

tui.cmd.run

tui.cmd.run ID

Runs a command by id. Returns 1 and prints a message on stderr for an unknown id.

tui.cmd.list

tui.cmd.list

Prints every command as ID<TAB>GROUP<TAB>TITLE<TAB>ACTION, in registration order.

tui.cmd.load

tui.cmd.load FILE

Registers the commands in an XML file, one <cmd id="…" title="…" action="…" [group="…"] [desc="…"] [when="…"] [key="…"]/> per line.

Returns: 1 when FILE can’t be read.

Notes

  • Lines missing id, title or action are skipped. share/defaults/commands.xml is an example.

tui.cmd.provider

tui.cmd.provider FN

Registers a function that runs every time the palette opens and adds commands that depend on current state.

Notes

  • Commands added inside FN are removed and rebuilt on every open, so they never go stale.
  • Registering the same FN twice is a no-op.

Example

theme_commands() {
    local f
    for f in "$APP"/themes/*.css; do
        tui.cmd.add "theme:${f##*/}" "Theme: ${f##*/}" "tui.theme.set $f" --group Themes
    done
}
tui.cmd.provider theme_commands

tui.palette.open

tui.palette.open [QUERY]

Opens the command palette, optionally with the search prefilled. Bound to ctrl+p and : by default.

Notes

  • Does nothing before the app runs.
  • Keys inside: type to filter (every word must match), Up/Down or ctrl+p/ctrl+n, PgUp/PgDn, Enter runs, Esc closes, ctrl+u clears. Click a row to run it.
  • Shows TUI_PALETTE_ROWS rows (default 10).

tui.palette.close

tui.palette.close

Closes the palette if it is open.

A function layer is a draw function in the layer stack (lib/chrome/tui_layer.sh): it is appended to every repaint of the page, so it stays on top. A modal is a function layer that also captures all input.

Function Summary
tui.layer.fn_add Adds a function layer to the layer stack: a layer drawn by a function instead of a pane tree.
tui.layer.fn_remove Removes a function layer.
tui.overlay.add Adds a function layer that draws on top of the panes after every repaint (an alias of tui.layer.fn_add that a plugin owns).
tui.overlay.remove Removes a function layer (an alias of tui.layer.fn_remove).
tui.overlay.box Draws a framed box at an absolute position. Meant for overlay and modal draw functions.
tui.modal.open Opens a modal: a function layer that receives all input until it is closed.
tui.modal.count_keys Names the keys the open modal’s key function handles with a repeat count, so a held key reaches it as one call instead of one per press.
tui.modal.close Closes the open modal and repaints the screen under it.
tui.modal.dismiss Closes the open modal without running anything, replaying the saved page frame when it still matches the screen.
tui.modal.active Returns 0 while a modal is open (or, with NAME, while that modal is open).
tui.modal.redraw Redraws the layer stack now. Call it after changing the state a modal draws.

tui.layer.fn_add

tui.layer.fn_add DRAWFN [ambient]

Adds a function layer to the layer stack: a layer drawn by a function instead of a pane tree.

Parameters

  • DRAWFN: draws with absolute cursor moves (e.g. tui.overlay.box), appends to the frame and keeps no state of its own.
  • ambient: drawn with the page and not again after a page repaint (the footer row); without it the function is redrawn after every page repaint.

Notes

  • Function layers sit in one stack with the pane layers: ambient ones below, then the pane layers, then the others in the order they were added.
  • Adding the same function twice is a no-op. tui.overlay.add is the same call, owned by the loading plugin.

tui.layer.fn_remove

tui.layer.fn_remove DRAWFN

Removes a function layer.

Notes

  • What it drew stays on screen until the next full repaint. Call tui.relayout to wipe it.

tui.overlay.add

tui.overlay.add DRAWFN

Adds a function layer that draws on top of the panes after every repaint (an alias of tui.layer.fn_add that a plugin owns).

Parameters

  • DRAWFN: draws with absolute cursor moves (e.g. tui.overlay.box) and keeps no state of its own.

Notes

  • Overlays survive page changes; remove page-specific ones yourself.
  • Adding the same function twice is a no-op.

tui.overlay.remove

tui.overlay.remove DRAWFN

Removes a function layer (an alias of tui.layer.fn_remove).

Notes

  • What it drew stays on screen until the next full repaint. Call tui.relayout to wipe it.

tui.overlay.box

tui.overlay.box ROW COL WIDTH SGR TITLE [LINE...]

Draws a framed box at an absolute position. Meant for overlay and modal draw functions.

Parameters

  • ROW, COL: top-left corner, 1-based.
  • WIDTH: outer width including the frame.
  • SGR: colors as SGR parameters, e.g. 1;97;44.
  • LINE: one per content row, cut or padded to the inner width.

Notes

  • Saves and restores the cursor. Draws immediately; nothing is kept.

tui.modal.open

tui.modal.open NAME KEYFN DRAWFN [MOUSEFN [POINTERFN]]

Opens a modal: a function layer that receives all input until it is closed.

Parameters

  • NAME: modal name, for tui.modal.active.
  • KEYFN: called as KEYFN KEY for every key (a, enter, ctrl+p, …), and KEYFN paste with TUI_EVENT_PASTE set.
  • DRAWFN: draws the modal.
  • MOUSEFN: called as MOUSEFN EVENT X Y (mouse:left, wheel:up, … at a 1-based cell). Without it, mouse events are ignored.
  • POINTERFN: called as POINTERFN X Y on pointer movement; set _PS to a CSS pointer shape name (pointer, text, …) for the cell. Without it the pointer keeps the terminal’s own shape while the modal is open.

Notes

  • Opening a modal closes the one already open. Dialogs and the palette are modals too.
  • While open, bindings, focus and scrolling are suspended. Only the terminal-mode chord still works.
  • Closed on page change.
  • Call tui.modal.redraw after your state changes.

Example

my_draw() { tui.overlay.box 5 10 40 "1;97;44" "Confirm" "Delete file?" "[y] yes   [n] no"; }
my_keys() { case "$1" in y) do_delete; tui.modal.close ;; n|esc) tui.modal.close ;; esac; }
tui.modal.open confirm my_keys my_draw

tui.modal.count_keys

tui.modal.count_keys "KEY ..."

Names the keys the open modal’s key function handles with a repeat count, so a held key reaches it as one call instead of one per press.

Parameters

  • "KEY ..." - canonical key names separated by spaces, e.g. "up down pgup pgdn".

Notes

  • Call it right after tui.modal.open; it is cleared when the modal closes.
  • When identical presses of a named key are already waiting in the input, they are merged into one event. The key function sees TUI_EVENT_COUNT set to the number of presses and moves by that many, with one redraw.
  • Only name keys that move or scroll. Typing and one-shot keys (enter, esc) should not be counted.

Example

tui.modal.open pick my_keys my_draw
tui.modal.count_keys "up down"
my_keys() { [[ $1 == down ]] && ((sel += TUI_EVENT_COUNT)); tui.modal.redraw; }

tui.modal.close

tui.modal.close

Closes the open modal and repaints the screen under it.

tui.modal.dismiss

tui.modal.dismiss

Closes the open modal without running anything, replaying the saved page frame when it still matches the screen.

Notes

  • Use it for esc and click-outside. It falls back to tui.modal.close (a full repaint) when anything but an overlay has painted, restyled or resized since the last full render.
  • Do not use it when the close is followed by an action that changes state: the saved frame cannot know about that.
  • TUI_DISMISS_REPLAY=0 turns the replay off.

tui.modal.active

tui.modal.active [NAME]

Returns 0 while a modal is open (or, with NAME, while that modal is open).

tui.modal.redraw

tui.modal.redraw

Redraws the layer stack now. Call it after changing the state a modal draws.

Dialogs and notifications

Dialogs never block: they return at once and call your function after the user answers, when the dialog is gone and the screen repainted, so the callback may open the next dialog or change page. A callback is a function name plus optional fixed arguments ("do_delete file1"); answers such as the prompt text are appended. One dialog at a time: opening a second replaces the first. TUI_DIALOG_RESULT holds yes, no, ok, submit, cancel or choose while the callback runs.

Common flags: --title T, --width N, --ok LABEL, --yes LABEL, --no LABEL, --danger, --default yes|no. Theme classes (all optional): .dialog .dialog_title .dialog_btn .dialog_btn_sel .dialog_danger .dialog_dim .dialog_error and .toast .toast_success .toast_warn .toast_error.

Function Summary
tui.confirm Shows a Yes/No dialog and returns immediately; the callback runs after the user answers.
tui.message Shows a message with an OK button. ON_CLOSE runs after OK, Enter or Esc.
tui.prompt Shows a one-line text input dialog. ON_SUBMIT is called with the text appended as its last argument.
tui.choose Shows a list picker. ON_CHOOSE is called with the 0-based index and the item text appended.
tui.view Shows scrollable read-only text, for help screens and logs.
tui.dialog.close Closes the open dialog without calling any of its callbacks.
tui.dialog.active Returns 0 while a dialog is open.
tui.notify Shows a toast notification that disappears on its own.
tui.notify.clear Dismisses one toast by id, or all toasts, and repaints what they covered.
tui.notify.count Prints the number of toasts showing.
tui.notify.position Sets where toasts appear, or prints the current position without an argument.
tui.notify.seconds Sets the default toast lifetime in seconds (decimals allowed, 0 = until cleared), or prints it without an argument. Default: 5.

tui.confirm

tui.confirm MESSAGE [ON_YES [ON_NO]] [flags]

Shows a Yes/No dialog and returns immediately; the callback runs after the user answers.

Parameters

  • ON_YES, ON_NO: commands: a function name plus fixed arguments, split on spaces. Either may be empty.

Options

  • --danger: red primary button, title Warning, and No selected by default.
  • --default yes|no, --title T, --width N, --yes LABEL, --no LABEL.

Notes

  • Keys: y yes, n or Esc no, arrows/Tab move, Enter picks. Mouse clicks work.
  • The callback runs after the dialog is closed and the screen repainted, so it may open another dialog or change page. TUI_DIALOG_RESULT is yes or no.
  • Commands can’t chain with ; or quote arguments, and must be shell functions. Pass values with spaces through a variable.
  • Does nothing before the app runs.

Example

tui.confirm "Delete report.csv?" "rm_file report.csv" --danger --yes Delete --no Keep

tui.message

tui.message MESSAGE [ON_CLOSE] [flags]

Shows a message with an OK button. ON_CLOSE runs after OK, Enter or Esc.

Notes

  • Flags: --title, --width, --ok LABEL.

tui.prompt

tui.prompt MESSAGE ON_SUBMIT [flags]

Shows a one-line text input dialog. ON_SUBMIT is called with the text appended as its last argument.

Options

  • --value TEXT: initial text.
  • --placeholder TEXT: grey hint while empty.
  • --validate FN: called as FN TEXT on submit. A non-zero return keeps the dialog open; set TUI_DIALOG_ERROR to show why.
  • --cancel CMD: runs on Esc or Cancel.
  • Common: --title, --width, --ok.

Notes

  • Supports the text-editing keys of an input (cursor, Home/End, ctrl+u/ctrl+k/ctrl+w, paste).

Example

name_ok() { [[ -n "$1" && "$1" != */* ]] || { TUI_DIALOG_ERROR="no slashes, not empty"; return 1; }; }
tui.prompt "New name:" do_rename --value "$old" --validate name_ok
do_rename() { mv -- "$old" "$1" && tui.notify "Renamed to $1" success; }

tui.choose

tui.choose TITLE ON_CHOOSE ITEM... [flags]

Shows a list picker. ON_CHOOSE is called with the 0-based index and the item text appended.

Options

  • --message TEXT: text above the list.
  • --selected N: initially selected index.
  • --cancel CMD: runs on Esc.

Returns: 1 when there are no items.

Notes

  • Keys: arrows, j/k, PgUp/PgDn, Enter, digits 1–9 pick directly. Click and wheel work.

Example

tui.choose "Export as" do_export csv json yaml
do_export() { tui.notify "Exporting as $2 (#$1)"; }

tui.view

tui.view TITLE TEXT [--width N] [--close CMD]

Shows scrollable read-only text, for help screens and logs.

Notes

  • Keys: Up/Down, j/k, PgUp/PgDn, Space, Home/End, wheel. Esc, q or Enter close.
  • --close CMD (or --cancel CMD) runs after it closes.

tui.dialog.close

tui.dialog.close

Closes the open dialog without calling any of its callbacks.

tui.dialog.active

tui.dialog.active

Returns 0 while a dialog is open.

tui.notify

tui.notify MESSAGE [LEVEL] [SECONDS]

Shows a toast notification that disappears on its own.

Parameters

  • LEVEL: info (default), success, warn (or warning), error. Anything else counts as info.
  • SECONDS: lifetime. Default: tui.notify.seconds (5). 0 = until cleared.

Sets: TUI_NOTIFY_ID to the new toast’s id.

Notes

  • Up to 5 toasts stack; the oldest is dropped. Toasts survive page changes.
  • Position: tui.notify.position.
  • Styled with .toast, .toast_success, .toast_warn, .toast_error when the theme defines them.

Example

tui.notify "Report saved" success
tui.notify "Upload failed" error 0; err_toast=$TUI_NOTIFY_ID

tui.notify.clear

tui.notify.clear [ID]

Dismisses one toast by id, or all toasts, and repaints what they covered.

tui.notify.count

tui.notify.count

Prints the number of toasts showing.

tui.notify.position

tui.notify.position [POS]

Sets where toasts appear, or prints the current position without an argument.

Parameters

  • POS: bottom-right (default), bottom-left, bottom-center, top-right, top-left, top-center.

Returns: 1 and a message on stderr for any other value.

Notes

  • Lasts for this run. Persist it with tui.config.set notify.position POS (the Settings page does).

tui.notify.seconds

tui.notify.seconds [N]

Sets the default toast lifetime in seconds (decimals allowed, 0 = until cleared), or prints it without an argument. Default: 5.

Notes

  • Invalid values are ignored silently. Persist it with the notify.seconds config key.
Function Summary
tui.footer.set Declares the footer bar, as <footer/> does. Records the items only; the page layout then leaves the last row free.
tui.footer.show Sets and shows the footer at runtime, then relayouts so the outermost pane gives up the last row. Empty ITEMS shows the default items.
tui.footer.add Appends one item to the footer (to the default items when none were set) and shows it.
tui.footer.hide Removes the footer and gives the last row back to the panes.

tui.footer.set

tui.footer.set [ITEMS]

Declares the footer bar, as <footer/> does. Records the items only; the page layout then leaves the last row free.

Parameters

  • ITEMS: KEY|LABEL[|WHEN_FN] items separated by ;. Empty: the default (quit, command bar, and Back when there is a page to go back to).
    • KEY is shown as written (ctrl+s), or @COMMAND shows whichever key is bound to that command right now, so the footer follows rebinding. An @COMMAND with no key is skipped.
    • WHEN_FN: the item is shown only while it returns 0.

Notes

  • The footer belongs to its page and is removed on page change. At runtime use tui.footer.show, which also relayouts.
  • Styled with .footer, .footer_key, .footer_label.

Example

tui.footer.set "@tui.action.quit|Quit;@tui.palette.open|Commands;ctrl+s|Save|is_dirty"

tui.footer.show

tui.footer.show [ITEMS]

Sets and shows the footer at runtime, then relayouts so the outermost pane gives up the last row. Empty ITEMS shows the default items.

tui.footer.add

tui.footer.add KEY LABEL [WHEN_FN]

Appends one item to the footer (to the default items when none were set) and shows it.

tui.footer.hide

tui.footer.hide

Removes the footer and gives the last row back to the panes.

Layers

Layers are panes that float above the page as overlays. They have independent rectangles and can be shown, hidden, moved, resized, zoomed, and minimized. A modal layer captures all input (focus scope, Tab, clicks and keys) until it closes. Layers are created from markup tags <window>, <modal>, <dialog>, <popup>, <tooltip>, <contextmenu>, <toast>, with attributes x y width height anchor=screen|parent|#id float shadow closable fullscreen minimizable modal open timeout persist=layout. Panes can be detached from splits and floated as layers (detachable dock_group leave on_detach on_dock persist=layout).

Function Summary
tui.layer.show Shows a hidden layer on top, restoring it to visibility. A modal layer takes the focus scope and remembers the focused widget; a layer with a timeout attribute hides itself after the specified seconds.
tui.layer.hide Hides a visible layer, removing it from display. A modal layer gives the focus back to the widget that had focus before the layer opened.
tui.layer.close Alias for tui.layer.hide. Hides a visible layer.
tui.layer.toggle Shows a hidden layer or hides a visible layer.
tui.layer.raise Makes a layer the topmost visible layer and repaints the screen. A click inside a layer or focus moving into it raises it automatically.
tui.layer.move Moves the layer’s top-left corner to the specified position on the screen (1-based cells), clamped to keep the layer inside the screen. After moving, the layer stays where it was put; the layout does not re-place it on the next repaint.
tui.layer.size Sets the layer’s size in cells. The minimum is 3 rows by 8 columns; the maximum is the screen size. The position is adjusted if needed to keep the layer inside the screen.
tui.layer.reset Resets the layer to the position and size specified in the markup. Clears any manual moves, resizes, zoom state, and minimize state.
tui.layer.zoom Toggles the layer between its normal size and filling the entire screen.
tui.layer.minimize Toggles the layer between its normal display and a collapsed one-row title bar.
tui.layer.active Returns 0 while any layer is shown, or while a specific layer is shown.
tui.layer.top Gets the id of the topmost visible layer. The result is printed or stored in a variable; returns 1 when no layer is visible.
tui.layer.detach Detaches a pane from its horizontal or vertical split, converting it into a floating layer that appears as a window on top of the page. The siblings of the detached pane take the freed space. Runs the on_detach callback if defined.
tui.layer.dock Docks a floating pane back into its original split, restoring it to its previous position and size spec. If PANE is given, docks the pane as the last child of that split pane instead. Runs the on_dock callback if defined.

tui.layer.show

tui.layer.show ID

Shows a hidden layer on top, restoring it to visibility. A modal layer takes the focus scope and remembers the focused widget; a layer with a timeout attribute hides itself after the specified seconds.

Parameters

  • ID - layer id.

Returns: 1 for an unknown id.

Notes

  • A hidden layer is not drawn, not hit-testable, and its widgets are not focusable. Showing a layer places it at the top of the stack. For a modal layer (created with <modal> or modal="true"), the focus scope is restricted to the layer’s widgets while it is shown; the previously focused widget outside the layer is remembered and restored when the layer hides.
  • A layer with timeout=SECONDS (as an integer or EPOCHREALTIME seconds) automatically calls tui.layer.hide after that many seconds pass.
  • Markup tags: <window>, <modal>, <dialog>, <popup>, <tooltip>, <contextmenu>, <toast> (see tui.layer overview).

See also: tui.layer.hide, tui.layer.toggle, tui.layer.active, tui.layer.top

tui.layer.hide

tui.layer.hide ID

Hides a visible layer, removing it from display. A modal layer gives the focus back to the widget that had focus before the layer opened.

Parameters

  • ID - layer id.

Returns: 1 when the layer is not visible.

Notes

  • A hidden layer is not drawn, not hit-testable, and its widgets are not focusable. For a modal layer, focus is restored to the widget that had focus in the page before the modal opened, if it still exists and is not hidden.
  • Markup tags: <window>, <modal>, <dialog>, <popup>, <tooltip>, <contextmenu>, <toast>.

See also: tui.layer.show, tui.layer.close, tui.layer.toggle

tui.layer.close

tui.layer.close ID

Alias for tui.layer.hide. Hides a visible layer.

Parameters

  • ID - layer id.

Returns: 1 when the layer is not visible.

See also: tui.layer.hide, tui.layer.show

tui.layer.toggle

tui.layer.toggle ID

Shows a hidden layer or hides a visible layer.

Parameters

  • ID - layer id.

Notes

See also: tui.layer.show, tui.layer.hide

tui.layer.raise

tui.layer.raise ID

Makes a layer the topmost visible layer and repaints the screen. A click inside a layer or focus moving into it raises it automatically.

Parameters

  • ID - layer id.

Returns: 1 when the layer is not visible.

Notes

  • The topmost layer is drawn last and appears on top of all others. Raising a layer reorders the layer stack and triggers a full repaint. Keyboard focus moving into a layer or a pointer click on any part of it also raises the layer automatically.

See also: tui.layer.top, tui.layer.show

tui.layer.move

tui.layer.move ID ROW COL

Moves the layer’s top-left corner to the specified position on the screen (1-based cells), clamped to keep the layer inside the screen. After moving, the layer stays where it was put; the layout does not re-place it on the next repaint.

Parameters

  • ID - layer id.
  • ROW - 1-based row position (clamped to screen bounds).
  • COL - 1-based column position (clamped to screen bounds).

Returns: 1 when the layer is not visible.

Notes

  • The layer’s rectangle is kept inside the screen bounds; if the requested position would move part of the layer off-screen, the position is adjusted.
  • A layer normally returns to its markup-specified position and size during layout. Moving a layer with this function marks it as manually placed, so it stays where you put it unless the layer is reset with tui.layer.reset or resized with tui.layer.size.
  • The header of a floating layer (float attribute) can be dragged with the mouse to move it interactively.

See also: tui.layer.size, tui.layer.reset, tui.layer.zoom

tui.layer.size

tui.layer.size ID HEIGHT WIDTH

Sets the layer’s size in cells. The minimum is 3 rows by 8 columns; the maximum is the screen size. The position is adjusted if needed to keep the layer inside the screen.

Parameters

  • ID - layer id.
  • HEIGHT - height in rows (clamped to 3..screen height).
  • WIDTH - width in columns (clamped to 8..screen width).

Returns: 1 when the layer is not visible.

Notes

  • If the requested size is too small, it is enlarged to the minimum (3x8). If it exceeds the screen, it is shrunk to fit.
  • Like tui.layer.move, sizing a layer marks it as manually placed and kept as-is on the next layout. Reset it with tui.layer.reset to return to the markup-specified size.
  • A floating layer’s bottom-right corner can be dragged with the mouse to resize it interactively.

See also: tui.layer.move, tui.layer.reset

tui.layer.reset

tui.layer.reset ID

Resets the layer to the position and size specified in the markup. Clears any manual moves, resizes, zoom state, and minimize state.

Parameters

  • ID - layer id.

Returns: 1 when the layer is not visible.

Notes

See also: tui.layer.move, tui.layer.size, tui.layer.zoom, tui.layer.minimize

tui.layer.zoom

tui.layer.zoom ID

Toggles the layer between its normal size and filling the entire screen.

Parameters

  • ID - layer id.

Returns: 1 when the layer is not visible.

Notes

  • When zoomed, the layer covers the entire screen from (1,1) to the bottom-right corner, regardless of its previous position and size. Zooming again returns the layer to its previous dimensions. Zooming and unzooming does not affect the manual position or size set by tui.layer.move or tui.layer.size.
  • A zoomed state is preserved across calls and can be saved with persist="layout" in the markup.

See also: tui.layer.minimize, tui.layer.reset

tui.layer.minimize

tui.layer.minimize ID

Toggles the layer between its normal display and a collapsed one-row title bar.

Parameters

  • ID - layer id.

Returns: 1 when the layer is not visible.

Notes

  • When minimized, the layer shows only its title bar (one row) with the title text and any available control buttons (close, minimize, fullscreen, reset). The content is hidden and not focusable or hit-testable.
  • The layer’s position and size are retained; unminimizing restores the full view. Minimizing works independently of zoom state.
  • A minimized state is preserved across calls and can be saved with persist="layout" in the markup.
  • A layer with minimizable="true" shows a minimize button (the – glyph) in its header when it has space.

See also: tui.layer.zoom, tui.layer.reset

tui.layer.active

tui.layer.active [ID]

Returns 0 while any layer is shown, or while a specific layer is shown.

Parameters

  • ID - (optional) layer id. If provided, checks only that layer; if omitted, checks if any layer is visible.

Returns: 0 if the condition is met, 1 otherwise.

Notes

  • A layer is considered active (shown) when it has been made visible with tui.layer.show and has not been hidden with tui.layer.hide or tui.layer.close.
  • Useful for conditional logic: check if a modal layer is in effect before allowing certain operations.

See also: tui.layer.show, tui.layer.hide, tui.layer.top

tui.layer.top

tui.layer.top [VAR]

Gets the id of the topmost visible layer. The result is printed or stored in a variable; returns 1 when no layer is visible.

Parameters

  • VAR - (optional) variable name to store the result. If omitted, the id is printed.

Returns: 0 if a layer is visible, 1 if none.

Notes

  • The topmost layer is the one drawn last and appears on top of all others. This is the layer raised most recently by tui.layer.raise, shown with tui.layer.show, or by user interaction (clicking or focusing).
  • Useful for determining which layer has priority for input or to check if a specific critical layer is on top.

See also: tui.layer.raise, tui.layer.active

tui.layer.detach

tui.layer.detach PANE

Detaches a pane from its horizontal or vertical split, converting it into a floating layer that appears as a window on top of the page. The siblings of the detached pane take the freed space. Runs the on_detach callback if defined.

Parameters

  • PANE - pane id. Must be in an h (horizontal) or v (vertical) split and have detachable="true" in the markup.

Returns: 1 when the pane is not in an h/v split, already floats, or does not have detachable="true".

Notes

  • The detached pane floats as a <window> with shadow and close button over the place it occupied, inheriting size from its last dimensions.
  • With leave="placeholder", an empty placeholder pane keeps the original space; without it, the siblings redistribute the freed space.
  • The pane’s on_detach callback (if defined) is called after detachment. The floating pane can be docked back with tui.layer.dock.
  • Markup: pane element with detachable="true", optional dock_group="NAME", leave="placeholder", on_detach="FN", on_dock="FN", and persist="layout" (to remember detached state across reloads).

See also: tui.layer.dock

tui.layer.dock

tui.layer.dock LAYER [PANE]

Docks a floating pane back into its original split, restoring it to its previous position and size spec. If PANE is given, docks the pane as the last child of that split pane instead. Runs the on_dock callback if defined.

Parameters

  • LAYER - floating layer id (created by tui.layer.detach).
  • PANE - (optional) split pane to dock into. If omitted, the layer returns to its original parent and position.

Returns: 1 when the layer was not detached, or (with PANE) when PANE is not in the same dock_group.

Notes

  • A layer can be docked only if it was originally detached from a split with tui.layer.detach.
  • If a placeholder pane was left behind (created with leave="placeholder"), docking restores the original pane to that placeholder’s position. Otherwise, the pane becomes the last child of its target.
  • When docking into a different pane with PANE, both must share the same dock_group="NAME" attribute.
  • The pane’s on_dock callback (if defined) is called after docking. The docked pane returns to being a normal split child.

See also: tui.layer.detach

<nav> builds a pane of page buttons; the item of the current page wears the active class (see Navigation).

Function Summary
tui.nav.sync Re-applies the highlight of every <nav>: the item whose page is the current one gets the nav’s active_class, the others their item_class, and the nav buttons are redrawn.

tui.nav.sync

tui.nav.sync

Re-applies the highlight of every <nav>: the item whose page is the current one gets the nav’s active_class, the others their item_class, and the nav buttons are redrawn.

Notes

  • It runs by itself after every page load (also a cached one), so a click, a shortcut, Back and tui.goto need no call. Use it only after code changed what the current page is without loading one.
  • The current page is compared by name: the file name without directory and extension (see tui.get.page_name).
  • Does nothing when the page has no <nav>, or for a nav with active="none".