-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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
Add support for DECBKM (Backarrow Key Mode) #13894
Conversation
// GH#12799 - If the app requested that we disable focus events, DON'T pass | ||
// that through. ConPTY would _always_ like to know about focus events. | ||
|
||
return !_api.IsConsolePty() || | ||
!_api.IsVtInputEnabled() || | ||
(!enable && mode == TerminalInput::Mode::FocusEvent); | ||
|
||
// Another way of writing the above statement is: | ||
// | ||
// const bool inConpty = _api.IsConsolePty(); | ||
// const bool shouldPassthrough = inConpty && _api.IsVtInputEnabled(); | ||
// const bool disabledFocusEvents = inConpty && (!enable && mode == TerminalInput::Mode::FocusEvent); | ||
// return !shouldPassthrough || disabledFocusEvents; | ||
// | ||
// It's like a "filter" left to right. Due to the early return via | ||
// !IsConsolePty, once you're at the !enable part, IsConsolePty can only be | ||
// true anymore. | ||
return !_api.IsConsolePty() || !_api.IsVtInputEnabled(); |
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.
Note to reviewers, if you didn't read the PR description, the additional check here that was specific to the FocusEvent
mode has now been moved down into the EnableFocusEventMode
method. I think this reduces some of the confusion that was introduced here, and also avoids unnecessary overhead in the other input mode operations.
This is isn't strictly related to DECBKM
mode, though (other than as a minor optimisation), so if you'd prefer not to include this change in the PR, it wouldn't be a problem to revert it.
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.
This makes way more sense. Thanks!
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.
Not a single complaint. Thank you!
// GH#12799 - If the app requested that we disable focus events, DON'T pass | ||
// that through. ConPTY would _always_ like to know about focus events. | ||
|
||
return !_api.IsConsolePty() || | ||
!_api.IsVtInputEnabled() || | ||
(!enable && mode == TerminalInput::Mode::FocusEvent); | ||
|
||
// Another way of writing the above statement is: | ||
// | ||
// const bool inConpty = _api.IsConsolePty(); | ||
// const bool shouldPassthrough = inConpty && _api.IsVtInputEnabled(); | ||
// const bool disabledFocusEvents = inConpty && (!enable && mode == TerminalInput::Mode::FocusEvent); | ||
// return !shouldPassthrough || disabledFocusEvents; | ||
// | ||
// It's like a "filter" left to right. Due to the early return via | ||
// !IsConsolePty, once you're at the !enable part, IsConsolePty can only be | ||
// true anymore. | ||
return !_api.IsConsolePty() || !_api.IsVtInputEnabled(); |
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.
This makes way more sense. Thanks!
Hello @DHowett! Because this pull request has the p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (
|
🎉 Handy links: |
This PR adds support for the
DECBKM
sequence, which provides a way forapplications to specify whether the
Backspace
key should generate aBS
character or aDEL
character.On the original VT100 terminals, the
Backarrow
key generated aBS
,and there was a separate
Delete
key that generatedDEL
. However, onthe VT220 and later, there was only the
Backarrow
key. By default itgenerated
DEL
, but from the VT320 onwards there was an option to makeit generate
BS
, and theDECBKM
sequence provided a way to controlthat behavior programmatically.
On modern terminals, the
Backspace
key serves as the equivalent of theVT
Backarrow
, and typically generatesDEL
, whileCtrl
+Backspace
generates
BS
. WhenDECBKM
is enabled (for those that support it),that behavior is reversed, i.e.
Backspace
generatesBS
andCtrl
+Backspace
generatesDEL
.This PR also gets the other
Backspace
modifiers more closely alignedwith the expected behavior for modern terminals. The
Shift
modifiertypically has no effect, and the
Alt
modifier typically prefixes thegenerated sequence with an
ESC
character.While not strictly related to
DECBKM
, I noticed while testing that the_SetInputMode
method was doing unnecessary work that was specific tothe
FocusEvent
mode. I've now moved that additional processing intothe
EnableFocusEventMode
method, which I think makes things somewhatsimpler.
Validation Steps Performed
I've tested the basic
DECBKM
functionality in Vttest, and I'vemanually tested all the modifier key combinations to make sure they
match what most modern terminals generate.
I've also added a unit test that confirms that the expected sequences
are generated correctly when the
DECBKM
mode is toggled.Closes #13884