summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornicm <nicm>2023-07-13 06:03:48 +0000
committernicm <nicm>2023-07-13 06:03:48 +0000
commit84936b832f7a2ec1d4b98aad4eb285087a1a2708 (patch)
tree2fcbb2ba6f5f1f3f5ce4b249fc3f3712411e4c50
parent8fcc212e7a24cfb4cc3973469c4ee8974e7d9bde (diff)
Use 8 for underscore colour defaults instead of 0 which is less
confusing, and fix writing tge default colour. GitHub issue 3627.
-rw-r--r--grid.c10
-rw-r--r--input.c2
-rw-r--r--tty.c7
3 files changed, 10 insertions, 9 deletions
diff --git a/grid.c b/grid.c
index 014e8b8f..edada819 100644
--- a/grid.c
+++ b/grid.c
@@ -37,7 +37,7 @@
/* Default grid cell data. */
const struct grid_cell grid_default_cell = {
- { { ' ' }, 0, 1, 1 }, 0, 0, 8, 8, 0, 0
+ { { ' ' }, 0, 1, 1 }, 0, 0, 8, 8, 8, 0
};
/*
@@ -45,12 +45,12 @@ const struct grid_cell grid_default_cell = {
* appears in the grid - because of this, they are always extended cells.
*/
static const struct grid_cell grid_padding_cell = {
- { { '!' }, 0, 0, 0 }, 0, GRID_FLAG_PADDING, 8, 8, 0, 0
+ { { '!' }, 0, 0, 0 }, 0, GRID_FLAG_PADDING, 8, 8, 8, 0
};
/* Cleared grid cell data. */
static const struct grid_cell grid_cleared_cell = {
- { { ' ' }, 0, 1, 1 }, 0, GRID_FLAG_CLEARED, 8, 8, 0, 0
+ { { ' ' }, 0, 1, 1 }, 0, GRID_FLAG_CLEARED, 8, 8, 8, 0
};
static const struct grid_cell_entry grid_cleared_entry = {
{ .data = { 0, 8, 8, ' ' } }, GRID_FLAG_CLEARED
@@ -528,7 +528,7 @@ grid_get_cell1(struct grid_line *gl, u_int px, struct grid_cell *gc)
gc->bg = gce->data.bg;
if (gce->flags & GRID_FLAG_BG256)
gc->bg |= COLOUR_FLAG_256;
- gc->us = 0;
+ gc->us = 8;
utf8_set(&gc->data, gce->data.data);
gc->link = 0;
}
@@ -956,7 +956,7 @@ grid_string_cells_code(const struct grid_cell *lastgc,
for (i = 0; i < nitems(attrs); i++) {
if (((~attr & attrs[i].mask) &&
(lastattr & attrs[i].mask)) ||
- (lastgc->us != 0 && gc->us == 0)) {
+ (lastgc->us != 8 && gc->us == 8)) {
s[n++] = 0;
lastattr &= GRID_ATTR_CHARSET;
break;
diff --git a/input.c b/input.c
index ee31b7e1..5f2cac46 100644
--- a/input.c
+++ b/input.c
@@ -2186,7 +2186,7 @@ input_csi_dispatch_sgr(struct input_ctx *ictx)
gc->attr &= ~GRID_ATTR_OVERLINE;
break;
case 59:
- gc->us = 0;
+ gc->us = 8;
break;
case 90:
case 91:
diff --git a/tty.c b/tty.c
index e34b186a..ad4a110a 100644
--- a/tty.c
+++ b/tty.c
@@ -2815,9 +2815,10 @@ tty_check_us(__unused struct tty *tty, struct colour_palette *palette,
}
/* Underscore colour is set as RGB so convert. */
- gc->us = colour_force_rgb (gc->us);
- if (gc->us == -1)
+ if ((c = colour_force_rgb (gc->us)) == -1)
gc->us = 8;
+ else
+ gc->us = c;
}
static void
@@ -2892,7 +2893,7 @@ tty_colours_us(struct tty *tty, const struct grid_cell *gc)
u_char r, g, b;
/* Clear underline colour. */
- if (gc->us == 0) {
+ if (COLOUR_DEFAULT(gc->us)) {
tty_putcode(tty, TTYC_OL);
goto save;
}