From 0a62c283a13c2f911ea660ce736ed522cde3c1b9 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Mon, 10 Feb 2025 01:33:49 -0800 Subject: Check for changed window size at prompt time. - In basta.check_cursor, we already query the terminal's current position via basta.get_cur_line, and avoid doing so if there is pending TTY input. Why don't we also check the screen size here. If it has changed, we yield a false return status. - In basta.prompt_hook, we check the return status of basta.check_cursor. If it is failed, then we add the WINCH parameter when calling basta.update_status. --- basta.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/basta.sh b/basta.sh index 0117f30..174dbd0 100644 --- a/basta.sh +++ b/basta.sh @@ -99,11 +99,19 @@ basta.check_cursor() if ! read -t 0; then local exit=$? local curln=$(basta.get_cur_line) + local realrows if [ $curln ] && [ $curln -gt $basta_scroll_lines ]; then printf $'\e[%s;1H' $basta_scroll_lines fi + + basta.query_terminal_lines realrows + + [ $LINES -eq $((realrows - $basta_prev_reserved_rows - 1)) ] + return $? fi + + return 0 } basta.do_exit_status() @@ -131,10 +139,12 @@ basta.initial_prompt_hook() basta.prompt_hook() { local exit=$? + local winch= + stty raw -echo onlcr opost - basta.check_cursor + basta.check_cursor || winch=WINCH basta.do_exit_status $exit - basta.update_status + basta.update_status $winch stty sane } -- cgit v1.2.3