gocui: standard close
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
4e8a1bc432
commit
a4403975e7
|
@ -75,21 +75,19 @@ func addDebugKeys(g *gocui.Gui) {
|
|||
// exit
|
||||
g.SetKeybinding("", 'q', gocui.ModNone,
|
||||
func(g *gocui.Gui, v *gocui.View) error {
|
||||
me.baseGui.Close()
|
||||
sendBackQuit()
|
||||
standardExit()
|
||||
return nil
|
||||
})
|
||||
g.SetKeybinding("", gocui.KeyCtrlC, gocui.ModNone,
|
||||
func(g *gocui.Gui, v *gocui.View) error {
|
||||
me.baseGui.Close()
|
||||
sendBackQuit()
|
||||
standardExit()
|
||||
return nil
|
||||
})
|
||||
|
||||
// panic
|
||||
g.SetKeybinding("", 'p', gocui.ModNone,
|
||||
func(g *gocui.Gui, v *gocui.View) error {
|
||||
me.baseGui.Close()
|
||||
standardExit()
|
||||
panic("forced panic in gocui")
|
||||
return nil
|
||||
})
|
||||
|
|
|
@ -60,10 +60,17 @@ func catchActionChannel() {
|
|||
|
||||
func Exit() {
|
||||
// TODO: what should actually happen here?
|
||||
me.baseGui.Close()
|
||||
sendBackQuit()
|
||||
standardExit()
|
||||
}
|
||||
|
||||
func standardExit() {
|
||||
me.baseGui.Close()
|
||||
outf.Close()
|
||||
setOutput(os.Stdout)
|
||||
sendBackQuit()
|
||||
sleep(.5)
|
||||
exit()
|
||||
}
|
||||
func sendBackQuit() {
|
||||
// send 'Quit' back to the program (?)
|
||||
var a toolkit.Action
|
||||
|
@ -89,7 +96,5 @@ func main() {
|
|||
MouseMain()
|
||||
|
||||
log(true, "MouseMain() closed")
|
||||
me.baseGui.Close()
|
||||
|
||||
sendBackQuit()
|
||||
standardExit()
|
||||
}
|
||||
|
|
|
@ -1,16 +1,11 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
// if you include more than just this import
|
||||
// then your plugin might be doing something un-ideal (just a guess from 2023/02/27)
|
||||
"git.wit.org/wit/gui/toolkit"
|
||||
)
|
||||
|
||||
func Quit() {
|
||||
me.baseGui.Close()
|
||||
}
|
||||
|
||||
func action(a *toolkit.Action) {
|
||||
log(logInfo, "action() START", a.WidgetId, a.ActionType, a.WidgetType, a.Name)
|
||||
w := findWidget(a.WidgetId, me.rootNode)
|
||||
|
@ -41,9 +36,7 @@ func action(a *toolkit.Action) {
|
|||
log(logNow, "attempt to move() =", a.ActionType, a.WidgetType, a.Name)
|
||||
case toolkit.CloseToolkit:
|
||||
log(logNow, "attempting to close the plugin and release stdout and stderr")
|
||||
me.baseGui.Close()
|
||||
// defer outf.Close()
|
||||
setOutput(os.Stdout)
|
||||
standardExit()
|
||||
default:
|
||||
log(logError, "action() Unknown =", a.ActionType, a.WidgetType, a.Name)
|
||||
}
|
||||
|
|
|
@ -8,8 +8,8 @@ import (
|
|||
"git.wit.org/wit/gui/toolkit"
|
||||
)
|
||||
|
||||
var outputW int = 200
|
||||
var outputH int = 36
|
||||
var outputW int = 180
|
||||
var outputH int = 24
|
||||
|
||||
func moveMsg(g *gocui.Gui) {
|
||||
mx, my := g.MousePosition()
|
||||
|
|
|
@ -220,8 +220,8 @@ func (w *cuiWidget) Write(p []byte) (n int, err error) {
|
|||
s = strings.TrimSuffix(s, "\n")
|
||||
tmp := strings.Split(s, "\n")
|
||||
outputS = append(outputS, tmp...)
|
||||
if (len(outputS) > 50) {
|
||||
outputS = outputS[10:]
|
||||
if (len(outputS) > outputH) {
|
||||
outputS = outputS[4:]
|
||||
}
|
||||
fmt.Fprintln(me.logStdout.v, strings.Join(outputS, "\n"))
|
||||
|
||||
|
|
Loading…
Reference in New Issue