question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Curly and colored underlines

See original GitHub issue

This is originally a feature of Kitty, now also adopted by VTE (GNOME Terminal and friends). Technically two separate features, but they mostly make sense together, e.g. for spell checking.

Apparently vim and neovim have already / are about to support these, see e.g. vim undercurl, vim color, neovim.


The new SGR 4:3 (\e[4:3m) attribute, strictly with a colon as separator, was introduced to start a curly underline.

In the mean time, 4:0, 4:1 and 4:2 were also added as aliases for the standard 24 (turn off all kinds of underlining), 4 (single underline) and 21 (double underline), respectively.

At some point in the future, probably 4:4 and 4:5 could also stand for dotted and dashed underlines in some order (these are the five types of underlining supported by HTML/CSS).


The new SGR 58 and 59 sequences specify the color of the underline, following the pattern of 38 and 39. That is, 58;5;idx for an entry of the 256-color palette, or 58;2;r;g;b for direct RGB. There’s no shortcut notation for the first 16 entries (corresponding to SGR 30-37 and 90-97), use the 256-color mode with indices of 0-15 instead.

59 reverts to the default, that is, the underline’s color auto-following the text color.

In case you’re short of bits, I believe it’s okay to drop some precision, e.g. store only 4 bits per color channel. We were also considering this in the VTE bug.

Update: In VTE we ended up approximating the truecolor underline to 4+5+4 bits (R, G, B respectively). This means: 8+8+8+1 = 25 bits for foreground (in addition to truecolor, we have to be able to denote palette and default values too). Same for background. 4+5+4+1 = 14 bits for underline (again, an extra bit to denote palette and default values). That’s a total of 64 bits for the colors, stored in an int64 (bold, italic etc. are additional bits are next to this in another variable). With multiplication instead of bitpacking, it could have been 5+5+5 bits for the underline. Of couse it’s not a necessity to put all the color and no other attributes in the same integer, we just decided it’s nice this way (and results in some performance improvement).

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:5
  • Comments:22 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
jerchcommented, Mar 9, 2020

Early self-drawing approach with DOM renderer:

grafik

The underline is actually a 3px high background image on the line, thus text will print on top. It seems easier to get complex underlines working with this approach, will see.

1reaction
egmontkobcommented, Apr 16, 2018

(As per https://github.com/kovidgoyal/kitty/issues/226#issuecomment-381665023, mintty decided that 4:4 is dotted underline, and 4:5 is dashed.)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Curly and colored underlines (#6382) · Issues - iterm2 - GitLab
Sorry to bump an old post, but I just got coloured undercurls working in Neovim under Gnome Terminal and it is so so...
Read more >
387811 – Curly and colored underlines - KDE Bugs
The new SGR 4:3 (\e[4:3m) attribute, strictly with a colon as separator, was introduced to start a curly underline. In the mean time,...
Read more >
Colored and styled underlines - kitty - Kovid Goyal
kitty supports colored and styled (wavy) underlines. This is of particular use in terminal based text editors such as vim and emacs to...
Read more >
1157 Curly Underline Images, Stock Photos & Vectors
Find Curly Underline stock images in HD and millions of other royalty-free stock photos, ... Handdrawn colored pen marker design sketch elements set....
Read more >
Has anyone figured out how to get curly or colored underlines ...
For me right now, my underlines are always flat and take the color of the token that is underlined. 3.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found