remove dumb old stuff and clean up struct.go
This commit is contained in:
parent
8d007ec10d
commit
96fdfd1338
2
debug.go
2
debug.go
|
@ -13,7 +13,7 @@ import (
|
||||||
func (w *guiWidget) dumpTree(s string) {
|
func (w *guiWidget) dumpTree(s string) {
|
||||||
// log.Log(ERROR, "dump w", w.node.WidgetId, w.WidgetType, w.String())
|
// log.Log(ERROR, "dump w", w.node.WidgetId, w.WidgetType, w.String())
|
||||||
if w == nil {
|
if w == nil {
|
||||||
log.Log(ERROR, "dump w.TK == nil", w.node.WidgetId, w.WidgetType, w.String())
|
log.Log(ERROR, "dump w.TK == nil", w.node.WidgetId, w.node.WidgetType, w.String())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w.dumpWidget("dumpTree() " + s)
|
w.dumpWidget("dumpTree() " + s)
|
||||||
|
|
|
@ -149,7 +149,7 @@ func (w *guiWidget) dropdownClicked(mouseW, mouseH int) string {
|
||||||
log.Log(GOCUI, "dropdownClicked() found", items[itemNumber-1])
|
log.Log(GOCUI, "dropdownClicked() found", items[itemNumber-1])
|
||||||
if items[itemNumber-1] != "" {
|
if items[itemNumber-1] != "" {
|
||||||
if me.dropdownW != nil {
|
if me.dropdownW != nil {
|
||||||
log.Log(GOCUI, "dropdownClicked() send event for", me.dropdownW.cuiName, me.dropdownW.WidgetType)
|
log.Log(GOCUI, "dropdownClicked() send event for", me.dropdownW.cuiName, me.dropdownW.node.WidgetType)
|
||||||
me.dropdownW.SetText(items[itemNumber-1])
|
me.dropdownW.SetText(items[itemNumber-1])
|
||||||
me.dropdownW.node.SetCurrentS(items[itemNumber-1])
|
me.dropdownW.node.SetCurrentS(items[itemNumber-1])
|
||||||
me.myTree.SendUserEvent(me.dropdownW.node)
|
me.myTree.SendUserEvent(me.dropdownW.node)
|
||||||
|
@ -174,7 +174,7 @@ func dropdownUnclicked(w, h int) {
|
||||||
// examine everything under X & Y on the screen)
|
// examine everything under X & Y on the screen)
|
||||||
for _, tk := range findByXY(w, h) {
|
for _, tk := range findByXY(w, h) {
|
||||||
// tk.dumpWidget("dropdownUnclicked()")
|
// tk.dumpWidget("dropdownUnclicked()")
|
||||||
if tk.WidgetType == widget.Dropdown {
|
if tk.node.WidgetType == widget.Dropdown {
|
||||||
d = tk
|
d = tk
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ func theNotsure(g *gocui.Gui, v *gocui.View) error {
|
||||||
log.Info("got keypress 2. now what?")
|
log.Info("got keypress 2. now what?")
|
||||||
w, h := g.MousePosition()
|
w, h := g.MousePosition()
|
||||||
for _, tk := range findByXY(w, h) {
|
for _, tk := range findByXY(w, h) {
|
||||||
if tk.WidgetType == widget.Stdout {
|
if tk.node.WidgetType == widget.Stdout {
|
||||||
tk.dumpWidget("theNotsure()")
|
tk.dumpWidget("theNotsure()")
|
||||||
log.Info("skipping stdout")
|
log.Info("skipping stdout")
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -103,7 +103,7 @@ func click(g *gocui.Gui, v *gocui.View) error {
|
||||||
for _, tk := range findByXY(w, h) {
|
for _, tk := range findByXY(w, h) {
|
||||||
// will show you everything found on a mouse click. great for debugging!
|
// will show you everything found on a mouse click. great for debugging!
|
||||||
// tk.dumpWidget("click()")
|
// tk.dumpWidget("click()")
|
||||||
if tk.WidgetType == widget.Stdout {
|
if tk.node.WidgetType == widget.Stdout {
|
||||||
// don't send clicks to the stdout debugging window
|
// don't send clicks to the stdout debugging window
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
10
find.go
10
find.go
|
@ -44,7 +44,7 @@ func findByXYreal(widget *guiWidget, w int, h int) []*guiWidget {
|
||||||
if (widget.gocuiSize.w0 <= w) && (w <= widget.gocuiSize.w1) &&
|
if (widget.gocuiSize.w0 <= w) && (w <= widget.gocuiSize.w1) &&
|
||||||
(widget.gocuiSize.h0 <= h) && (h <= widget.gocuiSize.h1) {
|
(widget.gocuiSize.h0 <= h) && (h <= widget.gocuiSize.h1) {
|
||||||
widgets = append(widgets, widget)
|
widgets = append(widgets, widget)
|
||||||
// log.Log(GOCUI, "findByXY() found", widget.WidgetType, w, h)
|
// log.Log(GOCUI, "findByXY() found", widget.node.WidgetType, w, h)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,20 +69,20 @@ func findUnderMouse() *guiWidget {
|
||||||
// up the window widgets, then it will ignore everything else
|
// up the window widgets, then it will ignore everything else
|
||||||
// and allow the user (hopefully) to redraw or switch windows
|
// and allow the user (hopefully) to redraw or switch windows
|
||||||
// TODO: display the window widgets on top
|
// TODO: display the window widgets on top
|
||||||
if w.WidgetType == widget.Window {
|
if w.node.WidgetType == widget.Window {
|
||||||
return w
|
return w
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// return anything else that is interactive
|
// return anything else that is interactive
|
||||||
for _, w := range widgets {
|
for _, w := range widgets {
|
||||||
if w.WidgetType == widget.Button {
|
if w.node.WidgetType == widget.Button {
|
||||||
return w
|
return w
|
||||||
}
|
}
|
||||||
if w.WidgetType == widget.Combobox {
|
if w.node.WidgetType == widget.Combobox {
|
||||||
return w
|
return w
|
||||||
}
|
}
|
||||||
if w.WidgetType == widget.Checkbox {
|
if w.node.WidgetType == widget.Checkbox {
|
||||||
return w
|
return w
|
||||||
}
|
}
|
||||||
w.dumpWidget("findUnderMouse() found something unknown")
|
w.dumpWidget("findUnderMouse() found something unknown")
|
||||||
|
|
6
place.go
6
place.go
|
@ -35,7 +35,7 @@ func (tk *guiWidget) Position() (int, int) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *guiWidget) placeBox(startW int, startH int) {
|
func (w *guiWidget) placeBox(startW int, startH int) {
|
||||||
if w.WidgetType != widget.Box {
|
if w.node.WidgetType != widget.Box {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ func (tk *guiWidget) placeWidgets(startW int, startH int) (int, int) {
|
||||||
tk.startW = startW
|
tk.startW = startW
|
||||||
tk.startH = startH
|
tk.startH = startH
|
||||||
|
|
||||||
switch tk.WidgetType {
|
switch tk.node.WidgetType {
|
||||||
case widget.Window:
|
case widget.Window:
|
||||||
newW := startW
|
newW := startW
|
||||||
newH := startH
|
newH := startH
|
||||||
|
@ -128,7 +128,7 @@ func (tk *guiWidget) placeWidgets(startW int, startH int) (int, int) {
|
||||||
|
|
||||||
func (w *guiWidget) placeGrid(startW int, startH int) (int, int) {
|
func (w *guiWidget) placeGrid(startW int, startH int) (int, int) {
|
||||||
// w.showWidgetPlacement("grid0:")
|
// w.showWidgetPlacement("grid0:")
|
||||||
if w.WidgetType != widget.Grid {
|
if w.node.WidgetType != widget.Grid {
|
||||||
return 0, 0
|
return 0, 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
4
size.go
4
size.go
|
@ -20,7 +20,7 @@ func (tk *guiWidget) Size() (int, int) {
|
||||||
return 0, 0
|
return 0, 0
|
||||||
}
|
}
|
||||||
|
|
||||||
switch tk.WidgetType {
|
switch tk.node.WidgetType {
|
||||||
case widget.Window:
|
case widget.Window:
|
||||||
var maxH int = 0
|
var maxH int = 0
|
||||||
var maxW int = 0
|
var maxW int = 0
|
||||||
|
@ -105,7 +105,7 @@ func (w *guiWidget) sizeGrid() (int, int) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *guiWidget) sizeBox() (int, int) {
|
func (w *guiWidget) sizeBox() (int, int) {
|
||||||
if w.WidgetType != widget.Box {
|
if w.node.WidgetType != widget.Box {
|
||||||
return 0, 0
|
return 0, 0
|
||||||
}
|
}
|
||||||
if w.node.Hidden() {
|
if w.node.Hidden() {
|
||||||
|
|
200
structs.go
200
structs.go
|
@ -22,7 +22,6 @@ import (
|
||||||
|
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
"go.wit.com/toolkits/tree"
|
"go.wit.com/toolkits/tree"
|
||||||
"go.wit.com/widget"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// It's probably a terrible idea to call this 'me'
|
// It's probably a terrible idea to call this 'me'
|
||||||
|
@ -34,77 +33,48 @@ var redoWidgets bool = true
|
||||||
// This is the window that is currently active
|
// This is the window that is currently active
|
||||||
// var currentWindow *tree.Node
|
// var currentWindow *tree.Node
|
||||||
|
|
||||||
|
// todo: move all this to a protobuf. then, redo all this mess. it got me here, but now it's time to clean it up for good
|
||||||
type config struct {
|
type config struct {
|
||||||
baseGui *gocui.Gui // the main gocui handle
|
baseGui *gocui.Gui // the main gocui handle
|
||||||
// rootNode *node // the base of the binary tree. it should have id == 0
|
treeRoot *tree.Node // the base of the binary tree. it should have id == 0
|
||||||
|
myTree *tree.TreeInfo // ?
|
||||||
treeRoot *tree.Node // the base of the binary tree. it should have id == 0
|
ctrlDown *tree.Node // shown if you click the mouse when the ctrl key is pressed
|
||||||
myTree *tree.TreeInfo
|
currentWindow *guiWidget // this is the current tab or window to show
|
||||||
|
logStdout *tree.Node // where to show STDOUT
|
||||||
ctrlDown *tree.Node // shown if you click the mouse when the ctrl key is pressed
|
startOutputW int // ?
|
||||||
currentWindow *guiWidget // this is the current tab or window to show
|
startOutputH int // ?
|
||||||
logStdout *tree.Node // where to show STDOUT
|
helpLabel *gocui.View // ?
|
||||||
startOutputW int
|
dropdownV *guiWidget // this is a floating widget that we show whenever the user clicks on a
|
||||||
startOutputH int
|
dropdownW *guiWidget // grab the dropdown choices from this widget
|
||||||
helpLabel *gocui.View
|
FramePadW int `default:"1" dense:"0"` // When the widget has a frame, like a button, it adds 2 lines runes on each side
|
||||||
|
FramePadH int `default:"1" dense:"0"` // When the widget has a frame, like a button, it adds 2 lines runes on each side
|
||||||
// this is a floating widget that we show whenever the user clicks on a
|
PadW int `default:"1" dense:"0"` // pad spacing
|
||||||
// dropdown menu or combobox
|
PadH int `default:"1" dense:"0"` // pad spacing
|
||||||
// the dropdown widget to select dropdrown lists
|
WindowW int `default:"8" dense:"0"` // how far down to start Window or Tab headings
|
||||||
dropdownV *guiWidget
|
WindowH int `default:"-1"` // how far down to start Window or Tab headings
|
||||||
dropdownW *guiWidget // grab the dropdown choices from this widget
|
TabW int `default:"5" dense:"0"` // how far down to start Window or Tab headings
|
||||||
|
TabH int `default:"1" dense:"0"` // how far down to start Window or Tab headings
|
||||||
// When the widget has a frame, like a button, it adds 2 lines runes on each side
|
WindowPadW int `default:"8" dense:"0"` // additional amount of space to put between window & tab widgets
|
||||||
// so you need 3 char spacing in each direction to not have them overlap
|
TabPadW int `default:"4" dense:"0"` // additional amount of space to put between window & tab widgets
|
||||||
// the amount of padding when there is a frame
|
GroupPadW int `default:"2" dense:"1"` // additional amount of space to indent on a group
|
||||||
FramePadW int `default:"1" dense:"0"`
|
BoxPadW int `default:"2" dense:"1"` // additional amount of space to indent on a box
|
||||||
FramePadH int `default:"1" dense:"0"`
|
GridPadW int `default:"2" dense:"1"` // additional amount of space to indent on a grid
|
||||||
|
RawW int `default:"1"` // the raw beginning of each window (or tab)
|
||||||
PadW int `default:"1" dense:"0"`
|
RawH int `default:"5"` // the raw beginning of each window (or tab)
|
||||||
PadH int `default:"1" dense:"0"`
|
FakeW int `default:"20"` // offset for the hidden widgets
|
||||||
|
padded bool // add space between things like buttons
|
||||||
// how far down to start Window or Tab headings
|
bookshelf bool // do you want things arranged in the box like a bookshelf or a stack?
|
||||||
WindowW int `default:"8" dense:"0"`
|
canvas bool // if set to true, the windows are a raw canvas
|
||||||
WindowH int `default:"-1"`
|
menubar bool // for windows
|
||||||
TabW int `default:"5" dense:"0"`
|
stretchy bool // expand things like buttons to the maximum size
|
||||||
TabH int `default:"1" dense:"0"`
|
margin bool // add space around the frames of windows
|
||||||
|
writeMutex sync.Mutex // TODO: writeMutex protects locks the write process
|
||||||
// additional amount of space to put between window & tab widgets
|
fakefile *FakeFile // JUNK? used to attempt to write to the stdout window
|
||||||
WindowPadW int `default:"8" dense:"0"`
|
dtoggle bool // is a dropdown or combobox currently active?
|
||||||
TabPadW int `default:"4" dense:"0"`
|
showHelp bool // toggle boolean for the help menu (deprecate?)
|
||||||
|
ecount int // counts how many mouse and keyboard events have occurred
|
||||||
// additional amount of space to indent on a group
|
supermouse bool // prints out every widget found while you move the mouse around
|
||||||
GroupPadW int `default:"2" dense:"1"`
|
depth int // used for listWidgets() debugging
|
||||||
|
|
||||||
// additional amount of space to indent on a group
|
|
||||||
BoxPadW int `default:"2" dense:"1"`
|
|
||||||
|
|
||||||
// additional amount of space to indent on a group
|
|
||||||
GridPadW int `default:"2" dense:"1"`
|
|
||||||
|
|
||||||
// the raw beginning of each window (or tab)
|
|
||||||
RawW int `default:"1"`
|
|
||||||
RawH int `default:"5"`
|
|
||||||
|
|
||||||
// offset for the hidden widgets
|
|
||||||
FakeW int `default:"20"`
|
|
||||||
|
|
||||||
padded bool // add space between things like buttons
|
|
||||||
bookshelf bool // do you want things arranged in the box like a bookshelf or a stack?
|
|
||||||
canvas bool // if set to true, the windows are a raw canvas
|
|
||||||
menubar bool // for windows
|
|
||||||
stretchy bool // expand things like buttons to the maximum size
|
|
||||||
margin bool // add space around the frames of windows
|
|
||||||
|
|
||||||
writeMutex sync.Mutex // TODO: writeMutex protects locks the write process
|
|
||||||
fakefile *FakeFile // JUNK? used to attempt to write to the stdout window
|
|
||||||
dtoggle bool // is a dropdown or combobox currently active?
|
|
||||||
showHelp bool // toggle boolean for the help menu (deprecate?)
|
|
||||||
|
|
||||||
// debugging things
|
|
||||||
ecount int // counts how many mouse and keyboard events have occurred
|
|
||||||
supermouse bool // prints out every widget found while you move the mouse around
|
|
||||||
depth int // used for listWidgets() debugging
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// deprecate these
|
// deprecate these
|
||||||
|
@ -128,69 +98,31 @@ func (r *rectType) Height() int {
|
||||||
}
|
}
|
||||||
|
|
||||||
type guiWidget struct {
|
type guiWidget struct {
|
||||||
// the gocui package variables
|
v *gocui.View // this is nil if the widget is not displayed
|
||||||
v *gocui.View // this is nil if the widget is not displayed
|
cuiName string // what gocui uses to reference the widget (usually "TK <widgetId>"
|
||||||
cuiName string // what gocui uses to reference the widget
|
parent *guiWidget // mirrors the binary node tree
|
||||||
|
children []*guiWidget // mirrors the binary node tree
|
||||||
WidgetType widget.WidgetType
|
node *tree.Node // the pointer back to the tree
|
||||||
|
hasTabs bool // does the window have tabs?
|
||||||
// tw *toolkit.Widget
|
currentTab bool // the visible tab
|
||||||
parent *guiWidget
|
value string // ?
|
||||||
children []*guiWidget
|
checked bool // ?
|
||||||
|
labelN string // the actual text to display in the console
|
||||||
node *tree.Node
|
vals []string // dropdown menu items
|
||||||
|
active bool // ?
|
||||||
hasTabs bool // does the window have tabs?
|
enable bool // ?
|
||||||
currentTab bool // the visible tab
|
defaultColor *colorT // store the color to go back to
|
||||||
|
gocuiSize rectType // should mirror the real display size. todo: verify these are accurate. they are not yet
|
||||||
value string
|
startW int // ?
|
||||||
checked bool
|
startH int // ?
|
||||||
|
isCurrent bool // is this the currently displayed Window or Tab?
|
||||||
// the actual text to display in the console
|
isFake bool // widget types like 'box' are 'false'
|
||||||
labelN string
|
widths map[int]int // how tall each row in the grid is
|
||||||
|
heights map[int]int // how wide each column in the grid is
|
||||||
vals []string // dropdown menu items
|
tainted bool // ?
|
||||||
|
frame bool // ?
|
||||||
active bool
|
selectedTab *tree.Node // for a window, this is currently selected tab
|
||||||
|
color *colorT // what color to use
|
||||||
enable bool
|
|
||||||
defaultColor *colorT // store the color to go back to
|
|
||||||
|
|
||||||
// hidden bool
|
|
||||||
|
|
||||||
// AtW int
|
|
||||||
// AtH int
|
|
||||||
|
|
||||||
// direction widget.Orientation
|
|
||||||
|
|
||||||
// progname string
|
|
||||||
|
|
||||||
// the logical size of the widget
|
|
||||||
// For example, 40x12 would be the center of a normal terminal
|
|
||||||
// size rectType
|
|
||||||
|
|
||||||
// the actual gocui display view of this widget
|
|
||||||
// sometimes this isn't visible like with a Box or Grid
|
|
||||||
gocuiSize rectType
|
|
||||||
|
|
||||||
startW int
|
|
||||||
startH int
|
|
||||||
|
|
||||||
isCurrent bool // is this the currently displayed Window or Tab?
|
|
||||||
isFake bool // widget types like 'box' are 'false'
|
|
||||||
|
|
||||||
// used to track the size of grids
|
|
||||||
widths map[int]int // how tall each row in the grid is
|
|
||||||
heights map[int]int // how wide each column in the grid is
|
|
||||||
|
|
||||||
tainted bool
|
|
||||||
frame bool
|
|
||||||
|
|
||||||
// for a window, this is currently selected tab
|
|
||||||
selectedTab *tree.Node
|
|
||||||
|
|
||||||
// what color to use
|
|
||||||
color *colorT
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// from the gocui devs:
|
// from the gocui devs:
|
||||||
|
|
|
@ -53,7 +53,7 @@ func (w *guiWidget) drawTree(draw bool) {
|
||||||
// deletes the old view if it exists and recreates it
|
// deletes the old view if it exists and recreates it
|
||||||
func (w *guiWidget) drawView() {
|
func (w *guiWidget) drawView() {
|
||||||
var err error
|
var err error
|
||||||
log.Log(INFO, "drawView() START", w.WidgetType, w.String())
|
log.Log(INFO, "drawView() START", w.node.WidgetType, w.String())
|
||||||
if me.baseGui == nil {
|
if me.baseGui == nil {
|
||||||
log.Log(ERROR, "drawView() ERROR: me.baseGui == nil", w)
|
log.Log(ERROR, "drawView() ERROR: me.baseGui == nil", w)
|
||||||
return
|
return
|
||||||
|
|
|
@ -18,7 +18,7 @@ func initWidget(n *tree.Node) *guiWidget {
|
||||||
|
|
||||||
w.node = n
|
w.node = n
|
||||||
w.cuiName = strconv.Itoa(w.node.WidgetId) + " TK"
|
w.cuiName = strconv.Itoa(w.node.WidgetId) + " TK"
|
||||||
w.WidgetType = n.WidgetType
|
// w.node.WidgetType = n.WidgetType
|
||||||
w.labelN = n.State.Label
|
w.labelN = n.State.Label
|
||||||
if w.labelN == "" {
|
if w.labelN == "" {
|
||||||
// remove this debugging hack once things are stable and fixed
|
// remove this debugging hack once things are stable and fixed
|
||||||
|
@ -38,11 +38,11 @@ func initWidget(n *tree.Node) *guiWidget {
|
||||||
|
|
||||||
p := n.Parent
|
p := n.Parent
|
||||||
if p == nil {
|
if p == nil {
|
||||||
log.Log(ERROR, "parent == nil", w.String(), n.WidgetId, w.WidgetType)
|
log.Log(ERROR, "parent == nil", w.String(), n.WidgetId, w.node.WidgetType)
|
||||||
return w
|
return w
|
||||||
}
|
}
|
||||||
if p.TK == nil {
|
if p.TK == nil {
|
||||||
log.Log(ERROR, "parent.TK == nil", w.String(), n.WidgetId, w.WidgetType)
|
log.Log(ERROR, "parent.TK == nil", w.String(), n.WidgetId, w.node.WidgetType)
|
||||||
return w
|
return w
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ func setupCtrlDownWidget() {
|
||||||
|
|
||||||
func (w *guiWidget) deleteView() {
|
func (w *guiWidget) deleteView() {
|
||||||
// make sure the view isn't really there
|
// make sure the view isn't really there
|
||||||
// log.Log(GOCUI, "deleteView()", w.cuiName, w.WidgetType, w.node.WidgetId)
|
// log.Log(GOCUI, "deleteView()", w.cuiName, w.node.WidgetType, w.node.WidgetId)
|
||||||
me.baseGui.DeleteView(w.cuiName)
|
me.baseGui.DeleteView(w.cuiName)
|
||||||
w.v = nil
|
w.v = nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue