terminal: report modifyOtherKeys state via XTQMODKEYS#13332
Open
aymanbagabas wants to merge 3 commits into
Open
terminal: report modifyOtherKeys state via XTQMODKEYS#13332aymanbagabas wants to merge 3 commits into
aymanbagabas wants to merge 3 commits into
Conversation
Ghostty implements xterm modifyOtherKeys mode 1 by default (ambiguous modified keys are encoded in the CSI 27 numeric form) and mode 2 when enabled, but it never responded to the query `CSI ? 4 m`, so applications couldn't detect support or the active mode. Parse `CSI ? 4 m` (XTQMODKEYS resource 4) and reply with `CSI > 4 ; Pv m`, where Pv is 2 when mode 2 is active and 1 otherwise. Pv is never 0 because the mode 1 encoding is always active and cannot be disabled. Discussion: ghostty-org#13331 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9b663367-2ceb-4a1d-b634-28f22ef0a653 Signed-off-by: Ayman Bagabas <ayman.bagabas@gmail.com>
Member
|
Initial read-through looks good but I'm on mobile so maybe I missed something. |
mitchellh
requested changes
Jul 14, 2026
- Short-circuit the libghostty-vt query handler when no write_pty effect is configured. - Drop the pointless debug log in the termio query handler. - Add parser unit tests covering CSI ? 4 m and the ignored resources. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9b663367-2ceb-4a1d-b634-28f22ef0a653 Signed-off-by: Ayman Bagabas <ayman.bagabas@gmail.com>
Contributor
Author
|
Thank you @jcollie @mitchellh for the review. Addressed the review comments and also added DECRQSS report support. |
aymanbagabas
marked this pull request as ready for review
July 15, 2026 13:42
jcollie
reviewed
Jul 15, 2026
CSI ? 4 m is technically a private SGR sequence, which historically indicated a superscript rendition. Support the DECRQSS form (DCS $ q > 4 m ST) as a safer alternative, as suggested in review, while keeping the CSI form. Both query forms reply with the XTMODKEYS control `> 4 ; Pv m`, now shared via Terminal.modifyOtherKeysReport so the emitted bytes are unit tested. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9b663367-2ceb-4a1d-b634-28f22ef0a653 Signed-off-by: Ayman Bagabas <ayman.bagabas@gmail.com>
aymanbagabas
force-pushed
the
aymanbagabas/vt-modify-other-keys-query
branch
from
July 16, 2026 13:09
fe66d80 to
b60a83f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements querying support for xterm
modifyOtherKeys(XTQMODKEYS resource 4) via two forms:CSI ? 4 m— the XTQMODKEYS query.DCS $ q > 4 m ST— the DECRQSS form.CSI ? 4 mis technically a privateSGRsequence (historically a superscript rendition), so DECRQSS is offered as a safer alternative per review feedback. Both forms are kept.Ghostty implements mode 1 by default (ambiguous modified keys use the
CSI 27numeric form) and mode 2 when enabled, but never responded to either query, so applications could not detect support or the active mode.Both forms reply with the XTMODKEYS control
> 4 ; Pv m(CSI-prefixed forCSI ? 4 m, wrapped inDCS 1 $ r … STfor DECRQSS), wherePvis2when mode 2 is active and1otherwise.Pvis never0because the mode 1 encoding is always active and cannot be disabled. The reply payload is shared viaTerminal.modifyOtherKeysReportand unit tested.Discussion: #13331
AI disclosure
Implemented with AI assistance (GitHub Copilot CLI, model Claude Opus 4.8). I reviewed, understand, and can explain all of the code and its interaction with the key encoder without AI aid, per the AI Usage Policy.