summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Culverhouse <tim@timculverhouse.com>2022-10-06 11:46:40 -0500
committerRobin Jarry <robin@jarry.cc>2022-10-07 10:51:53 +0200
commitd847073bdf67a2fd8c8695dbacbe010bcbfd27c8 (patch)
treec36a26a3abc4810a3cd7ba9b56bb0d8f01af7f69
parentc6561d32a8430f99bb84224ba8fde3ddcd44257e (diff)
downloadaerc-d847073bdf67a2fd8c8695dbacbe010bcbfd27c8.tar.gz
aerc-d847073bdf67a2fd8c8695dbacbe010bcbfd27c8.zip
events: introduce AercMsg and QueueRedraw
Add AercMsg as a main interface for internal communication in aerc in preparation for a main event loop. Add a QueueRedraw function to to trigger a redraw. This will be needed for widgets which should be drawn after some delay (completions, terminal, for example) Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
-rw-r--r--lib/ui/interfaces.go3
-rw-r--r--lib/ui/ui.go8
2 files changed, 11 insertions, 0 deletions
diff --git a/lib/ui/interfaces.go b/lib/ui/interfaces.go
index 7e117256..8a62ecf0 100644
--- a/lib/ui/interfaces.go
+++ b/lib/ui/interfaces.go
@@ -4,6 +4,9 @@ import (
"github.com/gdamore/tcell/v2"
)
+// AercMsg is used to communicate within aerc
+type AercMsg interface{}
+
// Drawable is a UI component that can draw. Unless specified, all methods must
// only be called from a single goroutine, the UI goroutine.
type Drawable interface {
diff --git a/lib/ui/ui.go b/lib/ui/ui.go
index 632d5f1d..d477242e 100644
--- a/lib/ui/ui.go
+++ b/lib/ui/ui.go
@@ -7,6 +7,14 @@ import (
"github.com/gdamore/tcell/v2"
)
+var MsgChannel = make(chan AercMsg, 50)
+
+// QueueRedraw sends a nil message into the MsgChannel. Nothing will handle this
+// message, but a redraw will occur if the UI is marked as invalid
+func QueueRedraw() {
+ MsgChannel <- nil
+}
+
type UI struct {
Content DrawableInteractive
exit atomic.Value // bool