Repository navigation
bugfix leaked XTGETTCAP responses into inkey() - #383
Merged
Merged
Conversation
With GNOME Terminal, some awful leaking of null XTGETTCAP responses are
received into the next call to inkey()::
$ python bin/keyboard_kitty_simple.py
Press and hold keys to see raw kitty keystrokes and their names (press 'q' to quit)
kitty keyboard state: None
name=KEY_ALT_SHIFT_P value=P kind=pressed, sequence='\x1bP'
name=None value=0 kind=pressed, sequence='0'
name=None value=+ kind=pressed, sequence='+'
name=None value=r kind=pressed, sequence='r'
name=KEY_ALT_\ value=\ kind=pressed, sequence='\x1b\\'
name=KEY_ALT_SHIFT_P value=P kind=pressed, sequence='\x1bP'
name=None value=0 kind=pressed, sequence='0'
name=None value=+ kind=pressed, sequence='+'
name=None value=r kind=pressed, sequence='r'
name=KEY_ALT_\ value=\ kind=pressed, sequence='\x1b\\'
name=KEY_ALT_SHIFT_P value=P kind=pressed, sequence='\x1bP'
name=None value=0 kind=pressed, sequence='0'
name=None value=+ kind=pressed, sequence='+'
name=None value=r kind=pressed, sequence='r'
name=KEY_ALT_\ value=\ kind=pressed, sequence='\x1b\\'
name=KEY_ALT_SHIFT_P value=P kind=pressed, sequence='\x1bP'
name=None value=0 kind=pressed, sequence='0'
name=None value=+ kind=pressed, sequence='+'
name=None value=r kind=pressed, sequence='r'
name=KEY_ALT_\ value=\ kind=pressed, sequence='\x1b\\'
name=KEY_ALT_SHIFT_P value=P kind=pressed, sequence='\x1bP'
name=None value=0 kind=pressed, sequence='0'
name=None value=+ kind=pressed, sequence='+'
name=None value=r kind=pressed, sequence='r'
name=KEY_ALT_\ value=\ kind=pressed, sequence='\x1b\\'
name=KEY_ALT_SHIFT_P value=P kind=pressed, sequence='\x1bP'
name=None value=0 kind=pressed, sequence='0'
name=None value=+ kind=pressed, sequence='+'
name=None value=r kind=pressed, sequence='r'
name=KEY_ALT_\ value=\ kind=pressed, sequence='\x1b\\'
name=KEY_ALT_SHIFT_P value=P kind=pressed, sequence='\x1bP'
name=None value=0 kind=pressed, sequence='0'
name=None value=+ kind=pressed, sequence='+'
name=None value=r kind=pressed, sequence='r'
name=KEY_ALT_\ value=\ kind=pressed, sequence='\x1b\\'
In this case, exactly 7 "no data" XTGETTCAP responses are received,
which is XTGETTCAP_INIT_CAPABILITIES: 10 - 7 = 3,
3 = colors, TN, and 'RGB', which do succeed.
We "ungetch()" any data that does not match, to help ensure natural
passthrough of terminal input during Terminal initialization, we fix by
changing only _RE_GETTCAP_RESPONSE for zero or more ``*`` instead of 1
or more ``+`` matcher on the hex sequence that is missing by libvte
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #383 +/- ##
=======================================
Coverage 97.35% 97.35%
=======================================
Files 13 13
Lines 3781 3781
Branches 671 671
=======================================
Hits 3681 3681
Misses 82 82
Partials 18 18 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
jquast
added a commit
to jquast/ttyscan
that referenced
this pull request
May 23, 2026
see jquast/blessed#383 for more details
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.
With GNOME Terminal, some awful leaking of null XTGETTCAP responses are received into the next call to inkey():
In this case, exactly 7 "no data" XTGETTCAP responses are received,
which is XTGETTCAP_INIT_CAPABILITIES: 10 - 7 = 3,
3 = colors, TN, and 'RGB', which do succeed.
ungetch()is done after XTGETTCAP for any data that does not match, to help ensure natural pass-through of terminal input during Terminal initialization, so inkey() gets it but should not.We fix by changing only
_RE_GETTCAP_RESPONSEfor zero or more*instead of 1 or more+matcher on the hex sequence that is missing by libvte, so they are "consumed" but otherwise have no effect