From cf71534768b01e2a94a8f8f13faca2fb1920e93e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Wed, 10 Jul 2019 18:45:12 +0200 Subject: [PATCH] terminal: remove 'blink' attribute from cell struct This makes the other attribute bits fit in a single uint8_t, which makes each cell smaller which improves cache usage. --- csi.c | 61 +++++++++++++++++++++++++++--------------------------- terminal.h | 2 +- 2 files changed, 32 insertions(+), 31 deletions(-) diff --git a/csi.c b/csi.c index 3311b7b3..51f7705d 100644 --- a/csi.c +++ b/csi.c @@ -79,6 +79,33 @@ sgr_reset(struct terminal *term) term->vt.attrs.background = term->background; } +static const char * +csi_as_string(struct terminal *term, uint8_t final) +{ + static char msg[1024]; + int c = snprintf(msg, sizeof(msg), "CSI: "); + + if (term->vt.private != 0) + c += snprintf(&msg[c], sizeof(msg) - c, "%c", term->vt.private); + + for (size_t i = 0; i < term->vt.params.idx; i++){ + c += snprintf(&msg[c], sizeof(msg) - c, "%d", + term->vt.params.v[i].value); + + for (size_t j = 0; i < term->vt.params.v[i].sub.idx; j++) { + c += snprintf(&msg[c], sizeof(msg) - c, ":%d", + term->vt.params.v[i].sub.value[j]); + } + + c += snprintf(&msg[c], sizeof(msg) - c, "%s", + i == term->vt.params.idx - 1 ? "" : ";"); + } + + c += snprintf(&msg[c], sizeof(msg) - c, "%c (%zu parameters)", + final, term->vt.params.idx); + return msg; +} + static void csi_sgr(struct terminal *term) { @@ -99,8 +126,8 @@ csi_sgr(struct terminal *term) case 2: term->vt.dim = true; break; case 3: term->vt.attrs.italic = true; break; case 4: term->vt.attrs.underline = true; break; - case 5: term->vt.attrs.blink = true; break; - case 6: term->vt.attrs.blink = true; break; + case 5: LOG_WARN("unimplemented: %s (blink)", csi_as_string(term, 'm')); /*term->vt.attrs.blink = true; */break; + case 6: break; /* rapid blink, ignored */ case 7: term->vt.attrs.reverse = true; break; case 8: term->vt.attrs.conceal = true; break; case 9: term->vt.attrs.strikethrough = true; break; @@ -108,7 +135,8 @@ csi_sgr(struct terminal *term) case 22: term->vt.attrs.bold = term->vt.dim = false; break; case 23: term->vt.attrs.italic = false; break; case 24: term->vt.attrs.underline = false; break; - case 25: term->vt.attrs.blink = false; break; + case 25: /*term->vt.attrs.blink = false; */break; + case 26: break; /* rapid blink, ignored */ case 27: term->vt.attrs.reverse = false; break; case 28: term->vt.attrs.conceal = false; break; case 29: term->vt.attrs.strikethrough = false; break; @@ -239,33 +267,6 @@ csi_sgr(struct terminal *term) } } -static const char * -csi_as_string(struct terminal *term, uint8_t final) -{ - static char msg[1024]; - int c = snprintf(msg, sizeof(msg), "CSI: "); - - if (term->vt.private != 0) - c += snprintf(&msg[c], sizeof(msg) - c, "%c", term->vt.private); - - for (size_t i = 0; i < term->vt.params.idx; i++){ - c += snprintf(&msg[c], sizeof(msg) - c, "%d", - term->vt.params.v[i].value); - - for (size_t j = 0; i < term->vt.params.v[i].sub.idx; j++) { - c += snprintf(&msg[c], sizeof(msg) - c, ":%d", - term->vt.params.v[i].sub.value[j]); - } - - c += snprintf(&msg[c], sizeof(msg) - c, "%s", - i == term->vt.params.idx - 1 ? "" : ";"); - } - - c += snprintf(&msg[c], sizeof(msg) - c, "%c (%zu parameters)", - final, term->vt.params.idx); - return msg; -} - void csi_dispatch(struct terminal *term, uint8_t final) { diff --git a/terminal.h b/terminal.h index 4ddf017e..66cfebe0 100644 --- a/terminal.h +++ b/terminal.h @@ -56,7 +56,7 @@ struct attributes { uint8_t italic:1; uint8_t underline:1; uint8_t strikethrough:1; - uint8_t blink:1; + //uint8_t blink:1; /* Not supported yet, and removing it means all other attributes fit in a single uint8_t */ uint8_t conceal:1; uint8_t reverse:1; uint8_t have_foreground:1;