From d847073bdf67a2fd8c8695dbacbe010bcbfd27c8 Mon Sep 17 00:00:00 2001 From: Tim Culverhouse Date: Thu, 6 Oct 2022 11:46:40 -0500 Subject: 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 Acked-by: Robin Jarry --- lib/ui/ui.go | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lib/ui/ui.go') 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 -- cgit