summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--checkbox.go2
-rw-r--r--click.go6
-rw-r--r--color.go7
-rw-r--r--draw.go4
-rw-r--r--help.go2
-rw-r--r--plugin.go4
-rw-r--r--view.go42
-rw-r--r--widget.go40
-rw-r--r--window.go7
9 files changed, 51 insertions, 63 deletions
diff --git a/checkbox.go b/checkbox.go
index 8c4b3db..e5c730a 100644
--- a/checkbox.go
+++ b/checkbox.go
@@ -26,6 +26,6 @@ func (w *guiWidget) setCheckbox() {
// t := len(w.labelN) + 3
// w.gocuiSize.w1 = w.gocuiSize.w0 + t
- w.deleteView()
+ w.Hide()
w.Show()
}
diff --git a/click.go b/click.go
index 254d079..0074c3b 100644
--- a/click.go
+++ b/click.go
@@ -223,11 +223,5 @@ func ctrlDown(g *gocui.Gui, v *gocui.View) error {
tk.gocuiSize.h0 = newR.h0
tk.gocuiSize.w1 = newR.w1
tk.gocuiSize.h1 = newR.h1
- if tk.Visible() {
- // me.ctrlDown.hideView()
- } else {
- // me.ctrlDown.showView()
- }
- // me.ctrlDown.showWidgetPlacement("ctrlDown:")
return nil
}
diff --git a/color.go b/color.go
index 3452e30..2201690 100644
--- a/color.go
+++ b/color.go
@@ -145,10 +145,6 @@ func (w *guiWidget) enableColor() {
w.setColor(w.defaultColor)
}
-func (w *guiWidget) setDefaultWidgetColor() {
- w.showView()
-}
-
func (w *guiWidget) setDefaultHighlight() {
if w.v == nil {
log.Log(ERROR, "SetColor() failed on view == nil")
@@ -172,7 +168,8 @@ func (w *guiWidget) redoColor(draw bool) {
log.Sleep(.05)
w.setDefaultHighlight()
- w.setDefaultWidgetColor()
+ // w.setDefaultWidgetColor()
+ w.Show()
for _, child := range w.children {
child.redoColor(draw)
diff --git a/draw.go b/draw.go
index db22fe2..6e7304c 100644
--- a/draw.go
+++ b/draw.go
@@ -27,9 +27,9 @@ func (w *guiWidget) drawTree(draw bool) {
w.showWidgetPlacement("drawTree()")
if draw {
// w.textResize()
- w.showView()
+ w.Show()
} else {
- w.deleteView()
+ w.Hide()
}
for _, child := range w.children {
diff --git a/help.go b/help.go
index 832b397..7ea271e 100644
--- a/help.go
+++ b/help.go
@@ -32,8 +32,6 @@ var helpText []string = []string{"KEYBINDINGS",
func hidehelplayout() {
me.baseGui.DeleteView("help")
- // n.deleteView()
- // child.hideFake()
}
func helplayout() error {
diff --git a/plugin.go b/plugin.go
index b9ff8ee..4c84323 100644
--- a/plugin.go
+++ b/plugin.go
@@ -160,8 +160,8 @@ func (w *guiWidget) SetText(text string) {
if w.Visible() {
w.textResize()
- w.deleteView()
- w.showView()
+ w.Hide()
+ w.Show()
}
}
diff --git a/view.go b/view.go
index 6c9f692..9b0270a 100644
--- a/view.go
+++ b/view.go
@@ -48,23 +48,9 @@ func (w *guiWidget) textResize() bool {
return changed
}
-func (w *guiWidget) hideView() {
- w.deleteView()
-}
-
// display's the text of the widget in gocui
-// will create a new gocui view if there isn't one or if it has been moved
-func (w *guiWidget) showView() {
- if w.cuiName == "" {
- log.Log(ERROR, "showView() w.cuiName was not set for widget", w)
- w.cuiName = strconv.Itoa(w.node.WidgetId) + " TK"
- }
- log.Log(INFO, "showView() labelN =", w.labelN)
-
- w.recreateView()
-}
-
// create or recreate the gocui widget visible
+// will create a new gocui view if there isn't one or if it has been moved
// deletes the old view if it exists and recreates it
func (w *guiWidget) recreateView() {
var err error
@@ -74,6 +60,12 @@ func (w *guiWidget) recreateView() {
return
}
+ if w.cuiName == "" {
+ log.Log(ERROR, "recreateView() w.cuiName was not set for widget", w)
+ w.cuiName = strconv.Itoa(w.node.WidgetId) + " TK"
+ }
+ log.Log(INFO, "recreateView() labelN =", w.labelN)
+
// this deletes the button from gocui
me.baseGui.DeleteView(w.cuiName)
w.v = nil
@@ -111,8 +103,6 @@ func (w *guiWidget) recreateView() {
w.v.Frame = w.frame
w.v.Clear()
fmt.Fprint(w.v, w.labelN)
- // 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
if w.color != nil {
@@ -137,7 +127,7 @@ func (w *guiWidget) hideWidgets() {
case widget.Box:
case widget.Grid:
default:
- w.hideView()
+ w.Hide()
}
for _, child := range w.children {
child.hideWidgets()
@@ -158,7 +148,7 @@ func showFake() {
func (w *guiWidget) hideFake() {
if w.isFake {
- w.hideView()
+ w.Hide()
}
for _, child := range w.children {
child.hideFake()
@@ -167,8 +157,7 @@ func (w *guiWidget) hideFake() {
func (w *guiWidget) showFake() {
if w.isFake {
- // w.setFake()
- w.showView()
+ w.recreateView()
w.showWidgetPlacement("showFake:")
}
for _, child := range w.children {
@@ -177,15 +166,8 @@ func (w *guiWidget) showFake() {
}
func (w *guiWidget) showWidgets() {
- if w.isFake {
- // don't display by default
- } else {
- if w.node.State.Hidden {
- // don't display hidden views
- } else {
- w.showView()
- }
- }
+ w.Show()
+
for _, child := range w.children {
child.showWidgets()
}
diff --git a/widget.go b/widget.go
index ee6a12d..0f54750 100644
--- a/widget.go
+++ b/widget.go
@@ -101,35 +101,49 @@ func (tk *guiWidget) Visible() bool {
return true
}
-func (tk *guiWidget) Show() {
+func (w *guiWidget) Show() {
// always should the dropdown widget
- if tk == me.dropdownV {
- me.dropdownV.showView()
+ if w== me.dropdownV {
+ me.dropdownV.recreateView()
return
}
+
+ // don't display fake widgets
+ if w.isFake {
+ return
+ }
+
// if this isn't in the binary tree
// it's some internal widget so always display those
- if tk.node == nil {
- tk.showView()
+ if w.node == nil {
+ w.recreateView()
+ return
+ }
+
+ // always show window titles
+ if w.node.WidgetType != widget.Window {
+ w.recreateView()
return
}
// if the widget is not in the current displayed windo
// then ignore it
- log.Log(NOW, "Show() tk =", tk.cuiName, tk.String())
- log.Log(NOW, "Show() tk.IsCurrent() returned", tk.IsCurrent())
- if ! tk.IsCurrent() {
- log.Log(NOW, "Show() NOT drawing", tk.cuiName, tk.String())
+ log.Log(NOW, "Show() widget =", w.cuiName, w.String())
+ log.Log(NOW, "Show() w.IsCurrent() returned", w.IsCurrent())
+ if ! w.IsCurrent() {
+ log.Log(NOW, "Show() NOT drawing", w.cuiName, w.String())
return
}
- log.Log(NOW, "Show() drawing", tk.cuiName, tk.String())
+ log.Log(NOW, "Show() drawing", w.cuiName, w.String())
// finally, check if the widget State is hidden or not
- if tk.node.State.Hidden {
+ if w.node.State.Hidden {
// don't display hidden widgets
- } else {
- tk.showView()
+ return
}
+
+ // okay, if you made it this far, then display the widget
+ w.recreateView()
}
func (tk *guiWidget) Hide() {
diff --git a/window.go b/window.go
index 0918c45..789a355 100644
--- a/window.go
+++ b/window.go
@@ -17,8 +17,11 @@ func (w *guiWidget) redoWindows(nextW int, nextH int) {
child.hasTabs = false
child.gocuiSetWH(nextW, nextH)
- child.deleteView()
- child.showView()
+ child.Hide()
+
+ // use the direct method recreateView() to
+ // bypass sanity checks here (fix this?)
+ child.recreateView()
sizeW := child.gocuiSize.Width()
nextW += sizeW + 4
child.redoWindows(startW+3, startH+2)