gocui: ready for 0.7.6
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
c29faf4f9b
commit
c1edca0f0e
|
@ -8,9 +8,7 @@ import (
|
||||||
var fakeStartWidth int = 40
|
var fakeStartWidth int = 40
|
||||||
var fakeStartHeight int = 3
|
var fakeStartHeight int = 3
|
||||||
func (w *cuiWidget) setFake() {
|
func (w *cuiWidget) setFake() {
|
||||||
if (w.isFake == false) {
|
w.isFake = true
|
||||||
return
|
|
||||||
}
|
|
||||||
t := len(w.name)
|
t := len(w.name)
|
||||||
// setup fake labels for non-visable things off screen
|
// setup fake labels for non-visable things off screen
|
||||||
w.realWidth = t + 2
|
w.realWidth = t + 2
|
||||||
|
@ -27,7 +25,9 @@ func (w *cuiWidget) setFake() {
|
||||||
fakeStartWidth += 20
|
fakeStartWidth += 20
|
||||||
}
|
}
|
||||||
w.setWH()
|
w.setWH()
|
||||||
w.showWidgetPlacement(logNow, "setFake()")
|
if (debugAction) {
|
||||||
|
w.drawView()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the widget start width & height
|
// set the widget start width & height
|
||||||
|
@ -36,25 +36,17 @@ func (w *cuiWidget) addWidget() {
|
||||||
switch w.widgetType {
|
switch w.widgetType {
|
||||||
case toolkit.Root:
|
case toolkit.Root:
|
||||||
log(logInfo, "setStartWH() rootNode w.id =", w.id, "w.name", w.name)
|
log(logInfo, "setStartWH() rootNode w.id =", w.id, "w.name", w.name)
|
||||||
w.isFake = true
|
|
||||||
w.setFake()
|
w.setFake()
|
||||||
w.showWidgetPlacement(logNow, "StartWH:")
|
|
||||||
w.drawView()
|
|
||||||
return
|
return
|
||||||
case toolkit.Flag:
|
case toolkit.Flag:
|
||||||
w.isFake = true
|
|
||||||
w.setFake()
|
w.setFake()
|
||||||
w.showWidgetPlacement(logNow, "StartWH:")
|
|
||||||
w.drawView()
|
|
||||||
return
|
return
|
||||||
case toolkit.Window:
|
case toolkit.Window:
|
||||||
w.setTabWH()
|
w.setTabWH()
|
||||||
w.showWidgetPlacement(logNow, "StartWH:")
|
|
||||||
w.drawView()
|
w.drawView()
|
||||||
return
|
return
|
||||||
case toolkit.Tab:
|
case toolkit.Tab:
|
||||||
w.setTabWH()
|
w.setTabWH()
|
||||||
w.showWidgetPlacement(logNow, "StartWH:")
|
|
||||||
w.drawView()
|
w.drawView()
|
||||||
return
|
return
|
||||||
case toolkit.Box:
|
case toolkit.Box:
|
||||||
|
@ -62,16 +54,12 @@ func (w *cuiWidget) addWidget() {
|
||||||
w.setFake()
|
w.setFake()
|
||||||
w.startW = w.parent.startW
|
w.startW = w.parent.startW
|
||||||
w.startH = w.parent.startH
|
w.startH = w.parent.startH
|
||||||
w.showWidgetPlacement(logNow, "StartWH:")
|
|
||||||
w.drawView()
|
|
||||||
return
|
return
|
||||||
case toolkit.Grid:
|
case toolkit.Grid:
|
||||||
w.isFake = true
|
w.isFake = true
|
||||||
w.setFake()
|
w.setFake()
|
||||||
w.startW = w.parent.startW
|
w.startW = w.parent.startW
|
||||||
w.startH = w.parent.startH
|
w.startH = w.parent.startH
|
||||||
w.showWidgetPlacement(logNow, "StartWH:")
|
|
||||||
w.drawView()
|
|
||||||
return
|
return
|
||||||
case toolkit.Group:
|
case toolkit.Group:
|
||||||
w.startW = w.parent.startW + 4
|
w.startW = w.parent.startW + 4
|
||||||
|
@ -84,12 +72,11 @@ func (w *cuiWidget) addWidget() {
|
||||||
w.gocuiSize.startH = w.startH
|
w.gocuiSize.startH = w.startH
|
||||||
|
|
||||||
w.setWH()
|
w.setWH()
|
||||||
w.showWidgetPlacement(logNow, "StartWH:")
|
|
||||||
// w.drawView()
|
|
||||||
return
|
return
|
||||||
default:
|
default:
|
||||||
w.startW = w.parent.startW
|
w.startW = w.parent.startW
|
||||||
w.startH = w.parent.startH
|
w.startH = w.parent.startH
|
||||||
w.setWH()
|
w.setWH()
|
||||||
}
|
}
|
||||||
|
w.showWidgetPlacement(logInfo, "addWidget()")
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,8 @@ import (
|
||||||
// "github.com/awesome-gocui/gocui"
|
// "github.com/awesome-gocui/gocui"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var debugAction bool = false
|
||||||
|
|
||||||
func actionDump(b bool, a *toolkit.Action) {
|
func actionDump(b bool, a *toolkit.Action) {
|
||||||
if (a == nil) {
|
if (a == nil) {
|
||||||
log(b, "action = nil")
|
log(b, "action = nil")
|
||||||
|
|
|
@ -19,7 +19,7 @@ func helplayout(g *gocui.Gui) error {
|
||||||
var err error
|
var err error
|
||||||
maxX, _ := g.Size()
|
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 err != nil {
|
||||||
if !errors.Is(err, gocui.ErrUnknownView) {
|
if !errors.Is(err, gocui.ErrUnknownView) {
|
||||||
return err
|
return err
|
||||||
|
@ -27,17 +27,17 @@ func helplayout(g *gocui.Gui) error {
|
||||||
help.SelBgColor = gocui.ColorGreen
|
help.SelBgColor = gocui.ColorGreen
|
||||||
help.SelFgColor = gocui.ColorBlack
|
help.SelFgColor = gocui.ColorBlack
|
||||||
fmt.Fprintln(help, "KEYBINDINGS")
|
fmt.Fprintln(help, "KEYBINDINGS")
|
||||||
fmt.Fprintln(help, "Enter: Click Button")
|
// fmt.Fprintln(help, "Enter: Click Button")
|
||||||
fmt.Fprintln(help, "Tab/Space: Switch Buttons")
|
// fmt.Fprintln(help, "Tab/Space: Switch Buttons")
|
||||||
fmt.Fprintln(help, "")
|
fmt.Fprintln(help, "")
|
||||||
fmt.Fprintln(help, "h: Help")
|
// fmt.Fprintln(help, "h: Help")
|
||||||
fmt.Fprintln(help, "Backspace: Delete Button")
|
// fmt.Fprintln(help, "Backspace: Delete Button")
|
||||||
fmt.Fprintln(help, "Arrow keys: Move Button")
|
// fmt.Fprintln(help, "Arrow keys: Move Button")
|
||||||
fmt.Fprintln(help, "t: Move Button to the top")
|
// fmt.Fprintln(help, "t: Move Button to the top")
|
||||||
fmt.Fprintln(help, "b: Move Button to the button")
|
// fmt.Fprintln(help, "b: Move Button to the button")
|
||||||
fmt.Fprintln(help, "d: show/hide debugging")
|
fmt.Fprintln(help, "d: show/hide debugging")
|
||||||
fmt.Fprintln(help, "h: hide buttons")
|
fmt.Fprintln(help, "h: hide widgets")
|
||||||
fmt.Fprintln(help, "s: show buttons")
|
fmt.Fprintln(help, "s: show all widgets")
|
||||||
fmt.Fprintln(help, "p: panic()")
|
fmt.Fprintln(help, "p: panic()")
|
||||||
fmt.Fprintln(help, "STDOUT: /tmp/witgui.log")
|
fmt.Fprintln(help, "STDOUT: /tmp/witgui.log")
|
||||||
fmt.Fprintln(help, "Ctrl-C or Q: Exit")
|
fmt.Fprintln(help, "Ctrl-C or Q: Exit")
|
||||||
|
|
|
@ -15,8 +15,6 @@ import (
|
||||||
"git.wit.org/wit/gui/toolkit"
|
"git.wit.org/wit/gui/toolkit"
|
||||||
)
|
)
|
||||||
|
|
||||||
// const delta = 1
|
|
||||||
|
|
||||||
// It's probably a terrible idea to call this 'me'
|
// It's probably a terrible idea to call this 'me'
|
||||||
var me config
|
var me config
|
||||||
|
|
||||||
|
@ -52,20 +50,9 @@ type config struct {
|
||||||
buttonPadding int
|
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 (
|
var (
|
||||||
// g *gocui.Gui
|
|
||||||
// Custom func(string)
|
|
||||||
|
|
||||||
initialMouseX, initialMouseY, xOffset, yOffset int
|
initialMouseX, initialMouseY, xOffset, yOffset int
|
||||||
globalMouseDown, msgMouseDown, movingMsg bool
|
globalMouseDown, msgMouseDown, movingMsg bool
|
||||||
|
|
||||||
// err error
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// the gocui way
|
// the gocui way
|
||||||
|
@ -84,13 +71,6 @@ type rectType struct {
|
||||||
w0, h0, w1, h1 int // left top right bottom
|
w0, h0, w1, h1 int // left top right bottom
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
type realSizeT struct {
|
|
||||||
width, height int
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
type cuiWidget struct {
|
type cuiWidget struct {
|
||||||
id int // widget ID
|
id int // widget ID
|
||||||
// parentId int
|
// parentId int
|
||||||
|
@ -161,10 +141,12 @@ func (w *cuiWidget) Write(p []byte) (n int, err error) {
|
||||||
w.tainted = true
|
w.tainted = true
|
||||||
w.writeMutex.Lock()
|
w.writeMutex.Lock()
|
||||||
defer w.writeMutex.Unlock()
|
defer w.writeMutex.Unlock()
|
||||||
// v.makeWriteable(v.wx, v.wy)
|
if (w.v == nil) {
|
||||||
// v.writeRunes(bytes.Runes(p))
|
return
|
||||||
|
}
|
||||||
|
w.v.Clear()
|
||||||
fmt.Fprintln(w.v, p)
|
fmt.Fprintln(w.v, p)
|
||||||
log(logNow, "widget.Write()")
|
log(logNow, "widget.Write()", p)
|
||||||
|
|
||||||
return len(p), nil
|
return len(p), nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue