From 737c5b7b902c6a9a99219c412d48aacbb9bcc56e Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Tue, 16 Sep 2025 23:34:43 -0500 Subject: [PATCH] that dumb 'order' hack is gone. but boy it helped at first --- generateGui.go | 33 ++++++--------------------------- 1 file changed, 6 insertions(+), 27 deletions(-) diff --git a/generateGui.go b/generateGui.go index a412f86..b782e3e 100644 --- a/generateGui.go +++ b/generateGui.go @@ -135,12 +135,10 @@ func guiMain(w io.Writer, FRUITS string, FRUIT string) { fmt.Fprintln(w, " sf.f = func(x *"+FRUIT+") any {") fmt.Fprintln(w, " return f(x)") fmt.Fprintln(w, " }") - fmt.Fprintln(w, " sf.order = t.order") fmt.Fprintln(w, " sf.attr = new(guipb.ColAttr)") fmt.Fprintln(w, " sf.attr.Width = int32(sf.Width)") fmt.Fprintln(w, " sf.attr.Type = guipb.ColAttr_STRING") fmt.Fprintln(w, "") - fmt.Fprintln(w, " t.order += 1") fmt.Fprintln(w, " t.anyFuncs = append(t.anyFuncs, sf)") fmt.Fprintln(w, " return sf") fmt.Fprintln(w, "}") @@ -153,13 +151,11 @@ func guiMain(w io.Writer, FRUITS string, FRUIT string) { fmt.Fprintln(w, " sf.f = func(x *"+FRUIT+") any {") fmt.Fprintln(w, " return f(x)") fmt.Fprintln(w, " }") - fmt.Fprintln(w, " sf.order = t.order") fmt.Fprintln(w, " sf.attr = new(guipb.ColAttr)") fmt.Fprintln(w, " sf.attr.Width = int32(sf.Width)") fmt.Fprintln(w, " sf.attr.Type = guipb.ColAttr_STRING") fmt.Fprintln(w, " sf.attr.Click = true") fmt.Fprintln(w, "") - fmt.Fprintln(w, " t.order += 1") fmt.Fprintln(w, " t.anyFuncs = append(t.anyFuncs, sf)") fmt.Fprintln(w, " return sf") fmt.Fprintln(w, "}") @@ -172,12 +168,10 @@ func guiMain(w io.Writer, FRUITS string, FRUIT string) { fmt.Fprintln(w, " sf.f = func(x *"+FRUIT+") any {") fmt.Fprintln(w, " return f(x)") fmt.Fprintln(w, " }") - fmt.Fprintln(w, " sf.order = t.order") fmt.Fprintln(w, " sf.attr = new(guipb.ColAttr)") fmt.Fprintln(w, " sf.attr.Width = int32(sf.Width)") fmt.Fprintln(w, " sf.attr.Type = guipb.ColAttr_INT") fmt.Fprintln(w, "") - fmt.Fprintln(w, " t.order += 1") fmt.Fprintln(w, " t.anyFuncs = append(t.anyFuncs, sf)") fmt.Fprintln(w, " return sf") fmt.Fprintln(w, "}") @@ -190,12 +184,10 @@ func guiMain(w io.Writer, FRUITS string, FRUIT string) { fmt.Fprintln(w, " sf.f = func(x *"+FRUIT+") any {") fmt.Fprintln(w, " return f(x)") fmt.Fprintln(w, " }") - fmt.Fprintln(w, " sf.order = t.order") fmt.Fprintln(w, " sf.attr = new(guipb.ColAttr)") fmt.Fprintln(w, " sf.attr.Width = int32(sf.Width)") fmt.Fprintln(w, " sf.attr.Type = guipb.ColAttr_TIME") fmt.Fprintln(w, "") - fmt.Fprintln(w, " t.order += 1") fmt.Fprintln(w, " // t.timeFuncs = append(t.timeFuncs, sf)") fmt.Fprintln(w, " t.anyFuncs = append(t.anyFuncs, sf)") fmt.Fprintln(w, " return sf") @@ -225,7 +217,6 @@ func guiMain(w io.Writer, FRUITS string, FRUIT string) { fmt.Fprintln(w, " title string") fmt.Fprintln(w, " f func(*"+FRUIT+") any") fmt.Fprintln(w, " Custom func(*"+FRUIT+")") - fmt.Fprintln(w, " order int") fmt.Fprintln(w, " Width int") fmt.Fprintln(w, " attr *guipb.ColAttr") fmt.Fprintln(w, "}") @@ -235,23 +226,16 @@ func guiMain(w io.Writer, FRUITS string, FRUIT string) { fmt.Fprintln(w, " parent *gui.Node") fmt.Fprintln(w, " x *"+FRUITS+"") fmt.Fprintln(w, " hostnames []string") - fmt.Fprintln(w, "") fmt.Fprintln(w, " anyFuncs []*"+FRUIT+"AnyFunc") - fmt.Fprintln(w, "") fmt.Fprintln(w, " CustomFunc func(*"+FRUIT+")") - fmt.Fprintln(w, " order int") fmt.Fprintln(w, "}") } func guiStringFuncs(w io.Writer, ZOOPB string, FRUITS string, FRUIT string) { - fmt.Fprintln(w, "func (mt *"+FRUITS+"Table) doAnyFunc(name string) bool {") - fmt.Fprintln(w, " for _, sf := range mt.anyFuncs {") - fmt.Fprintln(w, " if sf.title != name {") - fmt.Fprintln(w, " continue") - fmt.Fprintln(w, " }") + fmt.Fprintln(w, "func (mt *"+FRUITS+"Table) doAnyFuncNew(sf *"+FRUIT+"AnyFunc) bool {") fmt.Fprintln(w, " r := new(guipb.AnyCol)") fmt.Fprintln(w, " r.Header = new(guipb.Widget)") - fmt.Fprintln(w, " r.Header.Name = name") + fmt.Fprintln(w, " r.Header.Name = sf.title") fmt.Fprintln(w, " r.Attr = proto.Clone(sf.attr).(*guipb.ColAttr)") fmt.Fprintln(w, "") @@ -289,15 +273,11 @@ func guiStringFuncs(w io.Writer, ZOOPB string, FRUITS string, FRUIT string) { fmt.Fprintln(w, " mt.pb.AnyCols = append(mt.pb.AnyCols, r)") fmt.Fprintln(w, " return true") - fmt.Fprintln(w, " }") - fmt.Fprintln(w, " return false") fmt.Fprintln(w, "}") fmt.Fprintln(w, "") fmt.Fprintln(w, "func (mt *"+FRUITS+"Table) MakeTable() {") - fmt.Fprintln(w, " for _, name := range mt.pb.Order {") - fmt.Fprintln(w, " if mt.doAnyFunc(name) {") - fmt.Fprintln(w, " continue") - fmt.Fprintln(w, " }") + fmt.Fprintln(w, " for _, sf := range mt.anyFuncs {") + fmt.Fprintln(w, " mt.doAnyFuncNew(sf)") fmt.Fprintln(w, " }") fmt.Fprintln(w, "}") } @@ -360,9 +340,8 @@ func guiTableCustom(w io.Writer, FRUITS string, fRUITS string, FRUIT string, fRU fmt.Fprintln(w, " row := mt.x."+FRUITS+"[w.Location.Y-1]") fmt.Fprintln(w, " // log.Info(\"got to "+fRUITS+"Custom() with\", w.Location.X, w.Location.Y-1)") fmt.Fprintln(w, "") - fmt.Fprintln(w, " for _, sf := range mt.anyFuncs {") - fmt.Fprintln(w, " if sf.order == int(w.Location.X) {") - fmt.Fprintln(w, " // log.Info(\"found order\", sf.order)") + fmt.Fprintln(w, " for i, sf := range mt.anyFuncs {") + fmt.Fprintln(w, " if i == int(w.Location.X) {") fmt.Fprintln(w, " if sf.Custom != nil {") fmt.Fprintln(w, " log.Info(\"doing Custom() func for button\")") fmt.Fprintln(w, " sf.Custom(row)")