Skip to content

fix(vt): Ctrl+letter keys not forwarded to child processes under kitty kb protocol#3414

Open
michaellukashov wants to merge 1 commit into
elfmz:masterfrom
michaellukashov:kitty-kb-ctrl-letter
Open

fix(vt): Ctrl+letter keys not forwarded to child processes under kitty kb protocol#3414
michaellukashov wants to merge 1 commit into
elfmz:masterfrom
michaellukashov:kitty-kb-ctrl-letter

Conversation

@michaellukashov

@michaellukashov michaellukashov commented May 27, 2026

Copy link
Copy Markdown
Contributor

fix(vt): Ctrl+letter keys not forwarded to child processes under kitty keyboard protocol

Problem

When kitty keyboard protocol is active in the VT shell, Ctrl+letter combinations (A-Z) generate kitty escape sequences (ESC[4;5u for Ctrl+D) instead of raw control bytes (0x04). Non-far2l child processes — like any terminal application that doesn't implement kitty keyboard protocol — receive nothing for these keypresses. This breaks Ctrl+D, Ctrl+K, Ctrl+U, Ctrl+A, Ctrl+E in editors, shells, and TUI applications running inside far2l's VT panels.

Root Cause

TranslateKeyEvent in far2l/src/vt/vtshell.cpp checks _kitty_kb_flags first. When set (child negotiated kitty keyboard protocol), VT_TranslateKeyToKitty always wins — even for keys that have trivial legacy encodings. The kitty escape sequences are only understood by terminals implementing that protocol, not by arbitrary child processes.

Fix

In TranslateKeyEvent, after kitty translation produces a result for Ctrl+letter keys (ctrl only, no alt/shift, VK between A-Z), fall through to the legacy VT_TranslateSpecialKey path which correctly maps Ctrl+D→\x04, Ctrl+K→\x0b, etc. All other keys (arrows, F-keys, modifiers, multi-modifier combos) continue to use kitty protocol unchanged.

// Ctrl+letter falls through to legacy translation
if (!(ctrl && !alt && !shift
    && KeyEvent.wVirtualKeyCode >= 'A'
    && KeyEvent.wVirtualKeyCode <= 'Z')) {
    return as_kitty;
}

Additional changes

  • TTYRawMode enhancement — explicit termios flag clearing beyond cfmakeraw (CREAD|CLOCAL, VMIN=1/VTIME=0, defensive clearing of IUTF8/IXOFF/IUCLC/ECHOCTL). Added dup() failure check. Previously, raw mode could fail silently.
  • FAR2L_TTY_DIAG — runtime diagnostic (env var, no recompile) prints actual terminal flags after raw mode setup
  • Build fixg_tty_profiler pointer access (g_tty_profiler.framesg_tty_profiler->frames) in TTYBackend.cpp WriterThread

Files changed

File Lines Purpose
far2l/src/vt/vtshell.cpp +7/-2 Main fix: kitty kb Ctrl+letter fallthrough

Verification

Tested under WindowsTerminal → SSH → far2l running oh-my-pi (a TUI application). Before: Ctrl+D/K/U/A/E produce no effect. After: all Ctrl+letter keys work correctly (confirmed with FAR2L_TTY_DIAG=1 and byte-level tracing).

@unxed

unxed commented May 27, 2026

Copy link
Copy Markdown
Contributor

Выглядит разумно

…rotocol

When kitty keyboard protocol is active, Ctrl+letter combinations (A-Z)
were being encoded as kitty escape sequences (e.g. \e[4;5u for Ctrl+D)
and written to the child process's stdin. Non-far2l child processes
don't recognize kitty escapes and received nothing usable.

Fall through from the kitty encoding path to VT_TranslateSpecialKey for
simple Ctrl+letter (ctrl-only, no alt/shift), which produces the standard
raw control bytes 0x01-0x1A that all processes expect.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants