aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorTim Culverhouse <tim@timculverhouse.com>2024-07-16 08:26:37 -0500
committerRobin Jarry <robin@jarry.cc>2024-08-03 17:39:57 +0200
commitf8b74a9a9f1b607e20f7b5654e85b03be34ce0ed (patch)
treed8a786e770ced718cacc80ff5017a7b614694cb7 /lib
parent4743e7ff81223ed28334f8370eac6b08472791ec (diff)
downloadaerc-f8b74a9a9f1b607e20f7b5654e85b03be34ce0ed.tar.gz
ui: add :redraw command
Add a :redraw command to force a repaint of the entire screen. Changelog-added: New `:redraw` command to force a repaint of the screen. Requested-by: Remko Tronçon <r@mko.re> Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Tested-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'lib')
-rw-r--r--lib/ui/ui.go14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/ui/ui.go b/lib/ui/ui.go
index 0825b5b5..c20eac37 100644
--- a/lib/ui/ui.go
+++ b/lib/ui/ui.go
@@ -45,6 +45,7 @@ var state struct {
dirty uint32 // == 1 if render has been queued in Redraw channel
// == 1 if suspend is pending
suspending uint32
+ refresh uint32 // == 1 if a refresh has been queued
}
func Initialize(content DrawableInteractive) error {
@@ -122,6 +123,12 @@ func Close() {
state.vx.Close()
}
+func QueueRefresh() {
+ if atomic.SwapUint32(&state.refresh, 1) != 1 {
+ Invalidate()
+ }
+}
+
func Render() {
if atomic.SwapUint32(&state.dirty, 0) != 0 {
state.vx.Window().Clear()
@@ -133,7 +140,12 @@ func Render() {
// if the Draw resulted in a popover, draw it
state.popover.Draw(state.ctx)
}
- state.vx.Render()
+ switch atomic.SwapUint32(&state.refresh, 0) {
+ case 0:
+ state.vx.Render()
+ case 1:
+ state.vx.Refresh()
+ }
}
}