mirror of
https://github.com/taigrr/bubbletea.git
synced 2026-04-02 02:59:09 -07:00
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:
@@ -11,7 +11,8 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
if err := tea.NewProgram(model{}).Start(); err != nil {
|
||||
p := tea.NewProgram(model{}, tea.WithAltScreen(), tea.WithMouseAllMotion())
|
||||
if err := p.Start(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
@@ -22,7 +23,7 @@ type model struct {
|
||||
}
|
||||
|
||||
func (m model) Init() tea.Cmd {
|
||||
return tea.Batch(tea.EnterAltScreen, tea.EnableMouseAllMotion)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
|
||||
Reference in New Issue
Block a user