diff options
| -rw-r--r-- | debug.go | 12 | ||||
| -rw-r--r-- | place.go | 4 | ||||
| -rw-r--r-- | size.go | 2 | ||||
| -rw-r--r-- | textbox.go | 5 | ||||
| -rw-r--r-- | treeWidget.go | 20 |
5 files changed, 29 insertions, 14 deletions
@@ -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) } @@ -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() { @@ -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: @@ -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 { |
