-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Keyboard Selection Spec #2840
Keyboard Selection Spec #2840
Conversation
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 have mostly thought experiment questions
When can we expect this PR to be merged? This is almost the last thing stopping me from using Terminal over ConEmu. |
@carlos-zamora With #3391 about to merge, I'd want to see those changes reflected in this PR if possible :) |
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.
A couple new questions. I want to see the things about tmux-style mark mode, and bindings for the conhost-style mark mode, but overall looks good.
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.
Consider this approving the non mark-mode parts of this spec. The holdSelectionAnchor
comment confuses me, could you elaborate on that?
This is a bit annoying but I feel like Mark Mode is just big/confusing enough that it deserves its own space. So please check out #5804 if you want to have a closer discussion there. That also means that the spec in its current state better fits #3758. So if you want to use the current implementation of this feature, you can build that branch. Lingering question(s) that I have for anybody that comes along to review this:
|
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'm definitely okay with everything in the spec here. I don't think we need to necessarily wait on #5804 to be approved to be able to merge this into master IMO. I think what's here is much more generally acceptable, and we'll have a LOT more discussion on the other thread, so let's not hold this one up
Heck let's just merge this. #10824 is like close enough to what's laid out here and I'm not sure we need to really discuss more. |
nomenclature changed: - anchor --> endpoint - moveSelectionPoint --> updateSelection - expandBy --> mode - cell --> char - SelectionExpansionMode --> SelectionExpansion - Direction --> SelectionDirection
Discussed offline with @DHowett:
|
Which ones? Would the defaults eventually still satisfy this use case? #6528 I'm just trying to figure when I can finally switch! |
@ofek The idea is to remove the terminal/doc/specs/Keyboard-Selection.md Lines 91 to 109 in 9a5c2d2
Hoping to fix up the spec and that other PR this week! 🙂 |
This comment has been minimized.
This comment has been minimized.
@DHowett We've discussed this like 80 times in team syncs since the first block - I'm 🤏 close to dismissing you since we've got a verbal approve |
Alright, I'm dismissing @DHowett's review. We've talked about it in person a few times this past week, and the implementation includes those changes. We're having an internal bug bash soon and we still have some time before release, so we'll use that time to polish this feature if anything comes up. |
Discussed in person. We'll iterate on this if more changes are needed.
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.
Great spec! Just a couple concerns.
I feel like we are missing some discussion about swapping the active selection endpoint, though I may have missed it(?); I would hope that it would cover what happens when the two endpoints are more than one screen apart (so, swapping would require jumping up and down).
Call out a future concern around how keyboard selection may be slower than mouse selection and we will need to consider how to handle a text buffer that is changing while the user is selecting it. What if the top endpoint circles out of the buffer before the user locks the selection?
How does it interact with VT mouse mode (right now it is an impediment to starting a selection(!)) which also uses shift as a modifier?
It may not be sufficient to say “keyboard selection is more accessible”; there are probably accessibility APIs we can plug into so folks don’t have to discover that they can use shift+arrows to move around.
I would suggest having key events (vkey, scancode, modifiers) go directly into ControlInteractivity and not have TermControl use _core.TryXxx
(Sorry, you may have already done this). A clearer delineation in Interactivity about what we are capturing to handle “as part of a terminal control” versus what we are giving the core to process as a terminal-encoded output event would be helpful.
We never expect crashes… but you may want to mention the test collateral you’re going to write for this!
Sorry to block you again! We are in the home stretch, however.
Implements the following keyboard selection non-configurable key bindings: - shift+arrow --> move endpoint by character - ctrl+shift+left/right --> move endpoint by word - shift+home/end --> move to beginning/end of line - ctrl+shift+home/end --> move to beginning/end of buffer This was purposefully done in the ControlCore layer to make keyboard selection an innate part of how the terminal functions (aka a shared component across terminal consumers). ## References #715 - Keyboard Selection #2840 - Spec ## Detailed Description of the Pull Request / Additional comment The most relevant section is `TerminalSelection.cpp`, where we define how each movement operates. It's basically a giant embedded switch-case statement. We leverage a lot of the work done in a11y to perform the movements. ## Validation Steps Performed - General cases: - test all of the key bindings added - Corner cases: - `char`: wide glyph support - `word`: move towards, away, and across the selection pivot - automatically scroll viewport - ESC (and other key combos) are still clearing the selection properly
I'll cover that in #5804. It'll fit better over there as a wholistic story of "how do we create a selection", whereas this one is more just "how do we update one we created with the mouse". It could honestly go in either but this spec is intended to cover the basics, and that's more of an advanced concept imo. EDIT: oh, it's already there haha
I don't actually think it'll be slower than mouse selection (or even slower enough to matter tbh). Mouse selection already relies on the same function calls on the text buffer:
The only difference I can think for mouse selection is that we convert the viewport position to a buffer position. Am I missing something here?
Isn't this something we already have to worry about (and handle) with mouse selection? I guess the only addition would be "if both endpoints moved off the buffer when the buffer circled, we need to ensure
I'm confused by your comments here. When in VT Mouse Mode, shift+click creates a selection. The bindings covered in this spec are used to alter the selection that was created. We're handling these key bindings exactly like we handle ESC when a selection is present (in any context): we alter the selection if one is present, otherwise we send the event to the app.
The UIA APIs are already implemented, so yes, it's up to the screen reader to expose that. That's out of our control. However, having a more direct in-house solution is always preferable. We're bridging the gap between different experiences based on the user, and creating a consistent experience for all of our users. As for discoverability, shift+arrows are already standard in Conhost. Windows users are pretty familiar with that experience. I guess this might be an issue for users who come from a different environment, but even text editors are consistent in having shift+arrows be how you select text.
Isn't that out of scope for the spec? Like, can't you say that about just about any feature that gets specced? |
🎉🎉🎉 |
## Summary of the Pull Request This introduces a selection marker overlay that tells the user which endpoint is currently being moved by the keyboard. The selection markers are respect font size changes and `cursor` color. ## References #715 - Keyboard Selection #2840 - Keyboard Selection Spec #5804 - Mark Mode Spec ## Detailed Description of the Pull Request / Additional comments - `TermControl` layer: - Use a canvas (similar to the one used for hyperlinks) to be able to draw the selection markers. - If we are notified that the selection changed, update the selection markers appropriately. - `UpdateSelectionMarkersEventArgs` lets us distinguish between mouse and keyboard selections. `ClearMarkers` is set to true in the following cases... 1. Mouse selection, via SetEndSelectionPoint 2. `LeftClickOnTerminal`, pretty self-explanatory 3. a selection created from searching for text - `ControlCore` layer: - Responsible for notifying `TermControl` to update the selection markers when a selection has changed. - Transfers info (the selection endpoint positions and which endpoint we're moving) from the terminal core to the term control. - `TerminalCore` layer: - Provides the viewport position of the selection endpoints. ## Validation Steps Performed - mouse selection (w/ and w/out shift) --> no markers - keyboard selection --> markers - markers update appropriately when we pivot the selection - markers scroll when you hit a boundary - markers take the color of the cursor color setting - markers are resized when the font size changes
## Summary of the Pull Request This is a spec specifically dedicated to Mark Mode. It's an addition to the Keyboard Selection spec. I felt that it makes the most sense to make this a separate PR because there's a lot of ideas that are very specific to Mark Mode, and this gives us the space to modify some of that behavior and get a good look at how other terminal emulators designed this feature. ## References #2840 - Keyboard Selection Spec (base spec/branch/PR) ## PR Checklist * [X] Contributes to #715
Summary of the Pull Request
This introduces a spec for keyboard selection. This enables the user to create and update a selection without the use of a mouse or stylus.
References
Contributes to #715
Validation Steps Performed
N/A