diff options
-rw-r--r-- | basta.sh | 37 |
1 files changed, 15 insertions, 22 deletions
@@ -36,6 +36,18 @@ basta.query_termios_lines_cols() colsvar=$2 } +basta.ensure_bottom_margin() +{ + local i + local realrows=$1 + + printf $'\e7\e[1;%sr\e8' $realrows + for (( i = 0; i <= basta_prev_reserved_rows; i++ )); do + printf $'\n' + done + printf $'\e[%sA' $i +} + basta.prepare_term() { local realrows @@ -47,11 +59,7 @@ basta.prepare_term() if [ -z "$basta_prev_reserved_rows" ] ; then basta_prev_reserved_rows=${#LC_basta_status[@]} - printf $'\e7\e[1;%sr\e8' $realrows - for (( i = 0; i <= basta_prev_reserved_rows; i++ )); do - printf $'\n' - done - printf $'\e[%sA' $i + basta.ensure_bottom_margin $realrows fi LINES=$((realrows - $basta_prev_reserved_rows - 1)) @@ -359,23 +367,8 @@ basta.fullscreen_alt() { basta_deferred_intr=WINCH LINES=$realrows command "$@" || exit=$? - local scrolls_needed=$((basta_prev_reserved_rows + 1)) - - if basta.query_terminal_lines realrows >&$ttyfd <&$ttyfd && - basta.get_cur_line curline >&$ttyfd <&$ttyfd - then - : $(( 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 $'\e[%sA' $(( basta_prev_reserved_rows + 1 )) >&$ttyfd - fi + basta.query_terminal_lines realrows >&$ttyfd <&$ttyfd && + basta.ensure_bottom_margin $realrows >&$ttyfd exec {ttyfd}>&- |