set the node.State.Label on SetText()
This commit is contained in:
parent
a81e931b9a
commit
12f3d5ac5c
30
debug.go
30
debug.go
|
@ -6,6 +6,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/awesome-gocui/gocui"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
"go.wit.com/widget"
|
"go.wit.com/widget"
|
||||||
)
|
)
|
||||||
|
@ -29,7 +30,7 @@ func (tk *guiWidget) dumpWidget(s string) {
|
||||||
var pId int
|
var pId int
|
||||||
// tk.verifyRect()
|
// tk.verifyRect()
|
||||||
if tk.node.Parent == nil {
|
if tk.node.Parent == nil {
|
||||||
log.Log(INFO, "showWidgetPlacement() parent == nil", tk.node.WidgetId, tk.cuiName)
|
log.Logf(WARN, "showWidgetPlacement() parent == nil wId=%d cuiName=%s", tk.node.WidgetId, tk.cuiName)
|
||||||
pId = 0
|
pId = 0
|
||||||
} else {
|
} else {
|
||||||
pId = tk.node.Parent.WidgetId
|
pId = tk.node.Parent.WidgetId
|
||||||
|
@ -63,5 +64,30 @@ func (tk *guiWidget) dumpWidget(s string) {
|
||||||
}
|
}
|
||||||
end = fmt.Sprintf("%5s %-8s %s", tk.cuiName, tk.node.WidgetType, tk.String())
|
end = fmt.Sprintf("%5s %-8s %s", tk.cuiName, tk.node.WidgetType, tk.String())
|
||||||
}
|
}
|
||||||
log.Log(NOW, s1, s, end)
|
log.Log(GOCUI, s1, s, end)
|
||||||
|
}
|
||||||
|
|
||||||
|
func printWidgetTree(g *gocui.Gui, v *gocui.View) error {
|
||||||
|
me.treeRoot.ListWidgets()
|
||||||
|
|
||||||
|
tk := me.logStdout
|
||||||
|
// msg := fmt.Sprintf("test out kb %d\n", ecount)
|
||||||
|
// tk.Write([]byte(msg))
|
||||||
|
if tk == nil {
|
||||||
|
log.Log(ERROR, "tk = nil")
|
||||||
|
}
|
||||||
|
if tk.v == nil {
|
||||||
|
log.Log(ERROR, "tk.v = nil")
|
||||||
|
} else {
|
||||||
|
log.Log(ERROR, "setting log.CaptureMode(tk.v)")
|
||||||
|
log.Log(ERROR, "setting log.CaptureMode(tk.v)")
|
||||||
|
log.CaptureMode(tk)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func printWidgetPlacements(g *gocui.Gui, v *gocui.View) error {
|
||||||
|
w := me.treeRoot.TK.(*guiWidget)
|
||||||
|
w.dumpTree("MM")
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,6 +65,9 @@ func addDropdownNew(wId int) *tree.Node {
|
||||||
tk.labelN = "DropBox text"
|
tk.labelN = "DropBox text"
|
||||||
|
|
||||||
tk.node = n
|
tk.node = n
|
||||||
|
if tk.node.Parent == nil {
|
||||||
|
tk.node.Parent = me.treeRoot
|
||||||
|
}
|
||||||
// copy the data from the action message
|
// copy the data from the action message
|
||||||
tk.node.State.Label = "DropBox"
|
tk.node.State.Label = "DropBox"
|
||||||
|
|
||||||
|
|
|
@ -38,14 +38,14 @@ func registerHandlers(g *gocui.Gui) {
|
||||||
g.SetKeybinding("", 'q', gocui.ModNone, doExit) // 'q' exit
|
g.SetKeybinding("", 'q', gocui.ModNone, doExit) // 'q' exit
|
||||||
|
|
||||||
// debugging
|
// debugging
|
||||||
g.SetKeybinding("", 'f', gocui.ModNone, theFind) // 'f' shows what is under your mouse
|
g.SetKeybinding("", 'f', gocui.ModNone, theFind) // 'f' shows what is under your mouse
|
||||||
g.SetKeybinding("", 'S', gocui.ModNone, setSuperMouse) // 'S' Super Mouse mode!
|
g.SetKeybinding("", 'S', gocui.ModNone, setSuperMouse) // 'S' Super Mouse mode!
|
||||||
g.SetKeybinding("", 'h', gocui.ModNone, theHide) // 'h' hide all widgets
|
g.SetKeybinding("", 'h', gocui.ModNone, theHide) // 'h' hide all widgets
|
||||||
g.SetKeybinding("", 'M', gocui.ModNone, dumpWidgetPlacement) // 'M' list all widgets with positions
|
g.SetKeybinding("", 'M', gocui.ModNone, printWidgetPlacements) // 'M' list all widgets with positions
|
||||||
g.SetKeybinding("", 'L', gocui.ModNone, dumpWidgets) // 'L' list all widgets in tree view
|
g.SetKeybinding("", 'L', gocui.ModNone, printWidgetTree) // 'L' list all widgets in tree view
|
||||||
g.SetKeybinding("", 'd', gocui.ModNone, theLetterD) // 'd' toggles on and off debugging buttons
|
g.SetKeybinding("", 'd', gocui.ModNone, theLetterD) // 'd' toggles on and off debugging buttons
|
||||||
g.SetKeybinding("", '2', gocui.ModNone, theNotsure) // '2' for testing new ideas
|
g.SetKeybinding("", '2', gocui.ModNone, theNotsure) // '2' for testing new ideas
|
||||||
g.SetKeybinding("", 'q', gocui.ModNone, quit) // 'q' only exits gocui. plugin stays alive (?)
|
g.SetKeybinding("", 'q', gocui.ModNone, quit) // 'q' only exits gocui. plugin stays alive (?)
|
||||||
}
|
}
|
||||||
|
|
||||||
// flips on 'super mouse' mode
|
// flips on 'super mouse' mode
|
||||||
|
@ -152,6 +152,7 @@ func theNotsure(g *gocui.Gui, v *gocui.View) error {
|
||||||
if notsure == nil {
|
if notsure == nil {
|
||||||
// notsure = makeDropdownView("addWidget() notsure")
|
// notsure = makeDropdownView("addWidget() notsure")
|
||||||
notsure = addDropdownTK(-118)
|
notsure = addDropdownTK(-118)
|
||||||
|
notsure.node.State.Label = "apple/pear"
|
||||||
notsure.makeTK([]string{"apple", "pear"})
|
notsure.makeTK([]string{"apple", "pear"})
|
||||||
}
|
}
|
||||||
notsure.MoveToOffset(w+2, h+1)
|
notsure.MoveToOffset(w+2, h+1)
|
||||||
|
@ -197,31 +198,6 @@ func doPanic(g *gocui.Gui, v *gocui.View) error {
|
||||||
panic("forced panic in gocui")
|
panic("forced panic in gocui")
|
||||||
}
|
}
|
||||||
|
|
||||||
func dumpWidgets(g *gocui.Gui, v *gocui.View) error {
|
|
||||||
me.treeRoot.ListWidgets()
|
|
||||||
|
|
||||||
tk := me.logStdout
|
|
||||||
// msg := fmt.Sprintf("test out kb %d\n", ecount)
|
|
||||||
// tk.Write([]byte(msg))
|
|
||||||
if tk == nil {
|
|
||||||
log.Log(ERROR, "tk = nil")
|
|
||||||
}
|
|
||||||
if tk.v == nil {
|
|
||||||
log.Log(ERROR, "tk.v = nil")
|
|
||||||
} else {
|
|
||||||
log.Log(ERROR, "setting log.CaptureMode(tk.v)")
|
|
||||||
log.Log(ERROR, "setting log.CaptureMode(tk.v)")
|
|
||||||
log.CaptureMode(tk)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func dumpWidgetPlacement(g *gocui.Gui, v *gocui.View) error {
|
|
||||||
w := me.treeRoot.TK.(*guiWidget)
|
|
||||||
w.dumpTree("MM")
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func openDebuggger(g *gocui.Gui, v *gocui.View) error {
|
func openDebuggger(g *gocui.Gui, v *gocui.View) error {
|
||||||
me.myTree.SendEnableDebugger()
|
me.myTree.SendEnableDebugger()
|
||||||
return nil
|
return nil
|
||||||
|
|
19
place.go
19
place.go
|
@ -4,6 +4,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
|
@ -86,14 +87,24 @@ func (tk *guiWidget) placeWidgets(startW int, startH int) (int, int) {
|
||||||
return startW, startH
|
return startW, startH
|
||||||
case widget.Tab:
|
case widget.Tab:
|
||||||
case widget.Grid:
|
case widget.Grid:
|
||||||
|
tk.dumpWidget(fmt.Sprintf("PlaceGridS(%d,%d)", startW, startH))
|
||||||
|
// reset the widths and heights maps here
|
||||||
|
tk.widths = make(map[int]int) // how tall each row in the grid is
|
||||||
|
tk.heights = make(map[int]int) // how wide each column in the grid is
|
||||||
newW, newH := tk.placeGrid(startW, startH)
|
newW, newH := tk.placeGrid(startW, startH)
|
||||||
tk.full.w0 = newW
|
tk.full.w0 = newW
|
||||||
tk.full.h0 = newH
|
tk.full.h0 = newH
|
||||||
|
tk.full.w1 = newW
|
||||||
|
tk.full.h1 = newH
|
||||||
|
tk.dumpWidget(fmt.Sprintf("PlaceGridE(%d,%d)", newW, newH))
|
||||||
return newW, newH
|
return newW, newH
|
||||||
case widget.Box:
|
case widget.Box:
|
||||||
tk.placeBox(startW, startH)
|
tk.placeBox(startW, startH)
|
||||||
tk.full.w0 = startW
|
tk.full.w0 = startW
|
||||||
tk.full.h0 = startH
|
tk.full.h0 = startH
|
||||||
|
tk.full.w1 = startW
|
||||||
|
tk.full.h1 = startH
|
||||||
|
tk.dumpWidget(fmt.Sprintf("PlaceBox(%d,%d)", startW, startH))
|
||||||
return 0, 0
|
return 0, 0
|
||||||
case widget.Stdout:
|
case widget.Stdout:
|
||||||
tk.setStdoutWH(startW, startH)
|
tk.setStdoutWH(startW, startH)
|
||||||
|
@ -103,6 +114,8 @@ func (tk *guiWidget) placeWidgets(startW int, startH int) (int, int) {
|
||||||
tk.gocuiSetWH(startW, startH)
|
tk.gocuiSetWH(startW, startH)
|
||||||
tk.full.w0 = startW
|
tk.full.w0 = startW
|
||||||
tk.full.h0 = startH
|
tk.full.h0 = startH
|
||||||
|
tk.full.w1 = startW
|
||||||
|
tk.full.h1 = startH
|
||||||
|
|
||||||
newW := startW + me.GroupPadW
|
newW := startW + me.GroupPadW
|
||||||
newH := startH + 1 // normal hight of the group label
|
newH := startH + 1 // normal hight of the group label
|
||||||
|
@ -121,7 +134,9 @@ func (tk *guiWidget) placeWidgets(startW int, startH int) (int, int) {
|
||||||
}
|
}
|
||||||
log.Log(INFO, "REAL HEIGHT sizeW:", sizeW, "sizeH:", sizeH)
|
log.Log(INFO, "REAL HEIGHT sizeW:", sizeW, "sizeH:", sizeH)
|
||||||
}
|
}
|
||||||
return maxW, newH - startH
|
newH = newH - startH
|
||||||
|
tk.dumpWidget(fmt.Sprintf("PlaceGroup(%d,%d)", maxW, newH))
|
||||||
|
return maxW, newH
|
||||||
default:
|
default:
|
||||||
tk.gocuiSetWH(startW, startH)
|
tk.gocuiSetWH(startW, startH)
|
||||||
return tk.gocuiSize.Width(), tk.gocuiSize.Height()
|
return tk.gocuiSize.Width(), tk.gocuiSize.Height()
|
||||||
|
@ -188,6 +203,8 @@ func (w *guiWidget) placeGrid(startW int, startH int) (int, int) {
|
||||||
// child.showWidgetPlacement("grid2:")
|
// child.showWidgetPlacement("grid2:")
|
||||||
}
|
}
|
||||||
// w.showWidgetPlacement("grid3:")
|
// w.showWidgetPlacement("grid3:")
|
||||||
|
w.full.w1 = startW + maxW
|
||||||
|
w.full.h1 = startH + maxH
|
||||||
return maxW, maxH
|
return maxW, maxH
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
17
plugin.go
17
plugin.go
|
@ -161,23 +161,24 @@ func (w *guiWidget) AddText(text string) {
|
||||||
w.SetText(text)
|
w.SetText(text)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *guiWidget) SetText(text string) {
|
func (tk *guiWidget) SetText(text string) {
|
||||||
var changed bool = false
|
var changed bool = false
|
||||||
if w == nil {
|
if tk == nil {
|
||||||
log.Log(NOW, "widget is nil")
|
log.Log(NOW, "widget is nil")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if w.labelN != text {
|
if tk.labelN != text {
|
||||||
w.labelN = text
|
tk.labelN = text
|
||||||
changed = true
|
changed = true
|
||||||
}
|
}
|
||||||
|
tk.node.State.Label = text
|
||||||
if !changed {
|
if !changed {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if w.Visible() {
|
if tk.Visible() {
|
||||||
w.textResize()
|
tk.textResize()
|
||||||
w.Hide()
|
tk.Hide()
|
||||||
w.Show()
|
tk.Show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue