diff options
| author | Jeff Carr <[email protected]> | 2022-11-06 12:59:24 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2022-11-06 12:59:24 -0600 |
| commit | e55fb6675d692e3f44fa67b02b12661e476bd028 (patch) | |
| tree | c16084dea9779f5ef244adb3937d33adb17e7bad /toolkit/gocui/greeter.go | |
| parent | 099efb6b24caf9eaad50d7386636a7ac23552bde (diff) | |
start trying to make the tookits pluginsv0.4.3
totally minimize helloworld demo
try to make a button plugin example
debug changes
final changes before attempting to use a golang plugin
actually running gocui as a plugin
add gocli-as-plugin example
try to convert the go-cui toolkit into a plugin
doc updates
make a minimal console gui
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'toolkit/gocui/greeter.go')
| -rw-r--r-- | toolkit/gocui/greeter.go | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/toolkit/gocui/greeter.go b/toolkit/gocui/greeter.go new file mode 100644 index 0000000..9d546a7 --- /dev/null +++ b/toolkit/gocui/greeter.go @@ -0,0 +1,57 @@ +package main + +import ( + "errors" + "fmt" + "log" + "strings" + + "github.com/awesome-gocui/gocui" +) + +type greeting string + + +// func main() { +func (g greeting) Greet() { + fmt.Println("Hello Universe") + Init() + // ToolkitMain() +} + +// this is exported +var Greeter greeting + +func AddGroup(name string) { + log.Println("addGroup()", name) + currentY = 2 + currentX += groupSize + 6 +} + +func AddButton(name string) error { + t := len(name) + v, err := baseGui.SetView(name, currentX, currentY, currentX+t+3, currentY+2, 0) + if err == nil { + return err + } + if !errors.Is(err, gocui.ErrUnknownView) { + return err + } + + v.Wrap = true + fmt.Fprintln(v, " " + name) + fmt.Fprintln(v, strings.Repeat("foo\n", 2)) + + if _, err := baseGui.SetCurrentView(name); err != nil { + return err + } + + views = append(views, name) + curView = len(views) - 1 + idxView += 1 + currentY += 3 + if (groupSize < len(views)) { + groupSize = len(views) + } + return nil +} |
