summaryrefslogtreecommitdiff
path: root/xC.c
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2022-09-05 22:34:20 +0200
committerPřemysl Eric Janouch <p@janouch.name>2022-09-05 23:22:09 +0200
commit25ad5ae0ec8afe0a8f60d7602ca2357f561246d6 (patch)
treea1d062c6ffb4c02fcbeb47e8a55bf8c19e536be5 /xC.c
parent10f6072da954f8eb59192e287b7eeb7a9efd1134 (diff)
downloadxK-25ad5ae0ec8afe0a8f60d7602ca2357f561246d6.tar.gz
xK-25ad5ae0ec8afe0a8f60d7602ca2357f561246d6.tar.xz
xK-25ad5ae0ec8afe0a8f60d7602ca2357f561246d6.zip
xC/xP: fix colour values, and render them with CSS
Diffstat (limited to 'xC.c')
-rw-r--r--xC.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/xC.c b/xC.c
index c628cb4..6f0a7ae 100644
--- a/xC.c
+++ b/xC.c
@@ -1480,7 +1480,7 @@ struct formatter_item
{
enum formatter_item_type type : 16; ///< Type of this item
int attribute : 16; ///< Attribute ID or a TEXT_* mask
- int color; ///< Colour
+ int color; ///< Colour ([256 << 16] | 16)
char *text; ///< String
};
@@ -3114,6 +3114,9 @@ relay_prepare_buffer_line (struct app_context *ctx, struct buffer *buffer,
union relay_item_data *p = e->items = xcalloc (len * 6, sizeof *e->items);
for (struct formatter_item *i = line->items; len--; i++)
{
+ // XXX: See attr_printer_decode_color(), this is a footgun.
+ int16_t c16 = i->color;
+ int16_t c256 = i->color >> 16;
switch (i->type)
{
case FORMATTER_ITEM_TEXT:
@@ -3125,11 +3128,11 @@ relay_prepare_buffer_line (struct app_context *ctx, struct buffer *buffer,
(p++)->kind = RELAY_ITEM_RESET;
break;
case FORMATTER_ITEM_FG_COLOR:
- p->fg_color.color = i->color;
+ p->fg_color.color = c256 <= 0 ? c16 : c256;
(p++)->kind = RELAY_ITEM_FG_COLOR;
break;
case FORMATTER_ITEM_BG_COLOR:
- p->bg_color.color = i->color;
+ p->bg_color.color = c256 <= 0 ? c16 : c256;
(p++)->kind = RELAY_ITEM_BG_COLOR;
break;
case FORMATTER_ITEM_SIMPLE: