aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2024-12-31 17:16:42 -0800
committerKaz Kylheku <kaz@kylheku.com>2024-12-31 17:16:42 -0800
commitd16f5cc9074b2c03fe870d4df3caea564c84fda7 (patch)
tree41cc63ef0236f0ca0e13599fcda7e55dbba830af
parent7fbdc5a088c37bd24da5954474a189cd4c890dce (diff)
downloadbasta-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.sh19
1 files changed, 18 insertions, 1 deletions
diff --git a/basta.sh b/basta.sh
index cec8af5..6779c06 100644
--- a/basta.sh
+++ b/basta.sh
@@ -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)