From d141b4d308f71418e8d43a58c2e04f9560db3092 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Tue, 25 Mar 2025 07:28:06 -0500 Subject: [PATCH] save the toolkit config options --- addNode.go | 6 +++--- init.go | 23 +++++++++++++++++++++++ toolkitConfig.proto | 4 ++-- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/addNode.go b/addNode.go index 63c54a5..715d3c4 100644 --- a/addNode.go +++ b/addNode.go @@ -38,9 +38,9 @@ func addNode(a *widget.Action) *Node { } if treeRoot.FindWidgetId(a.WidgetId) != nil { - log.Log(TREEWARN, "AddNode() WidgetId already exists", a.WidgetId) - log.Log(TREEWARN, "probably this is a Show() / Hide() issue") - log.Log(TREEWARN, "TODO: figure out what to do here") + // ignore these errors for now + log.Log(TREE, "AddNode() WidgetId already exists", a.WidgetId) + log.Log(TREE, "TODO: figure out what to do here probably this is a Show() / Hide() issue") return treeRoot.FindWidgetId(a.WidgetId) } diff --git a/init.go b/init.go index 6bb8efd..8122cca 100644 --- a/init.go +++ b/init.go @@ -72,3 +72,26 @@ func (t *TreeInfo) ConfigFind(n string) (string, error) { } return "", fmt.Errorf("toolkit config %s not found", n) } + +func (t *TreeInfo) ConfigSave(o *ToolkitConfig) { + t.configInsert(o) + t.config.configSave() +} + +// update the config option value (or append if new record) +func (t *TreeInfo) configInsert(newr *ToolkitConfig) { + all := t.config.All() // get the list of repos + for all.Scan() { + r := all.Next() + if t.PluginName != r.Plugin { + // option isn't for this plugin + continue + } + if newr.Name == r.Name { + // found the record! + r.Value = newr.Value + return + } + } + t.config.Append(newr) +} diff --git a/toolkitConfig.proto b/toolkitConfig.proto index a53fdc4..1ce14b4 100644 --- a/toolkitConfig.proto +++ b/toolkitConfig.proto @@ -7,8 +7,8 @@ package forgepb; import "google/protobuf/timestamp.proto"; // Import the well-known type for Timestamp message ToolkitConfig { // - string plugin = 1; // 'gocui', 'andlabs', etc - string name = 2; // variable name 'fullscreen' + string plugin = 1; // 'gocui', 'andlabs', etc `autogenpb:unique` + string name = 2; // variable name 'fullscreen' `autogenpb:unique` string value = 3; // value "true" }