try to use the stdout view

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-11-13 21:03:50 -06:00
parent 6d3dded68b
commit 2ace17294c
3 changed files with 15 additions and 27 deletions

View File

@ -30,6 +30,11 @@ func gocuiEvent(g *gocui.Gui) error {
makeOutputWidget(g, "this is a create before a mouse click")
if me.logStdout != nil {
// setOutput(me.logStdout)
// me.logStdout.Write("test out")
w := me.logStdout.TK.(*guiWidget)
w.Write([]byte("test out"))
// log.CaptureMode(w)
log.Log(NOW, "logStdout test out")
}
} else {
log.Verbose("output widget already exists", maxX, maxY, mx, my)

33
main.go
View File

@ -90,32 +90,18 @@ func mainGogui() {
log.Warn("YAHOOOO Recovered in guiMain application:", r)
log.Warn("Recovered from panic:", r)
me.baseGui.Close()
log.CaptureMode(nil)
log.Warn("YAHOOOO Recovered in guiMain application:", r)
log.Warn("Recovered from panic:", r)
me.myTree.SendToolkitPanic()
// attempts to control STDOUT
/*
// allow gocui to close if possible, then print stack
log.Sleep(1)
me.myTree.SendToolkitLoad("nocui")
log.Sleep(3)
os.Stdout = origStdout
os.Stderr = origStderr
log.Warn("Stack trace:")
debug.PrintStack()
// attempt to switch to the nocui toolkit
log.Sleep(1)
// panic("BUMMER")
*/
return
}
}()
// attempts to control STDOUT
/*
var err error
log.Log(INFO, "main() start Init()")
outf, err = os.OpenFile("/tmp/witgui.log", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
var err error
outf, err = os.OpenFile("/tmp/captureMode.log", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
if err != nil {
log.Error(err, "error opening file: %v")
os.Exit(0)
@ -124,13 +110,8 @@ func mainGogui() {
os.Stdout = outf
defer outf.Close()
// setOutput(outf)
// log("This is a test log entry")
log.CaptureMode(outf)
ferr, _ := os.OpenFile("/tmp/witgui.err", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0664)
origStderr = os.Stderr
os.Stderr = ferr
*/
gocuiMain()
}

View File

@ -38,7 +38,9 @@ func showMsg(g *gocui.Gui, v *gocui.View) error {
l = ""
}
makeOutputWidget(g, l)
outv := makeOutputWidget(g, l)
outv.Write([]byte("test out2"))
log.Info("test out2")
return nil
}