Kterm integration

Kvim home

Terminal theme adoption

Kvim defaults to adopting the active terminal emulator's palette:

[appearance]
theme = "terminal"

Kterm exports its resolved palette to child processes through KTERM_PALETTE:

1:<FG>:<BG>:<CURSOR>:<ACCENT>:<SURFACE>:<ANSI0>:...:<ANSI15>

Each field is exactly six uppercase hexadecimal RGB digits. Kvim accepts only that exact version, field count, width, separator placement, and character set. Unsupported or malformed values are ignored without warning or partial application. Terminal mode then retains its existing portable fallback: reset foreground/background for the editor canvas and ANSI indexes 0-15 for semantic accents.

With a valid export, terminal mode uses the supplied RGB foreground, background, cursor, accent, surface, and ANSI colors. Current-line, selection, preview, status, search, yank, substitute-preview, and diff surfaces are derived with small deterministic linear-light blends. Diff line and filler backgrounds use especially faint red/green tints, with a restrained stronger tint on changed words. Syntax and semantic foreground colors are unchanged, apart from existing contrast adjustments. Foregrounds on generated surfaces are selected from the terminal foreground/background by measured contrast. This keeps both light and dark Kterm themes legible.

Only theme = "terminal" consumes KTERM_PALETTE. Fixed themes ignore the export:

The Everforest variants use Kvim-specific semantic assignments for editor chrome, syntax, diagnostics, selection, search, and diff rendering while retaining the exact palettes from sainnhe/everforest commit 85a86eb62409e3ec88713bff3d1b9d7374e112e4. An unknown appearance theme still produces a visible startup warning and safely falls back to terminal.

Kvim does not issue OSC 4/10/11/12 palette queries. Reading Kterm's bounded startup snapshot avoids interleaving terminal replies with keyboard or mouse input, especially on Windows.

Kvim's normal-mode split controls integrate with Kterm automatically:

Kvim emits navigation and resize requests only when the parent advertises KTERM_PANE_NAVIGATION=1 or KTERM_PANE_RESIZE=1, respectively. Other terminals retain Kvim's normal split behavior and receive no Kterm-specific control sequences.

Kvim probes for SGR extended underline support with DECRQSS before rendering spelling decorations. On Unix it prefers the standard response and falls back to Kterm's KTERM_EXTENDED_UNDERLINE=1 advertisement if a response does not arrive before the bounded probe timeout. On Windows it uses the advertisement because Kvim's input backend cannot expose DCS responses. Unsupported terminals receive straight spelling underlines instead.

While its alternate screen is active, Kvim claims Kterm's cooperative pane controls so these shortcuts reach Kvim first. It releases the controls during terminal cleanup.