mirror of
https://github.com/tmux/tmux.git
synced 2025-09-02 05:21:10 +00:00
Instead of representing colours in several different forms with various
cell flags, convert to use an int with flags marking 256 or RGB colours in the top byte (except in cells, which we don't want to make any bigger). From Brad Town.
This commit is contained in:
43
input.c
43
input.c
@ -1628,23 +1628,15 @@ input_csi_dispatch_sgr_256(struct input_ctx *ictx, int fgbg, u_int *i)
|
||||
(*i)++;
|
||||
c = input_get(ictx, *i, 0, -1);
|
||||
if (c == -1) {
|
||||
if (fgbg == 38) {
|
||||
gc->flags &= ~(GRID_FLAG_FG256|GRID_FLAG_FGRGB);
|
||||
if (fgbg == 38)
|
||||
gc->fg = 8;
|
||||
} else if (fgbg == 48) {
|
||||
gc->flags &= ~(GRID_FLAG_BG256|GRID_FLAG_BGRGB);
|
||||
else if (fgbg == 48)
|
||||
gc->bg = 8;
|
||||
}
|
||||
} else {
|
||||
if (fgbg == 38) {
|
||||
gc->flags |= GRID_FLAG_FG256;
|
||||
gc->flags &= ~GRID_FLAG_FGRGB;
|
||||
gc->fg = c;
|
||||
} else if (fgbg == 48) {
|
||||
gc->flags |= GRID_FLAG_BG256;
|
||||
gc->flags &= ~GRID_FLAG_BGRGB;
|
||||
gc->bg = c;
|
||||
}
|
||||
if (fgbg == 38)
|
||||
gc->fg = c | COLOUR_FLAG_256;
|
||||
else if (fgbg == 48)
|
||||
gc->bg = c | COLOUR_FLAG_256;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1668,19 +1660,10 @@ input_csi_dispatch_sgr_rgb(struct input_ctx *ictx, int fgbg, u_int *i)
|
||||
if (b == -1 || b > 255)
|
||||
return;
|
||||
|
||||
if (fgbg == 38) {
|
||||
gc->flags &= ~GRID_FLAG_FG256;
|
||||
gc->flags |= GRID_FLAG_FGRGB;
|
||||
gc->fg_rgb.r = r;
|
||||
gc->fg_rgb.g = g;
|
||||
gc->fg_rgb.b = b;
|
||||
} else if (fgbg == 48) {
|
||||
gc->flags &= ~GRID_FLAG_BG256;
|
||||
gc->flags |= GRID_FLAG_BGRGB;
|
||||
gc->bg_rgb.r = r;
|
||||
gc->bg_rgb.g = g;
|
||||
gc->bg_rgb.b = b;
|
||||
}
|
||||
if (fgbg == 38)
|
||||
gc->fg = colour_join_rgb(r, g, b);
|
||||
else if (fgbg == 48)
|
||||
gc->bg = colour_join_rgb(r, g, b);
|
||||
}
|
||||
|
||||
/* Handle CSI SGR. */
|
||||
@ -1761,11 +1744,9 @@ input_csi_dispatch_sgr(struct input_ctx *ictx)
|
||||
case 35:
|
||||
case 36:
|
||||
case 37:
|
||||
gc->flags &= ~(GRID_FLAG_FG256|GRID_FLAG_FGRGB);
|
||||
gc->fg = n - 30;
|
||||
break;
|
||||
case 39:
|
||||
gc->flags &= ~(GRID_FLAG_FG256|GRID_FLAG_FGRGB);
|
||||
gc->fg = 8;
|
||||
break;
|
||||
case 40:
|
||||
@ -1776,11 +1757,9 @@ input_csi_dispatch_sgr(struct input_ctx *ictx)
|
||||
case 45:
|
||||
case 46:
|
||||
case 47:
|
||||
gc->flags &= ~(GRID_FLAG_BG256|GRID_FLAG_BGRGB);
|
||||
gc->bg = n - 40;
|
||||
break;
|
||||
case 49:
|
||||
gc->flags &= ~(GRID_FLAG_BG256|GRID_FLAG_BGRGB);
|
||||
gc->bg = 8;
|
||||
break;
|
||||
case 90:
|
||||
@ -1791,7 +1770,6 @@ input_csi_dispatch_sgr(struct input_ctx *ictx)
|
||||
case 95:
|
||||
case 96:
|
||||
case 97:
|
||||
gc->flags &= ~(GRID_FLAG_FG256|GRID_FLAG_FGRGB);
|
||||
gc->fg = n;
|
||||
break;
|
||||
case 100:
|
||||
@ -1802,7 +1780,6 @@ input_csi_dispatch_sgr(struct input_ctx *ictx)
|
||||
case 105:
|
||||
case 106:
|
||||
case 107:
|
||||
gc->flags &= ~(GRID_FLAG_BG256|GRID_FLAG_BGRGB);
|
||||
gc->bg = n - 10;
|
||||
break;
|
||||
}
|
||||
|
Reference in New Issue
Block a user