From 1e145a639be109f53381c64bd83483d32ffc8524 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Tue, 9 Sep 2008 17:35:04 +0000 Subject: [PATCH] Unbreak 256 colours when commands are combined. --- input.c | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/input.c b/input.c index 475cf22a..c7023a03 100644 --- a/input.c +++ b/input.c @@ -1,4 +1,4 @@ -/* $Id: input.c,v 1.56 2008-09-08 22:03:54 nicm Exp $ */ +/* $Id: input.c,v 1.57 2008-09-09 17:35:04 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -1061,35 +1061,35 @@ input_handle_sequence_sgr(struct input_ctx *ictx) bg = s->bg; n = ARRAY_LENGTH(&ictx->args); - switch (n) { - case 0: + if (n == 0) { attr = 0; fg = 8; bg = 8; - break; - case 3: - if (input_get_argument(ictx, 1, &m, 0) != 0) - return; - if (m == 5) { - if (input_get_argument(ictx, 0, &o, 0) != 0) - return; - if (input_get_argument(ictx, 2, &m, 0) != 0) - return; - if (o == 38) { - attr |= ATTR_FG256; - fg = m; - break; - } else if (o == 48) { - attr |= ATTR_BG256; - bg = m; - break; - } - } - /* FALLTHROUGH */ - default: + } else { for (i = 0; i < n; i++) { if (input_get_argument(ictx, i, &m, 0) != 0) return; + + if (m == 38 || m == 48) { + i++; + if (input_get_argument(ictx, i, &o, 0) != 0) + return; + if (o != 5) + continue; + + i++; + if (input_get_argument(ictx, i, &o, 0) != 0) + return; + if (m == 38) { + attr |= ATTR_FG256; + fg = o; + } else if (m == 48) { + attr |= ATTR_BG256; + bg = o; + } + continue; + } + switch (m) { case 0: case 10: