import { type Key } from './terminal.js'; import { type Draw, type Rect, type Size } from './draw.js'; import type { ViewCore, TuiPresenter, TextPresenter, KeyBinding, KeyHint, BannerLevel } from '../view/contract.js'; import { type BindingId, type BindingResolution, type RawTerminalInput } from '../keybindings/index.js'; export interface RunViewOptions { /** CLI flags forwarded verbatim to the view via host.options. */ options?: Record; } /** The host-tracked chrome state. `banner` + `busy` + `loaded` derive the title * state chip; `tick` advances the spinner under the busy-tick repaint. */ export interface Chrome { status: string | null; banner: { msg: string; level: BannerLevel; } | null; busy: boolean; loaded: boolean; lastRefresh: number; tick: number; subtitle: string | null; mode: string | null; } /** The slice of a view's manifest that drawChrome reads (title + subtitle), plus * the footer hints lifted from the TuiPresenter's keymap bindings. */ export interface ChromeManifest { title: string; subtitle?: string; keymap?: KeyHint[]; } /** Draw the host chrome into `draw` and return the content Rect for the view. * Three zones: title row (state rail + title/subtitle + state chip + liveness), * a hairline, and a footer (status left, keymap right) with a severity banner * on the row above it when set. */ declare function drawChrome(draw: Draw, size: Size, manifest: ChromeManifest, c: Chrome, now?: number): Rect; export { drawChrome }; /** Tokens a keystroke can match a keymap binding's `keys` against. Arrows → * up/down/left/right, return → return|enter, escape → escape|esc, a printable * char → the char itself (+ 'space' for ' '), ctrl+x → ctrl+x|c-x. */ export interface ViewKeypress { readonly input: string; readonly key: Key; readonly raw: RawTerminalInput; } /** Extend the shared legacy parser with the terminal gestures the catalog can * express. The raw shape goes only to the catalog matcher; custom literals keep * their established Key-based matching. When `bindings` is supplied the ambiguous * 0x08 byte resolves to Ctrl-H only if an effective binding claims it. */ export declare function parseViewKeypress(data: Buffer, bindings?: BindingResolution): ViewKeypress; /** Resolve footer hints for the CURRENT state: only bindings whose `when(state)` * passes contribute, so mode-gated affordances (compose/react send/cancel/pick) * appear exactly while active. Catalog bindings render the effective key label * (omitted entirely when disabled); custom-view literal hints stay verbatim. */ export declare function resolveViewKeyHints(keymap: KeyBinding[], bindings: BindingResolution, state: S): KeyHint[]; /** The first non-capture binding whose key matches and whose `when` (if any) * passes — catalog IDs use the terminal matcher; custom literals retain their * presenter-authored matching. */ export declare function matchViewBinding(keymap: KeyBinding[], bindings: BindingResolution, input: string, key: Key, state: S, raw?: RawTerminalInput): { intent: string; payload: unknown; } | null; /** Match a host-owned generic-view action through the same catalog snapshot. */ export declare function matchesViewHostBinding(bindings: BindingResolution, id: 'crtr.view.host.force-quit' | 'crtr.view.host.editor.backspace', raw: RawTerminalInput): boolean; /** Host a dual-target ViewCore + TuiPresenter in the alt screen until it quits * (or Ctrl-C). `text` is the optional text presenter for the piped path. */ export declare function runCoreView(core: ViewCore, tui: TuiPresenter, text: TextPresenter | null, opts?: RunViewOptions): Promise;