no more newaction(). finally.

This commit is contained in:
Jeff Carr 2025-02-13 15:04:28 -06:00
parent c215e3c2c4
commit 08a5b198c7
4 changed files with 3 additions and 62 deletions

View File

@ -1,7 +1,7 @@
VERSION = $(shell git describe --tags)
BUILDTIME = $(shell date +%Y.%m.%d)
all: goimports vet gocui
all: clean goimports vet gocui
@ldd gocui.so
vet:

View File

@ -13,6 +13,7 @@ import (
"os"
"runtime"
"runtime/debug"
"runtime/pprof"
"time"
"github.com/awesome-gocui/gocui"
@ -148,6 +149,7 @@ func gocuiMain() {
os.Stderr = outf
os.Stdout = outf
debug.PrintStack()
pprof.Lookup("goroutine").WriteTo(outf, 1)
panic(outf)
}
}()

View File

@ -79,66 +79,6 @@ func addText(n *tree.Node, s string) {
w.AddText(s)
}
func newaction(n *tree.Node, atype widget.ActionType) {
log.Log(INFO, "newaction() START", atype)
if !me.ok {
log.Log(INFO, "newaction() START NOT OKAY", atype)
log.Log(INFO, "newaction() START NOT OKAY", atype)
log.Log(INFO, "newaction() START NOT OKAY", atype)
waitOK()
}
if n == nil {
log.Warn("Tree Error: Add() sent n == nil")
return
}
if n.TK == nil {
log.Warn("Tree sent an action on a widget we didn't seem to have.")
// do this init here again? Probably something
// went wrong and we should reset the our while gocui.View tree
n.TK = initWidget(n)
}
w := n.TK.(*guiWidget)
switch atype {
case widget.Show:
if me.debug {
w.dumpWidget("Show()")
}
w.node.State.Hidden = false
w.Show()
case widget.Hide:
if me.debug {
w.dumpWidget("Hide()")
}
if n.Hidden() {
// already hidden
} else {
// log.Log(NOW, "attempt to hide() =", atype, n.WidgetId, n.WidgetType, n.ProgName())
w.node.State.Hidden = true
w.Hide()
}
case widget.Move:
log.Log(NOW, "attempt to move() =", atype, n.WidgetType, n.ProgName())
case widget.ToolkitClose:
log.Log(NOW, "attempting to close the plugin and release stdout and stderr")
standardClose()
case widget.Enable:
w.Enable()
case widget.Disable:
w.Disable()
case widget.Delete:
if w == nil {
return
} else {
w.hideWidgets()
w.deleteNode()
}
n.DeleteNode()
default:
log.Log(ERROR, "newaction() UNHANDLED Action Type =", atype, "WidgetType =", n.WidgetType, "Name =", n.ProgName())
}
log.Log(INFO, "newaction() END", atype, n.String())
}
func (w *guiWidget) deleteGocuiViews() {
if w.v == nil {
// no gocui view to delete for this widget

View File

@ -55,7 +55,6 @@ func PluginChannel() chan widget.Action {
func initTree() *tree.TreeInfo {
t := tree.New()
t.PluginName = PLUGIN
t.NodeAction = newaction
t.Add = newAdd
t.SetTitle = setTitle
t.SetLabel = setLabel