deadpixi / sam

An updated version of the sam text editor.
Other
430 stars 46 forks source link

more precise selections for an I-beam cursor #82

Closed andygoblins closed 6 years ago

andygoblins commented 6 years ago

Earlier versions of sam always used an arrow-like cursor for selecting text, because the hitbox for selection was based on whole runes; click on a rune with the arrow to place the selection caret (set the dot) to the left of that rune.

Starting with 5b68048, this version uses an I-beam cursor, but retains the old hitbox model. This patch alters the hitbox by shifting it over 50%. This makes it easier to click between runes to place the caret; click between two runes to place the selection caret. If you miss and click on a rune, the selection will go to the side of the rune closest to your click point.

As a side effect, the hitbox for the leftmost rune is a little smaller now, but this is offset by the fact that clicking on the margin space by the scrollbar will place the caret as expected. I think the benefits of this patch (make clicking work like it does in other modern text editors) outweighs this side effect.

Tested with mono and proportional fonts.

deadpixi commented 6 years ago

Beautiful, thanks @andygoblins