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
- 60b6f30: feat: add keystroke representation to Key struct (#1399) (@aymanbagabas)
Bug fixes
- 929ff5a: Revert "fix: ensure terminal prompt is on a new line after program shutdown" (@aymanbagabas)
- f4c8567: fix(examples): credit-card-form: use VirtualCursor in inputs (@aymanbagabas)
- 551bf9c: fix(examples): textarea: remove debug log (@aymanbagabas)
- 62ca063: fix(key): windows: recognize function keys on Windows (#1405) (@aymanbagabas)
- 0f9cd5b: fix(panics): fix race condition and false nil error return (@desertwitch)
- a79ab3f: fix(tests): account for multiple p.Wait() (@desertwitch)
- ed4fde7: fix: lint issues (@caarlos0)
- 1b5fc27: fix: prevent deadlock on ctx cancel during msg processing (@desertwitch)
- aa7a240: fix: release p.Wait() on p.Kill() to prevent external deadlocks (@desertwitch)
- 1923181: fix: report only external ctx cancel as ctx error (@desertwitch)
- c56f776: fix: resolve race conditions caused by p.Kill() (@desertwitch)
- d67e48a: fix: windows: remove broken key_windows.go (@aymanbagabas)
Documentation updates
- 5eee00a: docs(examples): add keyboard enhancements demo (@meowgorithm)
- 35334b9: docs(examples): remove extraneous lines in query-term example (@meowgorithm)
- 3797acb: docs(readme): fix header image mis-caching (@meowgorithm)
- 4e7ab6c: docs(viewport): update for viewport left gutter API changes (@meowgorithm)
Other work
- 7858a14: ci: fix lint issues (@andreynering)
- 1a0062b: ci: fix lint issues (@andreynering)
- 0b18d1f: ci: sync dependabot config (#1403) (@charmcli)
- a46d16d: ci: sync golangci-lint config (#1379) (@github-actions[bot])
- 5a360c9: ci: sync golangci-lint config (#1394) (@github-actions[bot])
- bf33130: refactor(examples): use glamour/v2 (@aymanbagabas)
Thoughts? Questions? We love hearing from you. Feel free to reach out on Twitter, The Fediverse, or on Discord.