From 8723098cda90975cf17fae7a781b89de5422a584 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 29 Jun 2019 21:09:58 +0200 Subject: [PATCH] terminal: move fore/background colors from grid to terminal --- csi.c | 8 ++++---- main.c | 10 +++++----- terminal.h | 5 ++--- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/csi.c b/csi.c index 8ffadb08..6b5c5808 100644 --- a/csi.c +++ b/csi.c @@ -92,8 +92,8 @@ sgr_reset(struct terminal *term) { memset(&term->vt.attrs, 0, sizeof(term->vt.attrs)); term->vt.dim = false; - term->vt.attrs.foreground = term->grid.foreground; - term->vt.attrs.background = term->grid.background; + term->vt.attrs.foreground = term->foreground; + term->vt.attrs.background = term->background; } static bool @@ -172,7 +172,7 @@ csi_sgr(struct terminal *term) break; } case 39: - term->vt.attrs.foreground = term->grid.foreground; + term->vt.attrs.foreground = term->foreground; term->vt.attrs.have_foreground = false; break; @@ -218,7 +218,7 @@ csi_sgr(struct terminal *term) break; } case 49: - term->vt.attrs.background = term->grid.background; + term->vt.attrs.background = term->background; term->vt.attrs.have_background = false; break; diff --git a/main.c b/main.c index 7f81f593..931b3431 100644 --- a/main.c +++ b/main.c @@ -104,9 +104,9 @@ grid_render_update(struct context *c, struct buffer *buf, const struct damage *d int height = c->term.cell_height; struct rgba foreground = cell->attrs.have_foreground - ? cell->attrs.foreground : c->term.grid.foreground; + ? cell->attrs.foreground : c->term.foreground; struct rgba background = cell->attrs.have_background - ? cell->attrs.background : c->term.grid.background; + ? cell->attrs.background : c->term.background; if (has_cursor) { struct rgba swap = foreground; @@ -743,9 +743,7 @@ main(int argc, const char *const *argv) .vt = { .state = 1, /* STATE_GROUND */ }, - .grid = {.foreground = default_foreground, - .background = default_background, - .damage = tll_init()}, + .grid = {.damage = tll_init()}, .kbd = { .repeat = { .pipe_read_fd = repeat_pipe_fds[0], @@ -753,6 +751,8 @@ main(int argc, const char *const *argv) .cmd = REPEAT_STOP, }, }, + .foreground = default_foreground, + .background = default_background, }, }; diff --git a/terminal.h b/terminal.h index 85b1828f..ac1625ab 100644 --- a/terminal.h +++ b/terminal.h @@ -71,9 +71,6 @@ struct grid { int col; } alt_saved_cursor; - struct rgba foreground; - struct rgba background; - tll(struct damage) damage; tll(struct damage) scroll_damage; }; @@ -152,6 +149,8 @@ struct terminal { struct scroll_region scroll_region; + struct rgba foreground; + struct rgba background; }; void term_damage_all(struct terminal *term);