summaryrefslogtreecommitdiff
path: root/help.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-03-02 13:34:09 -0600
committerJeff Carr <[email protected]>2025-03-02 13:34:09 -0600
commit063818335663e7aa626434d5dc035f8b5455e5ae (patch)
tree85a8543f77124fb919352a564775b3f77b567be0 /help.go
parentf24c5098597922913f68d22960033318fb56ad1d (diff)
start moving to standard internal TK functions
Diffstat (limited to 'help.go')
-rw-r--r--help.go100
1 files changed, 73 insertions, 27 deletions
diff --git a/help.go b/help.go
index 4c64ec2..fa011c6 100644
--- a/help.go
+++ b/help.go
@@ -15,6 +15,8 @@ import (
"github.com/awesome-gocui/gocui"
log "go.wit.com/log"
+ "go.wit.com/toolkits/tree"
+ "go.wit.com/widget"
)
/*
@@ -86,37 +88,81 @@ func showHelp() error {
}
g.SetViewOnTop("help")
me.helpLabel = help
- if me.clock.tk == nil {
- makeClock()
- me.clock.tk.MoveToOffset(maxX-10, 1)
- me.clock.tk.Hide()
- me.clock.tk.Show()
+ if me.treeRoot == nil {
+ log.Info("gogui makeClock() error. treeRoot == nil")
+ return nil
+ } else {
+ if me.notify.clock.tk == nil {
+ makeClock(me.notify.clock.wId)
+ me.notify.clock.tk.MoveToOffset(maxX-10, 1)
+ me.notify.clock.tk.Hide()
+ me.notify.clock.tk.Show()
+ }
+ if me.notify.clock.tk != nil {
+ me.notify.clock.tk.MoveToOffset(maxX-10, 1)
+ me.notify.clock.tk.Hide()
+ me.notify.clock.tk.Show()
+ }
+ if me.stdout.tk == nil {
+ makeOutputWidget(me.baseGui, "made this in showHelp()")
+ msg := fmt.Sprintf("test to stdout from in showHelp() %d\n", me.ecount)
+ me.stdout.Write([]byte(msg))
+ log.Log(NOW, "log.log(NOW) test")
+ }
}
- if me.clock.tk != nil {
- me.clock.tk.MoveToOffset(maxX-10, 1)
- me.clock.tk.Hide()
- me.clock.tk.Show()
+ return nil
+}
+
+// create a new widget in the binary tree
+func makeNewInternalWidget(wId int) *guiWidget {
+ if me.treeRoot == nil {
+ log.Info("GOGUI Init ERROR. treeRoot == nil")
+ return nil
}
- if me.stdout.tk == nil {
- makeOutputWidget(me.baseGui, "made this in showHelp()")
- msg := fmt.Sprintf("test to stdout from in showHelp() %d\n", me.ecount)
- me.stdout.Write([]byte(msg))
- log.Log(NOW, "log.log(NOW) test")
+ n := new(tree.Node)
+ n.WidgetType = widget.Flag
+ n.WidgetId = wId
+ n.ParentId = 0
+
+ // store the internal toolkit information
+ tk := new(guiWidget)
+ tk.frame = true
+
+ tk.node = n
+ tk.node.Parent = me.treeRoot
+
+ // set the name used by gocui to the id
+ tk.cuiName = fmt.Sprintf("%d DR", wId)
+
+ tk.setColorInput()
+
+ // add this new widget on the binary tree
+ tk.parent = me.treeRoot.TK.(*guiWidget)
+ if tk.parent == nil {
+ panic("makeNewFlagWidget() didn't get treeRoot guiWidget")
+ } else {
+ tk.parent.children = append(tk.parent.children, tk)
}
- return nil
+
+ n.TK = tk
+ return tk
}
-func makeClock() {
- me.clock.tk = makeNewFlagWidget(me.clock.wId)
- me.clock.tk.dumpWidget("init() clock")
+func makeClock(wId int) {
+ if me.treeRoot == nil {
+ log.Info("gogui makeClock() error. treeRoot == nil")
+ return
+ }
+ me.notify.clock.tk = makeNewInternalWidget(wId)
+ me.notify.clock.tk.dumpWidget("init() clock")
w, h := me.baseGui.MousePosition()
- me.clock.tk.MoveToOffset(w, h)
- me.clock.tk.labelN = time.Now().Format("15:04:05")
- me.clock.tk.frame = false
- me.clock.tk.setColorLabel()
- me.clock.tk.Show()
- me.clock.active = true
- me.clock.tk.dumpWidget("showClock()")
+ me.notify.clock.tk.MoveToOffset(w, h)
+ me.notify.clock.tk.labelN = time.Now().Format("15:04:05")
+ me.notify.clock.tk.frame = false
+ me.notify.clock.tk.setColorLabel()
+ me.notify.clock.tk.Show()
+ me.notify.clock.active = true
+ me.notify.clock.tk.dumpWidget("showClock()")
}
// in the very end of redrawing things, this will place the help and stdout on the top or botton
@@ -127,8 +173,8 @@ func setThingsOnTop() {
} else {
me.baseGui.SetViewOnTop("help")
}
- if me.clock.tk != nil {
- me.baseGui.SetViewOnTop(me.clock.tk.v.Name())
+ if me.notify.clock.tk != nil {
+ me.baseGui.SetViewOnTop(me.notify.clock.tk.v.Name())
}
if me.stdout.tk == nil {