aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ugrid.c
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2018-09-26 13:06:20 +0200
committerBjörn Linse <bjorn.linse@gmail.com>2018-09-27 08:50:48 +0200
commitedb26f2c65123a69e4ee0e2996f9962b70f9e7d7 (patch)
tree84a5b29b1bf03880a25cc6825c0d6adc8c2b3d18 /src/nvim/ugrid.c
parent1b8939d23321f5c7a818a5ba2125793797031835 (diff)
downloadrneovim-edb26f2c65123a69e4ee0e2996f9962b70f9e7d7.tar.gz
rneovim-edb26f2c65123a69e4ee0e2996f9962b70f9e7d7.tar.bz2
rneovim-edb26f2c65123a69e4ee0e2996f9962b70f9e7d7.zip
tui: eliminate scrolling region data structure
The scrolling region is always local to a single grid_scroll event, use local variables and parameters instead. The invocation of reset_scroll_region in grid_resize is cargo-culted to use margin reset under exactly the same circumstances, not sure if it is necessary though.
Diffstat (limited to 'src/nvim/ugrid.c')
-rw-r--r--src/nvim/ugrid.c31
1 files changed, 10 insertions, 21 deletions
diff --git a/src/nvim/ugrid.c b/src/nvim/ugrid.c
index 64d99bc649..e2b92d7112 100644
--- a/src/nvim/ugrid.c
+++ b/src/nvim/ugrid.c
@@ -32,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;
@@ -57,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;
}
@@ -83,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,
@@ -97,7 +86,7 @@ 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, 0);
+ clear_region(grid, *clear_top, *clear_bot, left, right, 0);
}
static void clear_region(UGrid *grid, int top, int bot, int left, int right,