diff options
Diffstat (limited to 'gocui/view.go')
| -rw-r--r-- | gocui/view.go | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/gocui/view.go b/gocui/view.go index 912cf21..b2bc81b 100644 --- a/gocui/view.go +++ b/gocui/view.go @@ -1,15 +1,15 @@ package main import ( - "fmt" - "errors" "bufio" + "errors" + "fmt" "strings" "github.com/awesome-gocui/gocui" + "go.wit.com/lib/widget" "go.wit.com/log" - "go.wit.com/gui/widget" ) func splitLines(s string) []string { @@ -28,20 +28,20 @@ func (n *node) textResize() bool { for i, s := range splitLines(n.tk.label) { log.Log(INFO, "textResize() len =", len(s), i, s) - if (width < len(s)) { + if width < len(s) { width = len(s) } height += 1 } - if (w.gocuiSize.w1 != w.gocuiSize.w0 + width + me.FramePadW) { + if w.gocuiSize.w1 != w.gocuiSize.w0+width+me.FramePadW { w.gocuiSize.w1 = w.gocuiSize.w0 + width + me.FramePadW changed = true } - if (w.gocuiSize.h1 != w.gocuiSize.h0 + height + me.FramePadH) { + if w.gocuiSize.h1 != w.gocuiSize.h0+height+me.FramePadH { w.gocuiSize.h1 = w.gocuiSize.h0 + height + me.FramePadH changed = true } - if (changed) { + if changed { n.showWidgetPlacement(true, "textResize() changed") } return changed @@ -57,22 +57,22 @@ func (n *node) showView() { var err error w := n.tk - if (w.cuiName == "") { + if w.cuiName == "" { log.Log(ERROR, "showView() w.cuiName was not set for widget", w) w.cuiName = string(n.WidgetId) } // if the gocui element doesn't exist, create it - if (w.v == nil) { + if w.v == nil { n.recreateView() - } + } x0, y0, x1, y1, err := me.baseGui.ViewPosition(w.cuiName) log.Log(INFO, "showView() w.v already defined for widget", n.progname, err) // n.smartGocuiSize() changed := n.textResize() - if (changed) { + if changed { log.Log(NOW, "showView() textResize() changed. Should recreateView here wId =", w.cuiName) } else { log.Log(NOW, "showView() Clear() and Fprint() here wId =", w.cuiName) @@ -85,21 +85,21 @@ func (n *node) showView() { // if the gocui element has changed where it is supposed to be on the screen // recreate it - if (x0 != w.gocuiSize.w0) { + if x0 != w.gocuiSize.w0 { n.recreateView() return } - if (y0 != w.gocuiSize.h0) { + if y0 != w.gocuiSize.h0 { log.Log(ERROR, "showView() start hight mismatch id=", w.cuiName, "gocui h vs computed h =", w.gocuiSize.h0, y0) n.recreateView() return } - if (x1 != w.gocuiSize.w1) { + if x1 != w.gocuiSize.w1 { log.Log(ERROR, "showView() too wide", w.cuiName, "w,w", w.gocuiSize.w1, x1) n.recreateView() return } - if (y1 != w.gocuiSize.h1) { + if y1 != w.gocuiSize.h1 { log.Log(ERROR, "showView() too high", w.cuiName, "h,h", w.gocuiSize.h1, y1) n.recreateView() return @@ -114,7 +114,7 @@ func (n *node) recreateView() { var err error w := n.tk log.Log(ERROR, "recreateView() START", n.WidgetType, n.progname) - if (me.baseGui == nil) { + if me.baseGui == nil { log.Log(ERROR, "recreateView() ERROR: me.baseGui == nil", w) return } @@ -123,11 +123,11 @@ func (n *node) recreateView() { me.baseGui.DeleteView(w.cuiName) w.v = nil - if (n.progname == "CLOUDFLARE_EMAIL") { - n.showWidgetPlacement(true, "n.progname=" + n.progname + " n.tk.label=" + n.tk.label + " " + w.cuiName) + if n.progname == "CLOUDFLARE_EMAIL" { + n.showWidgetPlacement(true, "n.progname="+n.progname+" n.tk.label="+n.tk.label+" "+w.cuiName) n.dumpWidget("jwc") n.textResize() - n.showWidgetPlacement(true, "n.progname=" + n.progname + " n.tk.label=" + n.tk.label + " " + w.cuiName) + n.showWidgetPlacement(true, "n.progname="+n.progname+" n.tk.label="+n.tk.label+" "+w.cuiName) } a := w.gocuiSize.w0 @@ -166,15 +166,15 @@ func (n *node) recreateView() { // n.dumpWidget("jwc 2") // if you don't do this here, it will be black & white only - if (w.color != nil) { + if w.color != nil { w.v.FrameColor = w.color.frame w.v.FgColor = w.color.fg w.v.BgColor = w.color.bg w.v.SelFgColor = w.color.selFg w.v.SelBgColor = w.color.selBg } - if (n.progname == "CLOUDFLARE_EMAIL") { - n.showWidgetPlacement(true, "n.progname=" + n.progname + " n.tk.label=" + n.tk.label + " " + w.cuiName) + if n.progname == "CLOUDFLARE_EMAIL" { + n.showWidgetPlacement(true, "n.progname="+n.progname+" n.tk.label="+n.tk.label+" "+w.cuiName) n.dumpTree(true) } log.Log(ERROR, "recreateView() END") @@ -199,7 +199,7 @@ func (n *node) hideWidgets() { func (n *node) hideFake() { w := n.tk - if (w.isFake) { + if w.isFake { n.hideView() } for _, child := range n.children { @@ -209,7 +209,7 @@ func (n *node) hideFake() { func (n *node) showFake() { w := n.tk - if (w.isFake) { + if w.isFake { n.setFake() n.showWidgetPlacement(true, "showFake:") n.showView() @@ -221,7 +221,7 @@ func (n *node) showFake() { func (n *node) showWidgets() { w := n.tk - if (w.isFake) { + if w.isFake { // don't display by default } else { n.showWidgetPlacement(true, "current:") |
