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.
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.
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.
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.
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
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.
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.
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
* 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>
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.
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.
* 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
* 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>
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.
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 Nil Renderer essentially disables the Bubble Tea renderer sending
loggings and print statements to stdout. It can be enabled via the
ProgramOption WithoutRenderer.