diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2025-02-13 22:21:42 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2025-02-13 22:21:42 -0800 |
commit | a4190442eacb8b8944761aad6d48d9c165b8ce6f (patch) | |
tree | f125cb943f7ce16e06b28089fb721e6d38d26482 | |
parent | 318f71bad51d0fe977a4101cbf764f70de4e5777 (diff) | |
download | basta-a4190442eacb8b8944761aad6d48d9c165b8ce6f.tar.gz basta-a4190442eacb8b8944761aad6d48d9c165b8ce6f.tar.bz2 basta-a4190442eacb8b8944761aad6d48d9c165b8ce6f.zip |
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.
-rw-r--r-- | basta.sh | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -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 |