Commit graph

11 commits

Author SHA1 Message Date
Ayman Bagabas
b947ade70d
refactor: change several message types to structs for extensibility 2025-11-04 14:01:26 -05:00
Ayman Bagabas
1805861a99
feat: separate view in its own interface
This change separates the viw from the main model by introducing new
interfaces `ViewModel` and `CursorModel`. The `ViewModel` interface
provides a view method that returns the string to render, while the
`CursorModel` interface provides a view method that returns the string
to render and the cursor position.

If a program does not implement a view interface, the program won't
render anything. This removes the need for the `WithoutRenderer` option.
2025-02-13 12:15:56 -05:00
Ayman Bagabas
99e3bbf892
refactor: rename CursorStyle to CursorShape 2025-01-23 16:08:53 -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
1ebb164f8b
chore: merge ferocious renderer (#1200)
~This implements a cell-based renderer instead of the existing
line-based one. The cell-based renderer will be used when
`TEA_EXPERIMENTAL=cellbuf` is exported.~ The cell-based renderer, now
called The Ferocious Renderer, is enabled by default. To disable it set
`TEA_EXPERIMENTAL=unferocious`.

To _trace_ the output of the program, you can export
`TEA_TRACE=<filename>` and `TEA_TRACE_OUTPUT=1` and/or
`TEA_TRACE_INPUT=1` to see the I/O of the program.

Supersedes: https://github.com/charmbracelet/bubbletea/pull/1132
2024-11-12 12:31:33 -05:00
Christian Rocha
d18aee523f
chore(cursor): invert SetCursorStyle blink argument (true=blink) 2024-11-06 17:41:19 -05:00
Ayman Bagabas
2142ea636a
feat: add RequestCursorPosition command 2024-11-05 10:09:12 -05:00
Ayman Bagabas
86d5db165a
feat: support setting cursor position (#1191)
* fix: cellrenderer: we need to repaint after clearing the screen

* fix: cellrenderer: reset cursor when at phantom cell

wip

* feat: cellrenderer: support setting cursor position

* fix: use x and y instead of row and column for CursorPositionMsg

This means we're now 0-indexed, which is consistent with the rest of the
library.
2024-10-28 13:39:23 -04:00
Ayman Bagabas
ad61ed6ff8 feat: support changing the cursor style
This commit adds support for changing the cursor style. The new
`SetCursorStyle` command can be used to change the cursor style to one of
the following:

- `CursorBlock`
- `CursorUnderline`
- `CursorBar`
2024-10-16 16:49:41 -04:00
Ayman Bagabas
cb37f8847e
fix: rename events to messages 2024-08-13 11:02:10 -04:00
Ayman Bagabas
13ffcad06c
refactor: reimplement the event loop with a sequence parser
Currently, Bubble Tea uses a simple lookup table to detect input events.
Here, we're introducing an actual input sequence parser instead of
simply using a lookup table. This will allow Bubble Tea programs to read
all sorts of input events such Kitty keyboard, background color, mode
report, and all sorts of ANSI sequence input events.

Supersedes: https://github.com/charmbracelet/bubbletea/pull/1079
Supersedes: https://github.com/charmbracelet/bubbletea/issues/1014
Related: https://github.com/charmbracelet/bubbletea/issues/869
Related: https://github.com/charmbracelet/bubbletea/issues/163
Related: https://github.com/charmbracelet/bubbletea/issues/918
Related: https://github.com/charmbracelet/bubbletea/issues/850
Related: https://github.com/charmbracelet/bubbletea/issues/207
2024-08-12 17:33:51 -04:00