diff options
-rw-r--r-- | basta.sh | 23 |
1 files changed, 14 insertions, 9 deletions
@@ -17,11 +17,14 @@ basta_deferred_intr=${basta_deferred_intr-} basta.query_terminal_lines() { local -n intovar=$1 + local result local curline printf $'\e7\e[999;999H' basta.get_cur_line curline + result=$? printf $'\e8' intovar=$curline + return $result } basta.query_termios_lines_cols() @@ -37,7 +40,10 @@ basta.query_termios_lines_cols() basta.prepare_term() { local realrows - basta.query_terminal_lines realrows + + if ! basta.query_terminal_lines realrows; then + return 1 + fi if [ -z "$basta_prev_reserved_rows" ] ; then basta_prev_reserved_rows=${#LC_basta_status[@]} @@ -61,6 +67,7 @@ basta.get_cur_line() local IFS="[;" set -- $response intovar=$2 + [[ "$intovar" =~ ^[0-9]+$ ]] } if [ $EPOCHSECONDS ] ; then @@ -142,15 +149,13 @@ basta.check_cursor() local curln local realrows - basta.get_cur_line curln - - if [ $curln ] && [ $curln -gt $basta_scroll_lines ]; then + if basta.get_cur_line curln && [ $curln -gt $basta_scroll_lines ]; then printf $'\e[%s;1H' $basta_scroll_lines fi basta_last_check_epoch=$now - basta.query_terminal_lines realrows + basta.query_terminal_lines realrows && [ $LINES -eq $((realrows - $basta_prev_reserved_rows - 1)) ] return $? fi @@ -351,10 +356,10 @@ basta.fullscreen_alt() { basta_deferred_intr=WINCH LINES=$realrows command "$@" || exit=$? - basta.query_terminal_lines realrows >&$ttyfd <&$ttyfd - basta.get_cur_line curline >&$ttyfd <&$ttyfd - - if [ $curline -ge $(( realrows - basta_prev_reserved_rows )) ] ; then + if basta.query_terminal_lines realrows >&$ttyfd <&$ttyfd && + basta.get_cur_line curline >&$ttyfd <&$ttyfd && + [ $curline -ge $(( realrows - basta_prev_reserved_rows )) ] + then local scrolls_needed=$(( curline - realrows + basta_prev_reserved_rows )) printf $'\e[%s;1H' $realrows >&$ttyfd for (( i = 0 ; i < scrolls_needed; i++ )) ; do |