aboutsummaryrefslogtreecommitdiff
path: root/render.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2024-06-23 15:39:15 +0000
committerDaniel Eklöf <daniel@ekloef.se>2024-06-26 16:39:23 +0000
commit32effc6657c1802cdf34098748337b0d7bc39dba (patch)
treeb87fd39cec2b17b72c51b530cef10e9c86ce68ad /render.c
parentgrid: refactor: first step towards a more generic range handling (diff)
csi: wip: styled underlines
This is work in progress, and fairly untested. This adds initial tracking of styled underlines. Setting attributes seems to work (both color and underline style). Grid reflow has *not* been tested. When rendering, style is currently ignored (all styles are rendered as a plain, legacy underline). Color however, *is* applied.
Diffstat (limited to 'render.c')
-rw-r--r--render.c39
1 files changed, 37 insertions, 2 deletions
diff --git a/render.c b/render.c
index fd7e743a..78cc5325 100644
--- a/render.c
+++ b/render.c
@@ -847,8 +847,43 @@ render_cell(struct terminal *term, pixman_image_t *pix, pixman_region32_t *damag
pixman_image_unref(clr_pix);
/* Underline */
- if (cell->attrs.underline)
- draw_underline(term, pix, font, &fg, x, y, cell_cols);
+ if (cell->attrs.underline) {
+ pixman_color_t underline_color = fg;
+
+ /* Check if cell has a styled underline. This lookup is fairly
+ expensive... */
+ if (row->extra != NULL) {
+ for (int i = 0; i < row->extra->curly_ranges.count; i++) {
+ const struct row_range *range = &row->extra->curly_ranges.v[i];
+
+ if (range->start <= col && col <= range->end) {
+ switch (range->curly.color_src) {
+ case COLOR_BASE256:
+ underline_color = color_hex_to_pixman(
+ term->colors.table[range->curly.color]);
+ break;
+
+ case COLOR_RGB:
+ underline_color =
+ color_hex_to_pixman(range->curly.color);
+ break;
+
+ case COLOR_DEFAULT:
+ break;
+
+ case COLOR_BASE16:
+ BUG("underline color can't be base-16");
+ break;
+ }
+
+ break;
+ }
+ }
+ }
+
+ draw_underline(term, pix, font, &underline_color, x, y, cell_cols);
+
+ }
if (cell->attrs.strikethrough)
draw_strikeout(term, pix, font, &fg, x, y, cell_cols);