diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2024-12-31 17:16:42 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2024-12-31 17:16:42 -0800 |
commit | d16f5cc9074b2c03fe870d4df3caea564c84fda7 (patch) | |
tree | 41cc63ef0236f0ca0e13599fcda7e55dbba830af | |
parent | 7fbdc5a088c37bd24da5954474a189cd4c890dce (diff) | |
download | basta-d16f5cc9074b2c03fe870d4df3caea564c84fda7.tar.gz basta-d16f5cc9074b2c03fe870d4df3caea564c84fda7.tar.bz2 basta-d16f5cc9074b2c03fe870d4df3caea564c84fda7.zip |
Check the termios rows and columns for sanity.
- In basta.update_status, we should be checking not only for
LINES and COLUMNS changing, but also for the underlying termios
parameters changing (which we can obtain using stty size).
The motivation for this change is that I'm still seeing situations
in which the scroll region gets messed up. I can get Basta to fix
it by manually setting basta_old_lines to 0 to force
basta.update_status to call basta.prepare_term.
That tells me that the problem is that basta_old_lines is
equal to $LINES. I've not root-caused the issue, though. The
hypothesis is that perhaps $LINES has become incorrect: perhaps Bash
didn't set LINES to the size that the kernel knows about and has
set up in termios. We can catch that discrepancy.
-rw-r--r-- | basta.sh | 19 |
1 files changed, 18 insertions, 1 deletions
@@ -21,6 +21,17 @@ basta.query_terminal_lines() intovar=$curline } +basta.query_termios_lines_cols() +{ + local esc=$(printf "\033") + local -n linesvar=$1 + local -n colsvar=$2 + local pair=$(stty size) + set -- $pair + linesvar=$1 + colsvar=$2 +} + basta.prepare_term() { local realrows @@ -55,9 +66,15 @@ basta.update_status() local esc=$(printf "\033") local pwd=$PWD local dots= + local tio_lines + local tio_cols + + basta.query_termios_lines_cols tio_lines tio_cols [ $LINES -eq $basta_old_lines -a \ - $COLUMNS -eq $basta_old_cols ] || basta.prepare_term + $COLUMNS -eq $basta_old_cols -a \ + $LINES -eq $tio_lines -a \ + $COLUMNS -eq $tio_cols ] || basta.prepare_term local status_esc="$esc[7m$esc[m" local status_date=$(date +%m-%d/%H:%M) |