forked from Mirrors/bubbletea
36 lines
575 B
Go
36 lines
575 B
Go
|
package main
|
||
|
|
||
|
// A simple example illustrating how to set a window title.
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"os"
|
||
|
|
||
|
tea "github.com/charmbracelet/bubbletea"
|
||
|
)
|
||
|
|
||
|
type model struct{}
|
||
|
|
||
|
func (m model) Init() tea.Cmd {
|
||
|
return tea.SetWindowTitle("Bubble Tea Example")
|
||
|
}
|
||
|
|
||
|
func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||
|
switch msg.(type) {
|
||
|
case tea.KeyMsg:
|
||
|
return m, tea.Quit
|
||
|
}
|
||
|
return m, nil
|
||
|
}
|
||
|
|
||
|
func (m model) View() string {
|
||
|
return "\nPress any key to quit."
|
||
|
}
|
||
|
|
||
|
func main() {
|
||
|
if _, err := tea.NewProgram(model{}).Run(); err != nil {
|
||
|
fmt.Println("Uh oh:", err)
|
||
|
os.Exit(1)
|
||
|
}
|
||
|
}
|