Skip to content

fix: decode the BS byte as backspace - #149

Merged
meszmate merged 1 commit into
mainfrom
fix/issue-146
Sep 3, 2026
Merged

meszmate merged 1 commit into
mainfrom
fix/issue-146

Conversation

@meszmate

@meszmate meszmate commented Sep 3, 2026

Copy link
Copy Markdown
Owner

Fixes #146.

Backspace did nothing in the text editor on xterm. xterm sends 0x08 for Backspace unless backarrowKey is turned off, but the parser only treated DEL as backspace and folded 0x08 into the Ctrl+letter range, so it arrived as ctrl+h. TextArea and TextInput return early on any ctrl key they don't recognise, so the event was dropped. Same reason Ctrl+D and Ctrl+Q kept working while Backspace and Ctrl+H did not.

0x08 now decodes to a plain backspace, and Kitty keycode 8 is accepted alongside 127.

The tradeoff: a legacy encoding cannot tell Backspace and Ctrl+H apart, they are the same byte. So Ctrl+H is only bindable under the Kitty protocol, which reports it separately as CSI 104;5u. There is a test pinning that. crossterm and vaxis make the same call, and nothing in this repo binds Ctrl+H.

Verified by driving the built binaries through a pty with TERM=xterm-256color, sending the exact bytes xterm sends. Showcase, tab 5, typing ABC then two backspaces:

before:  1 ABCconst std = @import("std");
after:   1 Aconst std = @import("std");

zig build and zig build test pass.

xterm sends 0x08 for Backspace unless backarrowKey is turned off, but the
parser only treated DEL as backspace and folded 0x08 into the Ctrl+letter
range as ctrl+h. TextArea and TextInput drop unrecognised ctrl keys, so the
key did nothing in the text editor example.

0x08 now decodes to a plain backspace, and Kitty keycode 8 is accepted
alongside 127. The cost is that a legacy encoding cannot tell Backspace and
Ctrl+H apart, so Ctrl+H is only bindable under the Kitty protocol, which
reports it as CSI 104;5u.

Fixes #146
@meszmate
meszmate merged commit f2ae106 into main Sep 3, 2026
12 checks passed
@meszmate
meszmate deleted the fix/issue-146 branch September 3, 2026 07:58
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.

Backspace in text editor example does not function in xterm

1 participant