aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2014-05-05 03:19:26 -0400
committerJesse Luehrs <doy@tozt.net>2014-05-05 03:19:26 -0400
commite07b9e065fa55449b362e417bc152e9a37d5f91a (patch)
tree7e5a1f78a42e14836c82f3e2515ccefa11a60480
parentb9c1d83b1bf9c80473cfe6ce18a7ce324832507e (diff)
downloadrunes-e07b9e065fa55449b362e417bc152e9a37d5f91a.tar.gz
runes-e07b9e065fa55449b362e417bc152e9a37d5f91a.zip
handle scroll regions when inserting or deleting lines
-rw-r--r--src/screen.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/screen.c b/src/screen.c
index ebff44b..17d77cc 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -364,16 +364,17 @@ void runes_screen_insert_lines(RunesTerm *t, int count)
}
else {
struct runes_row *row;
+ int bottom = scr->grid->scroll_bottom + 1;
int i;
- for (i = scr->grid->max.row - count; i < scr->grid->max.row; ++i) {
+ for (i = bottom - count; i < bottom; ++i) {
row = runes_screen_row_at(t, i);
free(row->cells);
}
row = runes_screen_row_at(t, scr->grid->cur.row);
memmove(
row + count, row,
- (scr->grid->max.row - scr->grid->cur.row - count) * sizeof(struct runes_row));
+ (bottom - scr->grid->cur.row - count) * sizeof(struct runes_row));
memset(row, 0, count * sizeof(struct runes_row));
for (i = scr->grid->cur.row; i < scr->grid->cur.row + count; ++i) {
row = runes_screen_row_at(t, i);
@@ -419,6 +420,7 @@ void runes_screen_delete_lines(RunesTerm *t, int count)
}
else {
struct runes_row *row;
+ int bottom = scr->grid->scroll_bottom + 1;
int i;
for (i = scr->grid->cur.row; i < scr->grid->cur.row + count; ++i) {
@@ -428,10 +430,10 @@ void runes_screen_delete_lines(RunesTerm *t, int count)
row = runes_screen_row_at(t, scr->grid->cur.row);
memmove(
row, row + count,
- (scr->grid->max.row - scr->grid->cur.row - count) * sizeof(struct runes_row));
- row = runes_screen_row_at(t, scr->grid->max.row - count);
+ (bottom - scr->grid->cur.row - count) * sizeof(struct runes_row));
+ row = runes_screen_row_at(t, bottom - count);
memset(row, 0, count * sizeof(struct runes_row));
- for (i = scr->grid->max.row - count; i < scr->grid->max.row; ++i) {
+ for (i = bottom - count; i < bottom; ++i) {
row = runes_screen_row_at(t, i);
row->cells = calloc(scr->grid->max.col, sizeof(struct runes_cell));
row->wrapped = 0;