mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-25 01:40:19 -05:00
csi: store color index, not actual color, in cell’s fg/bg attributes
When using indexed colors (i.e. SGR 30/40/90/100), store the index into the cell’s fg/bg attributes, not the actual color value. This has a couple of consequences: Color table lookup is now done when rendering. This means a rendered cell will always reflect the *current* color table, not the color table that was in use when the cell was printed to. This simplifies the OSC-4/104 logic, since we no longer need to update the grid - we just have to damage it to trigger rendering. Furthermore, this change simplifies the VT parsing, since we no longer need to do any memory loads (except loading the SGR parameter values), only writes.
This commit is contained in:
parent
8bf757f466
commit
c2bf2d3650
3 changed files with 43 additions and 74 deletions
33
render.c
33
render.c
|
|
@ -494,8 +494,37 @@ render_cell(struct terminal *term, pixman_image_t *pix,
|
|||
_bg = term->colors.selection_bg;
|
||||
} else {
|
||||
/* Use cell specific color, if set, otherwise the default colors (possible reversed) */
|
||||
_fg = cell->attrs.fg_src != COLOR_DEFAULT ? cell->attrs.fg : term->reverse ? term->colors.bg : term->colors.fg;
|
||||
_bg = cell->attrs.bg_src != COLOR_DEFAULT ? cell->attrs.bg : term->reverse ? term->colors.fg : term->colors.bg;
|
||||
switch (cell->attrs.fg_src) {
|
||||
case COLOR_RGB:
|
||||
_fg = cell->attrs.fg;
|
||||
break;
|
||||
|
||||
case COLOR_BASE16:
|
||||
case COLOR_BASE256:
|
||||
xassert(cell->attrs.fg < ALEN(term->colors.table));
|
||||
_fg = term->colors.table[cell->attrs.fg];
|
||||
break;
|
||||
|
||||
case COLOR_DEFAULT:
|
||||
_fg = term->reverse ? term->colors.bg : term->colors.fg;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (cell->attrs.bg_src) {
|
||||
case COLOR_RGB:
|
||||
_bg = cell->attrs.bg;
|
||||
break;
|
||||
|
||||
case COLOR_BASE16:
|
||||
case COLOR_BASE256:
|
||||
xassert(cell->attrs.bg < ALEN(term->colors.table));
|
||||
_bg = term->colors.table[cell->attrs.bg];
|
||||
break;
|
||||
|
||||
case COLOR_DEFAULT:
|
||||
_bg = term->reverse ? term->colors.fg : term->colors.bg;
|
||||
break;
|
||||
}
|
||||
|
||||
if (cell->attrs.reverse ^ is_selected) {
|
||||
uint32_t swap = _fg;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue