Skip to content
Myr

Update tutorials per new Model interface-based structure

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Christian Rocha · committed by Christian Rocha · parent c72ee75 · Browse files · 7 files+203 added−183 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

7 files+203 added−183 removed

  • other:+203 added−183 removed

7 files+203 added−183 removed

modified:tutorials/basics/main.go+9 added-11 removed
11 unmodified lines
12 choices []string13 selected map[int]struct{}14}1516func initialize() (tea.Model, tea.Cmd) {17 return model{18 choices: []string{"Carrots", "Celery", "Kohlrabi"},19 selected: make(map[int]struct{}),16var initialModel = model{17 choices: []string{"Carrots", "Celery", "Kohlrabi"},18 selected: make(map[int]struct{}),20 }, nil19}2023func update(msg tea.Msg, mdl tea.Model) (tea.Model, tea.Cmd) {24 m, _ := mdl.(model)21func (m model) Init() tea.Cmd {22 return nil23}2425func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {26 switch msg := msg.(type) {27 case tea.KeyMsg:28 switch msg.String() {29 case "ctrl+c", "q":
18 unmodified lines
4849 return m, nil50}5152func view(mdl tea.Model) string {53 m, _ := mdl.(model)5452func (m model) View() string {53 s := "What should we buy at the market?\n\n"5455 for i, choice := range m.choices {56 cursor := " "
14 unmodified lines
71 return s72}7374func main() {77 p := tea.NewProgram(initialize, update, view)75 p := tea.NewProgram(initialModel)76 if err := p.Start(); err != nil {77 fmt.Printf("Alas, there's been an error: %v", err)78 os.Exit(1)79 }
1 unmodified line
modified:tutorials/basics/README.md+29 added-36 removed
1Bubble Tea Basics2=================34Bubble Tea is based on the functional design paradigms of [The Elm5Architecture][elm]. It might not seem very Go-like at first, but once you get6used to the general structure you'll find that most of the idomatic Go things7you know and love are still relevant and useful here.5Architecture][elm] which happens work nicely with Go.67By the way, the non-annotated source code for this program is available8[on GitHub](https://github.com/charmbracelet/bubbletea/tree/master/tutorials/basics).9
19 unmodified lines
29 )30```3132Bubble Tea programs are comprised of a **model** that describes the application35state and three simple functions that are centered around that model:33state and three simple methods on that model:3437* **Initialize**, a function that returns the model's initial state.35* **Init**, a function that returns an initial command for the application to run.36* **Update**, a function that handles incoming events and updates the model accordingly.37* **View**, a function that renders the UI based on the data in the model.3839## The Model
8 unmodified lines
48 selected map[int]struct{} // which to-do items are selected49 }50```5154## The Initialization Function52## Initialization5356Next we'll define a function that will initialize our application. An57initialize function returns a model representing our application's initial58state, as well as a `Cmd` that could perform some initial I/O. For now, we59don't need to do any I/O, so for the command we'll just return `nil`, which60translates to "no command."54Next we'll define our application’s initial state. We’ll store our initial55model in a simple variable, and then define the `Init` method. `Init` can56return a `Cmd` that could perform some initial I/O. For now, we don't need to57do any I/O, so for the command we'll just return `nil`, which translates to "no58command."5960```go63 func initialize() (tea.Model, tea.Cmd) {64 m := model{61 var initialModel = model{62 // Our to-do list is just a grocery list63 choices: []string{"Buy carrots", "Buy celery", "Buy kohlrabi"},6466 // Our to-do list is just a grocery list67 choices: []string{"Buy carrots", "Buy celery", "Buy kohlrabi"},65 // A map which indicates which choices are selected. We're using66 // the map like a mathematical set. The keys refer to the indexes67 // of the `choices` slice, above.68 selected: make(map[int]struct{}),69 }7069 // A map which indicates which choices are selected. We're using70 // the map like a mathematical set. The keys refer to the indexes71 // of the `choices` slice, above.72 selected: make(map[int]struct{}),73 }7475 // Return the model and `nil`, which means "no I/O right now, please."71 func (m model) Init() (tea.Cmd) {72 // Just return `nil`, which means "no I/O right now, please."73 return m, nil74 }75```7680## The Update Function77## The Update Method7882Next we'll define the update function. The update function is called when79Next we'll define the update method. The update function is called when80"things happen." Its job is to look at what has happened and return an updated81model in response to whatever happened. It can also return a `Cmd` and make82more things happen, but for now don't worry about that part.83
10 unmodified lines
94For now, we'll just deal with `tea.KeyMsg` messages, which are automatically95sent to the update function when keys are pressed.9697```go101 func update(msg tea.Msg, mdl tea.Model) (tea.Model, tea.Cmd) {102 m, _ := mdl.(model)10398 func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {99 switch msg := msg.(type) {100101 // Is it a key press?102 case tea.KeyMsg:
38 unmodified lines
141You may have noticed that "ctrl+c" and "q" above return a `tea.Quit` command142with the model. That's a special command which instructs the Bubble Tea runtime143to quit, exiting the program.144150## The View Function145## The View Method146152At last, it's time to render our UI. Of all the functions, the view is the153simplest. A model, in it's current state, comes in and a `string` comes out.154That string is our UI!147At last, it's time to render our UI. Of all the methods, the view is the148simplest. We look at the model in it's current state and use it to return149a `string`. That string is our UI!150151Because the view describes the entire UI of your application, you don't have152to worry about redraw logic and stuff like that. Bubble Tea takes care of it153for you.154155```go161 func view(mdl tea.Model) string {162 m, _ := mdl.(model)163156 func (m model) View() string {157 // The header158 s := "What should we buy at the market?\n\n"159160 // Iterate over our choices
24 unmodified lines
185```186187## All Together Now188196The last step is to simply run our program. We pass our functions to189The last step is to simply run our program. We pass our initial model to190`tea.NewProgram` and let it rip:191192```go193 func main() {201 p := tea.NewProgram(initialize, update, view)194 p := tea.NewProgram(initialModel)195 if err := p.Start(); err != nil {196 fmt.Printf("Alas, there's been an error: %v", err)197 os.Exit(1)198 }
41 unmodified lines
modified:tutorials/commands/main.go+5 added-9 removed
31 unmodified lines
32// For messages that contain errors it's often handy to also implement the33// error interface on the message.34func (e errMsg) Error() string { return e.err.Error() }3536func initialize() (tea.Model, tea.Cmd) {37 return model{}, checkServer36func (m model) Init() tea.Cmd {37 return checkServer38}3940func update(msg tea.Msg, mdl tea.Model) (tea.Model, tea.Cmd) {41 m, _ := mdl.(model)4240func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {41 switch msg := msg.(type) {4243 case statusMsg:44 m.status = int(msg)
11 unmodified lines
5657 return m, nil58}5962func view(mdl tea.Model) string {63 m, _ := mdl.(model)6460func (m model) View() string {61 if m.err != nil {62 return fmt.Sprintf("\nWe had some trouble: %v\n\n", m.err)63 }64
4 unmodified lines
69 return "\n" + s + "\n\n"70}7172func main() {77 if err := tea.NewProgram(initialize, update, view).Start(); err != nil {73 if err := tea.NewProgram(model{}).Start(); err != nil {74 fmt.Printf("Uh oh, there was an error: %v\n", err)75 os.Exit(1)76 }77}
modified:tutorials/commands/README.md+13 added-15 removed
83 unmodified lines
84And notice that we've defined two new `Msg` types. They can be any type, even85an empty struct. We'll come back to them later later in our update function.86First, let's write our initialization function.8788## The Initialization Function88## The Initialization Method8990The initilization function is very simple. We return an empty model and the91the `Cmd` we made earlier. Note that we don't call the function; the Bubble Tea92runtime will do that when the time is right.90The initilization method is very simple: we return the `Cmd` we made earlier.91Note that we don't call the function; the Bubble Tea runtime will do that when92the time is right.9394```go95func initialize() (tea.Model, tea.Cmd) {96 return model{}, checkServer95func (m model) Init() (tea.Cmd) {96 return checkServer97}98```99100## The Update Function100## The Update Method101102Internally, `Cmd`s run asynchronously in a goroutine. The `Msg` they return is103collected and sent to our update function for handling. Remember those message104types we made earlier when we were making the `checkServer` command? We handle105them here. This makes dealing with many asynchronous operations very easy.106107```go108func update(msg tea.Msg, mdl tea.Model) (tea.Model, tea.Cmd) {109 m, _ := mdl.(model)110108func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {109 switch msg := msg.(type) {110111 case statusMsg:112 // The server returned a status message. Save it to our model. Also
28 unmodified lines
141Our view is very straightforward. We look at the current model and build a142string accordingly:143144```go147func view(mdl tea.Model) string {148 m, _ := mdl.(model)149145func (m model) View() string {146 // If there's an error, print it out and don't do anything else.147 if m.err != nil {148 return fmt.Sprintf("\nWe had some trouble: %v\n\n", m.err)149 }
12 unmodified lines
162```163164## Run the program165170The only thing left to do is run the program, so let's do that!166The only thing left to do is run the program, so let's do that! Our initial167model doesn't need any data at all in this case, we just initialize it with168as a `struct` with defaults.169170```go171func main() {174 if err := tea.NewProgram(initialize, update, view).Start(); err != nil {172 if err := tea.NewProgram(model{}).Start(); err != nil {173 fmt.Printf("Uh oh, there was an error: %v\n", err)174 os.Exit(1)175 }176}
66 unmodified lines
modified:tutorials/go.mod+1 added-1 removed
1module tutorial23go 1.1445require github.com/charmbracelet/bubbletea v0.10.35require github.com/charmbracelet/bubbletea v0.11.167replace github.com/charmbracelet/bubbletea => ../
modified:tutorials/go.sum+9 added-6 removed
1github.com/containerd/console v1.0.1 h1:u7SFAJyRqWcG6ogaMAx3KjSTy1e3hT9QxqX7Jco7dRc=2github.com/containerd/console v1.0.1/go.mod h1:XUsP6YE/mKtz6bxc+I8UiKKTP04qjQL4qcS3XoQ5xkw=3github.com/google/goterm v0.0.0-20190703233501-fc88cf888a3f h1:5CjVwnuUcp5adK4gmY6i72gpVFVnZDP2h5TmPScB6u4=4github.com/google/goterm v0.0.0-20190703233501-fc88cf888a3f/go.mod h1:nOFQdrUlIlx6M6ODdSpBj1NVA+VgLC6kmw60mkw34H4=5github.com/lucasb-eyer/go-colorful v1.0.3 h1:QIbQXiugsb+q10B+MI+7DI1oQLdmnep86tWFlaaUAac=6github.com/lucasb-eyer/go-colorful v1.0.3/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
2 unmodified lines
9github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=10github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=11github.com/muesli/termenv v0.7.2 h1:r1raklL3uKE7rOvWgSenmEm2px+dnc33OTisZ8YR1fw=12github.com/muesli/termenv v0.7.2/go.mod h1:ct2L5N2lmix82RaY3bMWwVu/jUFc9Ule0KGDCiKYPh8=11github.com/pkg/term v0.0.0-20200520122047-c3ffed290a03 h1:pd4YKIqCB0U7O2I4gWHgEUA2mCEOENmco0l/bM957bU=12github.com/pkg/term v0.0.0-20200520122047-c3ffed290a03/go.mod h1:Z9+Ul5bCbBKnbCvdOWbLqTHhJiYV414CURZJba6L8qA=13github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=14github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=15golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=14golang.org/x/crypto v0.0.0-20200709230013-948cd5f35899 h1:DZhuSZLsGlFL4CmhA8BcRA0mnthyA/nZ00AqCUo7vHg=15golang.org/x/crypto v0.0.0-20200709230013-948cd5f35899/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=16golang.org/x/crypto v0.0.0-20201012173705-84dcc777aaee h1:4yd7jl+vXjalO5ztz6Vc1VADv+S/80LGJmyl1ROJ2AI=17golang.org/x/crypto v0.0.0-20201012173705-84dcc777aaee/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=18golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=19golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=20golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=21golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=20golang.org/x/sys v0.0.0-20200821140526-fda516888d29 h1:mNuhGagCf3lDDm5C0376C/sxh6V7fy9WbdEu/YDNA04=21golang.org/x/sys v0.0.0-20200821140526-fda516888d29/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=22golang.org/x/sys v0.0.0-20200916030750-2334cc1a136f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=23golang.org/x/sys v0.0.0-20201009025420-dfb3f7c4e634 h1:bNEHhJCnrwMKNMmOx3yAynp5vs5/gRy+XWFtZFu7NBM=24golang.org/x/sys v0.0.0-20201009025420-dfb3f7c4e634/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=25golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
modified:README.md+137 added-105 removed
37 unmodified lines
3839## Tutorial4041Bubble Tea is based on the functional design paradigms of [The Elm42Architecture][elm]. It might not seem very Go-like at first, but once you get43used to the general structure you'll find that most of the idomatic Go things44you know and love are still relevant and useful here.42Architecture][elm] which happens work nicely with Go.4346By the way, the non-annotated source code for this program47[is also available](https://github.com/charmbracelet/bubbletea/tree/master/tutorials/basics).44By the way, the non-annotated source code for this program is available45[on GitHub](https://github.com/charmbracelet/bubbletea/tree/master/tutorials/basics).4647This tutorial assumes you have a working knowledge of Go.4849[elm]: https://guide.elm-lang.org/architecture/5053### Enough! Let's get to it.51## Enough! Let's get to it.5253For this tutorial we're making a to-do list.5457We'll start by defining our package and import some libraries. Our only external55To start we'll define our package and import some libraries. Our only external56import will be the Bubble Tea library, which we'll call `tea` for short.5758```go61package main59 package main6063import (64 "fmt"65 "os"61 import (62 "fmt"63 "os"6467 tea "github.com/charmbracelet/bubbletea"68)65 tea "github.com/charmbracelet/bubbletea"66 )67```6869Bubble Tea programs are comprised of a **model** that describes the application72state and three simple functions that are centered around that model:70state and three simple methods on that model:7174* **Initialize**, a function that returns the model's initial state.72* **Init**, a function that returns an initial command for the application to run.73* **Update**, a function that handles incoming events and updates the model accordingly.74* **View**, a function that renders the UI based on the data in the model.7578### The Model76## The Model7778So let's start by defining our model which will store our application's state.79It can be any type, but a `struct` usually makes the most sense.8081```go84type model struct {85 choices []string // items on the to-do list86 cursor int // which to-do list item our cursor is pointing at87 selected map[int]struct{} // which to-do items are selected88}82 type model struct {83 choices []string // items on the to-do list84 cursor int // which to-do list item our cursor is pointing at85 selected map[int]struct{} // which to-do items are selected86 }87```8891### The Initialization Function89## Initialization9093Next we'll define a function that will initialize our application. An94initialize function returns a model representing our application's initial95state, as well as a `Cmd` that could perform some initial I/O. For now, we96don't need to do any I/O, so for the command we'll just return `nil`, which97translates to "no command."91Next we'll define our application’s initial state. We’ll store our initial92model in a simple variable, and then define the `Init` method. `Init` can93return a `Cmd` that could perform some initial I/O. For now, we don't need to94do any I/O, so for the command we'll just return `nil`, which translates to "no95command."9697```go100func initialize() (tea.Model, tea.Cmd) {101 m := model{10298 var initialModel = model{99 // Our to-do list is just a grocery list100 choices: []string{"Buy carrots", "Buy celery", "Buy kohlrabi"},101102 // A map which indicates which choices are selected. We're using
1 unmodified line
104 // of the `choices` slice, above.105 selected: make(map[int]struct{}),106 }107108 func (m model) Init() (tea.Cmd) {112 // Return the model and `nil`, which means "no I/O right now, please."113 return m, nil114}109 // Just return `nil`, which means "no I/O right now, please."110 return m, nil111 }112```113117### The Update Function114## The Update Method115119Next we'll define the update function. The update function is called when116Next we'll define the update method. The update function is called when117"things happen." Its job is to look at what has happened and return an updated118model in response to whatever happened. It can also return a `Cmd` and make119more things happen, but for now don't worry about that part.120
10 unmodified lines
131For now, we'll just deal with `tea.KeyMsg` messages, which are automatically132sent to the update function when keys are pressed.133134```go138func update(msg tea.Msg, mdl tea.Model) (tea.Model, tea.Cmd) {139 m, _ := mdl.(model)135 func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {136 switch msg := msg.(type) {137141 switch msg := msg.(type) {138 // Is it a key press?139 case tea.KeyMsg:140143 // Is it a key press?144 case tea.KeyMsg:141 // Cool, what was the actual key pressed?142 switch msg.String() {143146 // Cool, what was the actual key pressed?147 switch msg.String() {144 // These keys should exit the program.145 case "ctrl+c", "q":146 return m, tea.Quit147149 // These keys should exit the program.150 case "ctrl+c", "q":151 return m, tea.Quit148 // The "up" and "k" keys move the cursor up149 case "up", "k":150 if m.cursor > 0 {151 m.cursor--152 }153153 // The "up" and "k" keys move the cursor up154 case "up", "k":155 if m.cursor > 0 {156 m.cursor--157 }154 // The "down" and "j" keys move the cursor down155 case "down", "j":156 if m.cursor < len(m.choices)-1 {157 m.cursor++158 }159159 // The "down" and "j" keys move the cursor down160 case "down", "j":161 if m.cursor < len(m.choices)-1 {162 m.cursor++160 // The "enter" key and the spacebar (a literal space) toggle161 // the selected state for the item that the cursor is pointing at.162 case "enter", " ":163 _, ok := m.selected[m.cursor]164 if ok {165 delete(m.selected, m.cursor)166 } else {167 m.selected[m.cursor] = struct{}{}168 }169 }164165 // The "enter" key and the spacebar (a literal space) toggle166 // the selected state for the item that the cursor is pointing at.167 case "enter", " ":168 _, ok := m.selected[m.cursor]169 if ok {170 delete(m.selected, m.cursor)171 } else {172 m.selected[m.cursor] = struct{}{}173 }170 }175 }171177 // Return the updated model to the Bubble Tea runtime for processing.178 // Note that we're not returning a command.179 return m, nil180}172 // Return the updated model to the Bubble Tea runtime for processing.173 // Note that we're not returning a command.174 return m, nil175 }176```177178You may have noticed that "ctrl+c" and "q" above return a `tea.Quit` command179with the model. That's a special command which instructs the Bubble Tea runtime180to quit, exiting the program.181187### The View Function182## The View Method183189At last, it's time to render our UI. Of all the functions, the view is the190simplest. A model, in it's current state, comes in and a `string` comes out.191That string is our UI!184At last, it's time to render our UI. Of all the methods, the view is the185simplest. We look at the model in it's current state and use it to return186a `string`. That string is our UI!187188Because the view describes the entire UI of your application, you don't have189to worry about redraw logic and stuff like that. Bubble Tea takes care of it190for you.191192```go198func view(mdl tea.Model) string {199 m, _ := mdl.(model)193 func (m model) View() string {194 // The header195 s := "What should we buy at the market?\n\n"196201 // The header202 s := "What should we buy at the market?\n\n"197 // Iterate over our choices198 for i, choice := range m.choices {199204 // Iterate over our choices205 for i, choice := range m.choices {200 // Is the cursor pointing at this choice?201 cursor := " " // no cursor202 if m.cursor == i {203 cursor = ">" // cursor!204 }205207 // Is the cursor pointing at this choice?208 cursor := " " // no cursor209 if m.cursor == i {210 cursor = ">" // cursor!211 }206 // Is this choice selected?207 checked := " " // not selected208 if _, ok := m.selected[i]; ok {209 checked = "x" // selected!210 }211213 // Is this choice selected?214 checked := " " // not selected215 if _, ok := m.selected[i]; ok {216 checked = "x" // selected!212 // Render the row213 s += fmt.Sprintf("%s [%s] %s\n", cursor, checked, choice)214 }215219 // Render the row220 s += fmt.Sprintf("%s [%s] %s\n", cursor, checked, choice)221 }216 // The footer217 s += "\nPress q to quit.\n"218223 // The footer224 s += "\nPress q to quit.\n"225226 // Send the UI for rendering227 return s228}219 // Send the UI for rendering220 return s221 }222```223231### All Together Now224## All Together Now225233The last step is to simply run our program. We pass our functions to226The last step is to simply run our program. We pass our initial model to227`tea.NewProgram` and let it rip:228229```go237func main() {238 p := tea.NewProgram(initialize, update, view)239 if err := p.Start(); err != nil {240 fmt.Printf("Alas, there's been an error: %v", err)241 os.Exit(1)230 func main() {231 p := tea.NewProgram(initialModel)232 if err := p.Start(); err != nil {233 fmt.Printf("Alas, there's been an error: %v", err)234 os.Exit(1)235 }236 }243}237```238239## What's Next?240241This tutorial covers the basics of building an interactive terminal UI, but242in the real world you'll also need to perform I/O. To learn about that have a243look at the [Command Tutorial][cmd]. It's pretty simple.244245There are also several [Bubble Tea examples][examples] available and, of course,246there are [Go Docs][docs].247248[cmd]: http://github.com/charmbracelet/bubbletea/tree/master/tutorials/commands/249[examples]: http://github.com/charmbracelet/bubbletea/tree/master/examples250[docs]: https://pkg.go.dev/github.com/charmbracelet/glow?tab=doc251252### Bubble Tea in the Wild253254For some Bubble Tea programs in production, see:255256* [Glow](https://github.com/charmbracelet/glow): a markdown reader, browser and online markdown stash257* [The Charm Tool](https://github.com/charmbracelet/charm): the Charm user account manager258259### Libraries we use with Bubble Tea260261* [Bubbles][bubbles] various Bubble Tea components262* [Termenv][termenv]: Advanced ANSI styling for terminal applications263* [Reflow][reflow]: ANSI-aware methods for reflowing blocks of text264* [go-runewidth][runewidth]: Measure the physical width of strings in terms of terminal cells. Many runes, such as East Asian charcters and emojis, are two cells wide, so measuring a layout with `len()` often won't cut it.265266[termenv]: https://github.com/muesli/termenv267[reflow]: https://github.com/muesli/reflow268[bubbles]: https://github.com/charmbracelet/bubbles269[runewidth]: https://github.com/mattn/go-runewidth270271### Feedback272273We'd love to hear your thoughts on this tutorial. Feel free to drop us a note!274275* [Twitter](https://twitter.com/charmcli)276* [The Fediverse](https://mastodon.technology/@charm)277278### What's Next?279280This tutorial covers the basics of building an interactive terminal UI, but281in the real world you'll also need to perform I/O. To learn about that have a
50 unmodified lines