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>
This commit is contained in:
parent
c6561d32a8
commit
d847073bdf
2 changed files with 11 additions and 0 deletions
|
@ -4,6 +4,9 @@ import (
|
||||||
"github.com/gdamore/tcell/v2"
|
"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
|
// Drawable is a UI component that can draw. Unless specified, all methods must
|
||||||
// only be called from a single goroutine, the UI goroutine.
|
// only be called from a single goroutine, the UI goroutine.
|
||||||
type Drawable interface {
|
type Drawable interface {
|
||||||
|
|
|
@ -7,6 +7,14 @@ import (
|
||||||
"github.com/gdamore/tcell/v2"
|
"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 {
|
type UI struct {
|
||||||
Content DrawableInteractive
|
Content DrawableInteractive
|
||||||
exit atomic.Value // bool
|
exit atomic.Value // bool
|
||||||
|
|
Loading…
Reference in a new issue