From ff32316084e11911462be420dd8310473b3d26fd Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Thu, 4 Jan 2024 23:28:55 -0600 Subject: 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 --- mainWindow.go | 172 ---------------------------------------------------------- 1 file changed, 172 deletions(-) delete mode 100644 mainWindow.go (limited to 'mainWindow.go') diff --git a/mainWindow.go b/mainWindow.go deleted file mode 100644 index b40056c..0000000 --- a/mainWindow.go +++ /dev/null @@ -1,172 +0,0 @@ -package debugger - -import ( - "os" - - "go.wit.com/log" - "go.wit.com/gui/gui" - "go.wit.com/gui/gadgets/logsettings" -) - -/* - Creates a window helpful for debugging this package -*/ - -func DebugWindow(p *gui.Node) { - myGui = p - bugWin = myGui.NewWindow("go.wit.com/gui debug window") - bugWin.StandardClose() - bugTab = DebugWindow2(bugWin, "Debug Tab") - bugTab.StandardClose() - // initialize the log settings window (does not display it) - myLS = logsettings.New(myGui) - if ArgDebug() { - log.SetTmp() - } -} - -func DebugWindow2(n *gui.Node, title string) *gui.Node { - var newW, newB, gr *gui.Node - // var logSettings *gadgets.LogSettings - - // time.Sleep(1 * time.Second) - newW = n.NewWindow(title) - - newB = newW.NewBox("hBox", true) - -//////////////////////// main debug things ////////////////////////////////// - gr = newB.NewGroup("Debugging Windows:") - - gr.NewButton("logging", func () { - myLS.Show() - }) - gr.NewButton("Debug Widgets", func () { - DebugWidgetWindow(myGui) - }) - - gr.NewLabel("Force Quit:") - - gr.NewButton("os.Exit()", func () { - os.Exit(0) - }) - -//////////////////////// window debugging things ////////////////////////////////// - gr = newB.NewGroup("list things") - - gr.NewButton("List toolkits", func () { - dropdownWindow(gr) - bugWin.ListToolkits() - }) - gr.NewButton("List Windows", func () { - dropdownWindow(gr) - }) - gr.NewButton("List Window Widgets", func () { - dropdownWindowWidgets(gr) - }) - - gr = newB.NewGroup("more things") - - gr.NewButton("Node.ListChildren(true)", func () { - if (activeWidget == nil) { - activeWidget = bugWin - } - activeWidget.ListChildren(true) - }) - - gr.NewButton("test conc", func () { - log.Log(true, "TODO: fix me") - // makeConc() - }) - - gr.NewButton("List Plugins", func () { - log.Log(true, "TODO: fix me") - /* - for _, aplug := range allPlugins { - log.Log(true, "Loaded plugin:", aplug.name, aplug.filename) - } - */ - }) - - gr.NewButton("load toolkit 'gocui'", func () { - bugWin.LoadToolkit("gocui") - }) - - gr.NewButton("load toolkit 'andlabs'", func () { - bugWin.LoadToolkit("andlabs") - }) - - gr = newB.NewGroup("Learn GO") - - gr.NewButton("GO Language Internals", func () { - DebugGolangWindow(myGui) - }) - gr.NewButton("GO Channels debug", func () { - DebugGoChannels(myGui) - }) - - return newB -} - -func dropdownWindow(p *gui.Node) { - var mapWindows map[string]*gui.Node - mapWindows = make(map[string]*gui.Node) - - dd := p.NewDropdown("Window Dropdown") - dd.Custom = func() { - name := dd.S - activeWidget = mapWindows[name] - setActiveWidget(activeWidget) - log.Log(true, "The Window was set to", name) - } - 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() { - log.Log(INFO, "\t\t", child.GetName()) - dd.AddDropdownName(child.GetName()) - // last = child.Name - mapWindows[child.GetName()] = child - 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) - - dd := p.NewDropdown("Window Widgets Dropdown") - dd.Custom = func() { - name := dd.S - 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) - s := n.GetName() - dd.AddDropdownName(s) - mapWindows[s] = n - - for _, child := range n.Children() { - addDropdowns(child) - } - } - - // list everything in the binary tree - addDropdowns(bugWin) -} - -func setActiveWidget(w *gui.Node) { -} -- cgit v1.2.3