@jsvision/ui / Application
Interface: Application
Defined in: ui/src/app/application.ts:87
A ready-to-run terminal application. Populate desktop/loop, then call run().
Properties
desktop
readonlydesktop:Desktop
Defined in: ui/src/app/application.ts:89
The desktop window manager. Add windows with desktop.addWindow(...).
loop
readonlyloop:EventLoop
Defined in: ui/src/app/application.ts:91
The underlying event loop. Use it to emit commands, manage focus, or run modals.
Methods
onCommand()
onCommand(
command,handler): () =>void
Defined in: ui/src/app/application.ts:105
Register an app-wide handler for a named command; returns a function that unregisters it. Every handler registered for a command runs when that command is emitted, and a handled command is consumed there. Forwards to loop.onCommand — see it for the pre-process ordering and the modal-open caveat.
Parameters
command
string
The command name to handle (e.g. a menu/status item's command).
handler
() => void
Called when the command is emitted.
Returns
A function that unregisters this handler (idempotent).
() => void
Example
const off = app.onCommand('about', () => messageBox(app, { title: 'About', text: '…' }));
// later: off(); // stop handling 'about'run()
run():
Promise<number>
Defined in: ui/src/app/application.ts:120
Connect to the terminal and run until the 'quit' command, resolving to the exit code. The terminal is always restored on exit — normal, thrown, or signalled.
Returns
Promise<number>
setTheme()
setTheme(
theme):void
Defined in: ui/src/app/application.ts:115
Replace the active theme at runtime and repaint every view with the new colors in one coalesced frame. Forwards to loop.setTheme, so it is safe to call from a command handler or a bare imperative call — the repainted frame reaches the terminal even outside an input tick.
Parameters
theme
Theme
The theme to switch to (a preset, a createTheme result, or a parseTheme result).
Returns
void
Example
app.onCommand('theme:nord', () => app.setTheme(nordTheme));