gocui: ready for 0.7.6

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2023-04-06 06:29:00 -05:00
parent c29faf4f9b
commit c1edca0f0e
4 changed files with 22 additions and 51 deletions

View File

@ -8,9 +8,7 @@ import (
var fakeStartWidth int = 40
var fakeStartHeight int = 3
func (w *cuiWidget) setFake() {
if (w.isFake == false) {
return
}
w.isFake = true
t := len(w.name)
// setup fake labels for non-visable things off screen
w.realWidth = t + 2
@ -27,7 +25,9 @@ func (w *cuiWidget) setFake() {
fakeStartWidth += 20
}
w.setWH()
w.showWidgetPlacement(logNow, "setFake()")
if (debugAction) {
w.drawView()
}
}
// set the widget start width & height
@ -36,25 +36,17 @@ func (w *cuiWidget) addWidget() {
switch w.widgetType {
case toolkit.Root:
log(logInfo, "setStartWH() rootNode w.id =", w.id, "w.name", w.name)
w.isFake = true
w.setFake()
w.showWidgetPlacement(logNow, "StartWH:")
w.drawView()
return
case toolkit.Flag:
w.isFake = true
w.setFake()
w.showWidgetPlacement(logNow, "StartWH:")
w.drawView()
return
case toolkit.Window:
w.setTabWH()
w.showWidgetPlacement(logNow, "StartWH:")
w.drawView()
return
case toolkit.Tab:
w.setTabWH()
w.showWidgetPlacement(logNow, "StartWH:")
w.drawView()
return
case toolkit.Box:
@ -62,16 +54,12 @@ func (w *cuiWidget) addWidget() {
w.setFake()
w.startW = w.parent.startW
w.startH = w.parent.startH
w.showWidgetPlacement(logNow, "StartWH:")
w.drawView()
return
case toolkit.Grid:
w.isFake = true
w.setFake()
w.startW = w.parent.startW
w.startH = w.parent.startH
w.showWidgetPlacement(logNow, "StartWH:")
w.drawView()
return
case toolkit.Group:
w.startW = w.parent.startW + 4
@ -84,12 +72,11 @@ func (w *cuiWidget) addWidget() {
w.gocuiSize.startH = w.startH
w.setWH()
w.showWidgetPlacement(logNow, "StartWH:")
// w.drawView()
return
default:
w.startW = w.parent.startW
w.startH = w.parent.startH
w.setWH()
}
w.showWidgetPlacement(logInfo, "addWidget()")
}

View File

@ -7,6 +7,8 @@ import (
// "github.com/awesome-gocui/gocui"
)
var debugAction bool = false
func actionDump(b bool, a *toolkit.Action) {
if (a == nil) {
log(b, "action = nil")

View File

@ -19,7 +19,7 @@ func helplayout(g *gocui.Gui) error {
var err error
maxX, _ := g.Size()
help, err := g.SetView("help", maxX-32, 0, maxX-1, 17, 0)
help, err := g.SetView("help", maxX-32, 0, maxX-1, 13, 0)
if err != nil {
if !errors.Is(err, gocui.ErrUnknownView) {
return err
@ -27,17 +27,17 @@ func helplayout(g *gocui.Gui) error {
help.SelBgColor = gocui.ColorGreen
help.SelFgColor = gocui.ColorBlack
fmt.Fprintln(help, "KEYBINDINGS")
fmt.Fprintln(help, "Enter: Click Button")
fmt.Fprintln(help, "Tab/Space: Switch Buttons")
// fmt.Fprintln(help, "Enter: Click Button")
// fmt.Fprintln(help, "Tab/Space: Switch Buttons")
fmt.Fprintln(help, "")
fmt.Fprintln(help, "h: Help")
fmt.Fprintln(help, "Backspace: Delete Button")
fmt.Fprintln(help, "Arrow keys: Move Button")
fmt.Fprintln(help, "t: Move Button to the top")
fmt.Fprintln(help, "b: Move Button to the button")
// fmt.Fprintln(help, "h: Help")
// fmt.Fprintln(help, "Backspace: Delete Button")
// fmt.Fprintln(help, "Arrow keys: Move Button")
// fmt.Fprintln(help, "t: Move Button to the top")
// fmt.Fprintln(help, "b: Move Button to the button")
fmt.Fprintln(help, "d: show/hide debugging")
fmt.Fprintln(help, "h: hide buttons")
fmt.Fprintln(help, "s: show buttons")
fmt.Fprintln(help, "h: hide widgets")
fmt.Fprintln(help, "s: show all widgets")
fmt.Fprintln(help, "p: panic()")
fmt.Fprintln(help, "STDOUT: /tmp/witgui.log")
fmt.Fprintln(help, "Ctrl-C or Q: Exit")

View File

@ -15,8 +15,6 @@ import (
"git.wit.org/wit/gui/toolkit"
)
// const delta = 1
// It's probably a terrible idea to call this 'me'
var me config
@ -52,20 +50,9 @@ type config struct {
buttonPadding int
}
/*
// This is a map between the widgets in wit/gui and the internal structures of gocui
var viewWidget map[*gocui.View]*toolkit.Widget
var stringWidget map[string]*toolkit.Widget
*/
var (
// g *gocui.Gui
// Custom func(string)
initialMouseX, initialMouseY, xOffset, yOffset int
globalMouseDown, msgMouseDown, movingMsg bool
// err error
)
// the gocui way
@ -84,13 +71,6 @@ type rectType struct {
w0, h0, w1, h1 int // left top right bottom
}
/*
type realSizeT struct {
width, height int
}
*/
type cuiWidget struct {
id int // widget ID
// parentId int
@ -161,10 +141,12 @@ func (w *cuiWidget) Write(p []byte) (n int, err error) {
w.tainted = true
w.writeMutex.Lock()
defer w.writeMutex.Unlock()
// v.makeWriteable(v.wx, v.wy)
// v.writeRunes(bytes.Runes(p))
if (w.v == nil) {
return
}
w.v.Clear()
fmt.Fprintln(w.v, p)
log(logNow, "widget.Write()")
log(logNow, "widget.Write()", p)
return len(p), nil
}