From a152cce4b6d0e5290c4da4ab55ce330cb8541035 Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Wed, 17 Jun 2020 12:10:03 -0400 Subject: [PATCH] Adjust comments + move some code around --- tea.go | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/tea.go b/tea.go index b137abe..8634b90 100644 --- a/tea.go +++ b/tea.go @@ -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