microsoft / terminal

The new Windows Terminal and the original Windows console host, all in the same place!
MIT License
95.51k stars 8.31k forks source link

Mouse selection should begin and end at nearest cell boundary #5099

Open egmontkob opened 4 years ago

egmontkob commented 4 years ago

Description of the new feature/enhancement

For the intuitive highlighting behavior, and consistency with most other applications; when selecting text with the mouse, the two endpoints should be rounded to the nearest vertical boundary between adjacent characters, and highlight/select whatever is between these two points; rather than necessarily including the character the mouse was clicked on / released at.

Note that this is for single click only. For double click, it's the characters under the click location and the release endpoint that should be expanded.

For more details, rationale etc. see for example https://github.com/kovidgoyal/kitty/issues/945.

DHowett-MSFT commented 4 years ago

I set about doing this as part of the outstanding selection refactor, and immediately ran into our selection endpoints not being exclusive on the right. @carlos-zamora, do you remember why this differed from a11y?

carlos-zamora commented 4 years ago

I set about doing this as part of the outstanding selection refactor, and immediately ran into our selection endpoints not being exclusive on the right. @carlos-zamora, do you remember why this differed from a11y?

I worked on selection before I worked on accessibility, so that's why haha. This would be a fun refactor I can do. And further combine the accessibility/selection code since they have so much in common.

vefatica commented 3 years ago

What's the status of this issue? I, also, would like to be able to select a line and get a newline and NOT get the first character of the next line.

DHowett commented 3 years ago

The status of this issue is: Open.

DHowett commented 3 years ago

We have a different issue tracking "the space at the end of the line should be treated as the newline."

vefatica commented 3 years ago

We have a different issue tracking "the space at the end of the line should be treated as the newline."

I'm not often successful when using this forum's search mechanism. How would I search for the above-mentioned issue?

zadjii-msft commented 2 years ago

Notes from https://github.com/microsoft/terminal/issues/11027

2. Another option would be to provide a configuration option to specify the minimum mouse movement (in pixels) before starting automatic copy selection. The default should be larger than is currently implemented - unless there is some issue with compatibility of UI experience. Or maybe it doesn't need to be configurable, just use a better minimum movement. Since it is unlikely that anyone wants to select a single character (or even two?), I think a reasonable default might be 1 character width. Actually anything up to 1 character height (to select a full line, moving down) would probably work.

I think this is kinda like #5099? (#5082 + #5096) made this a lot better, but it's still not perfect. I believe the threshold right now is 25% of the min(width, height) of a glyph.

Thanks for the pointers. I suspect that a fix to #5099 would fix my issue as well (looks like my proposal 1). But perhaps my proposal 2 is even easier to fix, as your comment (and #5096) implies:

the threshold right now is 25% of the min(width, height) of a glyph

I would argue that changing 25% to 100% would work as well for real selections, since that allows for moving from the centre of one glyph to the centre of the next. It could be even more, since one rarely needs to select a single character.

On the other hand any increase in the threshold would reduce the number of spurious selections, so a conservative change might be to increase the threshold to 75%.