-
Notifications
You must be signed in to change notification settings - Fork 826
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
Include the ANSI escape sequence that caused the instantiation of an events.Key
in the events.Key
class
#2347
Comments
Not opposed to it. But there isn't a one to one mapping of key events to escape sequences. Might complicate things. When you say terminal widget, do you mean a terminal widget that runs inside Textual ? |
Yes but what I was suggesting is that you don't discard the initial information on the escape sequence instead of reconstructing it. This way the sequence should be correct for the specific terminal in use as that terminal sent it in the first place.
Yes, using pyte. I'm aware there's already a similar 3rd-party widget but it's GPL3 so I cannot use it (or look at its code!). For now I'm just converting key strokes in a naive way. For instance, if I get an |
I don't think this is practical, given the somewhat inconsistent ways terminals deal with keys. |
Don't forget to star the repository! Follow @textualizeio for Textual updates. |
From what I can see in
src/textual/_xterm_parser.py
andsrc/textual/_ansi_sequences.py
, ANSI escape sequences get parsed and generate instances ofevents.Key
as needed.My terminal widget needs to generate ANSI escape sequences back from key events but this is non-trivial if you want to support different terminals. This could be easier if
events.Key
had an optional field containing the original ANSI escape sequence.The text was updated successfully, but these errors were encountered: