gocui: grid width fixed

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2023-04-27 20:41:53 -05:00
parent b79bb8e348
commit dc7762fc16
13 changed files with 40 additions and 28 deletions

View File

@ -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

View File

@ -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 { ... }`

View File

@ -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 .

View File

@ -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

View File

@ -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")

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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")

View File

@ -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

View File

@ -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 {