Skip to content
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

Improve the method via which unsupported sequences are ignored #3800

Merged
merged 13 commits into from
Jan 8, 2024

Conversation

davep
Copy link
Contributor

@davep davep commented Dec 4, 2023

This PR extends the current support for ignoring unsupported sequences. Until now a sequence could map to Keys.Ignore but this would result in an actual, bindable, <ignore> key event being raised. Here we make the ignoring of the sequence silent, but also ensure that it gets logged to keys.log if the key sequence parser logging is enabled.

Additionally, the PR makes a start on working through the known unhandled sequences list, either adding more aliasing for keys, or making use of the above change to ignore certain sequences altogether. In conjunction with this I've extended the code that produces the unknown sequences table so that it shows which sequences have been taken care of, and which PR took care of them. This makes it easier to keep track of what is and isn't done, and also provides a paper trail of how and why a sequence was ignored.

But when we do so, ensure that we log what sequence was ignored if the key
driver logging is enabled.

The core requirement for Textualize#3742.
@davep davep added enhancement New feature or request Task labels Dec 4, 2023
@davep davep self-assigned this Dec 4, 2023
davep added 7 commits December 4, 2023 13:36
And by "proper ignore section" I simply mean: have the sequences we want to
ignore all gathered together in a really obvious location, and with some
sort of explanation.
This brings them more in line with other terminals I've tested.
Most (all?) other terminals on macOS do this anyway.
@davep davep marked this pull request as ready for review December 4, 2023 15:58
Rather than use the pre-existing convention of a tuple that contains
Keys.Ignore, which *could* imply that a sequence maps to a set of keys that
happens to include Key.Ignore, but isn't exclusive to just that, here we
swap over to using a single special value for an ignored sequence.
@davep davep requested a review from willmcgugan December 7, 2023 15:31
src/textual/_ansi_sequences.py Outdated Show resolved Hide resolved
@davep davep requested a review from willmcgugan January 2, 2024 09:44
@willmcgugan willmcgugan merged commit 5cd5aa9 into Textualize:main Jan 8, 2024
20 checks passed
@davep davep deleted the sequence-black-hole branch January 8, 2024 10:28
willmcgugan pushed a commit that referenced this pull request Jan 11, 2024
* Make ignoring keys a silent operation

But when we do so, ensure that we log what sequence was ignored if the key
driver logging is enabled.

The core requirement for #3742.

* Start a proper ignore section in the dictionary of sequences

And by "proper ignore section" I simply mean: have the sequences we want to
ignore all gathered together in a really obvious location, and with some
sort of explanation.

* Simplify opt+§ in WezTerm on macOS

* Improve the wezterm opt mappings

This brings them more in line with other terminals I've tested.

* Tidy up the explanation for the WezTerm mappings

* Ignore various ctrl-cmd- sequences from kitty

* Fix a couple of incorrectly-copied sequences

* Transform Ctrl+§ into 0 under kitty

Most (all?) other terminals on macOS do this anyway.

* Tweak some wording

* Add Shift-F11 and Shift-F12 for rxvt

* Switch to using a special value for ignored sequences

Rather than use the pre-existing convention of a tuple that contains
Keys.Ignore, which *could* imply that a sequence maps to a set of keys that
happens to include Key.Ignore, but isn't exclusive to just that, here we
swap over to using a single special value for an ignored sequence.

* Swap to using a value as a flag, not a type

#3800 (review)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Task
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Extend the keyboard escape sequence handling code to have a "we don't handle this" registry
2 participants