Documentation
¶
Index ¶
- Variables
- func GetSize(text string) geom.Vec2
- func Progress(filledStyle, emptyStyle lipgloss.Style, text string, percent float64) string
- func Sequence(cmds ...tea.Cmd) tea.Cmd
- func Test(m Model, options ...Option) func(msgs ...interface{})
- func WithDebug(p *Program)
- func WithExisting(p *Program)
- func WithKittyKeys(p *Program)
- type Cmd
- type KeyMsg
- type KittyKeyMsg
- type Model
- type MouseMsg
- type Msg
- type Option
- type Program
- type PublishMsg
- type Renderer
- type ScreenUpdate
- type ScreenWatcher
Constants ¶
This section is empty.
Variables ¶
var ErrProgramKilled = errors.New("program was killed")
ErrProgramKilled is returned by Program.Run when the program got killed.
Functions ¶
func Progress ¶ added in v1.5.0
Progress applies a lipgloss.Style to a percentage of the input text.
func Sequence ¶
Sequence runs the given commands one at a time, in order. Contrast this with Batch, which runs commands concurrently.
func Test ¶ added in v0.1.13
Test returns a function that passes the given messages to the taro Model `m` one at a time. All `Cmd`s that would normally be executed in separate goroutines are instead executed in the calling goroutine. This is useful exclusively in testing.
func WithExisting ¶ added in v1.9.0
func WithExisting(p *Program)
func WithKittyKeys ¶ added in v1.9.0
func WithKittyKeys(p *Program)
Types ¶
type KittyKeyMsg ¶ added in v1.9.0
func KeysToMsg ¶ added in v0.1.5
func KeysToMsg(strs ...string) (msgs []KittyKeyMsg)
type Model ¶
type Model interface {
// Init is the first function that will be called. It returns an optional
// initial command. To not perform an initial command return nil.
Init() Cmd
// Update is called when a message is received. Use it to inspect messages
// and, in response, update the model and/or send a command.
Update(Msg) (Model, Cmd)
// View renders the program's UI, which consists of a full *tty.State. The
// view is rendered after every Update.
View(*tty.State)
}
Model contains the program's state as well as its core functions.
type MouseMsg ¶
MouseMsg contains information about a mouse event and are sent to a programs update function when mouse activity occurs. Note that the mouse must first be enabled in order for the mouse events to be received.
type Program ¶
Program is a terminal user interface.
func (*Program) Kill ¶
func (p *Program) Kill()
Kill stops the program immediately and restores the former terminal state. The final render that you would normally see when quitting will be skipped. [program.Run] returns a ErrProgramKilled error.
func (*Program) Quit ¶
func (p *Program) Quit()
Quit is a convenience function for quitting Bubble Tea programs. Use it when you need to shut down a Bubble Tea program from the outside.
If you wish to quit from within a Bubble Tea program use the Quit command.
If the program is not running this will be a no-op, so it's safe to call if the program is unstarted or has already exited.
func (*Program) Run ¶
Run initializes the program and runs its event loops, blocking until it gets terminated by either Program.Quit, Program.Kill, or its signal handler. Returns the final model.
func (*Program) Send ¶
Send sends a message to the main update function, effectively allowing messages to be injected from outside the program for interoperability purposes.
If the program hasn't started yet this will be a blocking operation. If the program has already been terminated this will be a no-op, so it's safe to send messages after the program has exited.
type PublishMsg ¶ added in v0.1.6
type PublishMsg struct {
Msg Msg
}
Indicates that this message should be emitted upwards.
type Renderer ¶
Renderer makes it easy to render lipgloss strings.
func NewRenderer ¶
func NewRenderer() *Renderer
func (*Renderer) LipglossToEmu ¶ added in v1.8.0
func (*Renderer) RenderAtSize ¶ added in v1.3.0
RenderAtSize renders the given string at (row, col) in `state` with a fixed terminal size.
type ScreenUpdate ¶ added in v0.1.5
func (ScreenUpdate) Wait ¶ added in v0.1.16
func (s ScreenUpdate) Wait() Cmd
type ScreenWatcher ¶ added in v0.1.6
func NewWatcher ¶ added in v0.1.6
func NewWatcher(ctx context.Context, screen mux.Screen) *ScreenWatcher
func (*ScreenWatcher) Wait ¶ added in v0.1.6
func (s *ScreenWatcher) Wait() Cmd