summaryrefslogtreecommitdiff
path: root/src/libvterm/src/screen.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libvterm/src/screen.c')
-rw-r--r--src/libvterm/src/screen.c29
1 files changed, 11 insertions, 18 deletions
diff --git a/src/libvterm/src/screen.c b/src/libvterm/src/screen.c
index 081bf408b..1da2b72ae 100644
--- a/src/libvterm/src/screen.c
+++ b/src/libvterm/src/screen.c
@@ -488,24 +488,9 @@ static void resize_buffer(VTermScreen *screen, int bufidx, int new_rows, int new
ScreenCell *new_buffer = vterm_allocator_malloc(screen->vt, sizeof(ScreenCell) * new_rows * new_cols);
/* Find the final row of old buffer content */
- int old_row;
+ int old_row = old_rows - 1;
+ int new_row = new_rows - 1;
int col;
- int new_row;
-
- for(old_row = old_rows - 1; old_row > 0; old_row--) {
- if(active && (old_row == screen->state->pos.row))
- /* The line with the active cursor is never "blank" */
- goto found_oldrow;
- for(col = 0; col < old_cols; col++)
- if(old_buffer[old_row * old_cols + col].chars[0])
- /* This row is not blank */
- goto found_oldrow;
- }
- old_row = 0;
-found_oldrow:
- ;
-
- new_row = new_rows - 1;
while(new_row >= 0 && old_row >= 0) {
for(col = 0; col < old_cols && col < new_cols; col++)
@@ -515,6 +500,15 @@ found_oldrow:
old_row--;
new_row--;
+
+ if(new_row < 0 && old_row >= 0 &&
+ new_buffer[(new_rows - 1) * new_cols].chars[0] == 0 &&
+ (!active || statefields->pos.row < (new_rows - 1))) {
+ int moverows = new_rows - 1;
+ memmove(&new_buffer[1 * new_cols], &new_buffer[0], moverows * new_cols * sizeof(ScreenCell));
+
+ new_row++;
+ }
}
if(old_row >= 0 && bufidx == BUFIDX_PRIMARY) {
@@ -877,7 +871,6 @@ VTermScreen *vterm_obtain_screen(VTerm *vt)
void vterm_screen_enable_altscreen(VTermScreen *screen, int altscreen)
{
-
if(!screen->buffers[BUFIDX_ALTSCREEN] && altscreen) {
int rows, cols;
vterm_get_size(screen->vt, &rows, &cols);