-
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
7395: do not clear text selection upon PrintScreen #7883
7395: do not clear text selection upon PrintScreen #7883
Conversation
After looking for several hours at the area I believe that this one is merely a patch, and the area requires some sort of refactor. For instance, the media buttons remove the selection as well - in addition to scrolling to the bottom (as reported in #5366). In #5366, @DHowett-MSFT mentioned that to prevent the scrolling behavior we need to run it only upon input. The same should probably apply to clearing text selection as well (besides few cases, like vk_escape, where we will want to clear the selection, even without passing a sequence to connection). I would like to work on the refactor that will probably cleanup the behavior for Terminal updates (e.g., scrolling to bottom, clearing selection) upon different kinds of events (e.g., clipboard, key), but I would like to align on the vision beforehands. Currently the logic is somewhat scattered between the Terminal and TermControl, e.g.:
My suggestion is:
E.g., upon key event:
WDYT? |
I'd caution you against too extensive of refactoring that moves logic into TermControl today. Not because I don't think it's the right thing to do, but because there's actually two TermControls (the one in WpfTerminalControl and the one that's used in Cascadia/Terminal.)[1] @lhecker and @zadjii-msft have worked extensively in this area and can give more correct or fine-grained guidance. 😄 [1]: I have a workitem in the backlog that suggests we should unify the interactivity layer (mouse, keyboard input, translation of pixel positions to coordinates, etc.) between the two and make it shared logic; this would likely live in TerminalCore or in another type that consumes TerminalCore. |
@DHowett - thanks for the reply! I must admit I am too new in the project to understand the implications of the suggested refactoring on WpfTerminalControl. I will learn 😄 Regarding this PR, I suggest to consider it as a short term mitigation for clearing text selection upon Print Screen (which is painful). In parallel, I have created a separate PR (#7896), that hopefully addresses this and #5366 by delaying the decision on scrolling / clearing selection until the input is sent to TermControl. |
@Don-Vito In my personal opinion the entire input handling should be abstracted out of the two If it was hoisted out of those, we could make them behave like a pipe of sorts: You put key and character events into the front and you get VT strings out of the end / returned from the pipe invocation. Each area of concern (filtering, buffering, ...) could be a seperate class, all of which share a common, abstract interface. The pipe could be constructed by simply concatenating the list of filters, mappers, etc. Since those classes are small we could theoretically also develop them one by one and integrate them directly into the existing code without constructing a "pipe". We could then also construct accurate unit tests for each class. E.g. we could ensure that a hypothetical Alternatively we could also just keep the entire logic within a single class (i.e. merge the 4 classes listed above). |
@lhecker - what you say make perfect sense to me, and I would glad to collaborate (not sure I can raise it alone still).
@lhecker - if it something you are planning to work, I will be glad to assist. By now I am just putting this PR to Review, so at least we mitigate the PrintScreen issue for now 😄 |
Alright so I'm gonna approve this PR now, but highly caution against more broad refactorings for the input in
If we were to abstract that into a class sitting between |
@Don-Vito The C++20 ranges library would be a good fit, stylistically at least, for many things in this project, as far as I can see it. Unfortunately - as far as I know - it suffers from a very poor compilation performance. As such creating an orchestrator sounds like the perfect solution to me. Apart from the general idea / intention of abstracting the input handling away, I haven't really thought about this any further yet.
I believe doing this involves a lot of small PRs, each of which abstracts away one aray of concern in the current |
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.
Thanks for doing this
🎉 Handy links: |
🎉 Handy links: |
Summary of the Pull Request
When handling SendKey, preserve selection upon PrintScreen (VK_SNAPSHOT)
References
PR Checklist
Detailed Description of the Pull Request / Additional comments
The explicitly ignores the VK_SNAPSHOT. Probably, additional keys should not alter the selection.
Validation Steps Performed