summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdriĆ  Arrufat <adria.arrufat@outlook.com>2024-08-04 20:55:21 +0900
committerAdriĆ  Arrufat <adria.arrufat@outlook.com>2024-08-04 20:55:21 +0900
commit2ab35fbb23baad69792d4cf45a3af83e2227c5af (patch)
treec2aa0fbd991a451f7d3efe768e9cdf7968f75f27
parent10ed78fe8a580b3558348746ee53f81c5b0aeae1 (diff)
Add support for double underline
-rw-r--r--doc/json_ui.asciidoc2
-rw-r--r--doc/pages/changelog.asciidoc1
-rw-r--r--doc/pages/faces.asciidoc3
-rw-r--r--src/commands.cc5
-rw-r--r--src/face.hh27
-rw-r--r--src/face_registry.cc2
-rw-r--r--src/json_ui.cc1
-rw-r--r--src/terminal_ui.cc2
8 files changed, 26 insertions, 17 deletions
diff --git a/doc/json_ui.asciidoc b/doc/json_ui.asciidoc
index 0fc0378b..63c5f325 100644
--- a/doc/json_ui.asciidoc
+++ b/doc/json_ui.asciidoc
@@ -15,7 +15,7 @@ Kakoune won't be able to parse named parameters in requests.
Here are the data structures used:
* Color: a string, either a named color, or #rrggbb, or 'default'
-* Attribute: one of {underline, reverse, blink, bold, dim, italic, final_fg, final_bg, final_attr}
+* Attribute: one of {underline, curly_underline, double_underline, reverse, blink, bold, dim, italic, final_fg, final_bg, final_attr}
* Face { Color fg; Color bg; Array<Attribute> attributes; }
* Atom { Face face; String contents; }
* Line : Array of Atom
diff --git a/doc/pages/changelog.asciidoc b/doc/pages/changelog.asciidoc
index a553433a..3a6804e5 100644
--- a/doc/pages/changelog.asciidoc
+++ b/doc/pages/changelog.asciidoc
@@ -6,6 +6,7 @@ released versions.
== Development version
* Expose env vars that are mentionned in the arguments passed to shell expansions
+* Support for colored double underlines
== Kakoune 2024.05.18
diff --git a/doc/pages/faces.asciidoc b/doc/pages/faces.asciidoc
index b7c6ad44..1b9ef468 100644
--- a/doc/pages/faces.asciidoc
+++ b/doc/pages/faces.asciidoc
@@ -33,6 +33,9 @@ attributes::
*c*:::
curly underline
Note: This takes precedence over underline if both are specified.
+ *U*:::
+ double underline
+ Note: This takes precedence over underline and curly underline if also specified.
*r*:::
reverse
*b*:::
diff --git a/src/commands.cc b/src/commands.cc
index d22c0647..e4a41ead 100644
--- a/src/commands.cc
+++ b/src/commands.cc
@@ -2482,8 +2482,9 @@ const CommandDesc set_face_cmd = {
" <fg color>[,<bg color>[,<underline color>]][+<attributes>][@<base>]\n"
"colors are either a color name, rgb:######, or rgba:######## values.\n"
"attributes is a combination of:\n"
- " u: underline, c: curly underline, i: italic, b: bold,\n"
- " r: reverse, s: strikethrough, B: blink, d: dim,\n"
+ " u: underline, c: curly underline, U: double underline,\n"
+ " i: italic, b: bold, r: reverse,\n"
+ " s: strikethrough, B: blink, d: dim,\n"
" f: final foreground, g: final background,\n"
" a: final attributes, F: same as +fga\n"
"facespec can as well just be the name of another face.\n"
diff --git a/src/face.hh b/src/face.hh
index 1ed986ef..7e887705 100644
--- a/src/face.hh
+++ b/src/face.hh
@@ -9,19 +9,20 @@ namespace Kakoune
enum class Attribute : int
{
- Normal = 0,
- Underline = 1 << 1,
- CurlyUnderline = 1 << 2,
- Reverse = 1 << 3,
- Blink = 1 << 4,
- Bold = 1 << 5,
- Dim = 1 << 6,
- Italic = 1 << 7,
- Strikethrough = 1 << 8,
- FinalFg = 1 << 9,
- FinalBg = 1 << 10,
- FinalAttr = 1 << 11,
- Final = FinalFg | FinalBg | FinalAttr
+ Normal = 0,
+ Underline = 1 << 1,
+ CurlyUnderline = 1 << 2,
+ DoubleUnderline = 1 << 3,
+ Reverse = 1 << 4,
+ Blink = 1 << 5,
+ Bold = 1 << 6,
+ Dim = 1 << 7,
+ Italic = 1 << 8,
+ Strikethrough = 1 << 9,
+ FinalFg = 1 << 10,
+ FinalBg = 1 << 11,
+ FinalAttr = 1 << 12,
+ Final = FinalFg | FinalBg | FinalAttr
};
constexpr bool with_bit_ops(Meta::Type<Attribute>) { return true; }
diff --git a/src/face_registry.cc b/src/face_registry.cc
index d6c5cd53..ebb71986 100644
--- a/src/face_registry.cc
+++ b/src/face_registry.cc
@@ -50,6 +50,7 @@ FaceSpec parse_face(StringView facedesc)
{
case 'u': face.attributes |= Attribute::Underline; break;
case 'c': face.attributes |= Attribute::CurlyUnderline; break;
+ case 'U': face.attributes |= Attribute::DoubleUnderline; break;
case 'r': face.attributes |= Attribute::Reverse; break;
case 'b': face.attributes |= Attribute::Bold; break;
case 'B': face.attributes |= Attribute::Blink; break;
@@ -78,6 +79,7 @@ String to_string(Attribute attributes)
attrs[] {
{ Attribute::Underline, "u" },
{ Attribute::CurlyUnderline, "c" },
+ { Attribute::DoubleUnderline, "U" },
{ Attribute::Reverse, "r" },
{ Attribute::Blink, "B" },
{ Attribute::Bold, "b" },
diff --git a/src/json_ui.cc b/src/json_ui.cc
index 01768897..66674cf7 100644
--- a/src/json_ui.cc
+++ b/src/json_ui.cc
@@ -39,6 +39,7 @@ String to_json(Attribute attributes)
attrs[] {
{ Attribute::Underline, "underline" },
{ Attribute::CurlyUnderline, "curly_underline" },
+ { Attribute::DoubleUnderline, "double_underline" },
{ Attribute::Reverse, "reverse" },
{ Attribute::Blink, "blink" },
{ Attribute::Bold, "bold" },
diff --git a/src/terminal_ui.cc b/src/terminal_ui.cc
index 33574e90..912dfb57 100644
--- a/src/terminal_ui.cc
+++ b/src/terminal_ui.cc
@@ -224,7 +224,7 @@ void TerminalUI::Screen::set_face(const Face& face, Writer& writer)
static constexpr int fg_table[]{ 39, 30, 31, 32, 33, 34, 35, 36, 37, 90, 91, 92, 93, 94, 95, 96, 97 };
static constexpr int bg_table[]{ 49, 40, 41, 42, 43, 44, 45, 46, 47, 100, 101, 102, 103, 104, 105, 106, 107 };
static constexpr int ul_table[]{ 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
- static constexpr const char* attr_table[]{ "0", "4", "4:3", "7", "5", "1", "2", "3", "9" };
+ static constexpr const char* attr_table[]{ "0", "4", "4:3", "21", "7", "5", "1", "2", "3", "9" };
auto set_color = [&](bool fg, const Color& color, bool join) {
if (join)