aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ugrid.c
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2018-09-27 12:59:31 +0200
committerGitHub <noreply@github.com>2018-09-27 12:59:31 +0200
commit64a8a8fd228a58de4971621bdd405a2081356d11 (patch)
tree49e87beb630d18d8d501d3e546864a267cb13b60 /src/nvim/ugrid.c
parent33887206b9e94a1ed7cce898d869023ff6ceb874 (diff)
parentedb26f2c65123a69e4ee0e2996f9962b70f9e7d7 (diff)
downloadrneovim-64a8a8fd228a58de4971621bdd405a2081356d11.tar.gz
rneovim-64a8a8fd228a58de4971621bdd405a2081356d11.tar.bz2
rneovim-64a8a8fd228a58de4971621bdd405a2081356d11.zip
Merge pull request #9056 from bfredl/tui_repr
TUI code simplification and dead code elimination
Diffstat (limited to 'src/nvim/ugrid.c')
-rw-r--r--src/nvim/ugrid.c59
1 files changed, 15 insertions, 44 deletions
diff --git a/src/nvim/ugrid.c b/src/nvim/ugrid.c
index 36936970f8..e2b92d7112 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;
}
@@ -33,10 +32,6 @@ void ugrid_resize(UGrid *grid, int width, int height)
grid->cells[i] = xcalloc((size_t)width, sizeof(UCell));
}
- grid->top = 0;
- grid->bot = height - 1;
- grid->left = 0;
- grid->right = width - 1;
grid->row = grid->col = 0;
grid->width = width;
grid->height = height;
@@ -44,13 +39,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)
@@ -59,25 +53,18 @@ void ugrid_goto(UGrid *grid, int row, int col)
grid->col = col;
}
-void ugrid_set_scroll_region(UGrid *grid, int top, int bot, int left, int right)
-{
- grid->top = top;
- grid->bot = bot;
- grid->left = left;
- grid->right = right;
-}
-
-void ugrid_scroll(UGrid *grid, int count, int *clear_top, int *clear_bot)
+void ugrid_scroll(UGrid *grid, int top, int bot, int left, int right,
+ int count, int *clear_top, int *clear_bot)
{
// Compute start/stop/step for the loop below
int start, stop, step;
if (count > 0) {
- start = grid->top;
- stop = grid->bot - count + 1;
+ start = top;
+ stop = bot - count + 1;
step = 1;
} else {
- start = grid->bot;
- stop = grid->top - count - 1;
+ start = bot;
+ stop = top - count - 1;
step = -1;
}
@@ -85,10 +72,10 @@ void ugrid_scroll(UGrid *grid, int count, int *clear_top, int *clear_bot)
// Copy cell data
for (i = start; i != stop; i += step) {
- UCell *target_row = grid->cells[i] + grid->left;
- UCell *source_row = grid->cells[i + count] + grid->left;
+ UCell *target_row = grid->cells[i] + left;
+ UCell *source_row = grid->cells[i + count] + left;
memcpy(target_row, source_row,
- sizeof(UCell) * (size_t)(grid->right - grid->left + 1));
+ sizeof(UCell) * (size_t)(right - left + 1));
}
// clear cells in the emptied region,
@@ -99,32 +86,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, left, 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;
});
}