summaryrefslogtreecommitdiff
path: root/view.go
diff options
context:
space:
mode:
Diffstat (limited to 'view.go')
-rw-r--r--view.go47
1 files changed, 14 insertions, 33 deletions
diff --git a/view.go b/view.go
index 35ed732..c6cd296 100644
--- a/view.go
+++ b/view.go
@@ -4,53 +4,34 @@
package main
import (
- "bufio"
"strings"
- "go.wit.com/log"
"go.wit.com/widget"
)
-func splitLines(s string) []string {
- var lines []string
- sc := bufio.NewScanner(strings.NewReader(s))
- for sc.Scan() {
- lines = append(lines, sc.Text())
- }
- return lines
-}
+// expands the gocuiSize rectangle to fit
+// all the text in tk.labelN
+func (tk *guiWidget) textResize() {
+ var w, h int = 0, 0
-func (w *guiWidget) textResize() bool {
- // w := n.tk
- var width, height int = 0, 0
- var changed bool = false
-
- for i, s := range splitLines(w.labelN) {
- log.Log(INFO, "textResize() len =", len(s), i, s)
- if width < len(s) {
- width = len(s)
+ for _, s := range strings.Split(tk.labelN, "\n") {
+ s = strings.TrimSpace(s)
+ // log.Log(INFO, "textResize() len =", len(s), i, s)
+ if w < len(s) {
+ w = len(s)
}
- height += 1
- }
- if w.gocuiSize.w1 != w.gocuiSize.w0+width+me.FramePadW {
- w.gocuiSize.w1 = w.gocuiSize.w0 + width + me.FramePadW
- changed = true
+ h += 1
}
- if w.gocuiSize.h1 != w.gocuiSize.h0+height+me.FramePadH {
- w.gocuiSize.h1 = w.gocuiSize.h0 + height + me.FramePadH
- changed = true
- }
- if changed {
- // w.showWidgetPlacement("textResize() changed")
- }
- return changed
+
+ // this is old code. now move this somewhere smarter
+ tk.gocuiSize.w1 = tk.gocuiSize.w0 + w + me.FramePadW // TODO: move this FramePadW out of here
+ tk.gocuiSize.h1 = tk.gocuiSize.h0 + h + me.FramePadH // TODO: fix this size computation
}
func (w *guiWidget) hideWidgets() {
if w == nil {
return
}
- w.isCurrent = false
switch w.node.WidgetType {
case widget.Root:
case widget.Flag: