summaryrefslogtreecommitdiff
path: root/plugin.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2023-03-29 23:03:04 -0500
committerJeff Carr <[email protected]>2023-03-29 23:03:04 -0500
commit4e28cde838683188bfbd9222746409538828592d (patch)
tree3c84fffc14352329bc41e6b58910ff278c99f08c /plugin.go
parentd4787a1ebdd08359746516dbb72f1feaf95be5b6 (diff)
add semi-working gocuiv0.7.4
commit 947169df5a22c9f9b53f825764747f648c70ff1e Author: Jeff Carr <[email protected]> Date: Wed Mar 29 22:44:08 2023 -0500 ready for version v0.7.4 start deprecating toolkit.Widget switch to variable name 'ParentId' use 'ActionType' and 'WidgetType' preliminary redraw() final definition of variables 'Name' and 'Text' more cleaning of the code remove lots of dumb code bind 'd' key press to dump out debugging info early color handling in gocui! Signed-off-by: Jeff Carr <[email protected]> commit 6013fde8332e8ecbffaf1a0977ba2e1da8ea8775 Author: Jeff Carr <[email protected]> Date: Sun Mar 26 17:19:20 2023 -0500 improvements towards a working dns control panel democui has the help menu try to add mouse support to gocui make a direct access method Margin() and Pad() tests add SPEW also push devel branch to github Signed-off-by: Jeff Carr <[email protected]> commit 6f91f5e080e06cdc0f34b13d23e5fd16ea37259a Author: Jeff Carr <[email protected]> Date: Fri Mar 24 20:14:18 2023 -0500 starting to try safe chan and goroutines fix tab title's right before attempting to add chan goroutines removed "where" widget pointer box added to tab experiement with log as it's own repo Signed-off-by: Jeff Carr <[email protected]> Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'plugin.go')
-rw-r--r--plugin.go63
1 files changed, 16 insertions, 47 deletions
diff --git a/plugin.go b/plugin.go
index 28bb324..a9cf4f9 100644
--- a/plugin.go
+++ b/plugin.go
@@ -29,12 +29,12 @@ type aplug struct {
// TODO: make Main() main() and never allow the user to call it
// run plugin.Main() when the plugin is loaded
Main func(func ()) // this never returns. Each plugin must have it's own goroutine
- Queue func(func ()) // Should this return right away? Should it wait (can it wait?)
+ // Queue func(func ()) // Should this return right away? Should it wait (can it wait?)
Quit func()
// NewWindow func(*toolkit.Widget)
// simplifies passing to the plugin
- Send func(*toolkit.Widget, *toolkit.Widget)
+ // Send func(*toolkit.Widget, *toolkit.Widget)
// should replace Send()
Action func(*toolkit.Action)
@@ -74,16 +74,11 @@ func LoadToolkit(name string) bool {
newPlug.Main = loadFuncF(&newPlug, "Main")
// should send things to the goroutine above
- newPlug.Queue = loadFuncF(&newPlug, "Queue")
+ // newPlug.Queue = loadFuncF(&newPlug, "Queue")
// unload the plugin and restore state
newPlug.Quit = loadFuncE(&newPlug, "Quit")
- // Sends a widget (button, checkbox, etc) and it's parent widget
- // This includes instructions like "Add", "Delete", "Disable", etc
-// newPlug.Send = loadFunc2(&newPlug, "Send")
-
- // This should replace Send()
// Sends instructions like "Add", "Delete", "Disable", etc
// Sends a widget (button, checkbox, etc) and it's parent widget
newPlug.Action = loadFuncA(&newPlug, "Action")
@@ -190,7 +185,8 @@ func loadPlugin(p *aplug, name string) {
homeDir, err := os.UserHomeDir()
if err != nil {
- exit(err)
+ log(logError, "loadPlugin() error. exiting here?")
+ return
}
// attempt to write out the file from the internal resource
@@ -230,36 +226,6 @@ func loadfile(filename string) *plugin.Plugin {
return plug
}
-/*
-// Sends a widget and what to do with it to the plugin
-// parent = n, child = c
-func send(p *Node, c *Node) {
- for _, aplug := range allPlugins {
- log(debugPlugin, "Send() aplug =", aplug.name, "type=", c.widget.Type, "action=", c.widget.Action, "name=", c.widget.Name)
- if (aplug.Send == nil) {
- log(debugPlugin, "Failed. Send() == nil for", aplug.name)
- continue
- }
- aplug.Send(&c.parent.widget, &c.widget)
- }
-}
-*/
-
-// Sends a widget and what to do with it to the plugin
-// parent = n, child = c
-/*
-func action(a *toolkit.Action) {
- for _, aplug := range allPlugins {
- log(debugPlugin, "Action() aplug =", aplug.name, "Action type=", a.Type)
- if (aplug.Action == nil) {
- log(debugPlugin, "Failed Action() == nil for", aplug.name)
- continue
- }
- aplug.Action(a)
- }
-}
-*/
-
// Sends a widget and what to do with it to the plugin
// parent = n, child = c
@@ -268,16 +234,19 @@ func action(a *toolkit.Action) {
func newaction(a *toolkit.Action, n *Node, where *Node) {
if (n != nil) {
a.Widget = &n.widget
+ a.WidgetId = n.id
+ a.WidgetType = n.widget.Type
+ a.ActionType = a.ActionType
}
// action(&a, newNode, n)
// newaction(&a, newNode, n)
if (where != nil) {
log(debugGui, "Action() START on where X,Y, Next X,Y =", where.Name, where.X, where.Y, where.NextX, where.NextY)
- a.Where = &where.widget
+ a.ParentId = where.id
switch where.widget.Type {
case toolkit.Grid:
- where.Dump(true)
+ // where.Dump(true)
log(debugGui, "Action() START on Grid (X,Y)", where.X, where.Y, "put next thing at (X,Y) =", where.NextX, where.NextY)
//
// fix values here if they are invalid. Index starts at 1
@@ -288,15 +257,15 @@ func newaction(a *toolkit.Action, n *Node, where *Node) {
where.NextY = 1
}
//
- a.Where.X = where.NextX
- a.Where.Y = where.NextY
+ a.X = where.NextX
+ a.Y = where.NextY
log(debugGui, "Action() END on Grid (X,Y)", where.X, where.Y, "put next thing at (X,Y) =", where.NextX, where.NextY)
default:
}
}
for _, aplug := range allPlugins {
- log(debugPlugin, "Action() aplug =", aplug.name, "Action type=", a.Type)
+ log(debugPlugin, "Action() aplug =", aplug.name, "Action type=", a.ActionType)
if (aplug.Action == nil) {
log(debugPlugin, "Failed Action() == nil for", aplug.name)
continue
@@ -307,19 +276,19 @@ func newaction(a *toolkit.Action, n *Node, where *Node) {
if (where != nil) {
switch where.widget.Type {
case toolkit.Grid:
- log(debugNow, "Action() START size (X,Y)", where.X, where.Y, "put next thing at (X,Y) =", where.NextX, where.NextY)
+ log(logInfo, "Action() START size (X,Y)", where.X, where.Y, "put next thing at (X,Y) =", where.NextX, where.NextY)
where.NextY += 1
if (where.NextY > where.Y) {
where.NextX += 1
where.NextY = 1
}
- log(debugNow, "Action() END size (X,Y)", where.X, where.Y, "put next thing at (X,Y) =", where.NextX, where.NextY)
+ log(logInfo, "Action() END size (X,Y)", where.X, where.Y, "put next thing at (X,Y) =", where.NextX, where.NextY)
where.Name = "jwc gridlaksdfjkl"
where.Width = 320
where.Height = 240
// where.NextX = 5
// where.NextY = 7
- where.Dump(true)
+ // where.Dump(logInfo)
default:
}
}