csi: sgr: treat CSI[m as CSI[0m (SGR reset)

This commit is contained in:
Daniel Eklöf 2019-06-22 21:38:47 +02:00
parent 4b6ea810fc
commit 9c9ad48745
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

21
csi.c
View file

@ -16,12 +16,9 @@
#define min(x, y) ((x) < (y) ? (x) : (y)) #define min(x, y) ((x) < (y) ? (x) : (y))
static bool static void
csi_sgr(struct terminal *term) sgr_reset(struct terminal *term)
{ {
for (size_t i = 0; i < term->vt.params.idx; i++) {
switch (term->vt.params.v[i].value) {
case 0:
term->vt.attrs.bold = false; term->vt.attrs.bold = false;
term->vt.dim = false; term->vt.dim = false;
term->vt.attrs.italic = false; term->vt.attrs.italic = false;
@ -32,6 +29,20 @@ csi_sgr(struct terminal *term)
term->vt.attrs.reverse = false; term->vt.attrs.reverse = false;
term->vt.attrs.foreground = term->grid.foreground; term->vt.attrs.foreground = term->grid.foreground;
term->vt.attrs.background = term->grid.background; term->vt.attrs.background = term->grid.background;
}
static bool
csi_sgr(struct terminal *term)
{
if (term->vt.params.idx == 0) {
sgr_reset(term);
return true;
}
for (size_t i = 0; i < term->vt.params.idx; i++) {
switch (term->vt.params.v[i].value) {
case 0:
sgr_reset(term);
break; break;
case 1: term->vt.attrs.bold = true; break; case 1: term->vt.attrs.bold = true; break;