2024-01-03 11:18:56 -06:00
|
|
|
package debugger
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
|
|
|
|
"go.wit.com/log"
|
|
|
|
"go.wit.com/gui/gui"
|
2024-01-04 23:28:55 -06:00
|
|
|
"go.wit.com/gui/gadgets"
|
2024-01-15 16:55:17 -06:00
|
|
|
"go.wit.com/gui/lib/logsettings"
|
2024-01-03 11:18:56 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
/*
|
|
|
|
Creates a window helpful for debugging this package
|
|
|
|
*/
|
|
|
|
|
|
|
|
func DebugWindow(p *gui.Node) {
|
2024-01-04 23:28:55 -06:00
|
|
|
if (me != nil) {
|
2024-01-05 14:50:14 -06:00
|
|
|
log.Warn("Draw then Toggle() debuging window here")
|
2024-01-04 23:28:55 -06:00
|
|
|
me.bugWin.Toggle()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
me = new(debuggerSettings)
|
|
|
|
me.myGui = p
|
|
|
|
|
|
|
|
me.bugWin = gadgets.NewBasicWindow(p,"go.wit.com/gui debug window")
|
2024-01-05 16:56:03 -06:00
|
|
|
me.bugWin.Draw()
|
2024-01-04 23:28:55 -06:00
|
|
|
DebugWindow2(me.bugWin.Box(), "Debug Tab")
|
|
|
|
|
2024-01-05 14:50:14 -06:00
|
|
|
// initialize the log settings window (does not display it)
|
2024-01-04 23:28:55 -06:00
|
|
|
me.myLS = logsettings.New(me.myGui)
|
2024-01-05 14:50:14 -06:00
|
|
|
|
2024-01-03 13:25:47 -06:00
|
|
|
if ArgDebug() {
|
2024-01-03 11:18:56 -06:00
|
|
|
log.SetTmp()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-04 23:28:55 -06:00
|
|
|
func DebugWindow2(newB *gui.Node, title string) *gui.Node {
|
|
|
|
var gr *gui.Node
|
2024-01-03 11:18:56 -06:00
|
|
|
|
|
|
|
//////////////////////// main debug things //////////////////////////////////
|
2024-01-03 22:10:13 -06:00
|
|
|
gr = newB.NewGroup("Debugging Windows:")
|
2024-01-03 11:18:56 -06:00
|
|
|
|
2024-01-03 22:10:13 -06:00
|
|
|
gr.NewButton("logging", func () {
|
2024-01-04 23:28:55 -06:00
|
|
|
me.myLS.Toggle()
|
2024-01-03 11:18:56 -06:00
|
|
|
})
|
2024-01-04 23:28:55 -06:00
|
|
|
gr.NewButton("Widgets Window", func () {
|
|
|
|
if me.widgets == nil {
|
|
|
|
me.widgets = DebugWidgetWindow(me.myGui)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
me.widgets.Toggle()
|
2024-01-03 11:18:56 -06:00
|
|
|
})
|
|
|
|
|
2024-01-03 22:10:13 -06:00
|
|
|
gr.NewLabel("Force Quit:")
|
2024-01-03 11:18:56 -06:00
|
|
|
|
2024-01-03 22:10:13 -06:00
|
|
|
gr.NewButton("os.Exit()", func () {
|
2024-01-03 11:18:56 -06:00
|
|
|
os.Exit(0)
|
|
|
|
})
|
|
|
|
|
|
|
|
//////////////////////// window debugging things //////////////////////////////////
|
2024-01-03 22:10:13 -06:00
|
|
|
gr = newB.NewGroup("list things")
|
2024-01-03 11:18:56 -06:00
|
|
|
|
2024-01-03 22:10:13 -06:00
|
|
|
gr.NewButton("List toolkits", func () {
|
|
|
|
dropdownWindow(gr)
|
2024-01-03 11:18:56 -06:00
|
|
|
bugWin.ListToolkits()
|
|
|
|
})
|
2024-01-03 22:10:13 -06:00
|
|
|
gr.NewButton("List Windows", func () {
|
|
|
|
dropdownWindow(gr)
|
2024-01-03 11:18:56 -06:00
|
|
|
})
|
2024-01-03 22:10:13 -06:00
|
|
|
gr.NewButton("List Window Widgets", func () {
|
|
|
|
dropdownWindowWidgets(gr)
|
2024-01-03 11:18:56 -06:00
|
|
|
})
|
|
|
|
|
2024-01-03 22:10:13 -06:00
|
|
|
gr = newB.NewGroup("more things")
|
2024-01-03 11:18:56 -06:00
|
|
|
|
2024-01-03 22:10:13 -06:00
|
|
|
gr.NewButton("Node.ListChildren(true)", func () {
|
2024-01-03 11:18:56 -06:00
|
|
|
if (activeWidget == nil) {
|
|
|
|
activeWidget = bugWin
|
|
|
|
}
|
|
|
|
activeWidget.ListChildren(true)
|
|
|
|
})
|
|
|
|
|
2024-01-03 22:10:13 -06:00
|
|
|
gr.NewButton("test conc", func () {
|
2024-01-08 22:33:18 -06:00
|
|
|
log.Log(WARN, "TODO: fix me")
|
2024-01-03 11:18:56 -06:00
|
|
|
// makeConc()
|
|
|
|
})
|
|
|
|
|
2024-01-03 22:10:13 -06:00
|
|
|
gr.NewButton("List Plugins", func () {
|
2024-01-08 22:33:18 -06:00
|
|
|
log.Log(WARN, "TODO: fix me")
|
2024-01-03 11:18:56 -06:00
|
|
|
/*
|
|
|
|
for _, aplug := range allPlugins {
|
|
|
|
log.Log(true, "Loaded plugin:", aplug.name, aplug.filename)
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
})
|
|
|
|
|
2024-01-03 22:10:13 -06:00
|
|
|
gr.NewButton("load toolkit 'gocui'", func () {
|
2024-01-03 11:18:56 -06:00
|
|
|
bugWin.LoadToolkit("gocui")
|
|
|
|
})
|
|
|
|
|
2024-01-03 22:10:13 -06:00
|
|
|
gr.NewButton("load toolkit 'andlabs'", func () {
|
2024-01-03 11:18:56 -06:00
|
|
|
bugWin.LoadToolkit("andlabs")
|
|
|
|
})
|
|
|
|
|
2024-01-03 22:10:13 -06:00
|
|
|
gr = newB.NewGroup("Learn GO")
|
|
|
|
|
|
|
|
gr.NewButton("GO Language Internals", func () {
|
2024-01-04 23:28:55 -06:00
|
|
|
if me.golang == nil {
|
|
|
|
me.golang = DebugGolangWindow(me.myGui)
|
|
|
|
return
|
|
|
|
}
|
2024-01-05 16:56:03 -06:00
|
|
|
log.Warn("going to toggle golang window")
|
2024-01-04 23:28:55 -06:00
|
|
|
if me.golang.Ready() {
|
|
|
|
me.golang.Toggle()
|
|
|
|
}
|
2024-01-03 22:10:13 -06:00
|
|
|
})
|
|
|
|
gr.NewButton("GO Channels debug", func () {
|
2024-01-04 23:28:55 -06:00
|
|
|
if me.gochan == nil {
|
|
|
|
me.gochan = DebugGoChannels(me.myGui)
|
|
|
|
return
|
|
|
|
}
|
2024-01-05 16:56:03 -06:00
|
|
|
log.Warn("going to toggle go channels window")
|
2024-01-04 23:28:55 -06:00
|
|
|
if me.gochan.Ready() {
|
|
|
|
me.gochan.Toggle()
|
|
|
|
}
|
2024-01-03 22:10:13 -06:00
|
|
|
})
|
|
|
|
|
2024-01-03 11:18:56 -06:00
|
|
|
return newB
|
|
|
|
}
|
|
|
|
|
|
|
|
func dropdownWindow(p *gui.Node) {
|
|
|
|
var mapWindows map[string]*gui.Node
|
|
|
|
mapWindows = make(map[string]*gui.Node)
|
|
|
|
|
2024-01-17 22:43:57 -06:00
|
|
|
dd := p.NewDropdown()
|
2024-01-03 11:18:56 -06:00
|
|
|
dd.Custom = func() {
|
2024-01-17 22:43:57 -06:00
|
|
|
name := dd.String()
|
2024-01-03 11:18:56 -06:00
|
|
|
activeWidget = mapWindows[name]
|
|
|
|
setActiveWidget(activeWidget)
|
2024-01-08 22:33:18 -06:00
|
|
|
log.Log(INFO, "The Window was set to", name)
|
2024-01-03 11:18:56 -06:00
|
|
|
}
|
|
|
|
log.Log(INFO, "dd =", dd)
|
|
|
|
if (activeWidget == nil) {
|
|
|
|
// the debug window doesn't exist yet so you can't display the change
|
|
|
|
// TODO: make a fake binary tree for this(?)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// var last = ""
|
|
|
|
for _, child := range p.Children() {
|
2024-01-13 21:29:40 -06:00
|
|
|
log.Log(INFO, "\t\t", child.GetProgName())
|
2024-01-17 22:43:57 -06:00
|
|
|
dd.AddText(child.GetProgName())
|
2024-01-03 11:18:56 -06:00
|
|
|
// last = child.Name
|
2024-01-13 21:29:40 -06:00
|
|
|
mapWindows[child.GetProgName()] = child
|
2024-01-03 11:18:56 -06:00
|
|
|
if (activeWidget == nil) {
|
|
|
|
activeWidget = child
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// dd.SetDropdownName(last)
|
|
|
|
}
|
|
|
|
|
|
|
|
func dropdownWindowWidgets(p *gui.Node) {
|
|
|
|
var mapWindows map[string]*gui.Node
|
|
|
|
mapWindows = make(map[string]*gui.Node)
|
|
|
|
|
2024-01-17 22:43:57 -06:00
|
|
|
dd := p.NewDropdown()
|
2024-01-03 11:18:56 -06:00
|
|
|
dd.Custom = func() {
|
2024-01-17 22:43:57 -06:00
|
|
|
name := dd.String()
|
2024-01-03 11:18:56 -06:00
|
|
|
activeWidget = mapWindows[name]
|
|
|
|
setActiveWidget(activeWidget)
|
|
|
|
}
|
|
|
|
log.Log(INFO, "dd =", dd)
|
|
|
|
|
|
|
|
// log.Log("dumpWidget() ", b, listChildrenDepth, defaultPadding, n.id, info)
|
|
|
|
|
|
|
|
var addDropdowns func (*gui.Node)
|
|
|
|
addDropdowns = func (n *gui.Node) {
|
|
|
|
// s := n.dumpWidget(true)
|
2024-01-13 21:29:40 -06:00
|
|
|
s := n.GetProgName()
|
2024-01-17 22:43:57 -06:00
|
|
|
dd.AddText(s)
|
2024-01-03 11:18:56 -06:00
|
|
|
mapWindows[s] = n
|
|
|
|
|
|
|
|
for _, child := range n.Children() {
|
|
|
|
addDropdowns(child)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// list everything in the binary tree
|
|
|
|
addDropdowns(bugWin)
|
|
|
|
}
|
|
|
|
|
|
|
|
func setActiveWidget(w *gui.Node) {
|
2024-01-04 23:28:55 -06:00
|
|
|
log.Warn("TODO: setActiveWidget()")
|
2024-01-03 11:18:56 -06:00
|
|
|
}
|