From 62c92629b40ea907c5cc6f69001e2fecdfa66b88 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 13 Feb 2025 23:41:20 -0800 Subject: prepare_term: account for all status lines. * basta.sh (basta.prepare_term): The old logic of printing \n ESC [ A (newline, go up one line) is inadequate when we have multiple previous status lines to draw. It only works if the previous status lines can be counted on to be already scroll-protected. We need to print as many new lines as we have status lines, and then move the cursor up that many lines. Also, before doing this, we reset the scrolling region to the full size. This same logic could simplify basta.fullscreen_alt. --- basta.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/basta.sh b/basta.sh index d0afc20..5707e0e 100644 --- a/basta.sh +++ b/basta.sh @@ -39,6 +39,7 @@ basta.query_termios_lines_cols() basta.prepare_term() { local realrows + local i if ! basta.query_terminal_lines realrows; then return 1 @@ -46,7 +47,11 @@ basta.prepare_term() if [ -z "$basta_prev_reserved_rows" ] ; then basta_prev_reserved_rows=${#LC_basta_status[@]} - printf $'\n\e[A' + printf $'\e7\e[1;%sr\e8' $realrows + for (( i = 0; i <= basta_prev_reserved_rows; i++ )); do + printf $'\n' + done + printf $'\e[%sA' $i fi LINES=$((realrows - $basta_prev_reserved_rows - 1)) -- cgit v1.2.3