aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2018-09-26 12:20:57 +0200
committerBjörn Linse <bjorn.linse@gmail.com>2018-09-26 19:30:21 +0200
commit1b8939d23321f5c7a818a5ba2125793797031835 (patch)
tree667190b7aade382b977ca1087badb61eb3d6fbf1
parentfc18fad74ff3be9929d9d10de964f4813497fba0 (diff)
downloadrneovim-1b8939d23321f5c7a818a5ba2125793797031835.tar.gz
rneovim-1b8939d23321f5c7a818a5ba2125793797031835.tar.bz2
rneovim-1b8939d23321f5c7a818a5ba2125793797031835.zip
tui: eliminate grid->attrs, use indexed cell->attr
remove dead ugrid_put
-rw-r--r--src/nvim/tui/tui.c10
-rw-r--r--src/nvim/ugrid.c30
-rw-r--r--src/nvim/ugrid.h3
3 files changed, 13 insertions, 30 deletions
diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c
index 8a5d9f6614..8ef2d5116c 100644
--- a/src/nvim/tui/tui.c
+++ b/src/nvim/tui/tui.c
@@ -574,7 +574,7 @@ static void print_cell(UI *ui, UCell *ptr)
// Printing the next character finally advances the cursor.
final_column_wrap(ui);
}
- update_attrs(ui, ptr->attrs);
+ update_attrs(ui, kv_A(data->attrs, ptr->attr));
out(ui, ptr->data, strlen(ptr->data));
grid->col++;
if (data->immediate_wrap_after_last_column) {
@@ -590,7 +590,8 @@ static bool cheap_to_print(UI *ui, int row, int col, int next)
UCell *cell = grid->cells[row] + col;
while (next) {
next--;
- if (attrs_differ(cell->attrs, data->print_attrs, ui->rgb)) {
+ if (attrs_differ(kv_A(data->attrs, cell->attr),
+ data->print_attrs, ui->rgb)) {
if (data->default_attr) {
return false;
}
@@ -1221,7 +1222,8 @@ static void tui_raw_line(UI *ui, Integer g, Integer linerow, Integer startcol,
UGrid *grid = &data->grid;
for (Integer c = startcol; c < endcol; c++) {
memcpy(grid->cells[linerow][c].data, chunk[c-startcol], sizeof(schar_T));
- grid->cells[linerow][c].attrs = kv_A(data->attrs, attrs[c-startcol]);
+ assert((size_t)attrs[c-startcol] < kv_size(data->attrs));
+ grid->cells[linerow][c].attr = attrs[c-startcol];
}
UGRID_FOREACH_CELL(grid, (int)linerow, (int)linerow, (int)startcol,
(int)endcol-1, {
@@ -1232,7 +1234,7 @@ static void tui_raw_line(UI *ui, Integer g, Integer linerow, Integer startcol,
if (clearcol > endcol) {
HlAttrs cl_attrs = kv_A(data->attrs, (size_t)clearattr);
ugrid_clear_chunk(grid, (int)linerow, (int)endcol, (int)clearcol,
- cl_attrs);
+ (sattr_T)clearattr);
clear_region(ui, (int)linerow, (int)linerow, (int)endcol, (int)clearcol-1,
cl_attrs);
}
diff --git a/src/nvim/ugrid.c b/src/nvim/ugrid.c
index 36936970f8..64d99bc649 100644
--- a/src/nvim/ugrid.c
+++ b/src/nvim/ugrid.c
@@ -16,7 +16,6 @@
void ugrid_init(UGrid *grid)
{
- grid->attrs = HLATTRS_INIT;
grid->cells = NULL;
}
@@ -44,13 +43,12 @@ void ugrid_resize(UGrid *grid, int width, int height)
void ugrid_clear(UGrid *grid)
{
- clear_region(grid, 0, grid->height-1, 0, grid->width-1,
- HLATTRS_INIT);
+ clear_region(grid, 0, grid->height-1, 0, grid->width-1, 0);
}
-void ugrid_clear_chunk(UGrid *grid, int row, int col, int endcol, HlAttrs attrs)
+void ugrid_clear_chunk(UGrid *grid, int row, int col, int endcol, sattr_T attr)
{
- clear_region(grid, row, row, col, endcol-1, attrs);
+ clear_region(grid, row, row, col, endcol-1, attr);
}
void ugrid_goto(UGrid *grid, int row, int col)
@@ -99,32 +97,16 @@ void ugrid_scroll(UGrid *grid, int count, int *clear_top, int *clear_bot)
*clear_bot = stop;
*clear_top = stop + count + 1;
}
- clear_region(grid, *clear_top, *clear_bot, grid->left, grid->right,
- HLATTRS_INIT);
-}
-
-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);
- }
-
- grid->col += 1;
- return cell;
+ clear_region(grid, *clear_top, *clear_bot, grid->left, grid->right, 0);
}
static void clear_region(UGrid *grid, int top, int bot, int left, int right,
- HlAttrs attrs)
+ sattr_T attr)
{
UGRID_FOREACH_CELL(grid, top, bot, left, right, {
cell->data[0] = ' ';
cell->data[1] = 0;
- cell->attrs = attrs;
+ cell->attr = attr;
});
}
diff --git a/src/nvim/ugrid.h b/src/nvim/ugrid.h
index 04e027bd46..0751010d6b 100644
--- a/src/nvim/ugrid.h
+++ b/src/nvim/ugrid.h
@@ -11,14 +11,13 @@ typedef struct ugrid UGrid;
struct ucell {
char data[CELLBYTES + 1];
- HlAttrs attrs;
+ sattr_T attr;
};
struct ugrid {
int top, bot, left, right;
int row, col;
int width, height;
- HlAttrs attrs;
UCell **cells;
};