working clear screen

This commit is contained in:
2026-03-03 23:17:47 +01:00
parent 787290a072
commit aab100fd9f
3 changed files with 110 additions and 0 deletions

41
tpwsetup/tpwsetup.go Normal file
View File

@@ -0,0 +1,41 @@
package main
import (
"fmt"
"os"
tea "github.com/charmbracelet/bubbletea"
)
type model int
func (m model) Init() tea.Cmd {
return nil
}
func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) {
case tea.KeyMsg:
switch msg.String() {
case "ctrl+c", "q":
return m, tea.Quit
case "+":
return m + 1, nil
case "-":
return m - 1, nil
}
}
return m, nil
}
func (m model) View() string {
return fmt.Sprintf("Count: %d\nPress + to increment, - to decrement, q to quit.\n", m)
}
func main() {
p := tea.NewProgram(model(0), tea.WithAltScreen())
if err := p.Start(); err != nil {
fmt.Fprintf(os.Stderr, "Error running program: %v\n", err)
os.Exit(1)
}
}