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
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,9 +35,6 @@ type config struct {
|
||||||
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
|
|
||||||
// startOutputW int // ?
|
|
||||||
// startOutputH int // ?
|
|
||||||
helpLabel *gocui.View // ?
|
helpLabel *gocui.View // ?
|
||||||
showHelp bool // toggle boolean for the help menu (deprecate?)
|
showHelp bool // toggle boolean for the help menu (deprecate?)
|
||||||
dropdownW *guiWidget // grab the dropdown choices from this widget
|
dropdownW *guiWidget // grab the dropdown choices from this widget
|
||||||
|
@ -75,6 +72,7 @@ type config struct {
|
||||||
|
|
||||||
// settings for the stdout window
|
// settings for the stdout window
|
||||||
type stdout struct {
|
type stdout struct {
|
||||||
|
tk *guiWidget // where to show STDOUT
|
||||||
w int // the width
|
w int // the width
|
||||||
h int // the width
|
h int // the width
|
||||||
outputOnTop bool // is the STDOUT window on top?
|
outputOnTop bool // is the STDOUT window on top?
|
||||||
|
@ -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