aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2019-07-03 12:16:01 +0000
committerDaniel Eklöf <daniel@ekloef.se>2019-07-03 12:16:01 +0000
commitda305abdd8b6a76156877e4cf1104767d77d6b56 (patch)
treeffc69d4b6c04080e1da3084c890fa30f6816fdf6
parentscrolling: make sure we don't clear too much memory (diff)
scrolling: initial implementation of scrolling region when reverse scrolling
-rw-r--r--terminal.c40
1 files changed, 38 insertions, 2 deletions
diff --git a/terminal.c b/terminal.c
index 49c8e390..7ba0aa13 100644
--- a/terminal.c
+++ b/terminal.c
@@ -295,8 +295,44 @@ void
term_scroll_reverse_partial(struct terminal *term,
struct scroll_region region, int rows)
{
- assert(region.start == 0);
- assert(region.end == term->rows);
+ if (region.end < term->rows) {
+ grid_memmove(
+ term->grid,
+ (region.end - rows) * term->cols,
+ region.end * term->cols,
+ (term->rows - region.end) * term->cols);
+
+ tll_foreach(term->grid->damage, it) {
+ int start = it->item.range.start - term->grid->offset;
+ int end = start + it->item.range.length;
+
+ if (end > region.end * term->cols) {
+ assert(start >= region.end * term->cols);
+ it->item.range.start -= rows * term->cols;
+ }
+ }
+
+ }
+
+ if (region.start > 0) {
+ grid_memmove(
+ term->grid, -rows * term->cols, 0, region.start * term->cols);
+
+ tll_foreach(term->grid->damage, it) {
+ int start = it->item.range.start - term->grid->offset;
+ int end __attribute__((unused)) = start + it->item.range.length;
+
+ if (start < region.start * term->cols) {
+ if (end > region.start * term->cols) {
+ LOG_ERR("region.start = %d, rows = %d, damage.start = %d, damage.end = %d (%s)",
+ region.start, rows, start, end, it->item.type == DAMAGE_UPDATE ? "UPDATE" : "ERASE");
+ abort();
+ }
+ assert(end <= region.start * term->cols);
+ it->item.range.start -= rows * term->cols;
+ }
+ }
+ }
term->grid->offset -= rows * term->cols;