aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ui/stack.go
diff options
context:
space:
mode:
authorTim Culverhouse <tim@timculverhouse.com>2022-10-07 11:00:31 -0500
committerRobin Jarry <robin@jarry.cc>2022-10-12 22:16:40 +0200
commitba24e92062f1a9b38065d503fd1dde749c27a56c (patch)
treed1a2981f8f9bda50a070b50c688388fe2130f770 /lib/ui/stack.go
parent34014d3ceeebe8a9c131213fa56d1977fbc26b4a (diff)
downloadaerc-ba24e92062f1a9b38065d503fd1dde749c27a56c.tar.gz
invalidatable: cleanup dead code
Remove invalidatable type and all associated calls. All items can directly invalidate the UI. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'lib/ui/stack.go')
-rw-r--r--lib/ui/stack.go25
1 files changed, 3 insertions, 22 deletions
diff --git a/lib/ui/stack.go b/lib/ui/stack.go
index 5ccf13bc..c0aca4e4 100644
--- a/lib/ui/stack.go
+++ b/lib/ui/stack.go
@@ -9,9 +9,8 @@ import (
)
type Stack struct {
- children []Drawable
- onInvalidate []func(d Drawable)
- uiConfig config.UIConfig
+ children []Drawable
+ uiConfig config.UIConfig
}
func NewStack(uiConfig config.UIConfig) *Stack {
@@ -22,14 +21,8 @@ func (stack *Stack) Children() []Drawable {
return stack.children
}
-func (stack *Stack) OnInvalidate(onInvalidate func(d Drawable)) {
- stack.onInvalidate = append(stack.onInvalidate, onInvalidate)
-}
-
func (stack *Stack) Invalidate() {
- for _, fn := range stack.onInvalidate {
- fn(stack)
- }
+ Invalidate()
}
func (stack *Stack) Draw(ctx *Context) {
@@ -50,11 +43,7 @@ func (stack *Stack) MouseEvent(localX int, localY int, event tcell.Event) {
}
func (stack *Stack) Push(d Drawable) {
- if len(stack.children) != 0 {
- stack.Peek().OnInvalidate(nil)
- }
stack.children = append(stack.children, d)
- d.OnInvalidate(stack.invalidateFromChild)
stack.Invalidate()
}
@@ -65,10 +54,6 @@ func (stack *Stack) Pop() Drawable {
d := stack.children[len(stack.children)-1]
stack.children = stack.children[:len(stack.children)-1]
stack.Invalidate()
- d.OnInvalidate(nil)
- if len(stack.children) != 0 {
- stack.Peek().OnInvalidate(stack.invalidateFromChild)
- }
return d
}
@@ -78,7 +63,3 @@ func (stack *Stack) Peek() Drawable {
}
return stack.children[len(stack.children)-1]
}
-
-func (stack *Stack) invalidateFromChild(d Drawable) {
- stack.Invalidate()
-}