neovide icon indicating copy to clipboard operation
neovide copied to clipboard

Handle different underlining styles supported by neovim

Open calops opened this issue 3 years ago • 2 comments

What kind of change does this PR introduce?

  • Feature
  • Fixes #764

Did this PR introduce a breaking change?

  • No

Content

This overhauls the drawing of underlines and actually implements the undercurl that was simulated with underdashes before.

Implemented in this PR:

  • underline underline

  • underdouble underdouble

  • underdashed underdashed

  • underdotted underdotted

  • undercurl undercurl

Points to note

  • Previously the underline thickness was proportional to the stroke width. This led to weird aliasing artifacts when drawing lines (especially dashes and dots) and isn't in line with how most other terminal emulators handle this. With this PR, all the lines are pixel-perfect and 1px thick. If desired, it'll be easy to add a configuration option to make it possible to configure the line thickness, but I don't recommend making it proportional to the text itself.
  • The undercurl looks (in my opinion) nice, but I don't really know what I'm doing here. I'm using quadratic interpolation from skia by generating points under the text every time. I haven't noticed any hangups, but I'm sure there's a better optimized way to do this if it becomes an issue.
  • I'm not sure if there should be an order of precedence between the different line styles (cf the TODO left in the code for now). I'm inclined to say we leave it like that, as I don't think multiple underline styles can happen at the same time in neovim (don't quote me on this though).
  • Maybe the gap between the dots for underdotted should be widened? I'm worried it'll look like a thin solid line on high-dpi screens.

calops avatar Aug 08 '22 19:08 calops

By the way, how did you even manage to set the "invalid" modifier names? :hi! Normal gui=underdouble results into neovim yelling at me with "invalid value".

The latest neovim versions have aligned with vim's names. Therefore, underlineline became underdouble, for example. Maybe for stability we should handle both versions of the names?

calops avatar Aug 09 '22 14:08 calops

Yeah, this is fair. In this case you should be able to just match both patterns using the | operator.

MultisampledNight avatar Aug 09 '22 14:08 MultisampledNight

(also, small sidenote since formatting seems to be quite your nemesis: check out :h g:rustfmt_autosave, which will format the file automatically upon writing in neovim)

MultisampledNight avatar Aug 12 '22 21:08 MultisampledNight

Alright. Truly, thank you! I'll merge this now.

MultisampledNight avatar Aug 13 '22 18:08 MultisampledNight