summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2023-05-09 19:24:37 -0500
committerJeff Carr <[email protected]>2023-05-09 19:24:37 -0500
commitcb2c88d8c12a58f4e791dffeaba0a685d63bbc79 (patch)
tree348a812e153d152f19502f99bf402b9233f6c267
parent28b7470328707da8d9701c4af1493f4730bcd1f9 (diff)
getting pretty clean at this point
Signed-off-by: Jeff Carr <[email protected]>
-rw-r--r--README-goreadme.md4
-rw-r--r--common.go75
-rw-r--r--debug.go11
-rw-r--r--debugWidget.go44
-rw-r--r--plugin.go5
5 files changed, 61 insertions, 78 deletions
diff --git a/README-goreadme.md b/README-goreadme.md
index e9b318c..63698b8 100644
--- a/README-goreadme.md
+++ b/README-goreadme.md
@@ -123,7 +123,7 @@ Creates a window helpful for debugging this package
`func ExampleCatcher(f func())`
-### func [Indent](/debug.go#L127)
+### func [Indent](/debug.go#L124)
`func Indent(b bool, a ...interface{})`
@@ -135,7 +135,7 @@ Creates a window helpful for debugging this package
`func SetFlag(s string, b bool)`
-### func [ShowDebugValues](/debug.go#L85)
+### func [ShowDebugValues](/debug.go#L82)
`func ShowDebugValues()`
diff --git a/common.go b/common.go
index 25e25e3..f9884d0 100644
--- a/common.go
+++ b/common.go
@@ -10,60 +10,56 @@ import (
// functions for handling text related GUI elements
func (n *Node) Show() *Node {
- var a toolkit.Action
- a.ActionType = toolkit.Show
- newaction(&a, n, nil)
+ a := newAction(n, toolkit.Show)
+ sendAction(a)
return n
}
func (n *Node) Hide() *Node {
- var a toolkit.Action
- a.ActionType = toolkit.Hide
- newaction(&a, n, nil)
+ a := newAction(n, toolkit.Hide)
+ sendAction(a)
return n
}
func (n *Node) Enable() *Node {
- var a toolkit.Action
- a.ActionType = toolkit.Enable
- newaction(&a, n, nil)
+ a := newAction(n, toolkit.Enable)
+ sendAction(a)
return n
}
func (n *Node) Disable() *Node {
- var a toolkit.Action
- a.ActionType = toolkit.Disable
- newaction(&a, n, nil)
+ a := newAction(n, toolkit.Disable)
+ sendAction(a)
return n
}
func (n *Node) Add(str string) {
log(debugGui, "gui.Add() value =", str)
- var a toolkit.Action
- a.ActionType = toolkit.Add
- a.S = str
- newaction(&a, n, nil)
+ n.S = str
+
+ a := newAction(n, toolkit.Add)
+ sendAction(a)
}
func (n *Node) AddText(str string) {
log(debugChange, "AddText() value =", str)
n.Text = str
- var a toolkit.Action
- a.ActionType = toolkit.AddText
- a.S = str
- newaction(&a, n, nil)
+ n.S = str
+
+ a := newAction(n, toolkit.AddText)
+ sendAction(a)
}
-func (n *Node) SetText(text string) *Node{
+func (n *Node) SetText(text string) *Node {
log(debugChange, "SetText() value =", text)
n.Text = text
- var a toolkit.Action
- a.ActionType = toolkit.SetText
- a.S = text
- newaction(&a, n, nil)
+ n.S = text
+
+ a := newAction(n, toolkit.SetText)
+ sendAction(a)
return n
}
@@ -93,13 +89,12 @@ func (n *Node) Set(val any) {
}
func (n *Node) AppendText(str string) {
- var a toolkit.Action
- a.ActionType = toolkit.SetText
tmp := n.S + str
- log(debugChange, "AppendText() value =", tmp)
- a.S = tmp
n.Text = tmp
- newaction(&a, n, nil)
+ n.S = tmp
+
+ a := newAction(n, toolkit.SetText)
+ sendAction(a)
}
func (n *Node) GetText() string {
@@ -152,30 +147,26 @@ func commonCallback(n *Node) {
}
func (n *Node) Margin() *Node {
- var a toolkit.Action
- a.ActionType = toolkit.Margin
- newaction(&a, n, nil)
+ a := newAction(n, toolkit.Margin)
+ sendAction(a)
return n
}
func (n *Node) Unmargin() *Node {
- var a toolkit.Action
- a.ActionType = toolkit.Unmargin
- newaction(&a, n, nil)
+ a := newAction(n, toolkit.Unmargin)
+ sendAction(a)
return n
}
func (n *Node) Pad() *Node {
- var a toolkit.Action
- a.ActionType = toolkit.Pad
- newaction(&a, n, nil)
+ a := newAction(n, toolkit.Pad)
+ sendAction(a)
return n
}
func (n *Node) Unpad() *Node {
- var a toolkit.Action
- a.ActionType = toolkit.Unpad
- newaction(&a, n, nil)
+ a := newAction(n, toolkit.Unpad)
+ sendAction(a)
return n
}
diff --git a/debug.go b/debug.go
index 2df06cc..955a246 100644
--- a/debug.go
+++ b/debug.go
@@ -71,15 +71,12 @@ func SetFlag (s string, b bool) {
log(debugGui, "Can't set unknown flag", s)
}
- var a toolkit.Action
+ a := new(toolkit.Action)
a.ActionType = toolkit.Set
a.WidgetType = toolkit.Flag
a.S = s
a.B = b
- // a.Widget = &newNode.widget
- // a.Where = &n.widget
- // action(&a)
- newaction(&a, nil, nil)
+ sendAction(a)
}
func ShowDebugValues() {
@@ -118,10 +115,10 @@ func (n *Node) Dump() {
}
Indent(b, "NODE DUMP END")
- var a toolkit.Action
+ a := new(toolkit.Action)
a.ActionType = toolkit.Dump
a.WidgetId = n.id
- newaction(&a, activeWidget, nil)
+ sendAction(a)
}
func Indent(b bool, a ...interface{}) {
diff --git a/debugWidget.go b/debugWidget.go
index cb801a8..385f47a 100644
--- a/debugWidget.go
+++ b/debugWidget.go
@@ -115,46 +115,38 @@ func DebugWidgetWindow(w *Node) {
g = bugWidget.NewGroup("change things")
g.NewButton("AddText()", func () {
- var a toolkit.Action
- a.ActionType = toolkit.AddText
- a.S = activeLabelNewName.S
- newaction(&a, activeWidget, nil)
+ activeWidget.S = activeLabelNewName.S
+ a := newAction(activeWidget, toolkit.AddText)
+ sendAction(a)
})
g.NewButton("SetText()", func () {
- var a toolkit.Action
- a.ActionType = toolkit.SetText
- a.S = activeLabelNewName.S
- newaction(&a, activeWidget, nil)
+ activeWidget.S = activeLabelNewName.S
+ a := newAction(activeWidget, toolkit.SetText)
+ sendAction(a)
})
g.NewButton("Margin()", func () {
- var a toolkit.Action
- a.ActionType = toolkit.Margin
- newaction(&a, activeWidget, nil)
+ a := newAction(activeWidget, toolkit.Margin)
+ sendAction(a)
})
g.NewButton("Unmargin()", func () {
- var a toolkit.Action
- a.ActionType = toolkit.Unmargin
- newaction(&a, activeWidget, nil)
+ a := newAction(activeWidget, toolkit.Unmargin)
+ sendAction(a)
})
g.NewButton("Pad()", func () {
- var a toolkit.Action
- a.ActionType = toolkit.Pad
- newaction(&a, activeWidget, nil)
+ a := newAction(activeWidget, toolkit.Pad)
+ sendAction(a)
})
g.NewButton("Unpad()", func () {
- var a toolkit.Action
- a.ActionType = toolkit.Unpad
- newaction(&a, activeWidget, nil)
+ a := newAction(activeWidget, toolkit.Unpad)
+ sendAction(a)
})
g.NewButton("Move(junk)", func () {
- var a toolkit.Action
- a.ActionType = toolkit.Move
- newaction(&a, activeWidget, activeJunk)
+ a := newAction(activeWidget, toolkit.Move)
+ sendAction(a)
})
g.NewButton("Delete()", func () {
- var a toolkit.Action
- a.ActionType = toolkit.Delete
- newaction(&a, activeWidget, activeJunk)
+ a := newAction(activeWidget, toolkit.Delete)
+ sendAction(a)
})
g = bugWidget.NewGroup("not working?")
diff --git a/plugin.go b/plugin.go
index c9e0466..e8b4beb 100644
--- a/plugin.go
+++ b/plugin.go
@@ -203,6 +203,8 @@ func initToolkit(name string, filename string) *aplug {
return newPlug
}
+// 2023/05/09 pretty clean
+// 2023/04/06 Queue() is also being used and channels are being used. memcopy() only
func newAction(n *Node, atype toolkit.ActionType) *toolkit.Action {
var a toolkit.Action
a.ActionType = atype
@@ -246,7 +248,7 @@ func sendAction(a *toolkit.Action) {
}
}
-// 2023/04/06 Queue() is also being used and channels are being used. memcopy() only
+/*
func newaction(a *toolkit.Action, n *Node, where *Node) {
// remove this
if (n != nil) {
@@ -275,6 +277,7 @@ func newaction(a *toolkit.Action, n *Node, where *Node) {
sleep(.02)
}
}
+*/
func (n *Node) InitEmbed(resFS embed.FS) *Node {
me.resFS = resFS