-
-
Notifications
You must be signed in to change notification settings - Fork 136
Bugfix DECRQM (Dec Request Mode) response #1797
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
christianparpart
merged 4 commits into
contour-terminal:master
from
jquast:jq/bugfix-request-dec-mode
Nov 2, 2025
Merged
Bugfix DECRQM (Dec Request Mode) response #1797
christianparpart
merged 4 commits into
contour-terminal:master
from
jquast:jq/bugfix-request-dec-mode
Nov 2, 2025
Conversation
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
785ce7c to
bd0b7a2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many thanks for the fix. Is it okay to apply the minors, for you?
Interactive terminal sequence response for DEC Private Mode Query is invalid -- it may respond with a different mode and status than the one requested. This causes programs to fail or mismatch contour's terminal capabilities. In my API I was expecting the requested mode value in the response pattern, and, not discovering it after some timeout, wrongly reported that Contour does not support any DEC Private Modes at all. This bug is present in all versions of Contour supporting DEC Private Mode, since 256e313 and refactored in faa66e7, the use of: static_cast<DECMode>(mode) Is invalid, because the DECMode enum has "holes". It is not contiguous. A new 'fromDECModeNum' function is provided, returning an optional DecMode, and, existing function 'isValidDECMode' is refactored to check whether the optional value returned by 'fromDECModeNum' has_value(). Given the provided file `test/display-modes.sh`, we can make inquiry of DEC Private modes and see that DEC modes 1 through 27 are returned with non-matching response modes mismatched by enum item order and status:: $ ./test/display-modes.sh Query mode 1: response=$'\E[?2;2$y' after 13ms Query mode 2: response=$'\E[?3;2$y' after 11ms Query mode 3: response=$'\E[?4;2$y' after 10ms Query mode 4: response=$'\E[?5;2$y' after 11ms Query mode 5: response=$'\E[?9;2$y' after 11ms Query mode 6: response=$'\E[?1000;2$y' after 12ms Query mode 7: response=$'\E[?1001;2$y' after 13ms Query mode 8: response=$'\E[?1002;2$y' after 13ms Query mode 9: response=$'\E[?1003;2$y' after 12ms Query mode 10: response=$'\E[?1048;2$y' after 14ms After this bugfix, this is corrected: $ ./test/display-modes.sh Query mode 1: response=$'\E[?1;2$y' after 11ms Query mode 2: response=$'\E[?2;2$y' after 11ms Query mode 3: response=$'\E[?3;2$y' after 8ms Query mode 4: response=$'\E[?4;2$y' after 10ms Query mode 5: response=$'\E[?5;2$y' after 8ms Query mode 6: response=$'\E[?6;2$y' after 11ms Query mode 7: response=$'\E[?7;1$y' after 11ms Query mode 8: response=$'\E[?8;0$y' after 10ms Query mode 9: response=$'\E[?9;2$y' after 10ms Query mode 10: response=$'\E[?10;2$y' after 12ms Further, looking at other uses of 'isValidDECMode', some were unnecessary, that they have the DECMode type bound to the variable is sufficient to describe that mode as valid for Contour, the check is superfluous: isValidDECMode(static_cast<unsigned int>(mode)));
Signed-off-by: Christian Parpart <christian@parpart.family>
58856f8 to
7467a30
Compare
…oid some code duplication Signed-off-by: Christian Parpart <christian@parpart.family>
9b66e21 to
48999ce
Compare
Signed-off-by: Christian Parpart <christian@parpart.family>
48999ce to
6ce2956
Compare
christianparpart
approved these changes
Nov 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much for your contribution, @jquast 😄
b2c0b5f
into
contour-terminal:master
26 of 27 checks passed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
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.
Interactive terminal sequence response for DEC Private Mode Query is invalid -- it may respond with a different mode and status than the one requested.
This causes programs to fail or mismatch contour's terminal capabilities. In my API I was expecting the requested mode value in the response and, not matching it for any modes under number 27, wrongly reported that Contour does not support any DEC Private Modes at all.
This bug is present in all versions of Contour supporting DEC Private Mode, since 256e313 and refactored in faa66e7, the use of:
Is invalid, because the DECMode enum has "holes". It is not contiguous.
A new
fromDECModeNum()function is provided, refactored form ofisValidDecMode()-- returning anoptional DecMode, existing functionisValidDECMode()is refactored to check whether the optional value returned by 'fromDECModeNum' tests true forhas_value().Given the provided test file
test/display-modes.sh, we can make inquiry of DEC Private modes and see that DEC modes 1 through 27 are returned with non-matching response modes mismatched by enum item order and status:After this bugfix, this is corrected:
Further, looking at other uses of
isValidDECMode(), some were unnecessary -- that they have theDECModetype bound to the variable is sufficient enough to describe that mode as valid, the check is superfluous and removed, eg:the call to
toDECModeNumis also superfluous and removed.