From 72a99052eed52e38775923a5f6d6a499151e16b9 Mon Sep 17 00:00:00 2001 From: "K. Lange" Date: Fri, 27 Apr 2018 22:23:45 +0900 Subject: [PATCH] Fix terminal resizing --- apps/terminal.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/apps/terminal.c b/apps/terminal.c index 8d210957..178c6851 100644 --- a/apps/terminal.c +++ b/apps/terminal.c @@ -1363,7 +1363,11 @@ void reinit(int send_sig) { int offset = 0; if (term_height < old_height) { - offset = old_height - term_height; + while (csr_y >= term_height) { + offset++; + old_height--; + csr_y--; + } } for (int row = 0; row < min(old_height, term_height); ++row) { for (int col = 0; col < min(old_width, term_width); ++col) { @@ -1372,7 +1376,9 @@ void reinit(int send_sig) { *new_cell = *old_cell; } } - csr_y -= offset; + if (csr_x >= term_width) { + csr_x = term_width-1; + } free(term_buffer); term_buffer = new_term_buffer;