summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile5
-rw-r--r--README-goreadme.md4
-rw-r--r--cmds/buttonplugin/Makefile2
-rw-r--r--cmds/buttonplugin/log.go2
-rw-r--r--cmds/buttonplugin/main.go11
-rw-r--r--grid.go8
-rw-r--r--structs.go8
-rw-r--r--toolkit/andlabs/Makefile2
-rw-r--r--toolkit/gocui/Makefile5
-rw-r--r--toolkit/gocui/common.go4
-rw-r--r--toolkit/gocui/main.go3
-rw-r--r--toolkit/gocui/place.go4
-rw-r--r--toolkit/gocui/structs.go10
13 files changed, 40 insertions, 28 deletions
diff --git a/Makefile b/Makefile
index dba769b..edac95c 100644
--- a/Makefile
+++ b/Makefile
@@ -82,11 +82,10 @@ clean:
plugins: plugins-gocui plugins-andlabs
plugins-gocui:
- make -C toolkit/gocui
+ GO111MODULE="off" go build -v -x -C toolkit/gocui -buildmode=plugin -o ../gocui.so
plugins-andlabs:
- cd toolkit/andlabs/ && GO111MODULE="off" go build -buildmode=plugin -o ../andlabs.so
- # make -C toolkit/andlabs
+ GO111MODULE="off" go build -v -x -C toolkit/andlabs -buildmode=plugin -o ../andlabs.so
objdump:
objdump -t toolkit/andlabs.so |less
diff --git a/README-goreadme.md b/README-goreadme.md
index 26dbce4..5211057 100644
--- a/README-goreadme.md
+++ b/README-goreadme.md
@@ -163,7 +163,7 @@ This goroutine can be used like a watchdog timer
This struct can be used with the go-arg package
-### type [GuiConfig](/structs.go#L34)
+### type [GuiConfig](/structs.go#L32)
`type GuiConfig struct { ... }`
@@ -173,7 +173,7 @@ This struct can be used with the go-arg package
var Config GuiConfig
```
-### type [Node](/structs.go#L61)
+### type [Node](/structs.go#L59)
`type Node struct { ... }`
diff --git a/cmds/buttonplugin/Makefile b/cmds/buttonplugin/Makefile
index 84ff928..1903a67 100644
--- a/cmds/buttonplugin/Makefile
+++ b/cmds/buttonplugin/Makefile
@@ -7,7 +7,7 @@
#
run: build
- ./buttonplugin >/tmp/witgui.log.stderr 2>&1
+ ./buttonplugin --gui-toolkit gocui >/tmp/witgui.log.stderr 2>&1
build-release:
go get -v -u -x .
diff --git a/cmds/buttonplugin/log.go b/cmds/buttonplugin/log.go
index fb85cfa..70039df 100644
--- a/cmds/buttonplugin/log.go
+++ b/cmds/buttonplugin/log.go
@@ -9,6 +9,7 @@ import (
"time"
"bufio"
arg "github.com/alexflint/go-arg"
+ "git.wit.org/wit/gui"
)
@@ -17,6 +18,7 @@ var args struct {
Bar bool
User string `arg:"env:USER"`
Demo bool `help:"run a demo"`
+ gui.GuiArgs
}
var f1 *os.File
diff --git a/cmds/buttonplugin/main.go b/cmds/buttonplugin/main.go
index 7ced40b..4b6a2ff 100644
--- a/cmds/buttonplugin/main.go
+++ b/cmds/buttonplugin/main.go
@@ -13,6 +13,8 @@ var outfile string = "/tmp/guilogfile"
var myGui *gui.Node
var buttonCounter int = 5
+var gridW int = 5
+var gridH int = 2
func main() {
// This will turn on all debugging
@@ -20,7 +22,12 @@ func main() {
// myGui = gui.New().LoadToolkit("gocui")
// myGui = gui.New().LoadToolkit("andlabs")
- myGui = gui.New().Default()
+ // myGui = gui.New().Default()
+ if (args.GuiToolkit == nil) {
+ myGui = gui.New().Default()
+ } else {
+ myGui = gui.New().LoadToolkit(args.GuiToolkit[0])
+ }
buttonWindow()
// This is just a optional goroutine to watch that things are alive
@@ -42,7 +49,7 @@ func buttonWindow() {
g1.NewButton("hello2", func () {
log.Println("world2")
})
- more2 = g1.NewGrid("gridnuts", 3, 3)
+ more2 = g1.NewGrid("gridnuts", gridW, gridH)
more2.NewLabel("more2")
diff --git a/grid.go b/grid.go
index 4ece4d2..3fb1b71 100644
--- a/grid.go
+++ b/grid.go
@@ -5,11 +5,17 @@ import (
)
// Grid numbering examples (H) or (W,H)
+// -----------------------
+// -- (1) -- (2) -- (3) -- (X)
+// -----------------------
+//
+// (Y)
// ---------
// -- (1) --
// -- (2) --
// ---------
//
+// (X,Y)
// -----------------------------
// -- (1,1) -- (2,1) -- (3,1) --
// -- (1,2) -- (2,2) -- (3,2) --
@@ -27,8 +33,6 @@ func (n *Node) NewGrid(name string, w int, h int) *Node {
a.Text = name
a.X = w
a.Y = h
- // a.Width = w
- // a.Height = h
newNode.X = w
newNode.Y = h
newNode.NextX = 1
diff --git a/structs.go b/structs.go
index b222138..4697dde 100644
--- a/structs.go
+++ b/structs.go
@@ -24,13 +24,11 @@ var Config GuiConfig
// This struct can be used with the go-arg package
type GuiArgs struct {
- Toolkit []string `arg:"--toolkit" help:"The order to attempt loading plugins [gocui,andlabs,gtk,qt]"`
- GuiDebug bool `arg:"--gui-debug" help:"debug the GUI"`
- GuiVerbose bool `arg:"--gui-verbose" help:"enable all GUI flags"`
+ GuiToolkit []string `arg:"--gui-toolkit" help:"The order to attempt loading plugins [gocui,andlabs,gtk,qt]"`
+ GuiDebug bool `arg:"--gui-debug" help:"open the GUI debugger"`
+ GuiVerbose bool `arg:"--gui-verbose" help:"enable all logging"`
}
-// var verbose GuiArgs.GuiDebug
-
type GuiConfig struct {
// This is the master node. The Binary Tree starts here
rootNode *Node
diff --git a/toolkit/andlabs/Makefile b/toolkit/andlabs/Makefile
index 65bd8f0..b839c33 100644
--- a/toolkit/andlabs/Makefile
+++ b/toolkit/andlabs/Makefile
@@ -1,7 +1,7 @@
all: plugin
plugin:
- GO111MODULE="off" go build -buildmode=plugin -o ../andlabs.so
+ GO111MODULE="off" go build -v -x -buildmode=plugin -o ../andlabs.so
goget:
GO111MODULE="off" go get -v -t -u
diff --git a/toolkit/gocui/Makefile b/toolkit/gocui/Makefile
index 43e804f..6c4f7d5 100644
--- a/toolkit/gocui/Makefile
+++ b/toolkit/gocui/Makefile
@@ -4,11 +4,8 @@ all: plugin
goget:
GO111MODULE="off" go get -v -t -u
-build:
- GO111MODULE="off" go build
-
plugin:
- GO111MODULE="off" go build -buildmode=plugin -o ../gocui.so
+ GO111MODULE="off" go build -v -x -buildmode=plugin -o ../gocui.so
objdump:
objdump -t ../gocui.so |less
diff --git a/toolkit/gocui/common.go b/toolkit/gocui/common.go
index 93dfbb6..94b63b1 100644
--- a/toolkit/gocui/common.go
+++ b/toolkit/gocui/common.go
@@ -15,8 +15,8 @@ func makeWidget(a *toolkit.Action) *cuiWidget {
w.b = a.B
w.i = a.I
w.s = a.S
- w.x = a.X
- w.y = a.Y
+ w.X = a.X
+ w.Y = a.Y
t := len(w.text)
diff --git a/toolkit/gocui/main.go b/toolkit/gocui/main.go
index 0dd2c0a..20e85ac 100644
--- a/toolkit/gocui/main.go
+++ b/toolkit/gocui/main.go
@@ -88,11 +88,14 @@ func main() {
if err != nil {
exit("error opening file: %v", err)
}
+ os.Stdout = outf
defer outf.Close()
// setOutput(outf)
// log("This is a test log entry")
+ ferr, _ := os.OpenFile("/tmp/witgui.err", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0664)
+ os.Stderr = ferr
MouseMain()
log(true, "MouseMain() closed")
diff --git a/toolkit/gocui/place.go b/toolkit/gocui/place.go
index 124908f..bcb273b 100644
--- a/toolkit/gocui/place.go
+++ b/toolkit/gocui/place.go
@@ -209,10 +209,10 @@ func (w *cuiWidget) placeGrid() {
if (w.heights[hCount] < child.realHeight) {
w.heights[hCount] = child.realHeight
}
- log(logVerbose, "grid1: (w,h count)", wCount, hCount, "(X,Y)", w.x, w.y, w.name)
+ log(logVerbose, "grid1: (w,h count)", wCount, hCount, "(X,Y)", w.X, w.Y, w.name)
child.showWidgetPlacement(logNow, "grid1: " + fmt.Sprintf("next()=(%2d,%2d)", w.nextW, w.nextH))
- if ((wCount + 1) < w.y) {
+ if ((wCount + 1) < w.X) {
wCount += 1
} else {
wCount = 0
diff --git a/toolkit/gocui/structs.go b/toolkit/gocui/structs.go
index 09d1f33..e9f89af 100644
--- a/toolkit/gocui/structs.go
+++ b/toolkit/gocui/structs.go
@@ -157,8 +157,8 @@ type cuiWidget struct {
b bool
i int
s string
- x int
- y int
+ X int
+ Y int
width int
height int
@@ -205,10 +205,12 @@ func (w *cuiWidget) Write(p []byte) (n int, err error) {
defer me.writeMutex.Unlock()
if (me.logStdout.v == nil) {
// optionally write the output to /tmp
- fmt.Fprintln(outf, string(p))
+ s := fmt.Sprint(string(p))
+ s = strings.TrimSuffix(s, "\n")
+ fmt.Fprintln(outf, s)
v, _ := me.baseGui.View("msg")
if (v != nil) {
- fmt.Fprintln(outf, "found msg")
+ // fmt.Fprintln(outf, "found msg")
me.logStdout.v = v
}
} else {