From a4190442eacb8b8944761aad6d48d9c165b8ce6f Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 13 Feb 2025 22:21:42 -0800 Subject: basta.fullscreen_alt: assume worst case if no realows * basta.sh (basta.fullscreen_alt): If not able to obtain the current line and number of terminal lines from the terminal, then assume that the worst case number of scrolls are needed: size of the status area. --- basta.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/basta.sh b/basta.sh index 9acaa89..2d55598 100644 --- a/basta.sh +++ b/basta.sh @@ -356,15 +356,21 @@ basta.fullscreen_alt() { basta_deferred_intr=WINCH LINES=$realrows command "$@" || exit=$? + local scrolls_needed=$basta_prev_reserved_rows + if basta.query_terminal_lines realrows >&$ttyfd <&$ttyfd && - basta.get_cur_line curline >&$ttyfd <&$ttyfd && - [ $curline -ge $(( realrows - basta_prev_reserved_rows )) ] + basta.get_cur_line curline >&$ttyfd <&$ttyfd then - local scrolls_needed=$(( curline - realrows + basta_prev_reserved_rows )) + : $(( scrolls_needed -= realrows - curline )) + fi + + if [ $scrolls_needed -gt 0 ] ; then printf $'\e[%s;1H' $realrows >&$ttyfd + for (( i = 0 ; i < scrolls_needed; i++ )) ; do printf $'\n' >&$ttyfd done + printf $'\n\e[%sA' $(( basta_prev_reserved_rows + 1 )) >&$ttyfd fi -- cgit v1.2.3