From 5d8da126d0b5ab7f550a74264ba434a2ad04280e Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Tue, 6 Feb 2018 19:46:45 +0100 Subject: ui/tui: highlighting refactor Make HlAttr contain highlighting state for both color modes (cterm and rgb). This allows us to implement termguicolors completely in the TUI. Simplify some logic duplicated between ui.c and screen.c. Also avoid some superfluous highlighting reset events. --- src/nvim/ugrid.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/nvim/ugrid.c') diff --git a/src/nvim/ugrid.c b/src/nvim/ugrid.c index e0880b4c76..6d420ef2f8 100644 --- a/src/nvim/ugrid.c +++ b/src/nvim/ugrid.c @@ -17,7 +17,7 @@ void ugrid_init(UGrid *grid) { grid->attrs = HLATTRS_INIT; - grid->fg = grid->bg = -1; + grid->clear_attrs = HLATTRS_INIT; grid->cells = NULL; } @@ -107,6 +107,7 @@ UCell *ugrid_put(UGrid *grid, uint8_t *text, size_t size) UCell *cell = grid->cells[grid->row] + grid->col; cell->data[size] = 0; cell->attrs = grid->attrs; + assert(size <= CELLBYTES); if (text) { memcpy(cell->data, text, size); @@ -118,9 +119,7 @@ UCell *ugrid_put(UGrid *grid, uint8_t *text, size_t size) static void clear_region(UGrid *grid, int top, int bot, int left, int right) { - HlAttrs clear_attrs = HLATTRS_INIT; - clear_attrs.foreground = grid->fg; - clear_attrs.background = grid->bg; + HlAttrs clear_attrs = grid->clear_attrs; UGRID_FOREACH_CELL(grid, top, bot, left, right, { cell->data[0] = ' '; cell->data[1] = 0; -- cgit