@jsvision/ui / DesktopApplication
Interface: DesktopApplication
Defined in: ui/src/app/application.ts:250
An application whose body is the default Desktop window manager (no content was given).
Extends
Properties
desktop
readonlydesktop:Desktop
Defined in: ui/src/app/application.ts:252
The desktop window manager — always present for a no-content app.
Overrides
i18n
readonlyi18n:I18n
Defined in: ui/src/app/application.ts:152
Translation service used by framework-owned UI and modal helpers.
Inherited from
loop
readonlyloop:EventLoop
Defined in: ui/src/app/application.ts:161
The underlying event loop. Use it to emit commands, manage focus, or run modals.
Inherited from
Methods
menuBase()
menuBase():
MenuItem[]
Defined in: ui/src/app/application.ts:241
The application's base menu items — the top-level menu nodes createApplication({ menuBar }) was given. Menu items are plain data (not views), so this returns a shallow copy safe to compose with withBase.
Returns
MenuItem[]
A copy of the base menu's top-level items (empty if no menu bar).
Example
import { createApplication, withBase, subMenu, item } from '@jsvision/ui';
import type { ScreenBundle } from '@jsvision/ui';
import { resolveCapabilities } from '@jsvision/core';
const caps = resolveCapabilities().profile;
const app = createApplication({ caps });
// A screen's menu = the app base plus a screen-specific submenu:
const screen: ScreenBundle = {
view: app.desktop,
menu: withBase(app.menuBase(), [subMenu('~S~creen', [item('~E~dit', 'detail.edit')])]),
};Inherited from
onCommand()
onCommand(
command,handler): () =>void
Defined in: ui/src/app/application.ts:181
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
import { createApplication, messageBox } from '@jsvision/ui';
import { resolveCapabilities } from '@jsvision/core';
const caps = resolveCapabilities().profile;
const app = createApplication({ caps });
const off = app.onCommand('about', () => messageBox(app, { title: 'About', text: '…' }));
// later: off(); // stop handling 'about'Inherited from
run()
run():
Promise<number>
Defined in: ui/src/app/application.ts:246
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>
Inherited from
setTheme()
setTheme(
theme):void
Defined in: ui/src/app/application.ts:197
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
import { createApplication } from '@jsvision/ui';
import { resolveCapabilities, nordTheme } from '@jsvision/core';
const caps = resolveCapabilities().profile;
const app = createApplication({ caps });
app.onCommand('theme:nord', () => app.setTheme(nordTheme));Inherited from
statusBase()
statusBase():
View[]
Defined in: ui/src/app/application.ts:220
A fresh copy of the application's base status items — the global affordances (e.g. quit/help) a screen composes with its own hints via withBase. Each call rebuilds new item views, because a view has a single parent: composing with the live base bar's own instances would re-parent them and corrupt the fallback bar. Only command items are reproduced (spacers/widgets are not part of a composable base).
Returns
View[]
Fresh status-item views mirroring the base bar's command items (empty if no status line).
Example
import { createApplication, withBase, statusItem } from '@jsvision/ui';
import type { ScreenBundle } from '@jsvision/ui';
import { resolveCapabilities } from '@jsvision/core';
const caps = resolveCapabilities().profile;
const app = createApplication({ caps });
// A screen's status = the app base plus a screen-specific action:
const screen: ScreenBundle = {
view: app.desktop,
status: withBase(app.statusBase(), [statusItem('~E~dit', 'detail.edit')]),
};