Commit Graph

17 Commits

Author SHA1 Message Date
Georgi Dimitrov 50a8461fbf fix: race condition on repaint 2022-06-04 15:35:59 +02:00
Christian Muehlhaeuser 3795c036c4
add: Exec, ReleaseTerminal and RestoreTerminal to re-use input and terminal (#237)
* 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>
2022-04-12 10:23:10 -04:00
Ayman Bagabas 42cd4c3191 feat: kill the program and restore terminal state
* Add Kill() to force kill the program from the outside
* Prevent renderer channel from being closed multiple times
2022-02-08 10:13:05 -08:00
Christian Rocha bef2c8ce66 Always redraw when toggling the altscreen 2022-01-07 13:21:43 -05:00
Christian Rocha 119144e78c ANSI compression is now opt-in via the WithANSICompressor program option 2021-10-30 13:04:27 -04:00
Christian Muehlhaeuser c29912c179 Enable ANSI compressor
With this change all ANSI output will be piped through an ANSI compressor that
eliminates redundant ANSI sequences. As such the compressor can be considered
"lossless".
2021-10-28 09:45:43 -04:00
Christian Rocha b957c32c18 Fix a bug where explicitly ignored lines weren't honored by the renderer 2021-06-22 13:06:55 -04:00
Christian Rocha 6547773a3f Clear output and render "nothing" when a view returns the empty string
Closes #100.
2021-06-02 14:49:54 -04:00
Christian Rocha 1f773e8f20 Fix a race where artifacts could print when exiting a program
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.
2021-06-02 14:49:54 -04:00
Christian Rocha 3256fae4d4 Force a full repaint when resizing the window
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.
2021-05-31 10:37:32 -04:00
Christian Rocha 70be13948a Re-render all lines if the total number of lines increases
If the number of lines increased there's a chance that the increase in
lines caused the terminal to scroll (even in the altscreen). Because of
this we must repaint everything, as skipping lines will mis-render.

Thanks to @fiws for reporting this bug.
2021-05-14 20:04:40 -04:00
Christian Rocha fb64f34bd0 Only render lines that have changed since the last render 2021-05-10 12:28:49 -04:00
Kiyon 2d602a1244 Remove redundant lock in listen 2021-04-08 03:47:22 +02:00
Kiyon 1ee40507ef Add lock for updating width and height 2021-04-08 03:45:08 +02:00
Christian Rocha 9d89d162c2 Clear the bottom line before exiting 2021-03-18 13:10:32 -04:00
Christian Muehlhaeuser a72db29ae0 Mutex protect buffer access in standard renderer 2021-03-13 04:31:34 +01:00
Christian Rocha b3f62af8b5 Add nil renderer and combination TUI-daemon program example
The Nil Renderer essentially disables the Bubble Tea renderer sending
loggings and print statements to stdout. It can be enabled via the
ProgramOption WithoutRenderer.
2021-03-07 13:01:54 -05:00