diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2016-07-15 00:42:57 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2016-07-15 00:42:57 +0000 |
commit | c86123dfcc50c7b6210c9b4ad9e653ad94395dd9 (patch) | |
tree | 1046d003f4ff6e0380b93e2888a0865ba2e082a4 /usr.bin/tmux/input.c | |
parent | 15375d7661dc3466e7e2c1f1d8561e63c891ae1b (diff) |
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.
Diffstat (limited to 'usr.bin/tmux/input.c')
-rw-r--r-- | usr.bin/tmux/input.c | 45 |
1 files changed, 11 insertions, 34 deletions
diff --git a/usr.bin/tmux/input.c b/usr.bin/tmux/input.c index bfb2b6fb855..c10b0da31ce 100644 --- a/usr.bin/tmux/input.c +++ b/usr.bin/tmux/input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: input.c,v 1.101 2016/03/02 15:36:02 nicm Exp $ */ +/* $OpenBSD: input.c,v 1.102 2016/07/15 00:42:56 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -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; } |