Selection rewrite
I'd like to pretty much rewrite the mouse selection code. IMHO it's way too complicated and hard to read.
More importantly, in its current form it's not BiDi-ready, and a clean rewrite seems to be way more feasible for me than patching it around.
One major issue is: It stores which vertical boundary between cells is the closest to the click's location. The BiDi algorithm results in a mapping between locical and visual character positions, but does not (cannot) define a mapping for the boundaries. Hence with BiDi in the game, instead of boundaries, we'll need to track on which character the click happened, plus whether it happened on its left or right half. In uni-directional text this will eventually resolve to the current user facing behavior: clicking on nth char's right side is always the same as (n+1)st char's left side. With BiDi, at the boundary of opposite directionality characters, this is no longer the case.
Other aspects of the code, such as where the mouse click and release coordinates are potentially swapped to become logical start and end coordinates aren't fortunate either and should be cleaned up.
Current features that are important to keep:
- Character selection (single click)
- Word selection (double click)
- Paragraph selection (triple click)
- Rectangular selection (Ctrl + click)
- Continuing a previous selection (Shift + click)
- Drag threshold for character selection
- Remove selection if contents inside change
Anything that I missed?
Planned improvements:
- Change Shift + click so that when the mouse is inside the selection then move the closer boundary of the selection, rather than wiping it out entirely (both normal and rectangular selection).
- Change Shift + click outside of the current selection in rectangular mode to move the closest corner rather than the one that was originally the moving one.
- Remove the 1/3rd cell handling (#31 (closed))
- Select CJK based on whether the mouse selection contains the middle of the double width character, rather than the middle of its first cell as it's done now.
- Remembering mouse clicks with half cell granularity will address bug 756058.
- Clean up an off-by-one throughout the code (currently -1 denotes the position before the first character, 0 is the position between the first and second character in a row and so on).
- Address bug 724253 "Selection regression at end of line".
This one is meant to be a tracking bug for the architectural preparation for BiDi, but without actual BiDi support yet.