github charmbracelet/bubbletea v0.14.0

latest releases: v0.26.1, v0.26.0, v0.25.0...
2 years ago

Improvements: Races and Rendering

This release introduces three new ProgramOptions for starting programs with the altscreen and mouse enabled. This was implemented to solve both race conditions when initializing programs as well as correctness with regard to custom inputs.

// New! This is the recommended way to start your program with the mouse and altscreen active.
p := tea.NewProgram(model, tea.WithAltScreen(), tea.WithMouseAllMotion())

// Deprecated as this will only operate on stdout, as opposed to a custom output you may have set.
p := tea.NewProgram(model)
p.EnableAltScreen()
p.EnableMouseAllMotion()

// Strongly discouraged as these commands could be sent before starting the renderer, resulting
// in rendering artifacts. This is due to the fact that commands run asynchronously in a goroutine.
func (m model) Init() tea.Cmd {
    return tea.Batch(tea.EnterAltScreen, tea.EnableMouseAllMotion)
}

Also included are two subtle—yet important—rendering improvements.

Changelog

New

  • Added ProgramOption WithAltScreen for starting programs in the alternate screen buffer.
  • Added ProgramOptions WithMouseCellMotion and WithMouseAllMotion for starting programs with the mouse enabled.

Fixed

  • Programs will no longer render artifacts when exiting due to an error or panic.
  • If a view returns the empty string output will be cleared. Previously, rendering would be skipped entirely.

Thoughts? Questions? We love hearing from you. Feel free to reach out on Twitter, The Fediverse, or right here in GitHub Discussions.

The Charm logo

Don't miss a new bubbletea release

NewReleases is sending notifications on new releases.