From 08a5b198c7c8b7d08ab9cd7f166a8ababc88b140 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Thu, 13 Feb 2025 15:04:28 -0600 Subject: [PATCH] no more newaction(). finally. --- Makefile | 2 +- init.go | 2 ++ plugin.go | 60 ----------------------------------------------------- treeInit.go | 1 - 4 files changed, 3 insertions(+), 62 deletions(-) diff --git a/Makefile b/Makefile index 1ae6757..8155be2 100644 --- a/Makefile +++ b/Makefile @@ -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: diff --git a/init.go b/init.go index 92e4e3d..3a63c0a 100644 --- a/init.go +++ b/init.go @@ -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) } }() diff --git a/plugin.go b/plugin.go index 19af06f..787ced3 100644 --- a/plugin.go +++ b/plugin.go @@ -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 diff --git a/treeInit.go b/treeInit.go index 57db353..c51a9fe 100644 --- a/treeInit.go +++ b/treeInit.go @@ -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