diff --git a/vt.c b/vt.c index 34c30ca..3a2e445 100644 --- a/vt.c +++ b/vt.c @@ -538,9 +538,8 @@ static Row *buffer_row_prev(Buffer *b, Row *row) return --row; } -static void cursor_clamp(Vt *t) +static void cursor_clamp(Vt *t, Buffer *b) { - Buffer *b = t->buffer; Row *lines = t->relposmode ? b->scroll_top : b->lines; int rows = t->relposmode ? b->scroll_bot - b->scroll_top : b->rows; @@ -581,7 +580,7 @@ static void cursor_restore(Vt *t) Buffer *b = t->buffer; b->curs_row = b->lines + b->curs_srow; b->curs_col = b->curs_scol; - cursor_clamp(t); + cursor_clamp(t, b); } static void attributes_save(Vt *t) @@ -765,7 +764,7 @@ static void interpret_csi_cup(Vt *t, int param[], int pcount) b->curs_col = param[1] - 1; } - cursor_clamp(t); + cursor_clamp(t, b); } /* Interpret the 'relative mode' sequences: CUU, CUD, CUF, CUB, CNL, @@ -807,7 +806,7 @@ static void interpret_csi_c(Vt *t, char verb, int param[], int pcount) break; } - cursor_clamp(t); + cursor_clamp(t, b); } /* Interpret the 'erase line' escape sequence */ @@ -1479,7 +1478,8 @@ void vt_resize(Vt *t, int rows, int cols) vt_noscroll(t); buffer_resize(&t->buffer_normal, rows, cols); buffer_resize(&t->buffer_alternate, rows, cols); - cursor_clamp(t); + cursor_clamp(t, &t->buffer_normal); + cursor_clamp(t, &t->buffer_alternate); ioctl(t->pty, TIOCSWINSZ, &ws); kill(-t->pid, SIGWINCH); }