Commit graph

27 commits

Author SHA1 Message Date
Cocoon-Break
729f05c315
fix: add missing signal.Stop in suspendProcess to prevent signal channel leak (Closes #1673) (#1674)
Each Ctrl+Z suspend call registered a SIGCONT channel via signal.Notify
but never called signal.Stop after receiving the signal. This caused a
signal channel leak on every suspend/resume cycle.

All other signal handlers in the codebase (handleSignals in tea.go and
listenForResize in signals_unix.go) correctly defer signal.Stop.

Signed-off-by: Cocoon-Break <54054995+kuishou68@users.noreply.github.com>
2026-04-13 08:46:47 -04:00
Ayman Bagabas
608155cf09
refactor: remove WithInputTTY option and related code 2025-10-01 13:50:33 -04:00
Ayman Bagabas
33dd5b01ba
refactor: rework tracing and use a standalone logger 2025-05-19 13:23:45 -04:00
Ayman Bagabas
28e82b66f2
fix: use platform specific termios settings to determine optimized cursor movements 2025-02-12 12:32:11 -05:00
Ayman Bagabas
076054da73
feat: renderer: optimize cursor movements with backspace
This updates the renderer to use backspace to optimize cursor movements
when the terminal supports it. This is similar to the hard tabs
optimization, but for backspace to move the cursor left.
2025-02-07 17:39:43 -05:00
Ayman Bagabas
777675cbe5
feat: use hard tabs to optimize cursor movements 2025-01-13 08:20:27 +03:00
Ayman Bagabas
9636413107 fix: use safeWriter to guard writing to output
This implements a wrapper around p.output that locks the output on every
write. We also need to redefine `channelHandlers` to be thread-safe
since `p.Kill()` can be called from a different thread while the program
is running.
2024-09-12 13:22:33 -04:00
Carlos Alexandro Becker
ea13ffb9a1
feat: allow to suspend bubbletea programs (#1054)
* feat: allow to suspend bubbletea programs

closes #497
closes #1053

* fix: typo

* fix: move things around, add example

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

* fix: block until CONT

* fix: ResumeMsg

* docs: improve example

* docs: one more example

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

* fix: examples tests

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

---------

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
2024-07-11 18:05:16 -03:00
Ayman Bagabas
cb801d8f2c
refactor: use x/term and x/ansi for renderer sequences (#962)
* refactor: use x/exp/term for renderer sequences

This replaces termenv.Output with raw sequences and a bytes.Buffer to
handle vt screen and cursor events.

* chore: update dependencies

* refactor: use x/term
2024-05-21 14:46:11 -04:00
Ayman Bagabas
46241068da
feat: reduce console/term dependencies (#897)
Replace mattn/isatty and containerd/console with golang.org/x/term.

This mostly affects Windows. On Windows, unlike Unix, the console (TTY)
has different handles for input/output. Using the Console API, we need
to enable VT input on the input handle (CONIN) and VT processing on the
output handle (CONOUT). Doing so enables processing VT sequences on
Windows i.e. ANSI colors, mouse sequences, cursor movements, etc.

We already handle enabling VT processing for the program output using
Termenv `EnableVirtualTerminalProcessing`. For the input side, we enable
VT input right before setting the console to raw.

By doing this, we can drop both containerd/console and mattn/isatty.
2024-03-01 15:53:09 -05:00
dustin-ward
3ee1489cf7 add support for z/OS 2024-02-05 14:52:33 +01:00
Christian Rocha
5bc2504690 chore(lint): wrap various TTY-related errors 2023-07-07 16:30:57 +02:00
aklyachkin
2c7890bdf5 enable compilation on AIX 2022-07-29 15:58:06 +02:00
Christian Muehlhaeuser
3afda07603 Annotate why we ignore error 2022-01-07 13:25:29 -05: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
d1fb02c39d Use the hot, new Go 1.17 build tags syntax 2021-09-07 16:13:48 -04:00
Christian Rocha
e1ca585c16 Simplify how we enable ANSI colors on Windows 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
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
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
64da3bcf7a Use correct output when enabling ANSI colors on Windows (see #39) 2020-12-30 22:23:19 -05:00
Christian Rocha
4d14af713f
Remove pkg/term dependency 2020-10-13 12:55:38 -04:00
Christian Rocha
3b8b011b5a
Rename to Bubble Tea (with the import name tea) 2020-05-25 19:48:36 -04:00
Christian Rocha
4bf40fbe62
Rename project to Boba 2020-05-12 16:39:08 -04:00
Christian Muehlhaeuser
bf92cd6cce
Add missing error handling 2020-04-17 20:35:54 +02:00
Christian Muehlhaeuser
f382f4db4a
Move ansi helpers to termenv 2020-01-31 13:52:20 +01:00
Christian Muehlhaeuser
bc67e3896b
Add platform-specific terminal init & restore 2020-01-25 07:15:29 +01:00