Skip to content

Commit

Permalink
Pull batch processing into the internal message switch
Browse files Browse the repository at this point in the history
  • Loading branch information
meowgorithm committed May 6, 2021
1 parent 4fbe50a commit ddb596b
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions tea.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()

Expand All @@ -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)
Expand Down

0 comments on commit ddb596b

Please sign in to comment.