| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
| |
|
|
|
|
|
|
|
|
|
| |
- When the bracketed paste feature is enablied in GNU Readline,
then each time the library processes a SIGLARM signal, it
emits codes to turn off and on bracketed paste. In between
these codes, it also emits a CR character that causes the cursor
to jump to the beginning of the line. We work around this by
turning off bracketed paste.
|
|
|
|
|
|
|
|
|
|
|
|
| |
- Remove basta_uln_save variable.
- In basta.alarm_timer use nicer sequence for saving and
restoring $_, stashing it directly in the command's
expansion, without requiring the global variable, taking
advantage of our handler ignoring its arguments.
- Independently pointed out by Janis Papagnou and
Koichi Murase.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
- Remove Bugs section from README.
- Add new basta_uln_save global variable. We don't
have to preserve its value across reloads since it
is only temporarily used.
- The ALRM and WINCH traps set up by basta.install_hooks
are now three-command sequences which save $_ into
the global, then run the handler, and the restore
it using a trick involving the : null command.
|
|
|
|
| |
- In README.md add note about the unreliable value of $_.
|
|
|
|
|
| |
- in basta.initial_prompt_hook and basta.prompt_hook,
the three space indent should be two spaces.
|
|
|
|
|
|
|
| |
- New functions: basta.install_hooks, basta.remove_hooks.
- Mainline now calls basta.install_hooks instead of
setting traps and the prompt hook at the top level.
|
|
|
|
|
|
|
|
| |
- in basta.cleanup we kill $basta_status_alarm_pid.
This is not strictly necessary because the process
quits if the command kill -ALRM $$ fails. If the
parent's PID got recycled, though, it would keep
sending SIGALRM to the wrong process.
|
|
|
|
|
| |
- in basta.get_cur_line, the default answer should
be obtained from $LINES, not $ROWS.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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".
|
|
|
|
|
|
|
|
| |
- in the basta.update_status function we have a loop that
trims the path until it fits the status line.
In that loop we have no reason to be calling date
on each iteration; let's sample the date once into a
variable.
|
|
|
|
|
|
|
| |
- When a new interactive shell is launched, there is a time
before the LINE variable exists, so we end up initializing
basta_scroll_lines to a blank value, which causes bad
syntax in the comparison [ $curln -gt $basta_scroll_lines ].
|
|
|
|
|
| |
- basta.prepare_term is calling a nonexistent function
called basta.query_terminal_line.
|
|
|
|
|
|
|
|
| |
- The basta.calc_prev_reserved and basta.calc_current_size
funtions disappear, replaced by open code in
basta.prepare_term. Since basta.prepare_term
calls stty rows near bottom, we don't bring in the
stty rows call from basta.calc_current_size.
|
|
|
|
|
|
|
|
|
| |
- New function: basta.query_terminal_lines. This stores the
result into a variable specified by the caller. We use Bash's
Korn-inspired namerefs for this to avoid eval.
- basta.calc_prev_reserved and basta.calc_current_size
now call this function.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Basta should not trust that a changed value of LINES reflects
the terminal size. In cases when LINES is set to a bad value,
it leaves the display in a bad state: wrong scrolling region,
wrong status line position.
As a test, try a command like "LINES=3; stty rows $LINES".
Before this change, Basta will react and move the status line
to the third line, setting up a two-line scrolling region.
With this change, Basta isn't fooled; it asks the terminal.
- New function basta.calc_current_size interrogates the
terminal to get the size, just like
basta.calc_prev_preserved does. The function sets up
LINES and stty rows to the discovered terminal size.
- basta.prepare_term calls this function the second and
subsequent time it is called.
|
|
|
|
|
|
|
| |
- In basta.update_status and basta.check_cursor, we don't
refer to the current value of $LINES to inform us of the
usable window area, but rely on our calculated
basta_scroll_lines value.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
- New variable basta_scroll_lines tracks the correct
of LINES and tty rows.
- In basta.prepare_term, we set the value of this
variable. Also, bugfix: we were referring to some
nonexistent variables in the calculation.
Luckily the bogus term existing_reserved-rows
evaluated to 0.
- In basta.prompt_hook we set the tty rows to
basta_scroll_lines.
|
|
|
|
|
|
|
|
|
|
|
| |
- Rather than putting the TTY raw and then sane just in
basta.check_cursor, we do that in basta.prompt_hook.
This way, the bash.update_status code also runs in
raw mode. This change greatly reduces the spurious echoing
of typed-ahead characters, since less of our logic runs with
the TTY in echo mode. When I hold down Enter to repeat it,
it's almost entirely clean now; spurious blank lines are
much more rarely observed.
|
|
|
|
|
|
|
|
|
| |
- We don't save and restore the TTY settings. They might not
be good anyway. We go for "stty sane".
- Add -echo to raw mode. I'm seeing a glitch whereby if I hold
down the Enter key, sometimes I see ^M being echoed; this
makes it go away.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
I'm addressing the following problem. Sometimes the user types
a new command while a previous command is still running. This
typed-ahead input is buffered in the TTY. When we execute our
check to query the terminal "is the cursor out of bounds?"
there is a conflict between that buffered input and the query.
An imperfect fix is to check for the presence of unread input
and skip doing the cursor check.
This means that if the user runs some program that puts the
cursor out of bounds, and impatiently types ahead before
that command has completed, the cursor will go out of bounds.
- We break the basta.before_prompt function into two:
basta.check_cursor and basta.do_exit_status.
- In basta.check_cursor, we now temporarily put the TTY into
raw mode, so that the file descriptor can be polled for
the presence of any bytes whatsoever. If we don't do this,
read -t 0 will only report true (input is present) if
the user has typed Enter, due to canonical input processing.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
- In basta.get_cur_line, use a three second timeout
in the read call. If we don't time out and the
terminal doesn't respond in the right way or
characters are lost for whatever reason (noisy
serial line), the read will block forever waiting
for the delimiter.
- Without this change, if the user types "stty iuclc",
basta locks up. The R delimiter turns into r.
The only way to recover is to
"stty -ilcuc < /dev/<whatever>" from another terminal
and then go to the locked up session and type R.
|
|
|
|
|
| |
If Basta is sourced from ~/.bashrc, then it activates in
non-login shells, which is important.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is motivated by a behavior of Gnome Terminal. When the user
switches tabs in Gnome Terminal, the terminal session gets a resize
event, even if no resize took place. So our response to resizing must be
smooth; we can't be printing a blank linke and moving the cursor.
- In basta.prepare_term, we now avoid printing a blank
line and moving the cursor, except when this is called for the
first time. When this is called at other times, it is due
to a resize, and so we don't do anything.
- We now trap the SIGWINCH signal to the basta.update_status
signal. This addresses the glitch that would otherwise result,
because basta.update_status won't otherwise be called until
the user runs a command line, and that will take place with our
scrolling region reset to the full window size, clobbering
the status line.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before or after hot-reloading this change, run the command
"kill $update_status_alarm", since this will run a new
background process to update the status line.
- the update_status_alarm variable becomes properly
namespaced as basta_status_alarm_pid and is defined
at the top.
- the basta.basta_alarm_timer function is renamed
to basta.alarm_timer to drop the repetition.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The status line update is not tightly connected to the prompt;
it can be called at any time (and we are invoking it from an
alarm handler). Therefore it shouldn't be doing any prompt-
related processing.
- bash.update_status now only draws the status line and
restores the cursor. The alarm timer function continues
to calal bash.update_status.
- New function basta.before_prompt does the check whether
the cursor is out-of-bounds on the prompt (and this is
done first). Then it does the check whether a failed
termination status should be printed.
- New function basta.prompt_hook calls both of these
functions, and that function is now the PROMPT_COMMAND.
|
| |
|
| |
|
|
|
|
| |
- Remove stray character in basta.cleanup.
|
| |
|
| |
|
|
|
|
|
|
| |
- Global variables now begin with basta_.
- Functions begin with basta.
|
|
|
|
|
|
|
|
|
|
|
| |
- Save and restore cursor position
- Restore scrolling region to just one line more;
do not use exsiting_reserved_rows in calculation.
- Clear the existing status line, and print the
good-bye message Basta! which will go into that
space if the cursor is currently at the bottom.
|
|
|
|
|
|
|
|
|
|
|
|
| |
- On startup, determine how many bottom rows of the terminal
are already reserved by something, and remember this value.
- When resizing, observe this value; set the scrolling region
such that we protect the existing one.
- When terminating, restore the protection to the original
one found, or else reset the scrolling region.
Also bump up the stty rows again; don't leave it trimmed.
|
|
|
|
|
|
| |
- README.md: text updated.
- bash-prompt.sh renamed to basta.sh
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
- We put the update loop into a function;
the while loop now checks for the kill command
failing, and terminates, so that if the parent
shell disappears, the loop will quit,
even if it doesn't get a SIGHUP.
- We close the standard file descriptors.
- We trap SIGINT so that runs the null command.
This solves the issue that the process dies
due to a TTY interrupt (Ctrl-C) because it's
not a proper job control backgrounded task.
- We use the Bash disown command to remove the
process from Bash's job control list.
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|