Skip to main content

@svatah/yam-tui

yam ui — the terminal cockpit, a second renderer of the screen model (REQ-TUI-1)

Exports

ExportKindSignature
actionForKeyvariableactionForKey = (The action a key runs on this screen in this mode, if any binds it.
ALL_KEYSvariableALL_KEYS: ReadonlyArray<KeyBinding & { readonly screen: ScreenId }> = SCREEN_IDS.flatMap(Every binding, for the check that no key names an action the registry does
ansi256Offunctiondeclare function ansi256Of(hex: string): number;The nearest xterm-256 index, computed.
Appfunctionexport function App(props: AppProps): React.JSX.Element
asJsonfunctionexport function asJson(ui: UiState): Record<string, unknown>What --json prints, and what the model produces on its own.
Boxinterfaceexport interface BoxWhere a pane ended up. Zero-based, in character cells.
Capabilitiesinterfaceexport interface CapabilitiesWhat a terminal can do, as far as it will admit.
capabilitiesOffunctionexport function capabilitiesOf(What this terminal can do (TV-05).
Cellinterfaceexport interface CellOne column of a line. grow takes whatever width is left over.
classicTreefunctionexport function classicTree(): RegionThe four numbered panes, as a tree (T9.4's artboard).
ColourDepthtypealiastype ColourDepth = "truecolor" | "ansi256" | "none";How much colour to send.
COMMAND_KEYSvariableCOMMAND_KEYS: readonly CommandKey[] = [
CommandKeyinterfaceexport interface CommandKeyThe keys the cockpit itself has, which run commands rather than actions.
decodeMousefunctionexport function decodeMouse(chunk: string): MouseEvent[]Every mouse event in a chunk of input, in the order they happened.
DEFAULT_SCREENvariableDEFAULT_SCREEN: ScreenId = "session"Where the cockpit opens (TV-14, REQ-ADE-11).
depthForfunctiondeclare function depthFor(capabilities: Capabilities, asked?: string): ColourDepth;--color, and what the terminal says when nobody passed it.
Emptyfunctionexport function Empty(props:A zero state that names its next action (TV-06).
fitvariablefit = (text: string, width: number): string =>"a string" cut to width, so a narrow terminal does not wrap a table.
flowsTreefunctionexport function flowsTree(): RegionFlows: the files, the text, what the cursor is on, and the lint.
focusPanefunctionexport function focusPane(ui: UiState, pane: Pane): UiState14 and Tab: which pane the keys go to (LLD §13.7).
foregroundfunctiondeclare function foreground(hex: string, depth: ColourDepth): string;The escape that colours the foreground, for this depth.
Framefunctionexport function Frame(props: FrameProps): React.JSX.ElementA bordered region that fills its box exactly.
GLYPHvariableGLYPH: Readonly<Record<StatusTone, string>> The gutter glyph per tone. The word is always beside it (LLD §13.7).
hexOfvariablehexOf: (what: StatusTone, appearance?: Theme) => stringThe hexadecimal a tone is, for a renderer that colours its own way.
hitTestfunctionexport function hitTest(Which region was clicked, and which of its rows.
inkColourfunctionexport function inkColour(What Ink is told, which is a hexadecimal or a name.
INSPECTOR_MIN_COLUMNSvariableINSPECTOR_MIN_COLUMNS = 120The width at which the inspector still has room to be read (Draft 2.12 §13.7).
isMousevariableisMouse = (chunk: string): boolean => /\u001b\[</.test(chunk)Whether a chunk of input is mouse reporting rather than something typed.
KeyBindinginterfaceexport interface KeyBindingOne key, and the action it runs.
keyMapfunctionexport function keyMap():The whole key map, as yam ui --keys --json prints it and the ? overlay
keysForvariablekeysFor = (screen: ScreenId, mode?: SessionMode): readonly KeyBinding[] =>The keys this screen binds in this mode, in the order the footer prints them.
Layoutinterfaceexport interface Layout
layoutForfunctionexport function layoutFor(columns: number, rows: number): LayoutThe panes' sizes for a terminal of this size.
Lineinterfaceexport interface Line
listWindowfunctionexport function window(cursor: number, total: number, height: number): numberWhich slice of a list to draw so the cursor is on screen.
loadUifunctionexport async function loadUi(Load a screen and build the state around it.
mainRowsvariablemainRows = (state: UiState["state"], now?: number): number =>How many rows the main pane has.
MouseEventinterfaceexport interface MouseEventOne thing a person did with the mouse, in character cells, one-based as the terminal counts.
moveCursorfunctionexport function moveCursor(ui: UiState, by: number, rows: number): UiStatej/k and the arrows, clamped to what the focused pane actually has.
moveSelectionvariablemoveSelection = (at: number, by: number, total: number): number =>Where the selection goes, clamped, with nothing to wrap around to.
nextPanefunctionexport function nextPane(ui: UiState): UiState
ownfunctionexport function own(options: OwnOptions = {}): OwnedTake the terminal, and answer with the way back.
Ownedinterfaceexport interface OwnedA terminal the cockpit has taken, and the one call that gives it back.
PaletteRowinterfaceexport interface PaletteRow
Panetypealiasexport type Pane = (typeof PANES)[number];
PaneContentinterfaceexport interface PaneContent
paneModelfunctionexport function paneModel(state: ScreenStateBase, now: number = Date.now()): PaneModel
PaneModelinterfaceexport interface PaneModel
PANESvariablePANES = ["tree", "main", "inspector", "audit"] as constThe four numbered panes of the TUI artboard.
panesOffunctionexport function panesOf(region: Region): string[]Every pane id in a tree, in the order it is laid out.
placefunctionexport function place(tree: Region, columns: number, rows: number): PlacedThe same solve, as a tree rather than a lookup (TV-T07).
Placedinterfaceexport interface PlacedA region and the box it was given, with its children beside it.
printJsonfunctionexport async function printJson(options: UiOptions): Promise<void>--json: the model's state, and the audit lines, as JSON.
printKeysfunctionexport function printKeys(out: (text: string) => void = (text) => process.stdout.write(${text}\n)): void--keys --json: the key map, printed and drawn nothing (TV-07).
Regiontypealiasexport type Region = Pane | Split;
Regionsfunctionexport function Regions(props: RegionsProps): React.JSX.ElementDraw a solved tree.
resizefunctionexport function resize(ui: UiState, columns: number, rows: number): UiStateThe terminal was resized: the panes follow it (T10.4).
rgbOffunctiondeclare function rgbOf(hex: string): readonly [number, number, number];#4fc48a[79, 196, 138].
rowsForfunctionexport function rowsFor(actions: readonly Action[], options: PaletteOptions): PaletteRow[]The rows to draw, in the order to draw them.
rowsInfunctionexport function rowsIn(ui: UiState, pane: Pane): numberHow many rows the focused pane has, so j/k can be clamped.
runTreefunctionexport function runTree(): RegionA run: a wide step list over the events arriving under it.
runUifunctionexport async function runUi(options: UiOptions): Promise<void>Draw the cockpit, and answer when it exits.
scorefunctionexport function score(query: string, text: string): { score: number; hits: number[] } | undefinedScore one candidate against a query, subsequence-wise.
screenFromfunctionexport function screenFrom(value: string | undefined): ScreenId | undefined--screen <id>, validated against the model's own list.
scrollbarfunctionexport function scrollbar(start: number, shown: number, total: number, height: number): string[]Where the view is, in a list too long to draw: over , one column wide.
selectionAtfunctionexport function selectionAt(ui: UiState, pane: Pane): Line["select"]What Enter on the focused pane's current row re-loads with, if anything.
sessionTreefunctionexport function sessionTree(): RegionSession: the target list, the subject, and what will be written (REQ-ADE-14).
sizeOfvariablesizeOf = (layout: Layout): string => ${layout.columns}×${layout.rows}``100×40, as the header prints it and a capture therefore records.
solvefunctionexport function solve(tree: Region, columns: number, rows: number): SolvedFit a tree to a terminal.
Solvedinterfaceexport interface Solved
StatusBarfunctionexport function StatusBar(props:One line: what this is, where, and what it is doing.
tonefunctiondeclare function tone(what: StatusTone, text: string, depth: ColourDepth, appearance?: Theme): string;A tone, drawn.
treeRowsvariabletreeRows = (state: UiState["state"], now?: number): readonly Line[] =>The rows the tree pane lists, kept for the tests that read them directly.
UiOptionsinterfaceexport interface UiOptions
UiStateinterfaceexport interface UiState
unknownBindingsvariableunknownBindings = (): readonly string[] =>Every key that names an action nobody declared. Empty, and checked.
Viewinterfaceexport interface ViewA screen's regions: the tree, what is in each, and the order Tab walks.
viewForfunctionexport function viewFor(state: ScreenStateBase, now?: number): ViewThe regions this screen is, and what is in them.