| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
| |
* basta.sh (basta.fullscreen): The args that we calculated
with the help of printf %q is shell syntax; it must be double
quoted when we eval.
|
|
|
|
|
|
|
| |
* basta.sh (basta.fullscreen): We must take the
arguments for the program after recognizing and
removing the function's options, otherwise we
treat those options as part of the command.
|
|
|
|
|
|
|
|
| |
* basta.sh (basta.fullscreen): Move the calculation of the
args variable to the top. It was not yet set in the case when
we run the command without fullscreen and return
(because standard output is not a TTY, and -f had not
been specified).
|
|
|
|
|
|
|
|
|
|
|
| |
* basta.sh (basta.fullscreen): Separate option parsing
from side effects an do it earlier. Recognize a new -f
option, separately or clumped with -s. If -f is not
supplied and standard output is not a TTY, then
just execute the command and return, without doing
full screen.
* README.md: Documented -f option.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
There is a difference between Bash 4 and Bash 5. When a command
which has been invoked by syntax like:
command "$@"
is suspended by Ctrl-Z, Bash 4 shows, as the displayed job string,
the real program that is running, and its arguents. Whereas
Bash 5 just shows the above unexpanded 'command "$@"' syntax!
To work around this, we expand "$@" ourselves, and eval
an expanded command.
* basta.sh (basta.fullscreen): Expand the command arguments into
a properly escaped variable with the help of the %q argument of printf.
Then we eval the command. We keep the LINES=$realrows out of the
command, putting that into the eval, otherwise that will appear
in the jobs also. The cosmetics is improved. For instance if the
Bash 5 user has an alias like "alias vim='basta.fullscreen vim'",
and then runs "vim file" and suspends the editor into the background,
they will see "command vim file" as the job name, rather than
LINES=$realrows command "$@".
|
|
|
|
|
|
| |
* basta.sh (basta.update_status): Gnome Terminal just
prints ESC [ = 7 l rather than executing it.
Let's just drop these escapes.
|
|
|
|
|
|
|
|
|
| |
* basta.sh (basta.update_status): Eliminate the deep
flag. Always repaint all the status lines together.
Without this, if the user runs the reset command,
the lower status lines disappear. I.e. it worked
better with the bug whereby we were always setting
deep=y.
|
|
|
|
|
|
|
|
| |
* basta.sh (basta,update_status): Fix another bogus
use of || and && into if statement. We only want deep=y
to be evaluated whenever the test fails; i.e. to
do the deep repaint in the same case when we called
basta.prepare_term.
|
|
|
|
|
|
|
|
|
|
|
|
| |
* basta.sh (basta.fullscreen): Clear to to the end of screen
in the else case of testing for -s, and set
basta_deferred_intr there. It doesn't matter that we do this
clearing before resetting the scrolling region.
A a result, we don't have to test the $saveterm variable
again before running the command. The old
structure with || and && was not correct; the intent is
to set basta_deffered_intro to WINCH only if we are
not saving and restoring the terminal.
|
|
|
|
|
|
|
| |
* bast.sh (basta.query_terminal_lines): Remove unused
curline variable.
(basta.fullscreen): Likewise. Also move curly brace to
next line.
|
|
|
|
| |
* README.md: New section, Bugs.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* basta.sh (basta_executing): Don't preserve the value of this
variable when reloading. Set it to y, and then blank at
the end of the script when loading is about to end.
This fixes the bug: we had the variable set to y, and
so basta.interrupt was deferring signal handling.
(basta.initial_prompt_hook): Bind basta_executing to y
while running this funcion also, like basta.prompt_hook.
(basta.fullscreen): Also here; while running any command,
we don't need to handle ALRM signals, only while editing
the command line.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* basta.sh (badsta.fullscreen); Merges functionality of
basta.fullscreen_alt. When -s is not specified,
clears to end of screen, and calls
basta.ensure_bottom_margin. When calling this function,
we use the current value of $LINES rather than
recalculating realrows, removing one interaction to the
terminal. Since we are in full screen mode, we can
trust that $LINES is tracking the size.
When -s is specified, we don't clear to end of screen
or call basta.ensure_bottom_margin. Also we don't
need to provoke WINCH handling.
(basta.fullscreen_alt): Function removed.
* README.md: Documentation trimmed and revised.
|
|
|
|
|
|
|
|
|
|
|
|
| |
* basta.sh (basta.ensure_bottom_margin): New function,
factored off from basta.prepare_term.
(basta.prepare_term): Code for ensuring that screen contents
move out of status-sized bottom area now moved into
basta.ensure_bottom_margin.
(basta.fullscreen_alt): Complex logic involving knowing
the current line, moving the cursor to the bottom,
and scrolling a certain nummber of lines removed.
Replaced with call to basta.ensure_bottom_margin.
|
|
|
|
|
|
|
|
|
|
|
|
| |
* basta.sh (basta.prepare_term): The old logic of printing \n
ESC [ A (newline, go up one line) is inadequate when we have
multiple previous status lines to draw. It only works if the
previous status lines can be counted on to be already
scroll-protected. We need to print as many new lines as we
have status lines, and then move the cursor up that many
lines. Also, before doing this, we reset the scrolling region
to the full size. This same logic could simplify
basta.fullscreen_alt.
|
|
|
|
|
|
|
|
|
|
| |
* basta.sh (basta.fullscreen_alt): The worst case number of
scrolls needed is basta_prev_reserved_rows + 1, the height of
the status area, not not basta_prev_reserved_rows. Now the [
$scrolls_needed -ge 0 ] test is correct, and we don't we don't
need the extra newline in the final printf. The behavior
is now good in the cases when the command prints zero, one,
two, and three lines.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* basta.sh (basta.query_terminal_lines): Streamline
by passing received variable name down to get_cur_line,
avoding intermediate variable. We don't need a
nameref now since we are just passing the name down.
(basta.get_cur_line): Do not assign into the
variable and test for validity after; test "$2"
for validity and only if valid assign to variable.
This is taken advantage in basta.fullscreen_alt
where the original estimate $realrows is unaffected
if query_terminal_lines fails.
|
|
|
|
|
|
|
| |
* basta.sh (basta.fullscreen_alt): If not able to obtain
the current line and number of terminal lines from
the terminal, then assume that the worst case number
of scrolls are needed: size of the status area.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
From time to time get_cur_line doesn't fetch a value
due to a timeout or, more likely, interference
from TTY input. We have to check those situations
so as not to try to calculate with a bad value or
pass it to stty or whatever.
* basta.sh (basta.query_terminal_lines): Propagate status now
returned by get_cur_line.
(basta.prepare_term): Skip logic and return failure if
query_terminal_lines failed, since realrows contains garbage.
(basta.get_cur_line): Return success if value obtained
is a string of one or more decimal digits.
(basta.check_cursor): Improve error checking.
(basta.fullscreen_alt): Error checks.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When the Bash completion stuff for git is loaded, it generates
a __git() function. That function's body calls the user's
expanded alias, such as "basta.fullscreen_alt git". This
expansion of the alias is baked into that function's code.
Other completion modules might do a similar thing.
The most prudent thing we can do is to assume that calls
to basta.fullscreen or basta.fullscreen_alt can happen
during tab completion, and in those cases just run the
command and bail without doing any full screen logic.
* basta.sh (basta.fullscreen, basta.fullscreen_alt): If
the $COMP_WORDS variable is not empty, run the command
and bail.
|
|
|
|
|
|
|
| |
* basta.sh (basta.fullscreen_alt): When calling
query_terminal_lines and get_cur_line, we must redirect
the input and output to $ttyfd, like we do for our
local printf and stty calls.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In the full screen functions, our strategy of disabling
fullscreen mode when standard input or output are redirected
is suboptimal. What we should be doing is opening /dev/tty
and doing our terminal interactions with that, and not
care that standard input and output are redirected.
* basta.sh (basta.fullscreen, basta.fullscreen_alt): Remove
the check for stdin and stdout not being a terminal,
which runs the command without fullscreen mode.
Open /dev/tty for reading and writing, retaining the
file descriptor in the ttyfd variable. Redirect all
tty interactions to this ttyfd descriptor.
|
|
|
|
|
|
|
|
|
|
| |
* README.md: Revised full screen documentation.
* basta.sh (basta.fullscreen): Recognize and consume
a -s option. If this is present, then issue the ANSI
escape sequence for saving the terminal before running
the command. Then issue the sequence for restoring
the terminal afterward.
|
|
|
|
|
|
|
|
|
|
|
|
| |
* basta.sh (basta.fullscreen, basta.fullscreen_alt): Only
perform the special fullscreening logic if the standard input
and output are a TTY. If either one is not a TTY, then just
run the command and return its status. Otherwise if the
program is redirected, the codes we send to the terminal
get mixed up in the output. This test isn't perfect, because
programs could bre redirected to a TTY which is not the
controlling TTY. This is rare to do, and users probably
won't be doing this with their basta.fullscreen aliases.
|
|
|
|
|
|
|
|
| |
* basta.sh (basta.cleanup): What we actually want to do is
restore the previous status line environment that we inherited.
We do this by deleting the entry that we added to the top
of the array and re-exporting the array.
(basta.unexport_array): Unused function removed.
|
|
|
|
|
|
|
|
|
|
| |
* basta.sh (basta.cleanup): Unexport the LC_basta_status
array. If we don't do this, then when the user performs
the recommended deep recycle on Basta, consisting of
manually invoking basta.cleanup followed by exec bash,
the user will see an extra status line. The executed
program sees the environment published by the previous
instance, which Basta interprets as status line recursion.
|
|
|
|
|
|
|
|
|
|
|
| |
* basta.sh (basta.prompt_hook): Exchange the order of
update_status and do_exit_status. When we are coming out
of fullscreen, if we print the exit status, it ends
up in the wrong place due to how we moved the cursor.
(basta.fullscreen, basta.fullscreen_alt): Disable SIGINT
around most of the function so the command is interrupted,
but the function isn't.. Capture the exit status and return
it. This way the function doesn't bail.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
- A basta_executing flag is introduced. The ALRM and WINCH
interrupts will not execute basta.update_status if the
flag is true (nonblank). The flag is false while the
command line is being edited.
- When an interrupt finds the basta_executing true,
it stores its keyword into basta_deferred_intr.
Code later is then aware that the interrupt happened
and can take some action. We take advantage of this
to cancel the holdoff time in basta.check_cursor,
and in the fullscreen functions to fake a WINCH,
which basta.check_cursor and basta.prompt_hook
will react to. Launching an an editor in full screen
and quickly exiting it is now perfectly reliable;
the cursor deosn't briefly end up in the status area.
* basta.sh (basta_executing, basta_deferred_intr): New
global variables.
(basta.check_cursor): Ignore the 3 second hold-off
period if a deferred interrupt has been recorded.
We could probably specifically check for it being WINCH
here, but this is fine.
(basta.prompt_hook): Initialize the winch variable
from basta_deferred_intr, so that we will force a
fulle rupdate if a WINCH interrupt balked.
Set the basta_executing flag over the execution
of the update logic. Clear basta_deferred_intr,
but not after basta.check_cursor has had a chance
to look at it.
(basta.interrupt): New function: the interrupt hooks
now point to this function.
(basta.install_hooks): Point ALRM and WINCH traps
to basta.interrupt.
(basta.fullscreen, basta.fullscreen_alt): Pretend
that a WINCH interrupt was just deferred, so the
update logic in basta.prompt_hook will react as
described above, to expedite the cursor out-of-bounds
:heck, and update of the status area.
|
|
|
|
|
|
|
|
| |
* basta.sh (basta.update_status): When repainting the parent
status lines, just disable wrap mode and enable it again.
Saving and restoring the terminal is doing weird things in
some terminals, like very quickly flashing some previously
saved screen.
|
|
|
|
|
| |
* basta.sh (basta.fullscreen_alt): Fix transposed ' and $
in $'...' literal for clearing to end of screen.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* basta.sh (basta.fullscreen_alt): More nicely handle any
program. Clear to the end of screen before the program runs to
get rid of the status lines, so that the program's output
does not get mingled with them. Do the correct amount of
scrolling based on the cursor position observed after the
program has run, so that the program's last line of output is
above the status area, plus prompt space.
* README.md: Recommend basta.fullscreen_alt for git, because
git doesn't always launch an editor or pager.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Starting with this comming, Basta will no longer look at the
difference between `$LINES` and the measured terminal size to
determine the presence of existing status lines.
Basta now maintains an array of status lines. Each recursive
instance adds a status line to the array. The array is
propagated through the environment via numbered environment
variables.
The names of the array variables is chosen in the LC_*
namespace such that they will propagate across ssh sessions;
because Debian, Ubuntu and perhaps other distros configure
OpenSSH to pass variables in this namespace.
* README.md: Documented and spellchecked.
* basta.sh (basta.prepare_term): Do not calculate
basta_prev_preserved_rows as the difference between realrows
and LINES. Instaed, measure the LC_basta_status array.
(basta.update_status): When doing a full refresh,
repaint the status lines provided to us from any parent
Basta sessions. We don't try to fit these to the terminal
width; instead we put the terminal in non-wrapping mode
temporarily. Also, when calculating the current (topmost)
status line, stick it into the topmost position in the
array and update the environment variables from the array.
(basta.check_cursor): Small off-topic change here. We
adjust the holdoff time from 5 seconds to 3 seconds.
I'm finding 5 to be a little too slow.
(basta.export_array, basta.import_array,
basta.unimport_array): New functions.
(basta.fullscreen, basta.fullscreen_alt): remove the hack
of exporting an incremented value of basta_prev_reserved_rows
into the environment. No such thing is now required for
any nested Basta session run out of an editor to reserve
its status line above existing status lines.
In basta.fullscreen_alt we also fix a variable name typo.
|
|
|
|
|
|
|
|
|
|
|
|
| |
- basta.fullscreen sets LINES also in addition to stty rows,
and also resets the scrolling region.
- bata.fulscreen_alt uses an escape sequence to move to the
last line instead of multiple \n characters.
Additionally, after moving to the last line, it issues
some newlines to scroll the screen, so that any material
printed by the executed program is out of the way of the
status area (taking into account stacked status lines).
|
| |
|
|
|
|
|
|
|
| |
- When you invoke `basta.fullscreen command [arg ...]`, the external
command `command` will make full use of the terminal. This
can be set up as an alias for certain commands, like your favorite
text editor.
|
|
|
|
|
|
| |
- Some advice about Bash configuration for people who are not Bash
experts. Bash trips people up by reading different config files
when run as a login shell versus non-login shell.
|
|
|
|
|
|
|
|
| |
- We take advantage of the $EPOCHSECONDS variable available in
newer Bash to get the current time. We don't perform the
cursor position or resize check in basta.check_cursor if
it has been done in the last 5 seconds, in addition to
continuing to avoid it if there is buffered TTY input.
|
|
|
|
|
|
|
|
|
|
|
|
| |
- 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.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
- When SIGWINCH and SIGALRM are received and we are calling
basta.update_status because of that, pass in an argument
which allows that to be distinguished. basta.update_status
will call basta.prepare_term if it was invoked because
of SIGWINCH, even the apparent terminal size has not
changed.
- One upshot of this is that the user can recover a broken
scrolling region now by doing "kill -WINCH $$",
which will work even in the pathological situation when
the full screen is scrolling, and basta_scroll_lines,
LINES and stty rows all contain the same value (the
full screen height).
|
|
|
|
|
|
|
|
| |
- When we query the current line from the terminal, there
are situations when that might time out and yield a blank
response. In basta.check_cursor, we guard against that, or
else the user may, rarely, see a message complaining that
the [ command is missing an operand for the -gt operator.
|
|
|
|
|
|
|
| |
- I suspect this is involved in the bug I'm seeing whereby
the scroll region goes wonky. It may be preventing our
logic from kicking in to fix the situation, by making
termios_lines equal LINES and to basta_old_lines.
|
|
|
|
|
| |
- We get rid of 'local esc=$(printf "\033")' everywhere and
use the escape sequence.
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
- In the basta.update_status function's path abbreviating
loop, we must test whether the path can be abbreviated,
and bail, before doing the abbreviation. If we do the
test after the abbreviation, we create a one off error
where we bail the loop with an overlong status line that
does not fit even though we could have abbreviated the
path by one more component. And then the status line
is surprisingly blanked.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
- 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.
|
|
|
|
|
|
|
|
| |
- We calculate the final LINES value unconditionally whether
or not it is the first call that sets basta_prev_reserved_rows.
Then we just copy that value into basta_scroll_lines and
basta_old_lines. We don't rely on the side effect of the
"stty rows" command setting LINES.
|
|
|
|
|
|
|
|
|
| |
- In basta.prepare_term, if we already know how many reserved
rows there are, we should not be calling
bsata.query_terminal_lines to get the real terminal size
into LINES. We need to get that into a local variable and
then subtract form that the lines we know are reserved,
and use that for setting the number of lines.
|
|
|
|
|
|
|
|
| |
- the basta.query_terminal_lines function is invoked
by a caller which passes in a variable name realrows.
If the function has a same-named local variable,
the name wrongly refers to that variable.
We rename the local to curline.
|