summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-01-28 03:33:08 -0600
committerJeff Carr <[email protected]>2024-01-28 03:33:08 -0600
commite678a5cc626c9cfdcb2f593b49598732052495cd (patch)
tree56361aa3408154f325a4f21f5e1f21b15f361251
parent1f3d664dbdee1b567f5b40e06c63c07c4667d5f4 (diff)
fake buttons have labels
Signed-off-by: Jeff Carr <[email protected]>
-rw-r--r--checkbox.go9
-rw-r--r--click.go8
-rw-r--r--debug.go4
-rw-r--r--plugin.go4
-rw-r--r--structs.go4
-rw-r--r--view.go15
-rw-r--r--widget.go10
7 files changed, 31 insertions, 23 deletions
diff --git a/checkbox.go b/checkbox.go
index 7fecb27..79128db 100644
--- a/checkbox.go
+++ b/checkbox.go
@@ -8,14 +8,17 @@ func (w *guiWidget) setCheckbox(b any) {
if w.node.WidgetType != widget.Checkbox {
return
}
+ if w.node.State.Label == "" {
+ w.node.State.Label = "BLANK"
+ }
if widget.GetBool(b) {
w.checked = widget.GetBool(b)
- w.label = "X " + w.label
+ w.labelN = "X " + w.node.State.Label
} else {
w.checked = widget.GetBool(b)
- w.label = " " + w.label
+ w.labelN = " " + w.node.State.Label
}
- t := len(w.label) + 1
+ t := len(w.labelN) + 1
w.gocuiSize.w1 = w.gocuiSize.w0 + t
// w.realWidth = w.gocuiSize.Width() + me.PadW
diff --git a/click.go b/click.go
index 53c4abf..3195085 100644
--- a/click.go
+++ b/click.go
@@ -242,7 +242,7 @@ func doWidgetClick(n *tree.Node) {
}
me.ddNode = n
log.Log(NOW, "new dns list should be set to:", dnsList)
- tk.label = dnsList
+ tk.labelN = dnsList
tk.SetText(dnsList)
SetVisible(me.ddview, true)
}
@@ -297,7 +297,7 @@ func click(g *gocui.Gui, v *gocui.View) error {
var w *guiWidget
w = n.TK.(*guiWidget)
if n != nil {
- log.Log(NOW, "click() Found widget =", n.WidgetId, n.String(), ",", w.label)
+ log.Log(NOW, "click() Found widget =", n.WidgetId, n.String(), ",", w.labelN)
if n.String() == "DropBox" {
log.Log(NOW, "click() this is the dropdown menu. set a flag here what did I click? where is the mouse?")
log.Log(NOW, "click() set a global dropdown clicked flag=true here")
@@ -372,7 +372,7 @@ func ctrlDown(g *gocui.Gui, v *gocui.View) error {
var tk *guiWidget
tk = me.ctrlDown.TK.(*guiWidget)
- tk.label = found.String()
+ tk.labelN = found.String()
tk.cuiName = "ctrlDown"
// me.ctrlDown.parent = me.rootNode
}
@@ -381,7 +381,7 @@ func ctrlDown(g *gocui.Gui, v *gocui.View) error {
if found == nil {
found = me.treeRoot
}
- tk.label = found.String()
+ tk.labelN = found.String()
newR := realGocuiSize(found)
tk.gocuiSize.w0 = newR.w0
tk.gocuiSize.h0 = newR.h0
diff --git a/debug.go b/debug.go
index 0ff8e1d..625a663 100644
--- a/debug.go
+++ b/debug.go
@@ -46,7 +46,7 @@ func (w *guiWidget) showWidgetPlacement(b bool, s string) {
w.gocuiSize.Width(), w.gocuiSize.Height(),
w.gocuiSize.w0, w.gocuiSize.h0, w.gocuiSize.w1, w.gocuiSize.h1)
} else {
- s1 += fmt.Sprintf(" ")
+ s1 += fmt.Sprintf(" w.Visable() == false ")
}
if w.node.Parent != nil {
if w.node.Parent.WidgetType == widget.Grid {
@@ -54,7 +54,7 @@ func (w *guiWidget) showWidgetPlacement(b bool, s string) {
}
}
tmp := "." + w.String() + "."
- log.Log(INFO, s1, s, w.node.WidgetType, ",", tmp) // , "text=", w.text)
+ log.Log(INFO, s1, s, w.node.WidgetType, ",", tmp, "jcarr") // , "text=", w.text)
}
/*
diff --git a/plugin.go b/plugin.go
index 7bf6757..0e55102 100644
--- a/plugin.go
+++ b/plugin.go
@@ -99,8 +99,8 @@ func (w *guiWidget) SetText(text string) {
log.Log(NOW, "widget is nil")
return
}
- if widget.GetString(w.value) != text {
- w.value = text
+ if w.labelN != text {
+ w.labelN = text
changed = true
}
if !changed {
diff --git a/structs.go b/structs.go
index 0599a0c..a3b9d89 100644
--- a/structs.go
+++ b/structs.go
@@ -139,7 +139,7 @@ type guiWidget struct {
checked bool
// the actual text to display in the console
- label string
+ labelN string
vals []string // dropdown menu items
@@ -148,7 +148,7 @@ type guiWidget struct {
direction widget.Orientation
- progname string
+ // progname string
// the logical size of the widget
// For example, 40x12 would be the center of a normal terminal
diff --git a/view.go b/view.go
index 7a26105..ee06f49 100644
--- a/view.go
+++ b/view.go
@@ -26,7 +26,7 @@ func (w *guiWidget) textResize() bool {
var width, height int = 0, 0
var changed bool = false
- for i, s := range splitLines(w.label) {
+ for i, s := range splitLines(w.labelN) {
log.Log(INFO, "textResize() len =", len(s), i, s)
if width < len(s) {
width = len(s)
@@ -60,6 +60,7 @@ func (w *guiWidget) showView() {
log.Log(ERROR, "showView() w.cuiName was not set for widget", w)
w.cuiName = string(w.node.WidgetId)
}
+ log.Log(ERROR, "showView() labelN =", w.labelN)
// if the gocui element doesn't exist, create it
if w.v == nil {
@@ -76,7 +77,7 @@ func (w *guiWidget) showView() {
} else {
log.Log(NOW, "showView() Clear() and Fprint() here wId =", w.cuiName)
w.v.Clear()
- fmt.Fprint(w.v, w.label)
+ fmt.Fprint(w.v, w.labelN)
w.SetVisible(false)
w.SetVisible(true)
return
@@ -122,10 +123,10 @@ func (w *guiWidget) recreateView() {
w.v = nil
if w.String() == "CLOUDFLARE_EMAIL" {
- w.showWidgetPlacement(true, "n.String()="+w.String()+" n.tk.label="+w.label+" "+w.cuiName)
+ w.showWidgetPlacement(true, "n.String()="+w.String()+" n.tk.label="+w.labelN+" "+w.cuiName)
// w.dumpWidget("jwc")
w.textResize()
- w.showWidgetPlacement(true, "n.String()="+w.String()+" n.tk.label="+w.label+" "+w.cuiName)
+ w.showWidgetPlacement(true, "n.String()="+w.String()+" n.tk.label="+w.labelN+" "+w.cuiName)
}
a := w.gocuiSize.w0
@@ -159,7 +160,7 @@ func (w *guiWidget) recreateView() {
w.v.Wrap = true
w.v.Frame = w.frame
w.v.Clear()
- fmt.Fprint(w.v, w.label)
+ fmt.Fprint(w.v, w.labelN)
// n.showWidgetPlacement(true, "n.String()=" + n.String() + " n.tk.label=" + n.tk.label + " " + w.cuiName)
// n.dumpWidget("jwc 2")
@@ -172,7 +173,7 @@ func (w *guiWidget) recreateView() {
w.v.SelBgColor = w.color.selBg
}
if w.String() == "CLOUDFLARE_EMAIL" {
- w.showWidgetPlacement(true, "w.String()="+w.String()+" w.label="+w.label+" "+w.cuiName)
+ w.showWidgetPlacement(true, "w.String()="+w.String()+" w.label="+w.labelN+" "+w.cuiName)
dumpTree(w.node, true)
}
log.Log(ERROR, "recreateView() END")
@@ -206,8 +207,8 @@ func (w *guiWidget) hideFake() {
func (w *guiWidget) showFake() {
if w.isFake {
// w.setFake()
- w.showWidgetPlacement(true, "showFake:")
w.showView()
+ w.showWidgetPlacement(true, "showFake:")
}
for _, child := range w.children {
child.showFake()
diff --git a/widget.go b/widget.go
index 9c2a5c2..47b7fe2 100644
--- a/widget.go
+++ b/widget.go
@@ -18,6 +18,10 @@ func initWidget(n *tree.Node) *guiWidget {
w.node = n
w.WidgetType = n.WidgetType
+ w.labelN = n.State.Label
+ if w.labelN == "" {
+ w.labelN = n.GetProgName()
+ }
if n.WidgetType == widget.Root {
log.Log(INFO, "setupWidget() FOUND ROOT w.id =", n.WidgetId)
@@ -104,7 +108,7 @@ func (w *guiWidget) IsCurrent() bool {
}
func (tk *guiWidget) String() string {
- return tk.progname
+ return tk.node.String()
}
func (tk *guiWidget) Visible() bool {
@@ -160,10 +164,10 @@ func addDropdown() *tree.Node {
// store the internal toolkit information
tk := new(guiWidget)
tk.frame = true
- tk.label = "DropBox text"
+ tk.labelN = "DropBox text"
// copy the data from the action message
- tk.progname = "DropBox"
+ tk.node.State.Label = "DropBox"
// set the name used by gocui to the id
tk.cuiName = "-1 dropbox"