aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/terminal.go
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2023-04-02 22:57:13 +0200
committerRobin Jarry <robin@jarry.cc>2023-04-04 00:20:24 +0200
commit382aea4a942600935a5c2d0e4d42cbe129e9be9a (patch)
tree3bbe3d5cb3e2c086f208753c2ea3d02515d599f4 /widgets/terminal.go
parent63019343660049eadb2273a7ea0e13a2a0580b51 (diff)
downloadaerc-382aea4a942600935a5c2d0e4d42cbe129e9be9a.tar.gz
terminal: avoid high cpu usage when not focused
When running dynamic tui applications (such as btop, htop, etc.) in the embedded :terminal and focusing an account tab, every tui application change triggers a full redraw of the whole window. When the message list is focused, this leads to high cpu usage because of the computationally intensive templates parsing and ansi sequence handling. Only redraw when the terminal is focused. Do not use tcell Watch and Unwatch functions since these completely disable all widget updates, including title changes and terminal close events. Reported-by: John Mcenroy <handplanet@outlook.com> Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: John Mcenroy <handplanet@outlook.com>
Diffstat (limited to 'widgets/terminal.go')
-rw-r--r--widgets/terminal.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/widgets/terminal.go b/widgets/terminal.go
index 0e31bf71..ca5a5ef2 100644
--- a/widgets/terminal.go
+++ b/widgets/terminal.go
@@ -149,7 +149,9 @@ func (term *Terminal) HandleEvent(ev tcell.Event) bool {
}
switch ev := ev.(type) {
case *views.EventWidgetContent:
- ui.QueueRedraw()
+ if term.focus {
+ ui.QueueRedraw()
+ }
return true
case *tcellterm.EventTitle:
if term.OnTitle != nil {