Pull batch processing into the internal message switch

This commit is contained in:
Christian Rocha 2021-05-06 13:48:46 -04:00
parent 4fbe50adb6
commit c07cbd1e32
1 changed files with 8 additions and 10 deletions

18
tea.go
View File

@ -422,8 +422,8 @@ func (p *Program) Start() error {
return err
case msg := <-msgs:
// Handle special messages
switch msg.(type) {
// Handle special internal messages
switch msg := msg.(type) {
case quitMsg:
p.ExitAltScreen()
p.DisableMouseCellMotion()
@ -432,6 +432,12 @@ func (p *Program) Start() error {
close(done)
return nil
case batchMsg:
for _, cmd := range msg {
cmds <- cmd
}
continue
case enterAltScreenMsg:
p.EnterAltScreen()
@ -452,14 +458,6 @@ func (p *Program) Start() error {
hideCursor(p.output)
}
// Process batch commands
if batchedCmds, ok := msg.(batchMsg); ok {
for _, cmd := range batchedCmds {
cmds <- cmd
}
continue
}
// Process internal messages for the renderer
if r, ok := p.renderer.(*standardRenderer); ok {
r.handleMessages(msg)