gocui: grid width fixed
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
b79bb8e348
commit
dc7762fc16
5
Makefile
5
Makefile
|
@ -82,11 +82,10 @@ clean:
|
||||||
plugins: plugins-gocui plugins-andlabs
|
plugins: plugins-gocui plugins-andlabs
|
||||||
|
|
||||||
plugins-gocui:
|
plugins-gocui:
|
||||||
make -C toolkit/gocui
|
GO111MODULE="off" go build -v -x -C toolkit/gocui -buildmode=plugin -o ../gocui.so
|
||||||
|
|
||||||
plugins-andlabs:
|
plugins-andlabs:
|
||||||
cd toolkit/andlabs/ && GO111MODULE="off" go build -buildmode=plugin -o ../andlabs.so
|
GO111MODULE="off" go build -v -x -C toolkit/andlabs -buildmode=plugin -o ../andlabs.so
|
||||||
# make -C toolkit/andlabs
|
|
||||||
|
|
||||||
objdump:
|
objdump:
|
||||||
objdump -t toolkit/andlabs.so |less
|
objdump -t toolkit/andlabs.so |less
|
||||||
|
|
|
@ -163,7 +163,7 @@ This goroutine can be used like a watchdog timer
|
||||||
|
|
||||||
This struct can be used with the go-arg package
|
This struct can be used with the go-arg package
|
||||||
|
|
||||||
### type [GuiConfig](/structs.go#L34)
|
### type [GuiConfig](/structs.go#L32)
|
||||||
|
|
||||||
`type GuiConfig struct { ... }`
|
`type GuiConfig struct { ... }`
|
||||||
|
|
||||||
|
@ -173,7 +173,7 @@ This struct can be used with the go-arg package
|
||||||
var Config GuiConfig
|
var Config GuiConfig
|
||||||
```
|
```
|
||||||
|
|
||||||
### type [Node](/structs.go#L61)
|
### type [Node](/structs.go#L59)
|
||||||
|
|
||||||
`type Node struct { ... }`
|
`type Node struct { ... }`
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
run: build
|
run: build
|
||||||
./buttonplugin >/tmp/witgui.log.stderr 2>&1
|
./buttonplugin --gui-toolkit gocui >/tmp/witgui.log.stderr 2>&1
|
||||||
|
|
||||||
build-release:
|
build-release:
|
||||||
go get -v -u -x .
|
go get -v -u -x .
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
"bufio"
|
"bufio"
|
||||||
arg "github.com/alexflint/go-arg"
|
arg "github.com/alexflint/go-arg"
|
||||||
|
"git.wit.org/wit/gui"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,6 +18,7 @@ var args struct {
|
||||||
Bar bool
|
Bar bool
|
||||||
User string `arg:"env:USER"`
|
User string `arg:"env:USER"`
|
||||||
Demo bool `help:"run a demo"`
|
Demo bool `help:"run a demo"`
|
||||||
|
gui.GuiArgs
|
||||||
}
|
}
|
||||||
|
|
||||||
var f1 *os.File
|
var f1 *os.File
|
||||||
|
|
|
@ -13,6 +13,8 @@ var outfile string = "/tmp/guilogfile"
|
||||||
var myGui *gui.Node
|
var myGui *gui.Node
|
||||||
|
|
||||||
var buttonCounter int = 5
|
var buttonCounter int = 5
|
||||||
|
var gridW int = 5
|
||||||
|
var gridH int = 2
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
// This will turn on all debugging
|
// This will turn on all debugging
|
||||||
|
@ -20,7 +22,12 @@ func main() {
|
||||||
|
|
||||||
// myGui = gui.New().LoadToolkit("gocui")
|
// myGui = gui.New().LoadToolkit("gocui")
|
||||||
// myGui = gui.New().LoadToolkit("andlabs")
|
// myGui = gui.New().LoadToolkit("andlabs")
|
||||||
|
// myGui = gui.New().Default()
|
||||||
|
if (args.GuiToolkit == nil) {
|
||||||
myGui = gui.New().Default()
|
myGui = gui.New().Default()
|
||||||
|
} else {
|
||||||
|
myGui = gui.New().LoadToolkit(args.GuiToolkit[0])
|
||||||
|
}
|
||||||
buttonWindow()
|
buttonWindow()
|
||||||
|
|
||||||
// This is just a optional goroutine to watch that things are alive
|
// This is just a optional goroutine to watch that things are alive
|
||||||
|
@ -42,7 +49,7 @@ func buttonWindow() {
|
||||||
g1.NewButton("hello2", func () {
|
g1.NewButton("hello2", func () {
|
||||||
log.Println("world2")
|
log.Println("world2")
|
||||||
})
|
})
|
||||||
more2 = g1.NewGrid("gridnuts", 3, 3)
|
more2 = g1.NewGrid("gridnuts", gridW, gridH)
|
||||||
|
|
||||||
more2.NewLabel("more2")
|
more2.NewLabel("more2")
|
||||||
|
|
||||||
|
|
8
grid.go
8
grid.go
|
@ -5,11 +5,17 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// Grid numbering examples (H) or (W,H)
|
// Grid numbering examples (H) or (W,H)
|
||||||
|
// -----------------------
|
||||||
|
// -- (1) -- (2) -- (3) -- (X)
|
||||||
|
// -----------------------
|
||||||
|
//
|
||||||
|
// (Y)
|
||||||
// ---------
|
// ---------
|
||||||
// -- (1) --
|
// -- (1) --
|
||||||
// -- (2) --
|
// -- (2) --
|
||||||
// ---------
|
// ---------
|
||||||
//
|
//
|
||||||
|
// (X,Y)
|
||||||
// -----------------------------
|
// -----------------------------
|
||||||
// -- (1,1) -- (2,1) -- (3,1) --
|
// -- (1,1) -- (2,1) -- (3,1) --
|
||||||
// -- (1,2) -- (2,2) -- (3,2) --
|
// -- (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.Text = name
|
||||||
a.X = w
|
a.X = w
|
||||||
a.Y = h
|
a.Y = h
|
||||||
// a.Width = w
|
|
||||||
// a.Height = h
|
|
||||||
newNode.X = w
|
newNode.X = w
|
||||||
newNode.Y = h
|
newNode.Y = h
|
||||||
newNode.NextX = 1
|
newNode.NextX = 1
|
||||||
|
|
|
@ -24,13 +24,11 @@ var Config GuiConfig
|
||||||
|
|
||||||
// This struct can be used with the go-arg package
|
// This struct can be used with the go-arg package
|
||||||
type GuiArgs struct {
|
type GuiArgs struct {
|
||||||
Toolkit []string `arg:"--toolkit" help:"The order to attempt loading plugins [gocui,andlabs,gtk,qt]"`
|
GuiToolkit []string `arg:"--gui-toolkit" help:"The order to attempt loading plugins [gocui,andlabs,gtk,qt]"`
|
||||||
GuiDebug bool `arg:"--gui-debug" help:"debug the GUI"`
|
GuiDebug bool `arg:"--gui-debug" help:"open the GUI debugger"`
|
||||||
GuiVerbose bool `arg:"--gui-verbose" help:"enable all GUI flags"`
|
GuiVerbose bool `arg:"--gui-verbose" help:"enable all logging"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// var verbose GuiArgs.GuiDebug
|
|
||||||
|
|
||||||
type GuiConfig struct {
|
type GuiConfig struct {
|
||||||
// This is the master node. The Binary Tree starts here
|
// This is the master node. The Binary Tree starts here
|
||||||
rootNode *Node
|
rootNode *Node
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
all: plugin
|
all: plugin
|
||||||
|
|
||||||
plugin:
|
plugin:
|
||||||
GO111MODULE="off" go build -buildmode=plugin -o ../andlabs.so
|
GO111MODULE="off" go build -v -x -buildmode=plugin -o ../andlabs.so
|
||||||
|
|
||||||
goget:
|
goget:
|
||||||
GO111MODULE="off" go get -v -t -u
|
GO111MODULE="off" go get -v -t -u
|
||||||
|
|
|
@ -4,11 +4,8 @@ all: plugin
|
||||||
goget:
|
goget:
|
||||||
GO111MODULE="off" go get -v -t -u
|
GO111MODULE="off" go get -v -t -u
|
||||||
|
|
||||||
build:
|
|
||||||
GO111MODULE="off" go build
|
|
||||||
|
|
||||||
plugin:
|
plugin:
|
||||||
GO111MODULE="off" go build -buildmode=plugin -o ../gocui.so
|
GO111MODULE="off" go build -v -x -buildmode=plugin -o ../gocui.so
|
||||||
|
|
||||||
objdump:
|
objdump:
|
||||||
objdump -t ../gocui.so |less
|
objdump -t ../gocui.so |less
|
||||||
|
|
|
@ -15,8 +15,8 @@ func makeWidget(a *toolkit.Action) *cuiWidget {
|
||||||
w.b = a.B
|
w.b = a.B
|
||||||
w.i = a.I
|
w.i = a.I
|
||||||
w.s = a.S
|
w.s = a.S
|
||||||
w.x = a.X
|
w.X = a.X
|
||||||
w.y = a.Y
|
w.Y = a.Y
|
||||||
|
|
||||||
|
|
||||||
t := len(w.text)
|
t := len(w.text)
|
||||||
|
|
|
@ -88,11 +88,14 @@ func main() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
exit("error opening file: %v", err)
|
exit("error opening file: %v", err)
|
||||||
}
|
}
|
||||||
|
os.Stdout = outf
|
||||||
defer outf.Close()
|
defer outf.Close()
|
||||||
|
|
||||||
// setOutput(outf)
|
// setOutput(outf)
|
||||||
// log("This is a test log entry")
|
// 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()
|
MouseMain()
|
||||||
|
|
||||||
log(true, "MouseMain() closed")
|
log(true, "MouseMain() closed")
|
||||||
|
|
|
@ -209,10 +209,10 @@ func (w *cuiWidget) placeGrid() {
|
||||||
if (w.heights[hCount] < child.realHeight) {
|
if (w.heights[hCount] < child.realHeight) {
|
||||||
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))
|
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
|
wCount += 1
|
||||||
} else {
|
} else {
|
||||||
wCount = 0
|
wCount = 0
|
||||||
|
|
|
@ -157,8 +157,8 @@ type cuiWidget struct {
|
||||||
b bool
|
b bool
|
||||||
i int
|
i int
|
||||||
s string
|
s string
|
||||||
x int
|
X int
|
||||||
y int
|
Y int
|
||||||
width int
|
width int
|
||||||
height int
|
height int
|
||||||
|
|
||||||
|
@ -205,10 +205,12 @@ func (w *cuiWidget) Write(p []byte) (n int, err error) {
|
||||||
defer me.writeMutex.Unlock()
|
defer me.writeMutex.Unlock()
|
||||||
if (me.logStdout.v == nil) {
|
if (me.logStdout.v == nil) {
|
||||||
// optionally write the output to /tmp
|
// 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")
|
v, _ := me.baseGui.View("msg")
|
||||||
if (v != nil) {
|
if (v != nil) {
|
||||||
fmt.Fprintln(outf, "found msg")
|
// fmt.Fprintln(outf, "found msg")
|
||||||
me.logStdout.v = v
|
me.logStdout.v = v
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue