Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(v2) feat: use the cursed renderer #1267

Merged
merged 30 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
2060f93
docs(examples): fix glamour example (#1204)
meowgorithm Dec 16, 2024
07288b1
docs(readme): add more stuff to "In the Wild"
meowgorithm Dec 17, 2024
79cc2fb
docs(readme): fix tiny typo in readme
meowgorithm Dec 17, 2024
1bf1886
docs(readme): additional readme tiyding up
meowgorithm Dec 17, 2024
d670334
chore(deps): bump golang.org/x/sys from 0.28.0 to 0.29.0 (#1281)
dependabot[bot] Jan 6, 2025
0cf58be
feat: use the cursed ferocious renderer
aymanbagabas Dec 9, 2024
aed1a53
chore: bump cellbuf
aymanbagabas Dec 10, 2024
c12bddd
chore: update deps
aymanbagabas Dec 12, 2024
8014f47
chore: update go.mod and go.sum
aymanbagabas Dec 12, 2024
04c0b43
refactor: use the cursed renderer for rendering and remove the standa…
aymanbagabas Dec 12, 2024
26be4d4
feat: tests: use golden files to test screen sequences
aymanbagabas Dec 12, 2024
98eed90
chore: remove unused
aymanbagabas Dec 12, 2024
3d79aff
perf: only reset mouse modes that are set
aymanbagabas Dec 12, 2024
ea8e8e7
chore: bump cellbuf
aymanbagabas Dec 12, 2024
3e7802a
fix: renderer: attempt to resolve race condition
aymanbagabas Dec 12, 2024
f343837
fix: renderer: lastFrame should be a pointer to string
aymanbagabas Dec 20, 2024
974dc31
chore: bump cellbuf to latest
aymanbagabas Dec 20, 2024
8d5202d
fix(examples): split-editors: add CursorLineNumber style
aymanbagabas Dec 20, 2024
9a23549
chore: bump cellbuf to latest main
aymanbagabas Dec 20, 2024
05ffb54
fix: send color profile message after setting it on the renderer
aymanbagabas Dec 22, 2024
777675c
feat: use hard tabs to optimize cursor movements
aymanbagabas Jan 6, 2025
f532620
fix: renderer: repaint screen after resize
aymanbagabas Jan 7, 2025
cdd901d
chore: bump cellbuf to main
aymanbagabas Jan 7, 2025
a5ff03a
fix: renderer: guard against concurrent access to screenRenderer
aymanbagabas Jan 8, 2025
ffa5bf4
chore: bump cellbuf to fix divide by zero
aymanbagabas Jan 13, 2025
e2768ff
chore: testdata: update golden files
aymanbagabas Jan 13, 2025
73843ab
chore(deps): bump golang.org/x/net from 0.27.0 to 0.33.0 in /examples…
dependabot[bot] Jan 13, 2025
c1cd8bb
chore(deps): bump github.com/charmbracelet/x/ansi from 0.6.0 to 0.7.0…
dependabot[bot] Jan 14, 2025
380db22
Merge remote-tracking branch 'origin/main' into v2-ferocious2
caarlos0 Jan 14, 2025
30a5dd4
Merge remote-tracking branch 'origin/v2-exp' into v2-ferocious2
caarlos0 Jan 14, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ complex terminal applications, either inline, full-window, or a mix of both.
</p>

Bubble Tea is in use in production and includes a number of features and
performance optimizations we’ve added along the way. Among those is a standard
framerate-based renderer, a renderer for high-performance scrollable
regions which works alongside the main renderer, and mouse support.
performance optimizations we’ve added along the way. Among those is
a framerate-based renderer, mouse support, focus reporting and more.

To get started, see the tutorial below, the [examples][examples], the
[docs][docs], the [video tutorials][youtube] and some common [resources](#libraries-we-use-with-bubble-tea).
Expand Down Expand Up @@ -61,8 +60,8 @@ import will be the Bubble Tea library, which we'll call `tea` for short.
```go
package main

// XXX: These imports will be used later on the tutorial. If you save the file
// now, Go might complain they are unused, but that is to be expected.
// These imports will be used later on the tutorial. If you save the file
// now, Go might complain they are unused, but that's fine.
// You may also need to run `go mod tidy` to download bubbletea and its
// dependencies.
import (
Expand Down Expand Up @@ -307,36 +306,36 @@ your program in another window.
- [Harmonica][harmonica]: A spring animation library for smooth, natural motion
- [BubbleZone][bubblezone]: Easy mouse event tracking for Bubble Tea components
- [ntcharts][ntcharts]: A terminal charting library built for Bubble Tea and [Lip Gloss][lipgloss]
- [Termenv][termenv]: Advanced ANSI styling for terminal applications
- [Reflow][reflow]: Advanced ANSI-aware methods for working with text

[bubbles]: /~https://github.com/charmbracelet/bubbles
[lipgloss]: /~https://github.com/charmbracelet/lipgloss
[harmonica]: /~https://github.com/charmbracelet/harmonica
[bubblezone]: /~https://github.com/lrstanley/bubblezone
[ntcharts]: /~https://github.com/NimbleMarkets/ntcharts
[termenv]: /~https://github.com/muesli/termenv
[reflow]: /~https://github.com/muesli/reflow

## Bubble Tea in the Wild

There are over 8k applications built with Bubble Tea! Here are a handful of ’em.
There are over [10,000 applications](/~https://github.com/charmbracelet/bubbletea/network/dependents) built with Bubble Tea! Here are a handful of ’em.

### Staff favourites

- [chezmoi](/~https://github.com/twpayne/chezmoi): securely manage your dotfiles across multiple machines
- [circumflex](/~https://github.com/bensadeh/circumflex): read Hacker News in the terminal
- [gh-dash](https://www.github.com/dlvhdr/gh-dash): a GitHub CLI extension for PRs and issues
- [Tetrigo](/~https://github.com/Broderick-Westrope/tetrigo): Tetris in the terminal
- [Signls](/~https://github.com/emprcl/signls): a generative midi sequencer designed for composition and live performance
- [Superfile](/~https://github.com/yorukot/superfile): a super file manager

### In Industry

- Microsoft Azure – [Aztify](/~https://github.com/Azure/aztfy): bring Microsoft Azure resources under Terraform
- Daytona – [Daytona](/~https://github.com/daytonaio/daytona): open source dev environment manager
- Cockroach Labs – [CockroachDB](/~https://github.com/cockroachdb/cockroach): a cloud-native, high-availability distributed SQL database
- Truffle Security Co. – [Trufflehog](/~https://github.com/trufflesecurity/trufflehog): find leaked credentials
- NVIDIA – [container-canary](/~https://github.com/NVIDIA/container-canary) from NVIDIA: a container validator
- AWS – [eks-node-viewer](/~https://github.com/awslabs/eks-node-viewer) from AWS: a tool for visualizing dynamic node usage within an EKS cluster
- MinIO – [mc](/~https://github.com/minio/mc) from Min.io: the official [MinIO](https://min.io) client
- NVIDIA – [container-canary](/~https://github.com/NVIDIA/container-canary): a container validator
- AWS – [eks-node-viewer](/~https://github.com/awslabs/eks-node-viewer): a tool for visualizing dynamic node usage within an EKS cluster
- MinIO – [mc](/~https://github.com/minio/mc): the official [MinIO](https://min.io) client
- Ubuntu – [Authd](/~https://github.com/ubuntu/authd): an authentication daemon for cloud-based identity providers

### Charm stuff

Expand Down
13 changes: 12 additions & 1 deletion examples/glamour/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,20 @@ func newExample() (*example, error) {
BorderForeground(lipgloss.Color("62")).
PaddingRight(2)

// We need to adjust the width of the glamour render from our main width
// to account for a few things:
//
// * The viewport border width
// * The viewport padding
// * The viewport margins
// * The gutter glamour applies to the left side of the content
//
const glamourGutter = 2
glamourRenderWidth := width - vp.Style.GetHorizontalFrameSize() - glamourGutter

renderer, err := glamour.NewTermRenderer(
glamour.WithAutoStyle(),
glamour.WithWordWrap(width),
glamour.WithWordWrap(glamourRenderWidth),
)
if err != nil {
return nil, err
Expand Down
17 changes: 8 additions & 9 deletions examples/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.23.1
require (
github.com/charmbracelet/bubbles/v2 v2.0.0-alpha.2.0.20250114183437-fbe642df174c
github.com/charmbracelet/bubbletea/v2 v2.0.0-alpha.2.0.20250114183054-9f703251e0d7
github.com/charmbracelet/colorprofile v0.1.8
github.com/charmbracelet/colorprofile v0.1.9
github.com/charmbracelet/glamour v0.8.0
github.com/charmbracelet/harmonica v0.2.0
github.com/charmbracelet/lipgloss/v2 v2.0.0-alpha.2.0.20250114171829-b67eb015d607
Expand All @@ -22,12 +22,11 @@ require (
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/aymanbagabas/go-udiff v0.2.0 // indirect
github.com/aymerick/douceur v0.2.0 // indirect
github.com/charmbracelet/lipgloss v0.13.0 // indirect
github.com/charmbracelet/x/cellbuf v0.0.6 // indirect
github.com/charmbracelet/x/exp/golden v0.0.0-20241011142426-46044092ad91 // indirect
github.com/charmbracelet/lipgloss v1.0.0 // indirect
github.com/charmbracelet/x/cellbuf v0.0.7-0.20250113065325-800d48271e72 // indirect
github.com/charmbracelet/x/exp/golden v0.0.0-20241212170349-ad4b7ae0f25f // indirect
github.com/charmbracelet/x/input v0.3.0 // indirect
github.com/charmbracelet/x/term v0.2.1 // indirect
github.com/charmbracelet/x/vt v0.0.0-20241121165045-a3720547cbb4 // indirect
github.com/charmbracelet/x/wcwidth v0.0.0-20241113152101-0af7d04e9f32 // indirect
github.com/charmbracelet/x/windows v0.2.0 // indirect
github.com/dlclark/regexp2 v1.11.0 // indirect
Expand All @@ -43,11 +42,11 @@ require (
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
github.com/yuin/goldmark v1.7.4 // indirect
github.com/yuin/goldmark-emoji v1.0.3 // indirect
golang.org/x/net v0.27.0 // indirect
golang.org/x/net v0.33.0 // indirect
golang.org/x/sync v0.10.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/term v0.22.0 // indirect
golang.org/x/text v0.20.0 // indirect
golang.org/x/sys v0.29.0 // indirect
golang.org/x/term v0.27.0 // indirect
golang.org/x/text v0.21.0 // indirect
)

replace github.com/charmbracelet/bubbletea/v2 => ../
34 changes: 16 additions & 18 deletions examples/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,28 @@ github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuP
github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4=
github.com/charmbracelet/bubbles/v2 v2.0.0-alpha.2.0.20250114183437-fbe642df174c h1:hhR5M/3Wt/mKLTPF/MyvA4/WWtnTmIzLXo69pW/9S5s=
github.com/charmbracelet/bubbles/v2 v2.0.0-alpha.2.0.20250114183437-fbe642df174c/go.mod h1:M271uOSMoLQsiVV1yhFZx6JprPQCVXgLYpSEbWXtidM=
github.com/charmbracelet/colorprofile v0.1.8 h1:PywDeXsiAzlPtkiiKgMEVLvb6nlEuKrMj9+FJBtj4jU=
github.com/charmbracelet/colorprofile v0.1.8/go.mod h1:+jpmObxZl1Dab3H3IMVIPSZTsKcFpjJUv97G0dLqM60=
github.com/charmbracelet/colorprofile v0.1.9 h1:5JnfvX+I9D6rRNu8xK3pgIqknaBVTXHU9pGu1jkZxLw=
github.com/charmbracelet/colorprofile v0.1.9/go.mod h1:+jpmObxZl1Dab3H3IMVIPSZTsKcFpjJUv97G0dLqM60=
github.com/charmbracelet/glamour v0.8.0 h1:tPrjL3aRcQbn++7t18wOpgLyl8wrOHUEDS7IZ68QtZs=
github.com/charmbracelet/glamour v0.8.0/go.mod h1:ViRgmKkf3u5S7uakt2czJ272WSg2ZenlYEZXT2x7Bjw=
github.com/charmbracelet/harmonica v0.2.0 h1:8NxJWRWg/bzKqqEaaeFNipOu77YR5t8aSwG4pgaUBiQ=
github.com/charmbracelet/harmonica v0.2.0/go.mod h1:KSri/1RMQOZLbw7AHqgcBycp8pgJnQMYYT8QZRqZ1Ao=
github.com/charmbracelet/lipgloss v0.13.0 h1:4X3PPeoWEDCMvzDvGmTajSyYPcZM4+y8sCA/SsA3cjw=
github.com/charmbracelet/lipgloss v0.13.0/go.mod h1:nw4zy0SBX/F/eAO1cWdcvy6qnkDUxr8Lw7dvFrAIbbY=
github.com/charmbracelet/lipgloss v1.0.0 h1:O7VkGDvqEdGi93X+DeqsQ7PKHDgtQfF8j8/O2qFMQNg=
github.com/charmbracelet/lipgloss v1.0.0/go.mod h1:U5fy9Z+C38obMs+T+tJqst9VGzlOYGj4ri9reL3qUlo=
github.com/charmbracelet/lipgloss/v2 v2.0.0-alpha.2.0.20250114171829-b67eb015d607 h1:lERE4ow371r5WMqQAt7Eqlg1A4tBNA8T4RLwdXnKyBo=
github.com/charmbracelet/lipgloss/v2 v2.0.0-alpha.2.0.20250114171829-b67eb015d607/go.mod h1:MD7Vb+O1zFRgBo+F94JHHuME7df8XBByNKuX5k/L/qs=
github.com/charmbracelet/x/ansi v0.7.0 h1:/QfFmiXOGGwN6fRbzvQaYp7fu1pkxpZ3qFBZWBsP404=
github.com/charmbracelet/x/ansi v0.7.0/go.mod h1:KBUFw1la39nl0dLl10l5ORDAqGXaeurTQmwyyVKse/Q=
github.com/charmbracelet/x/cellbuf v0.0.6 h1:pJUWN/G1jbt1Nj/+ILfC2/ABQoZzWu1vG73yHQEYELI=
github.com/charmbracelet/x/cellbuf v0.0.6/go.mod h1:d72o71glp8flkCz54PHLe3+nuw5u2v3UxmKqruUERWQ=
github.com/charmbracelet/x/exp/golden v0.0.0-20241011142426-46044092ad91 h1:payRxjMjKgx2PaCWLZ4p3ro9y97+TVLZNaRZgJwSVDQ=
github.com/charmbracelet/x/exp/golden v0.0.0-20241011142426-46044092ad91/go.mod h1:wDlXFlCrmJ8J+swcL/MnGUuYnqgQdW9rhSD61oNMb6U=
github.com/charmbracelet/x/cellbuf v0.0.7-0.20250113065325-800d48271e72 h1:P90NI2rZuBISjB1HIHdkBDE+riKtVzIOi6Xun3qjUn8=
github.com/charmbracelet/x/cellbuf v0.0.7-0.20250113065325-800d48271e72/go.mod h1:VXZSjC/QYH0t+9CG1qtcEx3XZubTDJb5ilWS6qJg4/0=
github.com/charmbracelet/x/exp/golden v0.0.0-20241212170349-ad4b7ae0f25f h1:UytXHv0UxnsDFmL/7Z9Q5SBYPwSuRLXHbwx+6LycZ2w=
github.com/charmbracelet/x/exp/golden v0.0.0-20241212170349-ad4b7ae0f25f/go.mod h1:wDlXFlCrmJ8J+swcL/MnGUuYnqgQdW9rhSD61oNMb6U=
github.com/charmbracelet/x/exp/teatest/v2 v2.0.0-20241016014612-3b4d04043233 h1:2bTR/MtnJuq9RrCZSPwCOO34YSDByKL6nzXQMnsKK6U=
github.com/charmbracelet/x/exp/teatest/v2 v2.0.0-20241016014612-3b4d04043233/go.mod h1:cw9df32BXdkcd0LzAHsFMmvXOsrrlDKazIW8PCq0cPM=
github.com/charmbracelet/x/input v0.3.0 h1:lVzEz92E2u9jCU0mUwcyKeSOxkoeat+1eUkjzL0WCYI=
github.com/charmbracelet/x/input v0.3.0/go.mod h1:M8CHPIYnmmiNHA17hqXmvSfeZLO2lj9pzJFX3aWvzgw=
github.com/charmbracelet/x/term v0.2.1 h1:AQeHeLZ1OqSXhrAWpYUtZyX1T3zVxfpZuEQMIQaGIAQ=
github.com/charmbracelet/x/term v0.2.1/go.mod h1:oQ4enTYFV7QN4m0i9mzHrViD7TQKvNEEkHUMCmsxdUg=
github.com/charmbracelet/x/vt v0.0.0-20241121165045-a3720547cbb4 h1:EacjHxcQEEgOZ7TbkAU3b84hd1Bn5NwA8YV5uyJ9EI4=
github.com/charmbracelet/x/vt v0.0.0-20241121165045-a3720547cbb4/go.mod h1:1/jFoHl7/I4br0StC9OXXEondkK9qi3nUtKoqI35HcI=
github.com/charmbracelet/x/wcwidth v0.0.0-20241113152101-0af7d04e9f32 h1:14czE6R5CgOlvONsJYa2B1uTyLvXzGXpBqw2AyZeTh4=
github.com/charmbracelet/x/wcwidth v0.0.0-20241113152101-0af7d04e9f32/go.mod h1:hyua5CY63kyl7IfyIxv1SjVEqoKze/XmDkEglItuVjA=
github.com/charmbracelet/x/windows v0.2.0 h1:ilXA1GJjTNkgOm94CLPeSz7rar54jtFatdmoiONPuEw=
Expand Down Expand Up @@ -86,14 +84,14 @@ github.com/yuin/goldmark-emoji v1.0.3 h1:aLRkLHOuBR2czCY4R8olwMjID+tENfhyFDMCRhb
github.com/yuin/goldmark-emoji v1.0.3/go.mod h1:tTkZEbwu5wkPmgTcitqddVxY9osFZiavD+r4AzQrh1U=
golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI=
golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo=
golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys=
golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE=
golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I=
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ=
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.22.0 h1:BbsgPEJULsl2fV/AT3v15Mjva5yXKQDyKf+TbDz7QJk=
golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4=
golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug=
golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4=
golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU=
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q=
golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM=
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
3 changes: 3 additions & 0 deletions examples/simple/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ func TestApp(t *testing.T) {
}

func TestAppInteractive(t *testing.T) {
t.Skip("This test is flaky and needs to be fixed.\n" +
"We need a more concrete way to set the initial terminal size")

m := model(10)
tm := teatest.NewTestModel(
t, m,
Expand Down
1 change: 1 addition & 0 deletions examples/split-editors/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ func newTextarea() textarea.Model {
t.Styles.Focused.Placeholder = focusedPlaceholderStyle
t.Styles.Blurred.Placeholder = placeholderStyle
t.Styles.Focused.CursorLine = cursorLineStyle
t.Styles.Focused.CursorLineNumber = cursorLineStyle
t.Styles.Focused.Base = focusedBorderStyle
t.Styles.Blurred.Base = blurredBorderStyle
t.Styles.Focused.EndOfBuffer = endOfBufferStyle
Expand Down
Loading
Loading