cleaner debugging
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
44ee09f798
commit
dab898f0f9
2
add.go
2
add.go
|
@ -80,5 +80,5 @@ func addWidget(n *tree.Node) {
|
|||
}
|
||||
*/
|
||||
}
|
||||
nw.showWidgetPlacement(true, "addWidget()")
|
||||
nw.showWidgetPlacement("addWidget()")
|
||||
}
|
||||
|
|
36
click.go
36
click.go
|
@ -101,6 +101,7 @@ func (w *guiWidget) doWidgetClick() {
|
|||
log.Log(NOW, "doWidgetClick() if this is the dropdown menu, handle it here?")
|
||||
case widget.Window:
|
||||
log.Log(NOW, "doWidgetClick() START on window", w.String())
|
||||
/*
|
||||
if me.currentWindow == w.node {
|
||||
return
|
||||
}
|
||||
|
@ -111,13 +112,19 @@ func (w *guiWidget) doWidgetClick() {
|
|||
curw.setColor(&colorWindow)
|
||||
curw.hideWidgets()
|
||||
}
|
||||
*/
|
||||
me.currentWindow = w.node
|
||||
|
||||
log.Log(NOW, "doWidgetClick() set currentWindow to", w.String())
|
||||
w.setColor(&colorActiveW)
|
||||
w.hideWidgets()
|
||||
w.placeWidgets(me.RawW, me.RawH)
|
||||
w.showWidgets()
|
||||
if w.active {
|
||||
w.active = false
|
||||
w.placeWidgets(me.RawW, me.RawH)
|
||||
w.showWidgets()
|
||||
} else {
|
||||
w.active = true
|
||||
w.hideWidgets()
|
||||
}
|
||||
/*
|
||||
w.redoTabs(me.TabW, me.TabH)
|
||||
for _, child := range w.children {
|
||||
|
@ -158,7 +165,22 @@ func (w *guiWidget) doWidgetClick() {
|
|||
w.showWidgets()
|
||||
case widget.Group:
|
||||
// n.placeWidgets(p.tk.startH, newH)
|
||||
w.toggleTree()
|
||||
if w.active {
|
||||
w.active = false
|
||||
startW := me.RawW
|
||||
startH := me.RawH
|
||||
for _, child := range w.children {
|
||||
log.Log(INFO, "START W,H", startW, startH)
|
||||
child.placeWidgets(me.RawW, me.RawH)
|
||||
child.showWidgets()
|
||||
}
|
||||
} else {
|
||||
w.active = true
|
||||
for _, child := range w.children {
|
||||
child.hideWidgets()
|
||||
}
|
||||
}
|
||||
w.dumpTree()
|
||||
case widget.Checkbox:
|
||||
if widget.GetBool(w.value) {
|
||||
w.setCheckbox(false)
|
||||
|
@ -255,7 +277,7 @@ func (w *guiWidget) drawTree(draw bool) {
|
|||
if w == nil {
|
||||
return
|
||||
}
|
||||
w.showWidgetPlacement(true, "drawTree()")
|
||||
w.showWidgetPlacement("drawTree()")
|
||||
if draw {
|
||||
// w.textResize()
|
||||
w.showView()
|
||||
|
@ -344,7 +366,7 @@ func findUnderMouse() *tree.Node {
|
|||
for _, n := range widgets {
|
||||
//log(logNow, "ctrlDown() FOUND widget", widget.id, widget.name)
|
||||
widget := n.TK.(*guiWidget)
|
||||
widget.showWidgetPlacement(true, "findUnderMouse() FOUND")
|
||||
widget.showWidgetPlacement("findUnderMouse() FOUND")
|
||||
}
|
||||
return found
|
||||
}
|
||||
|
@ -381,6 +403,6 @@ func ctrlDown(g *gocui.Gui, v *gocui.View) error {
|
|||
} else {
|
||||
// me.ctrlDown.showView()
|
||||
}
|
||||
// me.ctrlDown.showWidgetPlacement(true, "ctrlDown:")
|
||||
// me.ctrlDown.showWidgetPlacement("ctrlDown:")
|
||||
return nil
|
||||
}
|
||||
|
|
34
debug.go
34
debug.go
|
@ -7,20 +7,20 @@ import (
|
|||
"go.wit.com/widget"
|
||||
)
|
||||
|
||||
func (w *guiWidget) dumpTree(draw bool) {
|
||||
func (w *guiWidget) dumpTree() {
|
||||
// log.Log(ERROR, "dumpTree w", w.node.WidgetId, w.WidgetType, w.String())
|
||||
if w == nil {
|
||||
log.Log(ERROR, "dumpTree w.TK == nil", w.node.WidgetId, w.WidgetType, w.String())
|
||||
return
|
||||
}
|
||||
w.showWidgetPlacement(true, "dumpTree()")
|
||||
w.showWidgetPlacement("dumpTree()")
|
||||
|
||||
for _, child := range w.children {
|
||||
child.dumpTree(draw)
|
||||
child.dumpTree()
|
||||
}
|
||||
}
|
||||
|
||||
func (w *guiWidget) showWidgetPlacement(b bool, s string) {
|
||||
func (w *guiWidget) showWidgetPlacement(s string) {
|
||||
var s1 string
|
||||
var pId int
|
||||
if w.node.Parent == nil {
|
||||
|
@ -45,29 +45,3 @@ func (w *guiWidget) showWidgetPlacement(b bool, s string) {
|
|||
tmp := "." + w.String() + "."
|
||||
log.Log(INFO, s1, s, w.node.WidgetType, ",", tmp, "jcarr") // , "text=", w.text)
|
||||
}
|
||||
|
||||
/*
|
||||
func dumpWidget(n *tree.Node, pad string) {
|
||||
log.Log(NOW, "node:", pad, n.WidgetId, "At(", n.AtW, n.AtH, ") ,", n.WidgetType, ", n.progname =", n.progname, ", n.label =", n.label)
|
||||
}
|
||||
*/
|
||||
/*
|
||||
func listWidgets(n *tree.Node) {
|
||||
if n == nil {
|
||||
return
|
||||
}
|
||||
|
||||
var pad string
|
||||
for i := 0; i < me.depth; i++ {
|
||||
pad = pad + " "
|
||||
}
|
||||
n.dumpWidget(pad)
|
||||
|
||||
for _, child := range n.children {
|
||||
me.depth += 1
|
||||
child.listWidgets()
|
||||
me.depth -= 1
|
||||
}
|
||||
return
|
||||
}
|
||||
*/
|
||||
|
|
|
@ -119,7 +119,7 @@ func addDebugKeys(g *gocui.Gui) {
|
|||
g.SetKeybinding("", 'M', gocui.ModNone,
|
||||
func(g *gocui.Gui, v *gocui.View) error {
|
||||
w := me.treeRoot.TK.(*guiWidget)
|
||||
w.dumpTree(true)
|
||||
w.dumpTree()
|
||||
return nil
|
||||
})
|
||||
|
||||
|
|
18
place.go
18
place.go
|
@ -12,13 +12,13 @@ func (tk *guiWidget) placeBox(startW int, startH int) {
|
|||
if tk.WidgetType != widget.Box {
|
||||
return
|
||||
}
|
||||
tk.showWidgetPlacement(true, "boxS()")
|
||||
tk.showWidgetPlacement("boxS()")
|
||||
|
||||
newW := startW
|
||||
newH := startH
|
||||
for _, child := range tk.children {
|
||||
child.placeWidgets(newW, newH)
|
||||
// n.showWidgetPlacement(logNow, "boxS()")
|
||||
// n.showWidgetPlacement("boxS()")
|
||||
newR := child.realGocuiSize()
|
||||
w := newR.w1 - newR.w0
|
||||
h := newR.h1 - newR.h0
|
||||
|
@ -36,7 +36,7 @@ func (tk *guiWidget) placeBox(startW int, startH int) {
|
|||
// just compute this every time?
|
||||
// newR := n.realGocuiSize()
|
||||
|
||||
tk.showWidgetPlacement(true, "boxE()")
|
||||
tk.showWidgetPlacement("boxE()")
|
||||
}
|
||||
|
||||
func (tk *guiWidget) placeWidgets(startW int, startH int) {
|
||||
|
@ -65,7 +65,7 @@ func (tk *guiWidget) placeWidgets(startW int, startH int) {
|
|||
case widget.Group:
|
||||
// move the group to the parent's next location
|
||||
tk.gocuiSetWH(startW, startH)
|
||||
tk.showWidgetPlacement(true, "group()")
|
||||
tk.showWidgetPlacement("group()")
|
||||
|
||||
newW := startW + me.GroupPadW
|
||||
newH := startH + 3 // normal hight of the group label
|
||||
|
@ -86,7 +86,7 @@ func (tk *guiWidget) placeWidgets(startW int, startH int) {
|
|||
}
|
||||
|
||||
func (w *guiWidget) placeGrid(startW int, startH int) {
|
||||
w.showWidgetPlacement(true, "grid0:")
|
||||
w.showWidgetPlacement("grid0:")
|
||||
if w.WidgetType != widget.Grid {
|
||||
return
|
||||
}
|
||||
|
@ -104,13 +104,13 @@ func (w *guiWidget) placeGrid(startW int, startH int) {
|
|||
if w.heights[child.AtH] < childH {
|
||||
w.heights[child.AtH] = childH
|
||||
}
|
||||
// child.showWidgetPlacement(logInfo, "grid: ")
|
||||
// child.showWidgetPlacement("grid: ")
|
||||
log.Log(INFO, "placeGrid:", child.String(), "child()", childW, childH, "At()", child.AtW, child.AtH)
|
||||
}
|
||||
|
||||
// find the width and height offset of the grid for AtW,AtH
|
||||
for _, child := range w.children {
|
||||
child.showWidgetPlacement(true, "grid1:")
|
||||
child.showWidgetPlacement("grid1:")
|
||||
|
||||
var totalW, totalH int
|
||||
for i, w := range w.widths {
|
||||
|
@ -130,9 +130,9 @@ func (w *guiWidget) placeGrid(startW int, startH int) {
|
|||
|
||||
log.Log(INFO, "placeGrid:", child.String(), "new()", newW, newH, "At()", child.AtW, child.AtH)
|
||||
child.placeWidgets(newW, newH)
|
||||
child.showWidgetPlacement(true, "grid2:")
|
||||
child.showWidgetPlacement("grid2:")
|
||||
}
|
||||
w.showWidgetPlacement(true, "grid3:")
|
||||
w.showWidgetPlacement("grid3:")
|
||||
}
|
||||
|
||||
// computes the real, actual size of all the gocli objects in a widget
|
||||
|
|
|
@ -143,6 +143,8 @@ type guiWidget struct {
|
|||
|
||||
vals []string // dropdown menu items
|
||||
|
||||
active bool
|
||||
|
||||
AtW int
|
||||
AtH int
|
||||
|
||||
|
|
20
view.go
20
view.go
|
@ -42,7 +42,7 @@ func (w *guiWidget) textResize() bool {
|
|||
changed = true
|
||||
}
|
||||
if changed {
|
||||
w.showWidgetPlacement(true, "textResize() changed")
|
||||
w.showWidgetPlacement("textResize() changed")
|
||||
}
|
||||
return changed
|
||||
}
|
||||
|
@ -123,10 +123,10 @@ func (w *guiWidget) recreateView() {
|
|||
w.v = nil
|
||||
|
||||
if w.String() == "CLOUDFLARE_EMAIL" {
|
||||
w.showWidgetPlacement(true, "n.String()="+w.String()+" n.tk.label="+w.labelN+" "+w.cuiName)
|
||||
w.showWidgetPlacement("n.String()="+w.String()+" n.tk.label="+w.labelN+" "+w.cuiName)
|
||||
// w.dumpWidget("jwc")
|
||||
w.textResize()
|
||||
w.showWidgetPlacement(true, "n.String()="+w.String()+" n.tk.label="+w.labelN+" "+w.cuiName)
|
||||
w.showWidgetPlacement("n.String()="+w.String()+" n.tk.label="+w.labelN+" "+w.cuiName)
|
||||
}
|
||||
|
||||
a := w.gocuiSize.w0
|
||||
|
@ -136,12 +136,12 @@ func (w *guiWidget) recreateView() {
|
|||
|
||||
w.v, err = me.baseGui.SetView(w.cuiName, a, b, c, d, 0)
|
||||
if err == nil {
|
||||
w.showWidgetPlacement(true, "recreateView()")
|
||||
w.showWidgetPlacement("recreateView()")
|
||||
log.Log(ERROR, "recreateView() internal plugin error err = nil")
|
||||
return
|
||||
}
|
||||
if !errors.Is(err, gocui.ErrUnknownView) {
|
||||
w.showWidgetPlacement(true, "recreateView()")
|
||||
w.showWidgetPlacement("recreateView()")
|
||||
log.Log(ERROR, "recreateView() internal plugin error error.IS()", err)
|
||||
return
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ func (w *guiWidget) recreateView() {
|
|||
w.v.Frame = w.frame
|
||||
w.v.Clear()
|
||||
fmt.Fprint(w.v, w.labelN)
|
||||
// n.showWidgetPlacement(true, "n.String()=" + n.String() + " n.tk.label=" + n.tk.label + " " + w.cuiName)
|
||||
// n.showWidgetPlacement("n.String()=" + n.String() + " n.tk.label=" + n.tk.label + " " + w.cuiName)
|
||||
// n.dumpWidget("jwc 2")
|
||||
|
||||
// if you don't do this here, it will be black & white only
|
||||
|
@ -173,8 +173,8 @@ func (w *guiWidget) recreateView() {
|
|||
w.v.SelBgColor = w.color.selBg
|
||||
}
|
||||
if w.String() == "CLOUDFLARE_EMAIL" {
|
||||
w.showWidgetPlacement(true, "w.String()="+w.String()+" w.label="+w.labelN+" "+w.cuiName)
|
||||
w.dumpTree(true)
|
||||
w.showWidgetPlacement("w.String()="+w.String()+" w.label="+w.labelN+" "+w.cuiName)
|
||||
w.dumpTree()
|
||||
}
|
||||
log.Log(ERROR, "recreateView() END")
|
||||
}
|
||||
|
@ -208,7 +208,7 @@ func (w *guiWidget) showFake() {
|
|||
if w.isFake {
|
||||
// w.setFake()
|
||||
w.showView()
|
||||
w.showWidgetPlacement(true, "showFake:")
|
||||
w.showWidgetPlacement("showFake:")
|
||||
}
|
||||
for _, child := range w.children {
|
||||
child.showFake()
|
||||
|
@ -219,7 +219,7 @@ func (w *guiWidget) showWidgets() {
|
|||
if w.isFake {
|
||||
// don't display by default
|
||||
} else {
|
||||
w.showWidgetPlacement(true, "current:")
|
||||
w.showWidgetPlacement("current:")
|
||||
w.showView()
|
||||
}
|
||||
for _, child := range w.children {
|
||||
|
|
Loading…
Reference in New Issue