Skip to content

fix: support application cursor mode (DECCKM) for arrow keys#81

Merged
sreya merged 1 commit into
mainfrom
fix-htop-arrow-keys
Dec 4, 2025
Merged

fix: support application cursor mode (DECCKM) for arrow keys#81
sreya merged 1 commit into
mainfrom
fix-htop-arrow-keys

Conversation

@sreya

@sreya sreya commented Dec 4, 2025

Copy link
Copy Markdown
Contributor

fixes #79

Arrow keys now correctly send SS3 sequences (ESC O A/B/C/D) when
application cursor mode is enabled (DEC mode 1), and CSI sequences
(ESC [ A/B/C/D) when in normal mode.

This fixes arrow key navigation in applications like htop that enable
application cursor mode.

Changes:
- Rewrote Key enum to match Ghostty's internal values (was using USB HID codes)
- Arrow keys now go through the Ghostty encoder instead of fast path
- Sync encoder CURSOR_KEY_APPLICATION option with terminal mode 1 state
- Add getModeCallback to InputHandler for querying terminal mode state
- Add tests for both normal and application cursor modes

The Key enum change also fixes the encoder for all special keys (F-keys,
navigation keys, etc.) which were previously producing incorrect or empty
output due to the enum value mismatch.
@sreya sreya force-pushed the fix-htop-arrow-keys branch from 3210ee4 to e6aa575 Compare December 4, 2025 07:01
@sreya sreya merged commit 22f6d09 into main Dec 4, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant