* feat: add OSExec helper function for running exec.Cmds
* chore: for now, un-expose WrapExecCommand
* chore: move exec struff into its own file
* chore(exec): better name for Exec func that wraps exec.Cmd (thanks, @toby)
* add: program.ReleaseTerminal and RestoreTerminal to re-use input & terminal
* chore(examples): add altscreen toggling to exec demo
* chore: put low-level altscreen stuff alongside other screen funcs
* docs: edit GoDocs for ReleaseTerminal and RestoreTerminal
* feat(renderer): add internal Msg renderMsg to immediately repaint
* fix: repaint instantly on RestoreTerminal
* fix: restore the altscreen state when restoring the terminal
* feat: implement Cmd-based API for blocking *exec.Cmds
* feat: allow Exec to return custom messages
* feat: allow Exec to be run without a callback
* fix: separate parameters for exec.Command examples
* fix: error message would get printed over by prompt in exec example
* fix: ignore signals while child process is running
* feat: allow to execute other things besides exec.Commands (#280)
* feat: allow to execute other things besides exec.Commands.
* fix: lint issues
* fix: renames, examples
* fix: callback type should be exported
* docs(exce): tiny ExecCommand doc comment correction
* chore(exec): break out Cmd for clarity's sake in example
* fix(exec): give the terminal a moment to catch up if exiting altscreen
* docs(exec): tidy up doc comments
* chore(exec): disambiguate methods for restoring the terminal state vs input
Co-authored-by: Christian Rocha <christian@rocha.is>
Co-authored-by: Carlos A Becker <caarlos0@gmail.com>
Race condition bug: Start() is called in a new gorotuine, then Send(). If the
Send happens before the msgs channel is allocated, the message is dropped.
Instead allocate the channel in the constructor, so msgs is never nil.
Signed-off-by: Christian Stewart <christian@paral.in>
Sometimes it is useful to obtain the final model after the
program has finished. Add StartReturningModel() (Model, error),
so that it is possible to obtain the final model.
Make sure to keep the original Start() error function, so that
everything is backwards compatible.
This commit implements cancelable reads, which allows Bubble Tea programs to run in succession in a single application. It also makes sure all goroutines terminate before `Program.Start()` returns.
Closes#24.
This commit also contains some refactors:
* Refactor away inputStatus type
* Refactor away program.inputIsTTY member
* Simplify how we setup and restore input when it's a TTY
This commit also consolidates the exit operations for consistency's
sake, and adds a kill() method to renderers for stopping them without
performing any final rendering.
Because they run ansyncronously, the analogous commands, when run in
a Model's Init() function, could fire after the renderer has starting
writing to output, rendering artifacts to the commandline.
v0.13.4 introduced a regression where lines weren't always cleared when
resizing the window resulting in the presence of rendering artifacts.
This commit fixes that.
The golang.org/x/crypto/ssh/terminal package is deprecated and merely a
wrapper around golang.org/x/term. Use the latter directly and avoid the
dependency on the former altogether.
* Add commands EnterAltScreen and ExitAltScreen for toggling the altscreen
* Add altscreen toggling example
* ignore .idea
Co-authored-by: Christian Rocha <christian@rocha.is>
The Nil Renderer essentially disables the Bubble Tea renderer sending
loggings and print statements to stdout. It can be enabled via the
ProgramOption WithoutRenderer.