mirror of
https://github.com/neovim/neovim.git
synced 2024-12-20 19:25:11 -07:00
tui: eliminate grid->attrs, use indexed cell->attr
remove dead ugrid_put
This commit is contained in:
parent
fc18fad74f
commit
1b8939d233
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user