From d16f5cc9074b2c03fe870d4df3caea564c84fda7 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 31 Dec 2024 17:16:42 -0800 Subject: 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. --- basta.sh | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) 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) -- cgit v1.2.3