From 4fbbd2cee13546dbe570509e2c2e0755225a1489 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sun, 28 Jan 2024 02:20:31 -0600 Subject: large refactor to use the tree package Things build and now need to be fixed treeRoot has no children lists all widgets works shows help module loads Signed-off-by: Jeff Carr --- color.go | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) (limited to 'color.go') diff --git a/color.go b/color.go index 45600c3..4c9ffe6 100644 --- a/color.go +++ b/color.go @@ -1,10 +1,12 @@ package main import ( - "github.com/awesome-gocui/gocui" "math/rand" + "github.com/awesome-gocui/gocui" + "go.wit.com/log" + "go.wit.com/toolkits/tree" ) //w.v.SelBgColor = gocui.ColorCyan @@ -65,8 +67,10 @@ var colorNone colorT = colorT{none, none, none, none, none, "debug none"} // TODO: maybe enough of us could actually do that if we made it a goal. // TODO: start with riscv boards and fix it universally there // TODO: so just a small little 'todo' item here -func (n *node) setColor(newColor *colorT) { - tk := n.tk +func setColor(n *tree.Node, newColor *colorT) { + var tk *guiWidget + tk = n.TK.(*guiWidget) + if tk.color == newColor { // nothing to do since the colors have nto changed return @@ -80,15 +84,18 @@ func (n *node) setColor(newColor *colorT) { tk.color = &colorNone } log.Log(NOW, "Set the node to color =", tk.color.name) - n.recreateView() + tk.recreateView() } -func (n *node) setDefaultWidgetColor() { - n.showView() +func setDefaultWidgetColor(n *tree.Node) { + var w *guiWidget + w = n.TK.(*guiWidget) + w.showView() } -func (n *node) setDefaultHighlight() { - w := n.tk +func setDefaultHighlight(n *tree.Node) { + var w *guiWidget + w = n.TK.(*guiWidget) if w.v == nil { log.Log(ERROR, "SetColor() failed on view == nil") return @@ -104,17 +111,16 @@ func randColor() gocui.Attribute { return gocui.GetColor(colors[i]) } -func (n *node) redoColor(draw bool) { - w := n.tk +func (w *guiWidget) redoColor(draw bool) { if w == nil { return } log.Sleep(.05) - n.setDefaultHighlight() - n.setDefaultWidgetColor() + setDefaultHighlight(w.node) + setDefaultWidgetColor(w.node) - for _, child := range n.children { + for _, child := range w.children { child.redoColor(draw) } } -- cgit v1.2.3