2024-01-18 00:08:37 -06:00
|
|
|
// Copyright 2014 The gocui Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
2024-01-30 03:17:15 -06:00
|
|
|
"runtime/debug"
|
2024-01-18 00:08:37 -06:00
|
|
|
|
|
|
|
"go.wit.com/log"
|
2024-01-28 02:20:31 -06:00
|
|
|
"go.wit.com/toolkits/tree"
|
2024-01-18 00:08:37 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
// sets defaults and establishes communication
|
|
|
|
// to this toolkit from the wit/gui golang package
|
|
|
|
func init() {
|
|
|
|
log.Log(INFO, "Init() of awesome-gocui")
|
|
|
|
|
|
|
|
// init the config struct default values
|
|
|
|
Set(&me, "default")
|
|
|
|
|
2024-01-29 23:39:33 -06:00
|
|
|
// Set(&me, "dense")
|
|
|
|
|
2024-01-28 02:20:31 -06:00
|
|
|
me.myTree = tree.New()
|
|
|
|
me.myTree.PluginName = "gocui"
|
|
|
|
me.myTree.ActionFromChannel = action
|
|
|
|
|
|
|
|
// pluginChan = make(chan widget.Action)
|
2024-01-18 00:08:37 -06:00
|
|
|
|
|
|
|
log.Log(NOW, "Init() start pluginChan")
|
2024-01-28 02:20:31 -06:00
|
|
|
// go catchActionChannel()
|
2024-01-18 00:08:37 -06:00
|
|
|
log.Sleep(.1) // probably not needed, but in here for now under development
|
2024-01-30 03:17:15 -06:00
|
|
|
go mainGogui()
|
2024-01-18 00:08:37 -06:00
|
|
|
log.Sleep(.1) // probably not needed, but in here for now under development
|
|
|
|
}
|
|
|
|
|
|
|
|
func standardExit() {
|
|
|
|
log.Log(NOW, "standardExit() doing baseGui.Close()")
|
|
|
|
me.baseGui.Close()
|
|
|
|
log.Log(NOW, "standardExit() doing outf.Close()")
|
|
|
|
outf.Close()
|
|
|
|
// log(true, "standardExit() setOutput(os.Stdout)")
|
|
|
|
// setOutput(os.Stdout)
|
|
|
|
log.Log(NOW, "standardExit() send back Quit()")
|
2024-01-28 02:20:31 -06:00
|
|
|
// go sendBackQuit() // don't stall here in case the
|
2024-01-18 00:08:37 -06:00
|
|
|
// induces a delay in case the callback channel is broken
|
|
|
|
log.Sleep(1)
|
|
|
|
log.Log(NOW, "standardExit() exit()")
|
|
|
|
os.Exit(0)
|
|
|
|
}
|
|
|
|
|
2024-01-30 11:54:57 -06:00
|
|
|
func standardClose() {
|
|
|
|
log.Log(NOW, "standardExit() doing baseGui.Close()")
|
|
|
|
me.baseGui.Close()
|
|
|
|
log.Log(NOW, "standardExit() doing outf.Close()")
|
|
|
|
outf.Close()
|
|
|
|
os.Stdin = os.Stdin
|
|
|
|
os.Stdout = os.Stdout
|
|
|
|
os.Stderr = os.Stderr
|
|
|
|
log.Log(NOW, "standardExit() send back Quit()")
|
|
|
|
}
|
|
|
|
|
2024-01-18 00:08:37 -06:00
|
|
|
var outf *os.File
|
|
|
|
|
|
|
|
func main() {
|
2024-01-30 03:17:15 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
func mainGogui() {
|
|
|
|
defer func() {
|
|
|
|
if r := recover(); r != nil {
|
|
|
|
log.Warn("YAHOOOO Recovered in guiMain application:", r)
|
|
|
|
log.Warn("Recovered from panic:", r)
|
2024-01-30 11:54:57 -06:00
|
|
|
me.myTree.SendToolkitPanic()
|
2024-01-30 03:17:15 -06:00
|
|
|
log.Warn("Stack trace:")
|
|
|
|
debug.PrintStack()
|
2024-01-30 11:54:57 -06:00
|
|
|
// panic("BUMMER")
|
2024-01-30 03:17:15 -06:00
|
|
|
return
|
|
|
|
}
|
|
|
|
}()
|
2024-01-18 00:08:37 -06:00
|
|
|
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)
|
|
|
|
if err != nil {
|
|
|
|
log.Error(err, "error opening file: %v")
|
|
|
|
os.Exit(0)
|
|
|
|
}
|
|
|
|
os.Stdout = outf
|
|
|
|
defer outf.Close()
|
|
|
|
|
|
|
|
// setOutput(outf)
|
|
|
|
// log("This is a test log entry")
|
|
|
|
|
|
|
|
ferr, _ := os.OpenFile("/tmp/witgui.err", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0664)
|
|
|
|
os.Stderr = ferr
|
|
|
|
gocuiMain()
|
|
|
|
}
|