feat(terminal): add DECRQM (CSI ? Ps $ p) — report DEC private mode state#65
Draft
roramirez wants to merge 1 commit into
Draft
feat(terminal): add DECRQM (CSI ? Ps $ p) — report DEC private mode state#65roramirez wants to merge 1 commit into
roramirez wants to merge 1 commit into
Conversation
Report whether a DEC private mode is set (1), reset (2), or not recognized (0) in reply to a DECRQM query, covering the modes mmterm already tracks (cursor keys, autowrap, cursor visibility, mouse, focus reporting, alt screen, bracketed paste). neovim and others use this to probe capabilities before enabling a mode. Route all `?`-prefixed sequences through one handler and collapse the DECSET/DECRST arms into `h | l` patterns while here.
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.
Summary
Implements DECRQM (
CSI ? Ps $ p), the Request Mode query for DEC private modes. mmterm now repliesCSI ? Ps ; Pm $ ywherePmis1(set),2(reset), or0(mode not recognized). Applications such as neovim use DECRQM to probe terminal capabilities before enabling a mode, avoiding redundant or unsupported mode switches.Changes
src/terminal/parser.rs:?-prefixed CSI throughhandle_dec_private_modes(vte reports the$intermediate alongside the?, so DECRQM does not collide with plain set/reset).action == 'p'as DECRQM: reply from a newdecrqm_statehelper that maps a mode number to0/1/2over the state mmterm already tracks (?1,?7,?25,?1000/1002/1003,?1004,?1006,?1049,?2004).h/l) arms into('h' | 'l', …)patterns using a singleon = action == 'h'flag — same behavior, fewer lines.src/terminal/parser_test.rs: a test covering set, reset, reset-after-disable, unknown-mode, and that a query does not toggle the mode.CHANGELOG.md: entry under[Unreleased] / Added.How to test
cargo test(seedecrqm_reports_mode_stateinparser_test.rs; the full suite still passes with the refactored setter).printf '\033[?2004$p'replies\033[?2004;1$ywhen bracketed paste is enabled.Checks