diff --git a/debug.go b/debug.go index c4a0bfb..dbcccc3 100644 --- a/debug.go +++ b/debug.go @@ -5,7 +5,6 @@ package main import ( "fmt" - "strings" "github.com/awesome-gocui/gocui" "go.wit.com/log" @@ -83,16 +82,9 @@ func (tk *guiWidget) dumpWidget(s string) { } var end string if tk.node.WidgetType == widget.Box { - end = fmt.Sprintf("%-8s %-8s %s", tk.node.WidgetType, tk.cuiName, tk.node.State.Direction.String()) + end = fmt.Sprintf("%-8s %-8s %s %s", tk.node.WidgetType, tk.cuiName, tk.node.State.Direction.String(), tk.String()) } else { - curval := strings.TrimSpace(tk.node.ProgName()) - if curval == "" { - curval = strings.TrimSpace(tk.node.GetLabel()) - } - if curval == "" { - curval = strings.TrimSpace(tk.labelN) - } - end = fmt.Sprintf("%-8s %-8s %s", tk.node.WidgetType, tk.cuiName, curval) + end = fmt.Sprintf("%-8s %-8s %s", tk.node.WidgetType, tk.cuiName, tk.String()) } log.Log(GOCUI, s1, s, end) } diff --git a/place.go b/place.go index 7d74169..0eb0074 100644 --- a/place.go +++ b/place.go @@ -314,8 +314,8 @@ func textSize(n *tree.Node) (int, int) { */ func (tk *guiWidget) gocuiSetWH(sizeW, sizeH int) { - w := len(widget.GetString(tk.value)) - lines := strings.Split(widget.GetString(tk.value), "\n") + w := len(tk.node.GetLabel()) + lines := strings.Split(tk.node.GetLabel(), "\n") h := len(lines) if tk.Hidden() { diff --git a/size.go b/size.go index 68dcf38..f0cff48 100644 --- a/size.go +++ b/size.go @@ -76,7 +76,7 @@ func (tk *guiWidget) Size() (int, int) { case widget.Label: return len(tk.String()) + 2, 1 case widget.Textbox: - return len(tk.String()) + 10, 3 // TODO: compute this based on 'window dense' + return len(tk.String()) + 2, 3 // TODO: compute this based on 'window dense' case widget.Checkbox: return len(tk.String()) + 2, 3 // TODO: compute this based on 'window dense' case widget.Button: diff --git a/textbox.go b/textbox.go index 7537944..ecbba52 100644 --- a/textbox.go +++ b/textbox.go @@ -109,6 +109,11 @@ func textboxClosed() { win := me.textbox.callerTK.findParentWindow() if win != nil { win.dumpWidget("redraw this!!!") + tk := me.textbox.callerTK + me.textbox.callerTK.dumpWidget("resize this!!!") + me.textbox.callerTK.Size() + me.textbox.callerTK.placeWidgets(tk.gocuiSize.w0-4, tk.gocuiSize.h0-4) + tk.dumpWidget("resize:" + tk.String()) win.redrawWindow(win.gocuiSize.w0, win.gocuiSize.h0) } } diff --git a/treeWidget.go b/treeWidget.go index bd9c947..166cb77 100644 --- a/treeWidget.go +++ b/treeWidget.go @@ -5,6 +5,7 @@ package main import ( "strconv" + "strings" "github.com/awesome-gocui/gocui" "go.wit.com/log" @@ -74,7 +75,24 @@ func (w *guiWidget) deleteView() { } func (tk *guiWidget) String() string { - return tk.node.String() + curval := strings.TrimSpace(tk.node.GetLabel()) + if curval != "" { + return curval + } + curval = tk.node.String() + if curval != "" { + return curval + } + curval = strings.TrimSpace(tk.node.ProgName()) + if curval != "" { + return curval + } + // deprecate this? + curval = strings.TrimSpace(tk.labelN) + if curval != "" { + return curval + } + return "" } func (tk *guiWidget) Visible() bool {