Add ProgramOptions for entering the altscreen and enabling the mouse

Because they run ansyncronously, the analogous commands, when run in
a Model's Init() function, could fire after the renderer has starting
writing to output, rendering artifacts to the commandline.
This commit is contained in:
Christian Rocha
2021-05-19 20:52:01 -04:00
parent ec2fbf024b
commit 85ab476698
4 changed files with 176 additions and 60 deletions

View File

@@ -16,7 +16,8 @@ type model int
type tickMsg time.Time
func main() {
if err := tea.NewProgram(model(5)).Start(); err != nil {
p := tea.NewProgram(model(5), tea.WithAltScreen())
if err := p.Start(); err != nil {
log.Fatal(err)
}
}