Adjust comments + move some code around

This commit is contained in:
Christian Rocha 2020-06-17 12:10:03 -04:00
parent ae9ea29c0e
commit a152cce4b6
No known key found for this signature in database
GPG Key ID: D6CC7A16E5878018
1 changed files with 19 additions and 17 deletions

36
tea.go
View File

@ -176,23 +176,6 @@ func (p *Program) Start() error {
return nil
}
// Report resizes to the renderer. This only matters if we're doing
// higher performance scroll-based rendering.
if size, ok := msg.(WindowSizeMsg); ok {
mrRenderer.width = size.width
mrRenderer.height = size.height
}
// Handle messages telling the renderer to ignore ranges of lines
if ignore, ok := msg.(IgnoreLinesMsg); ok {
mrRenderer.setIgnoredLines(ignore.from, ignore.to)
}
// Handle messages telling the renderer to stop ignoring lines
if _, ok := msg.(IgnoreLinesMsg); ok {
mrRenderer.clearIgnoredLines()
}
// Process batch commands
if batchedCmds, ok := msg.(batchMsg); ok {
for _, cmd := range batchedCmds {
@ -201,6 +184,25 @@ func (p *Program) Start() error {
continue
}
// Report resizes to the renderer. Only necessary for special,
// performance-based rendering.
if size, ok := msg.(WindowSizeMsg); ok {
mrRenderer.width = size.width
mrRenderer.height = size.height
}
// Handle messages telling the main rendering routine to ignore
// ranges of lines. Useful for performance-based rendering.
if ignore, ok := msg.(IgnoreLinesMsg); ok {
mrRenderer.setIgnoredLines(ignore.from, ignore.to)
}
// Handle messages telling the main rendering to stop ignoring
// lines. Useful when disabling any performance-based rendering.
if _, ok := msg.(IgnoreLinesMsg); ok {
mrRenderer.clearIgnoredLines()
}
model, cmd = p.update(msg, model) // run update
cmds <- cmd // process command (if any)
mrRenderer.write(p.view(model)) // send view to renderer