stdout var cleanup
This commit is contained in:
parent
88e9594b93
commit
8522d4671e
2
debug.go
2
debug.go
|
@ -90,7 +90,7 @@ func (tk *guiWidget) dumpWidget(s string) {
|
||||||
func printWidgetTree(g *gocui.Gui, v *gocui.View) error {
|
func printWidgetTree(g *gocui.Gui, v *gocui.View) error {
|
||||||
me.treeRoot.ListWidgets()
|
me.treeRoot.ListWidgets()
|
||||||
|
|
||||||
tk := me.logStdout
|
tk := me.stdout.tk
|
||||||
// msg := fmt.Sprintf("test out kb %d\n", ecount)
|
// msg := fmt.Sprintf("test out kb %d\n", ecount)
|
||||||
// tk.Write([]byte(msg))
|
// tk.Write([]byte(msg))
|
||||||
if tk == nil {
|
if tk == nil {
|
||||||
|
|
|
@ -129,14 +129,6 @@ func (tk *guiWidget) moveNew() {
|
||||||
tk.full.w1 = w1
|
tk.full.w1 = w1
|
||||||
tk.full.h0 = h0
|
tk.full.h0 = h0
|
||||||
tk.full.h1 = h1
|
tk.full.h1 = h1
|
||||||
|
|
||||||
/* this totally fucks up stdout
|
|
||||||
me.logStdout.full.w0 = w - xOffset
|
|
||||||
me.logStdout.full.h0 = h - xOffset
|
|
||||||
me.logStdout.full.w1 = me.logStdout.full.w0 + 120 + me.logStdout.gocuiSize.Width()
|
|
||||||
me.logStdout.full.h1 = me.logStdout.full.h0 + 40 + me.logStdout.gocuiSize.Height()
|
|
||||||
me.logStdout.DrawAt(me.logStdout.full.w0, me.logStdout.full.h0)
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
// always place the help menu on top
|
// always place the help menu on top
|
||||||
setThingsOnTop() // sets help, Stdout, etc on the top after windows have been redrawn
|
setThingsOnTop() // sets help, Stdout, etc on the top after windows have been redrawn
|
||||||
|
@ -144,10 +136,10 @@ func (tk *guiWidget) moveNew() {
|
||||||
|
|
||||||
func createStdout(g *gocui.Gui) bool {
|
func createStdout(g *gocui.Gui) bool {
|
||||||
makeOutputWidget(g, "this is a create before a mouse click")
|
makeOutputWidget(g, "this is a create before a mouse click")
|
||||||
if me.logStdout != nil {
|
if me.stdout.tk != nil {
|
||||||
msg := fmt.Sprintf("test out gocuiEvent() %d\n", me.ecount)
|
msg := fmt.Sprintf("test out gocuiEvent() %d\n", me.ecount)
|
||||||
// me.logStdout.v.Write([]byte(msg))
|
// me.logStdout.v.Write([]byte(msg))
|
||||||
me.logStdout.Write([]byte(msg))
|
me.stdout.tk.Write([]byte(msg))
|
||||||
log.Log(NOW, "logStdout test out")
|
log.Log(NOW, "logStdout test out")
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
|
|
3
init.go
3
init.go
|
@ -38,8 +38,11 @@ func init() {
|
||||||
// init the config struct default values
|
// init the config struct default values
|
||||||
Set(&me, "default")
|
Set(&me, "default")
|
||||||
|
|
||||||
|
// initial stdout window settings
|
||||||
me.stdout.w = 180
|
me.stdout.w = 180
|
||||||
me.stdout.h = 40
|
me.stdout.h = 40
|
||||||
|
me.stdout.offsetW = 30
|
||||||
|
me.stdout.offsetH = 10
|
||||||
|
|
||||||
// Set(&me, "dense")
|
// Set(&me, "dense")
|
||||||
|
|
||||||
|
|
|
@ -34,14 +34,12 @@ func showMsg(g *gocui.Gui, v *gocui.View) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeOutputWidget(g *gocui.Gui, stringFromMouseClick string) *gocui.View {
|
func makeOutputWidget(g *gocui.Gui, stringFromMouseClick string) *gocui.View {
|
||||||
// maxX, maxY := g.Size()
|
|
||||||
|
|
||||||
if me.treeRoot == nil {
|
if me.treeRoot == nil {
|
||||||
// keep skipping this until the binary tree is initialized
|
// keep skipping this until the binary tree is initialized
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if me.logStdout == nil {
|
if me.stdout.tk == nil {
|
||||||
a := new(widget.Action)
|
a := new(widget.Action)
|
||||||
a.ProgName = "stdout"
|
a.ProgName = "stdout"
|
||||||
a.WidgetType = widget.Stdout
|
a.WidgetType = widget.Stdout
|
||||||
|
@ -49,13 +47,11 @@ func makeOutputWidget(g *gocui.Gui, stringFromMouseClick string) *gocui.View {
|
||||||
a.ParentId = 0
|
a.ParentId = 0
|
||||||
// n := addNode(a)
|
// n := addNode(a)
|
||||||
n := me.myTree.AddNode(a)
|
n := me.myTree.AddNode(a)
|
||||||
me.logStdout = initWidget(n)
|
me.stdout.tk = initWidget(n)
|
||||||
|
|
||||||
tk := me.logStdout
|
tk := me.stdout.tk
|
||||||
// tk.gocuiSize.w0 = maxX - 32
|
tk.gocuiSize.w0 = me.stdout.offsetW
|
||||||
// tk.gocuiSize.h0 = maxY / 2
|
tk.gocuiSize.h0 = me.stdout.offsetH
|
||||||
tk.gocuiSize.w0 = 30
|
|
||||||
tk.gocuiSize.h0 = 10
|
|
||||||
tk.gocuiSize.w1 = tk.gocuiSize.w0 + me.stdout.w
|
tk.gocuiSize.w1 = tk.gocuiSize.w0 + me.stdout.w
|
||||||
tk.gocuiSize.h1 = tk.gocuiSize.h0 + me.stdout.h
|
tk.gocuiSize.h1 = tk.gocuiSize.h0 + me.stdout.h
|
||||||
|
|
||||||
|
@ -68,21 +64,9 @@ func makeOutputWidget(g *gocui.Gui, stringFromMouseClick string) *gocui.View {
|
||||||
log.Log(NOW, "makeoutputwindow() msg != nil. WTF now? err =", err)
|
log.Log(NOW, "makeoutputwindow() msg != nil. WTF now? err =", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
rect := me.stdout.tk.gocuiSize
|
||||||
if me.startOutputW == 0 {
|
v, err = g.SetView("msg", rect.w0, rect.h0, rect.w1, rect.h1, 0)
|
||||||
me.startOutputW = maxX - 132
|
|
||||||
}
|
|
||||||
if me.startOutputW == 0 {
|
|
||||||
me.startOutputH = maxY / 2
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
a := me.logStdout.gocuiSize.w0
|
|
||||||
b := me.logStdout.gocuiSize.h0
|
|
||||||
c := me.logStdout.gocuiSize.w1
|
|
||||||
d := me.logStdout.gocuiSize.h1
|
|
||||||
v, err = g.SetView("msg", a, b, c, d, 0)
|
|
||||||
// v, err = g.SetView("msg", me.startOutputW, me.startOutputH, maxX/2+me.stdout.w, maxY/2+me.stdout.h, 0)
|
|
||||||
if errors.Is(err, gocui.ErrUnknownView) {
|
if errors.Is(err, gocui.ErrUnknownView) {
|
||||||
log.Log(NOW, "makeoutputwindow() this is supposed to happen?", err)
|
log.Log(NOW, "makeoutputwindow() this is supposed to happen?", err)
|
||||||
}
|
}
|
||||||
|
@ -96,7 +80,7 @@ func makeOutputWidget(g *gocui.Gui, stringFromMouseClick string) *gocui.View {
|
||||||
log.Log(NOW, "makeoutputwindow() msg == nil. WTF now? err =", err)
|
log.Log(NOW, "makeoutputwindow() msg == nil. WTF now? err =", err)
|
||||||
return nil
|
return nil
|
||||||
} else {
|
} else {
|
||||||
me.logStdout.v = v
|
me.stdout.tk.v = v
|
||||||
}
|
}
|
||||||
|
|
||||||
v.Clear()
|
v.Clear()
|
||||||
|
@ -105,7 +89,7 @@ func makeOutputWidget(g *gocui.Gui, stringFromMouseClick string) *gocui.View {
|
||||||
fmt.Fprintln(v, "figure out how to capture STDOUT to here\n"+stringFromMouseClick)
|
fmt.Fprintln(v, "figure out how to capture STDOUT to here\n"+stringFromMouseClick)
|
||||||
g.SetViewOnBottom("msg")
|
g.SetViewOnBottom("msg")
|
||||||
|
|
||||||
me.logStdout.v = v
|
me.stdout.tk.v = v
|
||||||
me.logStdout.DrawAt(10, 10)
|
me.stdout.tk.DrawAt(me.stdout.offsetW, me.stdout.offsetH)
|
||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
|
|
96
structs.go
96
structs.go
|
@ -30,58 +30,56 @@ var redoWidgets bool = true // todo: move this into config struct
|
||||||
|
|
||||||
// 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
|
// 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
|
||||||
treeRoot *tree.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 // ?
|
myTree *tree.TreeInfo // ?
|
||||||
ctrlDown *tree.Node // shown if you click the mouse when the ctrl key is pressed
|
ctrlDown *tree.Node // shown if you click the mouse when the ctrl key is pressed
|
||||||
currentWindow *guiWidget // this is the current tab or window to show
|
currentWindow *guiWidget // this is the current tab or window to show
|
||||||
logStdout *guiWidget // where to show STDOUT
|
helpLabel *gocui.View // ?
|
||||||
// startOutputW int // ?
|
showHelp bool // toggle boolean for the help menu (deprecate?)
|
||||||
// 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
|
||||||
showHelp bool // toggle boolean for the help menu (deprecate?)
|
FramePadH int `default:"1" dense:"0"` // When the widget has a frame, like a button, it adds 2 lines runes on each side
|
||||||
dropdownW *guiWidget // grab the dropdown choices from this widget
|
PadW int `default:"1" dense:"0"` // pad spacing
|
||||||
FramePadW int `default:"1" dense:"0"` // When the widget has a frame, like a button, it adds 2 lines runes on each side
|
PadH int `default:"1" dense:"0"` // pad spacing
|
||||||
FramePadH int `default:"1" dense:"0"` // When the widget has a frame, like a button, it adds 2 lines runes on each side
|
WindowW int `default:"8" dense:"0"` // how far down to start Window or Tab headings
|
||||||
PadW int `default:"1" dense:"0"` // pad spacing
|
WindowH int `default:"-1"` // how far down to start Window or Tab headings
|
||||||
PadH int `default:"1" dense:"0"` // pad spacing
|
TabW int `default:"5" dense:"0"` // how far down to start Window or Tab headings
|
||||||
WindowW int `default:"8" 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
|
||||||
WindowH int `default:"-1"` // how far down to start Window or Tab headings
|
WindowPadW int `default:"8" dense:"0"` // additional amount of space to put between window & tab widgets
|
||||||
TabW int `default:"5" dense:"0"` // how far down to start Window or Tab headings
|
TabPadW int `default:"4" dense:"0"` // additional amount of space to put between window & tab widgets
|
||||||
TabH int `default:"1" dense:"0"` // how far down to start Window or Tab headings
|
GroupPadW int `default:"2" dense:"1"` // additional amount of space to indent on a group
|
||||||
WindowPadW int `default:"8" dense:"0"` // additional amount of space to put between window & tab widgets
|
BoxPadW int `default:"2" dense:"1"` // additional amount of space to indent on a box
|
||||||
TabPadW int `default:"4" dense:"0"` // additional amount of space to put between window & tab widgets
|
GridPadW int `default:"2" dense:"1"` // additional amount of space to indent on a grid
|
||||||
GroupPadW int `default:"2" dense:"1"` // additional amount of space to indent on a group
|
RawW int `default:"1"` // the raw beginning of each window (or tab)
|
||||||
BoxPadW int `default:"2" dense:"1"` // additional amount of space to indent on a box
|
RawH int `default:"5"` // the raw beginning of each window (or tab)
|
||||||
GridPadW int `default:"2" dense:"1"` // additional amount of space to indent on a grid
|
FakeW int `default:"20"` // offset for the hidden widgets
|
||||||
RawW int `default:"1"` // the raw beginning of each window (or tab)
|
padded bool // add space between things like buttons
|
||||||
RawH int `default:"5"` // the raw beginning of each window (or tab)
|
bookshelf bool // do you want things arranged in the box like a bookshelf or a stack?
|
||||||
FakeW int `default:"20"` // offset for the hidden widgets
|
canvas bool // if set to true, the windows are a raw canvas
|
||||||
padded bool // add space between things like buttons
|
menubar bool // for windows
|
||||||
bookshelf bool // do you want things arranged in the box like a bookshelf or a stack?
|
stretchy bool // expand things like buttons to the maximum size
|
||||||
canvas bool // if set to true, the windows are a raw canvas
|
margin bool // add space around the frames of windows
|
||||||
menubar bool // for windows
|
writeMutex sync.Mutex // writeMutex protects writes to *guiWidget (it's global right now maybe)
|
||||||
stretchy bool // expand things like buttons to the maximum size
|
dtoggle bool // is a dropdown or combobox currently active?
|
||||||
margin bool // add space around the frames of windows
|
ecount int // counts how many mouse and keyboard events have occurred
|
||||||
writeMutex sync.Mutex // writeMutex protects writes to *guiWidget (it's global right now maybe)
|
supermouse bool // prints out every widget found while you move the mouse around
|
||||||
dtoggle bool // is a dropdown or combobox currently active?
|
depth int // used for listWidgets() debugging
|
||||||
ecount int // counts how many mouse and keyboard events have occurred
|
globalMouseDown bool // yep, mouse is pressed
|
||||||
supermouse bool // prints out every widget found while you move the mouse around
|
newWindowTrigger chan bool // work around hack to redraw windows a bit after NewWindow()
|
||||||
depth int // used for listWidgets() debugging
|
stdout stdout // information for the STDOUT window
|
||||||
globalMouseDown bool // yep, mouse is pressed
|
|
||||||
newWindowTrigger chan bool // work around hack to redraw windows a bit after NewWindow()
|
|
||||||
stdout stdout // information for the STDOUT window
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// settings for the stdout window
|
// settings for the stdout window
|
||||||
type stdout struct {
|
type stdout struct {
|
||||||
w int // the width
|
tk *guiWidget // where to show STDOUT
|
||||||
h int // the width
|
w int // the width
|
||||||
outputOnTop bool // is the STDOUT window on top?
|
h int // the width
|
||||||
offscreenW int // where to place the window offscreen
|
outputOnTop bool // is the STDOUT window on top?
|
||||||
offscreenH int // where to place the window offscreen
|
offscreenW int // where to place the window offscreen
|
||||||
offsetW int // the current 'w' offset
|
offscreenH int // where to place the window offscreen
|
||||||
offsetH int // the current 'h' offset
|
offsetW int // the current 'w' offset
|
||||||
|
offsetH int // the current 'h' offset
|
||||||
}
|
}
|
||||||
|
|
||||||
// deprecate these
|
// deprecate these
|
||||||
|
@ -154,7 +152,7 @@ func (w *guiWidget) Write(p []byte) (n int, err error) {
|
||||||
// _, outputH := w.Size()
|
// _, outputH := w.Size()
|
||||||
outputH := 33 // special output length for "msg" window until I figure things out
|
outputH := 33 // special output length for "msg" window until I figure things out
|
||||||
|
|
||||||
tk := me.logStdout
|
tk := me.stdout.tk
|
||||||
if tk.v == nil {
|
if tk.v == nil {
|
||||||
// optionally write the output to /tmp
|
// optionally write the output to /tmp
|
||||||
s := fmt.Sprint(string(p))
|
s := fmt.Sprint(string(p))
|
||||||
|
|
Loading…
Reference in New Issue