Skip to content

Releases: charmbracelet/bubbletea

v2.0.0-beta.3

02 May 13:48
v2.0.0-beta.3
07fa6f6
Compare
Choose a tag to compare
v2.0.0-beta.3 Pre-release
Pre-release

Another one! Bubble Tea Beta 3!

This is a fairly small update that makes key enhancements support even better. Let's get into it.

go get github.com/charmbracelet/bubbletea/v2@v2.0.0-beta.3

Keys

Better Keys by Default

Key disambiguation is now enabled by default, when supported. This means that ctrl+i, which would normally send a tab will now send an actual ctrl+i in supporting terminals. To check for support listen for tea.KeyboardEnhancementsMsg in your update:

switch msg := msg.(type) {
case tea.KeyboardEnhancementsMsg:
    if msg.SupportsKeyDisambiguation() {
           // Yay!
    }
}

Note that on Windows key disambiguation is always supported.

Does the terminal support key disambigation?

While we suggest designing your application in a way that gracefully upgrades when key disambiguation is available, you could detect for lack of support with a simple timeout:

// queryTimeoutMsg is a message that will get sent after a certain timeout.
type queryTimeoutMsg struct{}

// queryTimeout is a Bubble Tea command that waits for a timeout before sending a [queryTimeoutMsg].
func queryTimeout(d time.Duration) tea.Msg {
  time.Sleep(200*time.Millisecond) // 200 ms is purly arbitrary
  return queryTimeoutMsg{}
}

func (m model) Init() tea.Cmd {
  return tea.Batch(
    tea.RequestKeyboardEnhancements(),
    queryTimout,
  )
}

func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
  switch msg := msg.(type) {
  case tea.KeyboardEnhancementsMsg:
    // We have more keys, heh
    m.hasEnhancements = true
  case queryTimeoutMsg:
    if !m.hasEnhancements {
      // Terminal doesn't support keyboard enhancements :'(
      m.quit = true
    }
  }
}

Changelog

Bug fixes


The Charm logo

Thoughts? Questions? We love hearing from you. Feel free to reach out on Twitter, The Fediverse, or on Discord.

v2.0.0-beta.2

30 Apr 18:59
v2.0.0-beta.2
db124fa
Compare
Choose a tag to compare
v2.0.0-beta.2 Pre-release
Pre-release

Extra! Extra! Bubble Tea Beta 2!

We're honing in on v2! This update is fairly minor and makes some adjustments based on the awesome community feedback we've received. Let’s jump into it.

go get github.com/charmbracelet/bubbletea/v2@v2.0.0-beta.2

Keys

Easier Mappings

Thanks to some feedback from our beta users (thank you! ❤️), key events now always return the textual value when using key.String(). You can use key.Keystroke() to get the keystroke string representation of the event. For example, pressing shift+h would give you k.String() == "H" and k.Keystroke() == "shift+h" when keyboard enhancements is on. We believe this will make input handling closer to the good parts of v1 and avoid some gotchas with international keyboards.

// Imagine the user pressed shift+h and key is a KeyMsg
key.String () == "H"
key.Keytroke() == "shift+h"

// Now imagine the user entered a "?"
key.String() == "?"
key.Keytroke() == "shift+/ on an American keyboard, shift+, on a French keyboard"

Other Stuff

  • We reverted the new trailing newline character on program exit. We found that while it's a nice touch that simplifies many programs, it can cause issues for others. This brings rendering in-line with v1, so there will be no action needed migrating from v1
  • Fix concurrency and add deadlock prevention (courtesy @desertwitch)
  • Fixed some examples

Thanks again to @desertwitch for his amazing work on concurrency and deadlock prevention 🤘

Changelog

New Features

Bug fixes

Documentation updates

Other work


The Charm logo

Thoughts? Questions? We love hearing from you. Feel free to reach out on Twitter, The Fediverse, or on Discord.

v1.3.5

29 Apr 20:11
v1.3.5
62ca063
Compare
Choose a tag to compare

This release fixes an important bug on Windows where function keys (F1..F20) don't get recognized and sent to the program. It also fixes multiple concurrency bugs related to using external context and p.Wait() and p.Kill().

Also, huge thank you to @desertwitch who went in and just crushed a handful of deadlocks.

Happy hacking!

Changelog

Bug fixes

Documentation updates

Other work


The Charm logo

Thoughts? Questions? We love hearing from you. Feel free to reach out on Twitter, The Fediverse, or on Discord.

v2.0.0-beta.1

26 Mar 18:20
v2.0.0-beta.1
ba5883a
Compare
Choose a tag to compare
v2.0.0-beta.1 Pre-release
Pre-release

It’s time for Bubble Tea v2 Beta

We're very excited to announce the first beta release of Bubble Tea v2! This release includes a number of improvements and features over the last alpha 2 release.

🍔 New to v2? Looking to upgrade? Check out the full Bubble Tea v2 guide.

Changes Since Alpha 2

Since the last alpha 2 release, we've made a few changes and added some new features. Including restoring old Init behavior, actual cursor support, and some minor API name changes.

Init and Model Changes

We restored the old tea.Model interface and Init method changes. Now, Init returns a tea.Cmd as what it was before. The thought here is that it's more ergonomic and returning a tea.Model doesn't make much sense because during Init you already have a newly created model.

type Model struct
	// My model fields
}

func newModel() Model {
	return Model{
		// Initialize your model here
	}
}

