summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Culverhouse <tim@timculverhouse.com>2022-10-06 11:46:43 -0500
committerRobin Jarry <robin@jarry.cc>2022-10-07 10:51:53 +0200
commita49caf96b5419150989c2517fdb8f0aca7cfe92d (patch)
tree32e26fad6ceb9a1c2e4b40ddf032239abf2d9c53
parent725fe07d240b035205e48fba3af3de6dc0ddc9d2 (diff)
downloadaerc-a49caf96b5419150989c2517fdb8f0aca7cfe92d.tar.gz
aerc-a49caf96b5419150989c2517fdb8f0aca7cfe92d.zip
terminal: use Invalidate and QueueRedraw
The terminal widget uses it's own redraw logic to improve performance. With the addition of a main event loop, the redraw logic can happen in the main loop via the standard Invalidate logic. Use the Invalidate method to mark aerc invalid, and immediately trigger a redraw with ui.QueueRedraw. The follow up call to QueueRedraw is needed because the terminal update happens in a separate goroutine. This can result in the main event loop finishing it's process of the current event, redrawing the screen, and the terminal having additional updates to be drawn. This fixes race conditions by drawing and calling screen.Show in a separate goroutine. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
-rw-r--r--widgets/terminal.go16
1 files changed, 2 insertions, 14 deletions
diff --git a/widgets/terminal.go b/widgets/terminal.go
index 82954a70..39cd9f24 100644
--- a/widgets/terminal.go
+++ b/widgets/terminal.go
@@ -148,20 +148,8 @@ func (term *Terminal) HandleEvent(ev tcell.Event) bool {
}
switch ev := ev.(type) {
case *views.EventWidgetContent:
- if !term.focus {
- return false
- }
- // Draw here for performance improvement. We call draw again in
- // the main Draw, but tcell-term only draws dirty cells, so it
- // won't be too much extra CPU there. Drawing there is needed
- // for certain msgviews, particularly if the pager command
- // exits.
- term.draw()
- // Perform a tcell screen.Show() to show our updates
- // immediately
- if term.ctx != nil {
- term.ctx.Show()
- }
+ term.Invalidate()
+ ui.QueueRedraw()
return true
case *tcellterm.EventTitle:
if term.OnTitle != nil {