neovim-gtk
neovim-gtk copied to clipboard
Draw undercurls in addition to underdots
For reasons as laid out in #14, I understand why underdots are being rendered currently, but as mentioned in that issue it would be nice to be able to render undercurls again instead.
It would be nice to be able to subscribe to a tracking issue for that, so I wanted to open this.
Thanks!
Reviewing other GTK4 apps (GNOME's Text-Editor and Builder), when underlining spelling mistakes, the GTK4 decoration is a dotted line. It seems de default has changed from curly line to a dotted one.
Some remarks, the dotted underline on either of the GTK4 applications mentioned here are significantly thinner than the dotted underline in Neovim-gtk, for the same font size (tested with Iosevka Curly Slab 8.4pts).
@jacobmischka, perhaps a good compromise would be to have a flag or setting to re-enable the undercurl instead of a dotted underline, but it looks to me like the new behavior is the GTK4 default.
Reviewing other GTK4 apps (GNOME's Text-Editor and Builder), when underlining spelling mistakes, the GTK4 decoration is a dotted line. It seems de default has changed from curly line to a dotted one.
Some remarks, the dotted underline on either of the GTK4 applications mentioned here are significantly thinner than the dotted underline in Neovim-gtk, for the same font size (tested with Iosevka Curly Slab 8.4pts).
Yeah - I didn't take the time to dig through GTK4's rendering code to actually figure out what exactly they're doing with the font metrics to determine the undercurl size. I'm totally happy to accept patches to fix this
@jacobmischka, perhaps a good compromise would be to have a flag or setting to re-enable the undercurl instead of a dotted underline, but it looks to me like the new behavior is the GTK4 default.
I think we still want to support both actually, it's less about GTK4's decision and the fact that nvim does actually have two formatting options for both undercurl
and underdotted
(they're mentioned in :help ui-event-hl_attr_define
). Ideally, I'd like to move undercurl
back to something like what we had before - and then use underdotting for the actual underdotted
effect. This does have the limitation that we won't be able to do this effect in situations where we're using native GTK4 widgets to display text (like documentation in the PopupMenu overlay), but that's a small enough detail I'm willing to sacrifice (maybe I could submit patches to GTK4's PangoRenderer
to add an additional undercurl mode someday while maintaining underdot default to fix that, if I ever get the motivation to).
Ok cool, so I took a look at this again today and it seems like I actually got almost everything right after the initial 4.6+ fix. Seems like the only two things I was missing:
- The diameter of the circles should be equal to
underline_thickness
- We should round the
y
coordinate we start on to the nearest integer, so that at smaller sizes the dots still look perfectly consistent and don't end up with a different color as a result of fractional coordinates.
This gives us something that imho, looks far nicer and more legible:
Ironically, because I still didn't dig any further in GTK4's method for drawing underdots I think I actually came up with something that looks a bit nicer then GTK4's defaults (or at least, it certainly looks better then the underdots I see in gtk 4.6's inspector. Maybe 4.8+ look better though?). So I think I'm going to go with this, and look into whether the gtk folks would be interested in me porting this to GTK4 so everyone can have nice underdots.