// Before in alpha 2
func (m Model) Init() (tea.Model, tea.Cmd) {
	// But we already have a model, so why return a new one?
	return m, nil
}

// After in beta 1
func (m Model) Init() tea.Cmd {
	// Same as original Bubble Tea
	return nil
}

Cursor Support and View Interfaces

Yes, finally, you can control the cursor! We've added a new tea.CursorView interface that you can implement to control the cursor position and style. This is a long-awaited feature, and we're excited to see what you do with it.

Originally, tea.Model implemented a View method that returned a string. We changed this to be in its own tea.ViewModel interface and took it out of tea.Model. Now tea.Model only has Update and Init methods. Not implementing a View method is equivalent to disabling rendering. Both new interfaces are optional. The difference is that tea.CursorModel returns a tea.Cursor along with a string to control the cursor.

// Before
func (m Model) View() string {
	// How can I move the cursor?
	return "My awesome program! █" // <- fake cursor 😛
}

// After
func (m Model) View() (string, *tea.Cursor) {
	var c *tea.Cursor
	// Nil cursor means a hidden cursor
	if m.showCursor {
		// Move the cursor to the 21nd column right after the text
		c := tea.NewCursor(20, 0) // X: 20, Y: 0
		c.Style = tea.CursorBlock // 😎
		c.Blink = false
	}
	return "My awesome program!", c
}

Enhanced Keyboard Support

Terminologies matter. Previously, we introduced tea.EnableKeyboardEnhancements to request different keyboard enhancement features. We've renamed this to tea.RequestKeyboardEnhancement to signal that the program is requesting keyboard enhancements from the terminal and the terminal may or may not support them.

// Before in alpha 2
func (m Model) Init() (tea.Model, tea.Cmd) {
	return m, tea.EnableKeyboardEnhancements(
		tea.WithKeyReleases,
		tea.WithUniformKeyLayout,
	)
}

// After in beta 1
func (m Model) Init() tea.Cmd {
	return tea.RequestKeyboardEnhancement(
		tea.WithKeyReleases,
		tea.WithUniformKeyLayout,
	)
}

Like details?

Here’s the full changelog since v2.0.0-alpha.2


🌈 Feedback

Have thoughts on Bubble Tea v2 Alpha? We’d love to hear about it. Let us know on…


Part of Charm.

The Charm logo

Charm热爱开源 • Charm loves open source • نحنُ نحب المصادر المفتوحة.

v1.3.4

25 Feb 16:54
v1.3.4
bf1216d
Compare
Choose a tag to compare

This release fixes an issue on Windows where the mouse is always enabled even if it wasn't requested. Now, using mouse options such as tea.WithAllMouseMotion() and commands such as tea.EnableMouseAllMotion and tea.DisableMouse turns the mouse on/off as expected.

Changelog

New Features

Bug fixes

Other work


The Charm logo

Thoughts? Questions? We love hearing from you. Feel free to reach out on Twitter, The Fediverse, or on Discord.

v1.3.3

11 Feb 15:31
v1.3.3
cb6f840
Compare
Choose a tag to compare

This release restore the program options that were deprecated in the previous releases.

Changelog

Full Changelog: v1.3.2...v1.3.3


The Charm logo

Thoughts? Questions? We love hearing from you. Feel free to reach out on Twitter, The Fediverse, or on Discord.

v1.3.2

10 Feb 21:31
v1.3.2
b0186ad
Compare
Choose a tag to compare

Fix canceling terminal input reads on Windows.

Changelog

Bug fixes


The Charm logo

Thoughts? Questions? We love hearing from you. Feel free to reach out on Twitter, The Fediverse, or on Discord.

v1.3.1

10 Feb 21:25
v1.3.1
771a101
Compare
Choose a tag to compare

This release introduces some important bug fixes when it comes to cursor movements while rendering, and properly handle Windows AltGr key on non-English keyboards.

Changelog

Bug fixes

Other work


The Charm logo

Thoughts? Questions? We love hearing from you. Feel free to reach out on Twitter, The Fediverse, or on Discord.

v1.3.0

04 Feb 17:01
v1.3.0
7f68efb
Compare
Choose a tag to compare

Sorry to interrupt: it's time for Bubble Tea v1.3.0!

Bubble Tea now ships with refined interrupt handling, courtesy @caarlos0. Now, you can throw your terminal a ctrl+c or an interrupt signal, Bubble Tea will take it with grace and poise. Switch any ol’ run-of-the-mill tea.Quit command with tea.Interrupt for seamless interruptions.

Bug Fixes

  • 2556e01: The last rendered line count now includes those sneaky alt screen lines, thanks to @semihbkgr's keen eye (#1254)
  • c8d6005: Windows users rejoice! @awoodbeck has managed to cancel those unruly threads like an expert party planner using CancelIoEx (#1305)

New Contributors

Special thanks to the following new contributors:

Changelog

New Features

Bug fixes

Documentation updates

Other work


The Charm logo

Thoughts? Questions? We love hearing from you. Feel free to reach out on Twitter, The Fediverse, or on Discord.

v1.2.4

25 Nov 14:53
v1.2.4
Compare
Choose a tag to compare

A few little rendering fixes

This release fixes a couple rendering bugs. Quality rendering in Bubble Tea is paramount!

Changelog

Bug fixes

Other work


The Charm logo

Thoughts? Questions? We love hearing from you. Feel free to reach out on Twitter, The Fediverse, or on Discord.