summaryrefslogtreecommitdiff
path: root/toolkit/gocui
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2022-11-06 19:57:20 -0600
committerJeff Carr <[email protected]>2022-11-06 19:57:20 -0600
commitb410d0fd083ee89eed410cda2123a22cddcd3f44 (patch)
tree3f1a637003629a3ec7d383b5db6beb0df9e5a97c /toolkit/gocui
parente55fb6675d692e3f44fa67b02b12661e476bd028 (diff)
Implement a early AddButton() via a golang pluginv0.4.5
pass a name to gocui.AddButton() cleaner plugin usage add the start to golang plugin plugin stuff in a single file added a button correctly andlabs/ui added a button via plugin to gocli hot diggity! trying to invoke a gocli plugin function from the andlabs ui load the plugin hide more debugging output turn off all output Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'toolkit/gocui')
-rw-r--r--toolkit/gocui/greeter.go19
-rw-r--r--toolkit/gocui/main.go20
-rw-r--r--toolkit/gocui/newJ.go2
3 files changed, 26 insertions, 15 deletions
diff --git a/toolkit/gocui/greeter.go b/toolkit/gocui/greeter.go
index 9d546a7..de6ee68 100644
--- a/toolkit/gocui/greeter.go
+++ b/toolkit/gocui/greeter.go
@@ -11,6 +11,8 @@ import (
type greeting string
+// this is exported
+var Greeter greeting
// func main() {
func (g greeting) Greet() {
@@ -19,16 +21,25 @@ func (g greeting) Greet() {
// ToolkitMain()
}
-// this is exported
-var Greeter greeting
+func (g greeting) JcarrButton() {
+ fmt.Println("Hello GreetButton meet Universe")
+ addButton("Greet foo")
+ addButton("Greet foo 2")
+}
-func AddGroup(name string) {
+func addGroup(name string) {
log.Println("addGroup()", name)
currentY = 2
currentX += groupSize + 6
}
-func AddButton(name string) error {
+func (g greeting) AddButton(name string) {
+// func (g greeting) AddButton() {
+ log.Println("gui.gocui.AddButton()", name)
+ addButton(name)
+}
+
+func addButton(name string) error {
t := len(name)
v, err := baseGui.SetView(name, currentX, currentY, currentX+t+3, currentY+2, 0)
if err == nil {
diff --git a/toolkit/gocui/main.go b/toolkit/gocui/main.go
index 2439a3a..314f5be 100644
--- a/toolkit/gocui/main.go
+++ b/toolkit/gocui/main.go
@@ -50,18 +50,18 @@ func Init() {
log.Panicln(err)
}
- AddButton("hello")
- AddButton("world")
- AddButton("foo")
+ addButton("hello")
+ addButton("world")
+ addButton("foo")
- AddGroup("blank")
- AddButton("bar")
- AddButton("bar none")
- AddButton("bar going")
+ addGroup("blank")
+ addButton("bar")
+ addButton("bar none")
+ addButton("bar going")
- AddGroup("te")
- AddButton("world 2")
- AddButton("foo 2")
+ addGroup("te")
+ addButton("world 2")
+ addButton("foo 2")
if err := baseGui.MainLoop(); err != nil && !errors.Is(err, gocui.ErrQuit) {
log.Panicln(err)
diff --git a/toolkit/gocui/newJ.go b/toolkit/gocui/newJ.go
index 47c7439..3e04cd3 100644
--- a/toolkit/gocui/newJ.go
+++ b/toolkit/gocui/newJ.go
@@ -20,7 +20,7 @@ var bottomY int = 7
func newJ(g *gocui.Gui) error {
// maxX, maxY := g.Size()
- name := fmt.Sprintf("jcarr %v test ", idxView)
+ name := fmt.Sprintf("jcarr %v foo ", idxView)
v, err := g.SetView(name, topX, topY, bottomX, bottomY, 0)
if err == nil {
return err