Commit graph

48 commits

Author SHA1 Message Date
赵鑫亿
9806b0c763
fix(exec): clear View before releasing terminal for subprocess (#1762)
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Drew Smirnoff <drew@charm.land>
2026-11-12 17:23:45 +04:00
Viktor Danov
e4d617e7e0
perf(renderer): stop the frame ticker while nothing changes (#1832)
Co-authored-by: Drew Smirnoff <drew@charm.land>
Signed-off-by: Drew Smirnoff <drew@charm.land>
2026-11-09 14:55:22 +04:00
Ayman Bagabas
742b944f78
feat(render): enable Unicode mode (2027) for accurate width calculation (#1584)
When the terminal supports it, we now enable Unicode mode (ANSI mode
2027) to ensure accurate width calculation for wide characters and
emojis. This improves rendering fidelity in terminals that support this
mode.
2026-02-13 15:36:47 +03:00
Ayman Bagabas
61a3f5ccf8
fix(render): execute insert above immediately (#1576)
This commit modifies the behavior of the `insertAbove` method in the
renderer to execute the insertion of lines immediately rather than
queuing them for later processing. This change ensures that lines are
inserted above the current view without delay.
2026-02-05 12:46:27 +03:00
Ayman Bagabas
d1cf96d0d3
refactor: limit view callback to onMouse for mouse events 2025-11-24 10:34:05 -05:00
Ayman Bagabas
0b472523ea
feat: add view callback support
This change replaces the previous hit testing mechanism with a more
flexible callback function in the View struct. This allows views to
handle messages directly, enabling more customizable behavior that is
not limited to mouse hits.
2025-11-20 18:38:59 -05:00
Ayman Bagabas
f1799cdf05
feat: add synchronized updates option to renderer interface 2025-11-13 13:48:55 -05:00
Ayman Bagabas
4accb1c4d5 fix: renderer: avoid requesting keyboard enhancements on close
When the renderer is being closed, we should avoid requesting kitty
keyboard enhancements so that we don't leave the terminal with unhandled
input sequences.
2025-10-30 14:37:41 -04:00
Ayman Bagabas
0c3e204210
chore: remove unused repaint method from nilRenderer
Fixes: e9e4d1d87b (fix: renderer: remove unused repaint functionality)
2025-10-14 15:06:41 -04:00
Ayman Bagabas
78e3b36c60
fix: remove resetLinesRendered calls around exec
Resetting the lines rendered around exec was causing issues with cursor
position after exec commands. For example, if you want to persist the
output of your program after an exec command that uses the altscreen,
this would break that functionality.

We really need to choose one behavior or the other here, and I think
removing these calls is the right choice.

Reference: https://github.com/charmbracelet/bubbletea/pull/1276
Reference: https://github.com/charmbracelet/bubbletea/issues/1275
2025-10-14 13:34:51 -04:00
Ayman Bagabas
6c1e051b72
refactor: make renderer flush method not require Program parameter and
wrap errors
2025-10-01 13:50:40 -04:00
Ayman Bagabas
fb3e0a4a3e
refactor: lean more into the View struct to manage terminal state 2025-10-01 13:50:37 -04:00
Ayman Bagabas
f4c5598bfc
Merge branch 'v2-exp' into v2-exp-tv-io-viewable 2025-07-07 16:49:52 -04:00
Ayman Bagabas
911530d0a3
Merge branch 'main' into v2-exp 2025-07-07 16:42:38 -04:00
Ayman Bagabas
f1eadf45ea
feat: embed mouse events in hit messages 2025-06-02 13:02:37 -04:00
Ayman Bagabas
1e6aaa5c27
feat: implement hit detection for layers in cursed renderer 2025-06-02 11:41:12 -04:00
Ayman Bagabas
69b915ac1e
feat: add support for setting terminal window title using the View API 2025-06-02 10:14:36 -04:00
Ayman Bagabas
a73e08428e
feat: support setting terminal fg/bg using the View API 2025-06-02 09:58:51 -04:00
Ayman Bagabas
31fb5031cc
feat: update to use uv package 2025-05-30 17:44:58 -04:00
Ayman Bagabas
98f59a47be
feat: implement viewable model and layers
This implements a new `ViewableModel` interface that allows the main
model to return a view composed of multiple layers. The layers can be
rendered and composed together, and the cursor can be included in the
view. This change allows for more complex terminal UIs that can be
composed of multiple layers, each with its own content and properties.
2025-05-27 18:19:29 -04:00
Ayman Bagabas
33dd5b01ba
refactor: rework tracing and use a standalone logger 2025-05-19 13:23:45 -04:00
Raphaël Vigée
78ed49b060
fix: maintain exec output (#1276)
* Maintain exec output

* add test

---------

Co-authored-by: Ayman Bagabas <ayman.bagabas@gmail.com>
2025-05-13 12:27:50 -04:00
Ayman Bagabas
9087113343
feat,refactor!: introduce cursor model (#1303)
This introduces a new `CursorModel` interface that can be implemented by
the main model to provide a cursor position and style. A nil cursor will
hide the cursor. Otherwise, the cursor will be shown at the position and
with the style specified. Use `NewCursor` to quickly create a cursor for
a given position with default styles. This method is called in-sync with
the `Model.View` method.

It also removes the previously introduced `Frame` type and `NewFrame`
function. The main model can now return a `string` to render the program's
UI. The main model can return a `Cursor` to set the cursor position and
style.

The old `Init` method is now back and it returns a `Cmd` instead of a
both a `Model` and a `Cmd`. This is to make the mental model more straight
forward, and to keep things backwards compatible.
2025-02-04 12:47:23 -05:00
Ayman Bagabas
d93aa0090d
refactor!: model stringer interface 2025-01-23 14:58:43 -05:00
Ayman Bagabas
023af98640
feat: add Frame type and remove cursor commands
This commit introduces a new `Frame` type that represents a single frame of
the program's output. The `Frame` type contains the frame's content and cursor
settings. The cursor settings include the cursor's position, style, blink, and
visibility.

It also removes the cursor commands from the `tea` package. The cursor
commands are now part of the `Frame` type. The cursor commands were removed
because they were not idiomatic and were not flexible enough to support
additional cursor settings.

Supersedes: https://github.com/charmbracelet/bubbletea/pull/1293
2025-01-23 14:57:54 -05:00
Ayman Bagabas
04c0b438d1
refactor: use the cursed renderer for rendering and remove the standard renderer
This also removes the experimental flags and changes the renderer
interface to be more explicit about the methods that are available.
2025-01-13 08:19:40 +03:00
Ayman Bagabas
516b7cd4dc fix: renderer: nilRenderer doesn't need to be exported 2024-09-12 11:54:01 -04:00
Ayman Bagabas
614aa93d2c fix: renderer: don't return a Cmd on update 2024-09-12 11:54:01 -04:00
Ayman Bagabas
0fe006d28f feat: use the new renderer interface 2024-09-12 11:54:01 -04:00
Ayman Bagabas
e58efab371
feat: support focus-blur events (#1122)
* feat: support focus-blur events

This backports @caarlos0 focus-blur changes from v2-exp to v1 https://github.com/charmbracelet/bubbletea/pull/1081

Co-authored-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

* Update key_sequences.go

Co-authored-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

* fix: go mod tidy

---------

Co-authored-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
Co-authored-by: Christian Rocha <christian@rocha.is>
2024-08-30 09:20:01 -04:00
Ayman Bagabas
f31a5f352a
refactor: we don't care about renderer render errors 2024-08-21 16:02:15 -04:00
Ayman Bagabas
05f8399a93
feat: dry setting and retrieving terminal modes
Use Mode/SetMode instead of EnableAltScreenBuffer/DisableAltScreenBuffer
etc. This uses less code and makes it more usable in the future to
accommodate for more terminal capabilities and modes.
2024-08-21 16:02:02 -04:00
Ayman Bagabas
1f88b9ed6e
refactor: simplify renderer interface
Use Render instead of Write/WriteString
2024-08-20 17:11:04 -04:00
Ayman Bagabas
0825f6113d
feat: export nil renderer 2024-08-20 12:18:23 -04:00
Ayman Bagabas
53d72b4624
feat: add the ability to change the renderer output 2024-08-20 12:15:00 -04:00
Ayman Bagabas
c385aba97b
feat: add renderer Resize and InsertAbove 2024-08-20 12:14:59 -04:00
Ayman Bagabas
6f7f9e6492
feat: expose the renderer interface
This adds the ability to use a custom renderer using a modified version
of the existing `renderer` interface.
2024-08-20 12:14:59 -04:00
Ayman Bagabas
3075646dfd
refactor: bracketed-paste active state
Move tracking bp to the program instead of the renderer. The renderer
doesn't need to know about the state of bp and gains nothing from that
information.
2024-08-13 17:09:54 -04:00
Ayman Bagabas
7a49b33ec5
refactor: define renderer execute to write queries to the terminal
This replaces enable/disable directives with exception to alt-screen and
cursor visibility since those affect the renderer.
2024-08-13 11:17:04 -04: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
Raphael 'kena' Poss
2b46020ca0
feat: bracketed paste (#397)
* feat: bracketed paste

This introduces support for input via bracketed paste, where escape
characters in the pasted input are not interpreted.

Pasted input are marked as a special field in the KeyMsg. This is
useful because pasted input may need sanitation in individual widgets.

* fix(key): support bracketed paste with short reads

Some terminal emulators feed the bracketed paste data in multiple
chunks, which may not be aligned on a 256 byte boundary. So it's
possible for `input.Read` to return less than 256 bytes read
but while there's still more data to be read to complete a bracketed
paste input.

---------

Co-authored-by: Christian Muehlhaeuser <muesli@gmail.com>
2024-02-05 14:49:09 +01:00
Ayman Bagabas
a154847611
feat: extended Coordinates mouse reporting & additional buttons support (#594)
* feat(mouse): add extended mouse & shift key support

Support SGR(1006) mouse mode
Support parsing shift key press
Support additional mouse buttons
Report which button was released
Report button motion

* fix: key.go sgr len missing calculation (#841)

* chore(test): add sgr mouse msg detect test

---------

Co-authored-by: robinsamuel <96998379+robin-samuel@users.noreply.github.com>
2023-12-04 11:50:59 -05:00
Christian Muehlhaeuser
58c5e01d8c chore: fix linter warnings 2023-04-04 13:27:12 +02:00
Raphael 'kena' Poss
6e1065830a feat: support a Clear command 2022-10-04 06:01:52 +02:00
Christian Muehlhaeuser
ea36e19bee fix: move output handling to renderer 2022-10-04 05:06:42 +02: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
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