Skip to content

@jsvision/ui / EventLoopOptions

Interface: EventLoopOptions

Defined in: ui/src/event/types.ts:37

Options for createEventLoop. Only caps is required; everything else is optional.

Properties

caps

caps: CapabilityProfile

Defined in: ui/src/event/types.ts:39

Required. Terminal capability profile that drives color-depth encoding for every painted frame.


clipboardKeys?

optional clipboardKeys?: ClipboardKeys

Defined in: ui/src/event/types.ts:53

Which clipboard key set the framework binds by default (default 'both' — modern Ctrl+A/C/X/V plus the classic Ctrl+Insert/Shift+Insert/Shift+Delete aliases). A keymap you supply is merged on top and wins on any conflicting chord. 'none' binds no clipboard chords at all — only a widget's built-in raw Ctrl+A select-all still fires — so an app on 'none' supplies its own keymap for copy/cut/paste (and the classic chords).


commands?

optional commands?: Iterable<string, any, any>

Defined in: ui/src/event/types.ts:55

Optional list of command names known up front. Commands are enabled by default whether listed or not.


keymap?

optional keymap?: Keymap

Defined in: ui/src/event/types.ts:45

Key-chord → command map (from core's createKeymap): a matched chord fires the command and swallows the key.


logger?

optional logger?: Logger

Defined in: ui/src/event/types.ts:43

Logger that receives errors thrown from a view's onEvent()/draw(); defaults to a no-op logger.


now?

optional now?: () => number

Defined in: ui/src/event/types.ts:63

Clock used to time double-clicks (defaults to Date.now). Two mouse-downs on the same cell within the multi-click window are reported as a double-click via DispatchEvent.clickCount. Inject a controllable clock in headless tests to drive exact timestamps.

Returns

number


onIdle?

optional onIdle?: () => void

Defined in: ui/src/event/types.ts:57

Called once per dispatch tick after all cascaded events drain, just before the frame is painted.

Returns

void


onQuit?

optional onQuit?: (code) => void

Defined in: ui/src/event/types.ts:82

Called when the quitCommand is emitted, with the exit code carried by the command (0 when none was given). This is how the loop terminates: createApplication wires it to resolve run(). When unset (a bare loop), the quit command is a plain command with no special termination.

Parameters

code

number

Returns

void


quitCommand?

optional quitCommand?: string

Defined in: ui/src/event/types.ts:70

The command that terminates the app (default 'quit'). If a quit is emitted while modal windows are open, it cascades top-down through the modal stack: each modal is asked to close, and a modal that vetoes (e.g. a dialog whose validation fails) stops the cascade and keeps the app running. Once the stack is empty the quit reaches the app's quit handler.


revealKey?

optional revealKey?: string | null

Defined in: ui/src/event/types.ts:76

The key that toggles "accelerator mode" (default 'f12'). While it is on, every reachable ~X~ hotkey in the current scope is underlined and pressing a bare letter fires the matching accelerator as if you had pressed Alt+letter. Pass null to disable the feature entirely.


scheduleMicrotask?

optional scheduleMicrotask?: (cb) => void

Defined in: ui/src/event/types.ts:97

How the loop defers an out-of-tick repaint. Defaults to queueMicrotask. A mutation that reaches the retained view tree outside a dispatch tick — a timer callback, a promise continuation, or a direct imperative call between input ticks — is painted on the callback this schedules, coalesced so a burst of such mutations in one JS turn produces a single frame. Inject a capturing implementation to step that deferred paint deterministically in a test.

Parameters

cb

() => void

Returns

void

Example

ts
// Deterministic stepping in a test: capture the deferred paint instead of queuing a microtask.
const pending: Array<() => void> = [];
const loop = createEventLoop({ width: 40, height: 10 }, { caps, scheduleMicrotask: (cb) => pending.push(cb) });
// …cause an out-of-tick signal write…
pending.forEach((cb) => cb()); // run the coalesced deferred paint

theme?

optional theme?: Theme

Defined in: ui/src/event/types.ts:41

Color/style theme applied to every view; defaults to the built-in defaultTheme.