ah, a much cleaner start to a debugger

Finally there is some sense this debugger can
    finally be useful. It can be developed and worked on in
    isolation from the 'gui' package therefore it can call
    more sophisticated widget collections. 'gadgets'

    all moved to gadgets.BasicWindow()
    thank goodness all this code is isolated finally
    can finally rename the files
    first gadgets.BasicWindow()

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-01-04 23:28:55 -06:00
parent 1f0e212002
commit ff32316084
5 changed files with 95 additions and 59 deletions

View File

@ -9,18 +9,18 @@ import (
"go.wit.com/log" "go.wit.com/log"
"go.wit.com/gui/gui" "go.wit.com/gui/gui"
"go.wit.com/gui/gadgets"
) )
var debugWG *sync.WaitGroup var debugWG *sync.WaitGroup
var debugNumberChan chan int var debugNumberChan chan int
func DebugGoChannels(n *gui.Node) { func DebugGoChannels(p *gui.Node) *gadgets.BasicWindow {
var w, g *gui.Node var w *gadgets.BasicWindow
var g *gui.Node
w = n.NewWindow("Debug GO Channels") w = gadgets.NewBasicWindow(p, "Debug GO Channels")
w.Custom = w.StandardClose g = w.Box().NewGroup("Channel stuff").Pad()
g = w.NewGroup("Channel stuff")
// var debugWG sync.WaitGroup // var debugWG sync.WaitGroup
g.NewButton("init()", func () { g.NewButton("init()", func () {
@ -63,7 +63,9 @@ func DebugGoChannels(n *gui.Node) {
g.NewButton("print", func () { g.NewButton("print", func () {
log.Log(true, "waitgroup counter is ?") log.Log(true, "waitgroup counter is ?")
}) })
return w
} }
func sendNumber(i int) { func sendNumber(i int) {
log.Log(true, "START debugNumberChan <-", i, " (sending", i, "to channel)") log.Log(true, "START debugNumberChan <-", i, " (sending", i, "to channel)")
debugNumberChan <- i debugNumberChan <- i

View File

@ -10,16 +10,15 @@ import (
"go.wit.com/log" "go.wit.com/log"
"go.wit.com/gui/gui" "go.wit.com/gui/gui"
"go.wit.com/gui/gadgets"
) )
func DebugGolangWindow(n *gui.Node) { func DebugGolangWindow(p *gui.Node) *gadgets.BasicWindow {
var newW, newB, g, og, outputTextbox *gui.Node var w *gadgets.BasicWindow
var g, og, outputTextbox *gui.Node
newW = n.NewWindow("GO") w = gadgets.NewBasicWindow(p, "GO")
newW.Custom = newW.StandardClose g = w.Box().NewGroup("Language Internals").Pad()
newB = newW.NewBox("hBox", true)
g = newB.NewGroup("Language Internals")
g.NewButton("ReadModuleInfo()", func () { g.NewButton("ReadModuleInfo()", func () {
tmp, _ := debug.ReadBuildInfo() tmp, _ := debug.ReadBuildInfo()
@ -91,7 +90,7 @@ func DebugGolangWindow(n *gui.Node) {
panic("test") panic("test")
}) })
g = newB.NewGroup("TODO: finish these") g = w.Box().NewGroup("TODO: finish these").Pad()
// g.NewLabel("TODO:") // g.NewLabel("TODO:")
@ -122,11 +121,13 @@ func DebugGolangWindow(n *gui.Node) {
outputTextbox.SetText(dumpModuleInfo()) outputTextbox.SetText(dumpModuleInfo())
}) })
og = newB.NewGroup("output") og = w.Box().NewGroup("output").Pad()
outputTextbox = og.NewTextbox("outputBox") outputTextbox = og.NewTextbox("outputBox")
outputTextbox.Custom = func () { outputTextbox.Custom = func () {
log.Log(true, "custom TextBox() for golang output a =", outputTextbox.S) log.Log(true, "custom TextBox() for golang output a =", outputTextbox.S)
} }
return w
} }
func runtimeReadMemStats() string { func runtimeReadMemStats() string {

View File

@ -5,6 +5,7 @@ import (
"go.wit.com/log" "go.wit.com/log"
"go.wit.com/gui/gui" "go.wit.com/gui/gui"
"go.wit.com/gui/gadgets"
"go.wit.com/gui/gadgets/logsettings" "go.wit.com/gui/gadgets/logsettings"
) )
@ -13,35 +14,40 @@ import (
*/ */
func DebugWindow(p *gui.Node) { func DebugWindow(p *gui.Node) {
myGui = p if (me != nil) {
bugWin = myGui.NewWindow("go.wit.com/gui debug window") me.bugWin.Toggle()
bugWin.StandardClose() return
bugTab = DebugWindow2(bugWin, "Debug Tab") }
bugTab.StandardClose() me = new(debuggerSettings)
me.myGui = p
me.bugWin = gadgets.NewBasicWindow(p,"go.wit.com/gui debug window")
DebugWindow2(me.bugWin.Box(), "Debug Tab")
// initialize the log settings window (does not display it) // initialize the log settings window (does not display it)
myLS = logsettings.New(myGui)
me.myLS = logsettings.New(me.myGui)
if ArgDebug() { if ArgDebug() {
log.SetTmp() log.SetTmp()
} }
} }
func DebugWindow2(n *gui.Node, title string) *gui.Node { func DebugWindow2(newB *gui.Node, title string) *gui.Node {
var newW, newB, gr *gui.Node var gr *gui.Node
// var logSettings *gadgets.LogSettings
// time.Sleep(1 * time.Second)
newW = n.NewWindow(title)
newB = newW.NewBox("hBox", true)
//////////////////////// main debug things ////////////////////////////////// //////////////////////// main debug things //////////////////////////////////
gr = newB.NewGroup("Debugging Windows:") gr = newB.NewGroup("Debugging Windows:")
gr.NewButton("logging", func () { gr.NewButton("logging", func () {
myLS.Show() me.myLS.Toggle()
}) })
gr.NewButton("Debug Widgets", func () { gr.NewButton("Widgets Window", func () {
DebugWidgetWindow(myGui) if me.widgets == nil {
me.widgets = DebugWidgetWindow(me.myGui)
me.widgets.Draw()
return
}
me.widgets.Toggle()
}) })
gr.NewLabel("Force Quit:") gr.NewLabel("Force Quit:")
@ -98,10 +104,24 @@ func DebugWindow2(n *gui.Node, title string) *gui.Node {
gr = newB.NewGroup("Learn GO") gr = newB.NewGroup("Learn GO")
gr.NewButton("GO Language Internals", func () { gr.NewButton("GO Language Internals", func () {
DebugGolangWindow(myGui) if me.golang == nil {
me.golang = DebugGolangWindow(me.myGui)
me.golang.Draw()
return
}
if me.golang.Ready() {
me.golang.Toggle()
}
}) })
gr.NewButton("GO Channels debug", func () { gr.NewButton("GO Channels debug", func () {
DebugGoChannels(myGui) if me.gochan == nil {
me.gochan = DebugGoChannels(me.myGui)
me.gochan.Draw()
return
}
if me.gochan.Ready() {
me.gochan.Toggle()
}
}) })
return newB return newB
@ -169,4 +189,5 @@ func dropdownWindowWidgets(p *gui.Node) {
} }
func setActiveWidget(w *gui.Node) { func setActiveWidget(w *gui.Node) {
log.Warn("TODO: setActiveWidget()")
} }

View File

@ -2,17 +2,35 @@ package debugger
import ( import (
"go.wit.com/gui/gui" "go.wit.com/gui/gui"
"go.wit.com/gui/gadgets"
"go.wit.com/gui/gadgets/logsettings" "go.wit.com/gui/gadgets/logsettings"
) )
// main debugging window var me *debuggerSettings
var myGui *gui.Node
type debuggerSettings struct {
ready bool
hidden bool
err error
myGui *gui.Node
bugWin *gadgets.BasicWindow
widgets *gadgets.BasicWindow
golang *gadgets.BasicWindow
gochan *gadgets.BasicWindow
myLS *logsettings.LogSettings
mapWindows map[string]*gui.Node // tracks all windows that exist
}
var bugWin *gui.Node var bugWin *gui.Node
/*
// main debugging window
var bugTab *gui.Node var bugTab *gui.Node
var myGui *gui.Node
var myLS *logsettings.LogSettings */
var mapWindows map[string]*gui.Node // tracks all windows that exist
// global var for checking to see if this // global var for checking to see if this
// window/tab for debugging a widget exists // window/tab for debugging a widget exists

View File

@ -6,6 +6,7 @@ import (
"go.wit.com/log" "go.wit.com/log"
"go.wit.com/gui/gui" "go.wit.com/gui/gui"
"go.wit.com/gui/gadgets"
) )
@ -29,20 +30,11 @@ func setActiveWidget(w *gui.Node) {
} }
*/ */
func DebugWidgetWindow(w *gui.Node) { func DebugWidgetWindow(p *gui.Node) *gadgets.BasicWindow {
var newW, newB *gui.Node var w *gadgets.BasicWindow
if (bugWidget != nil) { w = gadgets.NewBasicWindow(p, "Widgets")
// this window was already created. Just change the widget we are working against
setActiveWidget(w)
return
}
newW = w.NewWindow("Widgets") g := w.Box().NewGroup("widget:").Pad()
newW.Custom = newW.StandardClose
bugWidget = newW
newB = newW.NewBox("hBox", true)
g := newB.NewGroup("widget:")
g2 := g.NewGroup("widget:") g2 := g.NewGroup("widget:")
activeLabel = g2.NewLabel("undef") activeLabel = g2.NewLabel("undef")
@ -67,7 +59,7 @@ func DebugWidgetWindow(w *gui.Node) {
// common things that should work against each widget // common things that should work against each widget
g = newB.NewGroup("common things") g = w.Box().NewGroup("common things")
g.NewButton("Enable()", func () { g.NewButton("Enable()", func () {
activeWidget.Enable() activeWidget.Enable()
}) })
@ -84,12 +76,12 @@ func DebugWidgetWindow(w *gui.Node) {
activeWidget.Dump() activeWidget.Dump()
}) })
g = newB.NewGroup("add things") g = w.Box().NewGroup("add things")
debugAddWidgetButton(g) debugAddWidgetButton(g)
g.NewLabel("experiments:") g.NewLabel("experiments:")
debugAddWidgetButtons(g) debugAddWidgetButtons(g)
g = newB.NewGroup("change things") g = w.Box().NewGroup("change things")
g.NewButton("AddText()", func () { g.NewButton("AddText()", func () {
activeWidget.AddText(activeLabelNewName.S) activeWidget.AddText(activeLabelNewName.S)
/* /*
@ -129,13 +121,15 @@ func DebugWidgetWindow(w *gui.Node) {
activeWidget.Delete(activeWidget) activeWidget.Delete(activeWidget)
}) })
g = newB.NewGroup("not working?") g = w.Box().NewGroup("not working?")
activeJunk = newB.NewGroup("junk:") activeJunk = w.Box().NewGroup("junk:")
activeJunk.NewLabel("test junk") activeJunk.NewLabel("test junk")
if (activeWidget == nil) { if (activeWidget == nil) {
setActiveWidget(myGui) setActiveWidget(me.myGui)
} }
return w
} }
func debugAddWidgetButtons(n *gui.Node) { func debugAddWidgetButtons(n *gui.Node) {