From e4f0524bdf5331d91c95c9cb89eb4f40138a0ab1 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sat, 1 Feb 2025 13:43:51 -0600 Subject: lots of code cleanup and debugging work --- debug.go | 5 +++-- eventBindings.go | 11 ++++++----- eventMouse.go | 3 ++- find.go | 2 +- init.go | 1 - structs.go | 2 +- treeAdd.go | 2 +- treeDraw.go | 8 ++++---- view.go | 2 +- 9 files changed, 19 insertions(+), 17 deletions(-) diff --git a/debug.go b/debug.go index e572f98..c880aba 100644 --- a/debug.go +++ b/debug.go @@ -16,14 +16,15 @@ func (w *guiWidget) dumpTree(s string) { log.Log(ERROR, "dump w.TK == nil", w.node.WidgetId, w.WidgetType, w.String()) return } - w.showWidgetPlacement("dumpTree() " + s) + w.dumpWidget("dumpTree() " + s) for _, child := range w.children { child.dumpTree(s) } } -func (w *guiWidget) showWidgetPlacement(s string) { +// a standard function to print out information about a widget +func (w *guiWidget) dumpWidget(s string) { var s1 string var pId int if w.node.Parent == nil { diff --git a/eventBindings.go b/eventBindings.go index 7bc5baf..b093718 100644 --- a/eventBindings.go +++ b/eventBindings.go @@ -164,17 +164,18 @@ func theLetterD(g *gocui.Gui, v *gocui.View) error { } func theHelp(g *gocui.Gui, v *gocui.View) error { - if showHelp { + if me.showHelp { helplayout() - showHelp = false + me.showHelp = false if me.dropdownV == nil { + log.Info("FIXME: MADE me.dropdownV AGAIN") me.dropdownV = makeDropdownView("addWidget() ddview") } - me.dropdownV.Show() + // me.dropdownV.Show() } else { me.baseGui.DeleteView("help") - showHelp = true - me.dropdownV.Hide() + me.showHelp = true + // me.dropdownV.Hide() } return nil } diff --git a/eventMouse.go b/eventMouse.go index 3a5e0a6..22d153c 100644 --- a/eventMouse.go +++ b/eventMouse.go @@ -35,7 +35,8 @@ func mouseMove(g *gocui.Gui) { if me.supermouse { for _, tk := range findByXY(w, h) { - log.Log(GOCUI, fmt.Sprintf("findByXY() mouseMove() %s wId=%d cuiName=%s at (%d,%d)", tk.WidgetType, tk.node.WidgetId, tk.cuiName, w, h)) + tk.dumpWidget("findByXY()") + // log.Log(GOCUI, fmt.Sprintf("findByXY() mouseMove() %s wId=%d cuiName=%s at (%d,%d)", tk.WidgetType, tk.node.WidgetId, tk.cuiName, w, h)) } } diff --git a/find.go b/find.go index 3f33b78..07edd3d 100644 --- a/find.go +++ b/find.go @@ -85,7 +85,7 @@ func findUnderMouse() *guiWidget { if w.WidgetType == widget.Checkbox { return w } - w.showWidgetPlacement("findUnderMouse() found something unknown") + w.dumpWidget("findUnderMouse() found something unknown") found = w } // maybe something else was found diff --git a/init.go b/init.go index 967c8ab..3f0c3d4 100644 --- a/init.go +++ b/init.go @@ -1,4 +1,3 @@ -//gjcarro:pjcarrlugin // Copyright 2017-2025 WIT.COM Inc. All rights reserved. // Use of this source code is governed by the GPL 3.0 diff --git a/structs.go b/structs.go index f126dd7..57c869c 100644 --- a/structs.go +++ b/structs.go @@ -29,7 +29,6 @@ import ( var me config var showDebug bool = true -var showHelp bool = true var redoWidgets bool = true // This is the window that is currently active @@ -100,6 +99,7 @@ type config struct { writeMutex sync.Mutex // TODO: writeMutex protects locks the write process fakefile *FakeFile // JUNK? used to attempt to write to the stdout window dtoggle bool // is a dropdown or combobox currently active? + showHelp bool // toggle boolean for the help menu (deprecate?) // debugging things ecount int // counts how many mouse and keyboard events have occurred diff --git a/treeAdd.go b/treeAdd.go index d69f714..d5e64b5 100644 --- a/treeAdd.go +++ b/treeAdd.go @@ -93,5 +93,5 @@ func addWidget(n *tree.Node) { } */ } - nw.showWidgetPlacement("addWidget()") + nw.dumpWidget("in addWidget()") } diff --git a/treeDraw.go b/treeDraw.go index 5fa991c..1177c97 100644 --- a/treeDraw.go +++ b/treeDraw.go @@ -18,7 +18,7 @@ func (w *guiWidget) DrawAt(offsetW, offsetH int) { w.setColor(&colorActiveW) w.placeWidgets(offsetW, offsetH) // compute the sizes & places for each widget w.active = false - w.showWidgets() + w.dumpWidget("DrawAt()") } func (w *guiWidget) toggleTree() { @@ -36,7 +36,7 @@ func (w *guiWidget) drawTree(draw bool) { if w == nil { return } - w.showWidgetPlacement("drawTree()") + w.dumpWidget("in drawTree()") if draw { // w.textResize() w.Show() @@ -77,12 +77,12 @@ func (w *guiWidget) drawView() { w.v, err = me.baseGui.SetView(w.cuiName, a, b, c, d, 0) if err == nil { - w.showWidgetPlacement("drawView()") + w.dumpWidget("drawView() err") log.Log(ERROR, "drawView() internal plugin error err = nil") return } if !errors.Is(err, gocui.ErrUnknownView) { - w.showWidgetPlacement("drawView()") + w.dumpWidget("drawView() err") log.Log(ERROR, "drawView() internal plugin error error.IS()", err) return } diff --git a/view.go b/view.go index 5bc7b33..35ed732 100644 --- a/view.go +++ b/view.go @@ -91,7 +91,7 @@ func (w *guiWidget) hideFake() { func (w *guiWidget) showFake() { if w.isFake { w.drawView() - w.showWidgetPlacement("showFake:") + w.dumpWidget("in showFake()") } for _, child := range w.children { child.showFake() -- cgit v1.2.3