diff options
-rw-r--r-- | basta.sh | 39 |
1 files changed, 30 insertions, 9 deletions
@@ -5,6 +5,7 @@ basta_old_cmdno=${basta_old_cmdno-0} basta_old_lines=${basta_old_lines-0} basta_old_cols=${basta_old_cols-0} +basta_last_check_epoch=${basta_last_check_epoch-0} basta_scroll_lines=${basta_scroll_lines-0} basta_prev_reserved_rows=${basta_prev_reserved_rows-} @@ -58,6 +59,20 @@ basta.get_cur_line() printf "%s\n" "$2" } +if [ $EPOCHSECONDS ] ; then + basta.epoch() + { + local -n intovar=$1 + intovar=$EPOCHSECONDS + } +else + basta.epoch() + { + local -n intovar=$1 + intovar=$(date +%s) + } +fi + basta.update_status() { local pwd=$PWD @@ -97,18 +112,24 @@ basta.update_status() basta.check_cursor() { if ! read -t 0; then - local exit=$? - local curln=$(basta.get_cur_line) - local realrows + local now + basta.epoch now - if [ $curln ] && [ $curln -gt $basta_scroll_lines ]; then - printf $'\e[%s;1H' $basta_scroll_lines - fi + if [ $((now - 5)) -ge $basta_last_check_epoch ] ; then + local exit=$? + local curln=$(basta.get_cur_line) + local realrows - basta.query_terminal_lines realrows + if [ $curln ] && [ $curln -gt $basta_scroll_lines ]; then + printf $'\e[%s;1H' $basta_scroll_lines + fi - [ $LINES -eq $((realrows - $basta_prev_reserved_rows - 1)) ] - return $? + basta_last_check_epoch=$now + + basta.query_terminal_lines realrows + [ $LINES -eq $((realrows - $basta_prev_reserved_rows - 1)) ] + return $? + fi fi return 0 |