-
Notifications
You must be signed in to change notification settings - Fork 695
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
Fixes #3516. Changes default QuitKey
to Esc
#3555
Conversation
There is something strange when clicking a button in a Dialog. Try opening the |
Do you think this has something to do with this PR? Does this reproduce on v2_develop. I'm not a computer to check. |
Yes it reproduce on v2_develop branch and so has nothing with this PR. |
I have a question. What happens when an escape literal is received on stdin? Quit, by default? Because I ran into stuff today that has drastically altered my stance, if that's the proposed change to default behavior, which I'm glad to share if that is, in fact, what it is. |
If only an escape is received it will Quit, otherwise the ANSI escape sequence will be processed if the terminal supports it, otherwise it will be echoed as text. |
OK. That I think mostly jives with expectations. I think it would be good to include some tests for it that do some things such as redirecting stdin and writing esc to it, to test/prove at least that particular case. Most other ways of testing scenarios and environments that I thought up aren't really things that can be done in that unit test project, but that one is simple and good enough for a basic case that should cover at least some of them, I think. Here were scenarios I thought up last night (food for thought, maybe, but not hard suggestions really):
And if you've already got that covered by your planned implementation, awesome! 🥳 |
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.
Just a quick scan taken over the changes to the Terminal.Gui code.
Didn't do in-depth analysis yet and didn't bother with the tests or samples either.
Nothing critical popped out at me anyway on scan.
Only things that prompted any questions were a nullable bool return and a hidden method. But both are pretty minor.
Oh, and some empty XmlDoc elements.
@@ -631,7 +631,7 @@ private void UpdateKeyBinding () | |||
/// - if the user presses the HotKey specified by CommandView | |||
/// - if HasFocus and the user presses Space or Enter (or any other key bound to Command.Accept). | |||
/// </summary> | |||
protected new bool? OnAccept (CommandContext ctx) | |||
protected bool? OnAccept (CommandContext ctx) |
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.
Is the nullable necessary here?
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.
I think so.
Part of the design of Command/KeyBinding is described here. For this, I believe we need to support propogating "don't know/yes/no" up and down the stack. OnAccept is right in the middle of all this.
Terminal.Gui/Terminal.Gui/View/ViewKeyboard.cs
Lines 653 to 658 in fd683d8
// * If no key binding was found, `InvokeKeyBindings` returns `null`. | |
// Continue passing the event (return `false` from `OnInvokeKeyBindings`). | |
// * If key bindings were found, but none handled the key (all `Command`s returned `false`), | |
// `InvokeKeyBindings` returns `false`. Continue passing the event (return `false` from `OnInvokeKeyBindings`).. | |
// * If key bindings were found, and any handled the key (at least one `Command` returned `true`), | |
// `InvokeKeyBindings` returns `true`. Continue passing the event (return `false` from `OnInvokeKeyBindings`). |
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.
Works for me.
An opportunity for a small future optimization is there, but it's fairly minor.
I also have been starting to think more about accessibility modifiers, as we get closer to completion. This one, being a kinda non-standard handler, because of not being void, might be a candidate for private protected
instead of just protected
.
The resulting visibility is the intersection of protected and internal, so it's visible to derived types in the same assembly only.
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.
That also lets it continue to do what it needs to do, without having to worry about it being overridden outside of the library.
Fixes
Appliation.QuitKey
toEsc
fromCtrl-Q
#3516Proposed Changes/Todos
Esc
Pull Request checklist:
CTRL-K-D
to automatically reformat your files before committing.dotnet test
before commit///
style comments)