aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2023-09-15 23:05:41 -0700
committerKaz Kylheku <kaz@kylheku.com>2023-09-15 23:11:47 -0700
commit191cdeac843e91e4316f76d4fa2d3f3337c7830d (patch)
tree7e06f79b8931f2f8f24954f332a73e79c699b7df
parentb04c417e4f0ac09377c037cd5ecba8280ea805da (diff)
downloadbasta-191cdeac843e91e4316f76d4fa2d3f3337c7830d.tar.gz
basta-191cdeac843e91e4316f76d4fa2d3f3337c7830d.tar.bz2
basta-191cdeac843e91e4316f76d4fa2d3f3337c7830d.zip
bugfix: regression: cursor jumps to first line on startup
This is a regression caused by commit f68dc7ccb1489dabce1fd3997a7c59e39b23b4ad Date: Tue Aug 29 11:51:07 2023 -0700 Subject: bugfix: don't use $LINE to initialize basta_scroll_lines. Issue is that if we initialize basta_scroll_lines to zero, the basta.check_cursor function reacts to it, and not very well. It moves the cursor to the top of the screen. - We add a new function basta.initial_prompt_hook which is installed at startup. This function doesn't do any processing of the exit status of the previous command (there isn't one) and doesn't call basta.check_cursor. - basta.initial_prompt_hook changes the hook to basta.prompt_hook after one call. The basta_scroll_lines variable is initialized at that point, so all is well. - with this approach, there is no added run-time check for "is basta_scroll_lines initialized".
-rw-r--r--basta.sh10
1 files changed, 9 insertions, 1 deletions
diff --git a/basta.sh b/basta.sh
index cc2fa0d..ce12a34 100644
--- a/basta.sh
+++ b/basta.sh
@@ -103,6 +103,14 @@ basta.do_exit_status()
basta_old_cmdno=$cmdno
}
+basta.initial_prompt_hook()
+{
+ local exit=$?
+ stty raw -echo onlcr opost
+ basta.update_status
+ stty sane rows $basta_scroll_lines
+ PROMPT_COMMAND='basta.prompt_hook'
+}
basta.prompt_hook()
{
@@ -147,7 +155,7 @@ basta.cleanup()
printf "Basta!\n"
}
-PROMPT_COMMAND='basta.prompt_hook'
+PROMPT_COMMAND='basta.initial_prompt_hook'
if ! [ $basta_status_alarm_pid ] ; then
trap basta.update_status ALRM