Commit Graph

119 Commits

Author SHA1 Message Date
Christian Rocha 119144e78c ANSI compression is now opt-in via the WithANSICompressor program option 2021-10-30 13:04:27 -04:00
Niklas Johansson 56aa4efb60 tea: Add StartReturningModel()
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.
2021-10-28 14:19:46 -04:00
Christian Rocha 1f12bda862 Add program-level quit convenience method 2021-10-15 10:37:25 -04:00
Christian Rocha 0e7cd09bf6 Tidy up comments 2021-09-28 14:00:29 -04:00
Erik G e402e8b567
Cancelable reads (#120)
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.
2021-09-28 13:30:11 -04:00
Christian Rocha ad19c664fe Condense/scope init cmd 2021-09-07 15:37:14 -04:00
Christian Rocha ea0550121e Don't close the msgs channel on shutdown 2021-08-02 10:50:04 -04:00
Christian Rocha 5f41a91e02 Fix Windows stuff related to the refactor at 49a5d16 2021-08-02 10:50:04 -04:00
Christian Rocha 4bfad658ad Simplify how we listen for window resizes 2021-08-02 10:50:04 -04:00
Christian Rocha 30fd7a8f20 Better logic in input checks 2021-08-02 10:50:04 -04:00
Christian Rocha 9f9b3aea96 Read input regardless of whether or not it's a TTY
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
2021-08-02 10:50:04 -04:00
Christian Rocha 9826251f08 Add WithInputTTY ProgramOption 2021-08-02 10:50:04 -04:00
Christian Rocha e87344b791 Move ProgramOptions into a separate file 2021-08-02 10:50:04 -04:00
Christian Rocha 3a9ede46f6 Condense a scoped if-statement 2021-08-02 10:50:04 -04:00
Christian Rocha 0886ee26b0 Msgs can now be sent to Programs with Program.Send(Msg) 2021-07-01 11:06:21 -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 85ab476698 Add ProgramOptions for entering the altscreen and enabling the mouse
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.
2021-06-02 14:49:54 -04:00
Christian Rocha 035d2abd3e Properly cast inputStatus types + mark related linter false positive 2021-05-31 10:43:31 -04:00
Christian Rocha 3e98f55adf Add linter ignore rule for windows-related false positive on unix 2021-05-31 10:43:31 -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 c07cbd1e32 Pull batch processing into the internal message switch 2021-05-06 18:10:17 -04:00
Christian Rocha 4fbe50adb6 Disable mouse when exiting due to a panic 2021-05-05 18:11:56 -04:00
Christian Rocha 3dff6d4b58 Deprecate Program.EnterAltScreen Program.ExitAltScreen methods
The EnterAltScreen/ExitAltScreen commands should be used instead.
2021-05-05 18:11:56 -04:00
Christian Rocha 5c150ebf38 Add cmds for toggling mouse mode + deprecate equivalent Program methods
Also automatically disable mouse mode on exit.
2021-05-05 18:11:56 -04:00
Tobias Klauser 295f7bd246 Use golang.org/x/term
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.
2021-04-29 15:05:50 +02:00
Christian Muehlhaeuser d2c1d9bfb0 Omit unhandled error 2021-03-12 01:25:54 +01:00
Kiyon ac36017f86 WithOutput option should take io.Writer as argument. 2021-03-09 03:51:34 +01:00
kiyon 86b93a31c0
Add commands for toggling the altscreen (#62)
* Add commands EnterAltScreen and ExitAltScreen for toggling the altscreen
* Add altscreen toggling example
* ignore .idea

Co-authored-by: Christian Rocha <christian@rocha.is>
2021-03-08 12:48:34 -05: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
Christian Rocha 0780601791 Open a TTY if input is not a TTY, unless the user has spec'd otherwise 2021-02-27 16:03:34 -05:00
Christian Rocha 4e2643f318 Make sure we pass our mutex by reference 2021-02-27 16:03:34 -05:00
Carlos Alexandro Becker b2d948b53c Fixed a couple of typos
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
2021-01-17 15:58:50 +01:00
Christian Rocha 9f04c936da Always listen for SIGINT 2021-01-11 18:11:28 -05:00
Christian Rocha c4aeadd762 Generalize output from an *os.File to an io.Writer 2020-12-30 17:59:00 -05:00
Christoph Hartmann e84314c622 allow custom input and handle eof for os.input properly
Signed-off-by: Christoph Hartmann <chris@lollyrock.com>
2020-12-30 17:59:00 -05:00
Christian Rocha 8e01f5f58a Add command for hiding the cursor 2020-12-03 13:56:37 -05:00
Christian Rocha 6d70abd7d5 When showing/hiding the cursor operate on the program's io.Writer
Previously we were operating on io.Stdout.
2020-12-03 13:56:37 -05:00
Christian Rocha 480bdd41fc
Fix typo in doc comment + improve that comment 2020-10-18 12:43:41 -04:00
Christian Rocha 26899c73b3
Init, Update and View are now methods on interface Model 2020-10-15 16:08:19 -04:00
Kilian Drechsler 26477f70c0 print recovered panic message to terminal 2020-10-08 19:45:16 +00:00
Christian Rocha 3b9d076c80
Fix typo in comment 2020-10-05 14:42:09 -04:00
Christian Rocha fb48e03639
Gracefully recover from panics (but still print stack traces) by default 2020-09-21 13:14:24 -04:00
Christian Muehlhaeuser e634ad5341
Fix typo 2020-08-19 23:54:42 +02:00
Christian Rocha 6fcdf9908f
Improve examples in docs 2020-07-30 11:30:33 -04:00
Christian Rocha 17035473db
More documentation edits 2020-07-29 20:54:15 -04:00
Christian Rocha a5e38222c5
Don't expose ReadInput 2020-07-29 20:51:55 -04:00
Christian Rocha c0f67a2927
Improve GoDocs 2020-07-29 20:50:00 -04:00
Christian Rocha 2f53eeb54b
Fix a bug in macOS terminal where stuff could get sucked into the scroll area 2020-07-13 11:39:04 -04:00
Christian Rocha 8d26b4ebd7
Use mouse consts in termenv 2020-06-25 12:42:31 -04:00
Christian Rocha f3fd9decc9
Improve some comments 2020-06-24 12:14:35 -04:00