more helpful and easier to read debugging output

This commit is contained in:
Jeff Carr 2025-01-31 12:08:13 -06:00
parent bbdf7fefbd
commit 5b39848b64
5 changed files with 18 additions and 19 deletions

View File

@ -8,9 +8,9 @@ import (
) )
func (w *guiWidget) dumpTree(s string) { func (w *guiWidget) dumpTree(s string) {
// log.Log(ERROR, "dumpTree w", w.node.WidgetId, w.WidgetType, w.String()) // log.Log(ERROR, "dump w", w.node.WidgetId, w.WidgetType, w.String())
if w == nil { if w == nil {
log.Log(ERROR, "dumpTree w.TK == nil", w.node.WidgetId, w.WidgetType, w.String()) log.Log(ERROR, "dump w.TK == nil", w.node.WidgetId, w.WidgetType, w.String())
return return
} }
w.showWidgetPlacement("dumpTree() " + s) w.showWidgetPlacement("dumpTree() " + s)
@ -29,27 +29,29 @@ func (w *guiWidget) showWidgetPlacement(s string) {
} else { } else {
pId = w.node.Parent.WidgetId pId = w.node.Parent.WidgetId
} }
s1 = fmt.Sprintf("(wId,pId)=(%2d,%2d) ", w.node.WidgetId, pId) s1 = fmt.Sprintf("(wId,pId)=(%4d,%4d) ", w.node.WidgetId, pId)
sizeW, sizeH := w.Size() sizeW, sizeH := w.Size()
s1 += fmt.Sprintf("size=(%2d,%2d)", sizeW, sizeH) s1 += fmt.Sprintf("size=(%3d,%3d)", sizeW, sizeH)
if w.Visible() { if w.Visible() {
s1 += fmt.Sprintf("gocui=(%2d,%2d,%2d,%2d)", s1 += fmt.Sprintf("gocui=(%3d,%3d,%3d,%3d)",
w.gocuiSize.w0, w.gocuiSize.h0, w.gocuiSize.w1, w.gocuiSize.h1) w.gocuiSize.w0, w.gocuiSize.h0, w.gocuiSize.w1, w.gocuiSize.h1)
} else { } else {
s1 += fmt.Sprintf(" %2s %2s %2s %2s ", "", "", "", "") s1 += fmt.Sprintf(" %3s %3s %3s %3s ", "", "", "", "")
} }
if w.node.Parent != nil { if w.node.Parent != nil {
if w.node.Parent.WidgetType == widget.Grid { if w.node.Parent.WidgetType == widget.Grid {
s1 += fmt.Sprintf("At(%2d,%2d) ", w.node.State.AtW, w.node.State.AtH) s1 += fmt.Sprintf("At(%3d,%3d) ", w.node.State.AtW, w.node.State.AtH)
} else { } else {
s1 += fmt.Sprintf(" %2s %2s ", "", "") s1 += fmt.Sprintf(" %3s %3s ", "", "")
} }
} else { } else {
s1 += fmt.Sprintf(" %2s %2s ", "", "") s1 += fmt.Sprintf(" %3s %3s ", "", "")
} }
tmp := "." + w.String() + ". " + w.cuiName var end string
if w.node.WidgetType == widget.Box { if w.node.WidgetType == widget.Box {
tmp = "." + w.node.State.Direction.String() + ". " + w.cuiName end = fmt.Sprintf("%5s %-8s %s", w.cuiName, w.node.WidgetType, w.node.State.Direction.String())
} else {
end = fmt.Sprintf("%5s %-8s %s", w.cuiName, w.node.WidgetType, w.String())
} }
log.Log(NOW, s1, s, w.node.WidgetType, ",", tmp) // log.Log(NOW, s1, s, end)
} }

View File

@ -49,7 +49,7 @@ func makeDropdownView(ddItems string) *guiWidget {
func addDropdown() *tree.Node { func addDropdown() *tree.Node {
n := new(tree.Node) n := new(tree.Node)
n.WidgetType = widget.Flag n.WidgetType = widget.Flag
n.WidgetId = 2222 n.WidgetId = -222
n.ParentId = 0 n.ParentId = 0
// store the internal toolkit information // store the internal toolkit information
@ -62,7 +62,7 @@ func addDropdown() *tree.Node {
tk.node.State.Label = "DropBox" tk.node.State.Label = "DropBox"
// set the name used by gocui to the id // set the name used by gocui to the id
tk.cuiName = "-1 dropbox" tk.cuiName = "-1 DR"
tk.color = &colorFlag tk.color = &colorFlag

View File

@ -64,7 +64,6 @@ func (w *guiWidget) doWidgetClick() {
child.hideWidgets() child.hideWidgets()
} }
} }
// w.dumpTree("click end")
case widget.Checkbox: case widget.Checkbox:
if w.node.State.Checked { if w.node.State.Checked {
log.Log(WARN, "checkbox is being set to false") log.Log(WARN, "checkbox is being set to false")

View File

@ -105,7 +105,7 @@ func addDebugKeys(g *gocui.Gui) {
func(g *gocui.Gui, v *gocui.View) error { func(g *gocui.Gui, v *gocui.View) error {
w, h := g.MousePosition() w, h := g.MousePosition()
for _, tk := range findByXY(w, h) { for _, tk := range findByXY(w, h) {
log.Log(GOCUI, fmt.Sprintf("findByXY() msgDown() %s wId=%d cuiName=%s at (%d,%d)", tk.WidgetType, tk.node.WidgetId, tk.cuiName, w, h)) log.Log(GOCUI, fmt.Sprintf("findByXY() msgDown() %s wId=%d at (%d,%d) %s", tk.WidgetType, tk.node.WidgetId, w, h, tk.node.String()))
} }
return nil return nil
}) })
@ -152,7 +152,7 @@ func addDebugKeys(g *gocui.Gui) {
g.SetKeybinding("", 'M', gocui.ModNone, g.SetKeybinding("", 'M', gocui.ModNone,
func(g *gocui.Gui, v *gocui.View) error { func(g *gocui.Gui, v *gocui.View) error {
w := me.treeRoot.TK.(*guiWidget) w := me.treeRoot.TK.(*guiWidget)
w.dumpTree("M") w.dumpTree("MM")
return nil return nil
}) })

View File

@ -35,7 +35,6 @@ func (w *guiWidget) placeBox(startW int, startH int) {
if w.WidgetType != widget.Box { if w.WidgetType != widget.Box {
return return
} }
// tk.dumpTree("beforebox")
newW := startW newW := startW
newH := startH newH := startH
@ -58,7 +57,6 @@ func (w *guiWidget) placeBox(startW int, startH int) {
} }
log.Log(INFO, "BOX END size(W,H) =", sizeW, sizeH, "new(W,H) =", newW, newH) log.Log(INFO, "BOX END size(W,H) =", sizeW, sizeH, "new(W,H) =", newW, newH)
} }
// tk.dumpTree("afterbox")
} }
func (tk *guiWidget) placeWidgets(startW int, startH int) (int, int) { func (tk *guiWidget) placeWidgets(startW int, startH int) (int, int) {