render: scroll: take margins into account when restoring bottom scroll region

This commit is contained in:
Daniel Eklöf 2020-03-23 20:15:53 +01:00
parent 7958f8b5ef
commit 75180cea37
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

View file

@ -624,16 +624,16 @@ grid_render_scroll(struct terminal *term, struct buffer *buf,
if (dmg->scroll.region.end < term->rows) {
int src = dmg->scroll.region.end - dmg->scroll.lines;
int dst = dmg->scroll.region.end;
size_t amount = max(0, term->rows - dmg->scroll.region.end);
size_t amount = term->rows - dmg->scroll.region.end;
LOG_DBG("memmoving %zu lines of scroll region", amount);
assert(src >= 0);
uint8_t *raw = buf->mmapped;
memmove(raw + dst * term->cell_height * buf->stride,
raw + src * term->cell_height * buf->stride,
amount * term->cell_height * buf->stride);
memmove(
raw + (term->margins.top + dst * term->cell_height) * buf->stride,
raw + (term->margins.top + src * term->cell_height) * buf->stride,
amount * term->cell_height * buf->stride);
}
/* Restore margins */