* fix: handle nested SequenceMsg in event loop and use sync.WaitGroup for BatchMsg
This simplifies the handling of nested BatchMsg within sequenceMsg and ensures
that all commands in a BatchMsg are executed before proceeding.
It also replaces errgroup with sync.WaitGroup for better clarity and performance
when waiting for multiple goroutines to finish.
Fixes: https://github.com/charmbracelet/bubbletea/issues/680
Supersedes: https://github.com/charmbracelet/bubbletea/pull/843
* chore: examples: bump dependencies
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
`WithFilter` lets you supply an event filter that will be invoked
before Bubble Tea processes a `tea.Msg`. The event filter can return
any `tea.Msg` which will then get handled by Bubble Tea instead of
the original event. If the event filter returns nil, the event
will be ignored and Bubble Tea will not process it.
As an example, this could be used to prevent a program from
shutting down if there are unsaved changes.
Based on the fantastic work by @aschey and supersedes #521.
Resolves#472.
WithContext lets you specify a context in which to run the Program.
This is useful if you want to cancel the execution from outside.
When a Program gets cancelled it will exit with an error
ErrProgramKilled.