|
|
@ -49,39 +49,9 @@ func (pb *Files) makeGuiFile(pf *File) error {
|
|
|
|
FRUIT := msg.GuiVarName
|
|
|
|
FRUIT := msg.GuiVarName
|
|
|
|
fruitVars := color.Vars
|
|
|
|
fruitVars := color.Vars
|
|
|
|
pf.generateAutoTablePB(newf, FRUITS, FRUIT, fruitVars)
|
|
|
|
pf.generateAutoTablePB(newf, FRUITS, FRUIT, fruitVars)
|
|
|
|
log.Printf("NEED TO ADD GUI FOR %s with var %s and found msg struct %s\n", msg.Name, msg.GuiVarName, color.Lockname)
|
|
|
|
log.Printf("Added GUI functions for protobuf '%s' with record '%s' using mutex '%s'\n", msg.Name, msg.GuiVarName, color.Lockname)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// os.Exit(-1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
guiMain(newf, pf.Bases.Name, pf.Base.Name)
|
|
|
|
|
|
|
|
guiStringFuncs(newf, pf.Package, pf.Bases.Name, pf.Base.Name)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for _, v := range pf.Base.Vars {
|
|
|
|
|
|
|
|
if v.IsRepeated {
|
|
|
|
|
|
|
|
// can't work against slices
|
|
|
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if v.VarType == "string" {
|
|
|
|
|
|
|
|
log.Printf("make Add function here %s %s %s\n", pf.Bases.Name, pf.Base.Name, v.VarName)
|
|
|
|
|
|
|
|
guiAddStringFunc(newf, pf.Bases.Name, pf.Base.Name, v.VarName)
|
|
|
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if v.VarType == "int64" {
|
|
|
|
|
|
|
|
log.Printf("make Add function here %s %s %s\n", pf.Bases.Name, pf.Base.Name, v.VarName)
|
|
|
|
|
|
|
|
guiAddIntFunc(newf, pf.Bases.Name, pf.Base.Name, v.VarName)
|
|
|
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
FRUITS := pf.Bases.Name
|
|
|
|
|
|
|
|
FRUIT := pf.Base.Name
|
|
|
|
|
|
|
|
fRUITS := untitle(pf.Bases.Name)
|
|
|
|
|
|
|
|
fRUIT := untitle(pf.Base.Name)
|
|
|
|
|
|
|
|
guiUpdate(newf, FRUITS, FRUIT)
|
|
|
|
|
|
|
|
guiTableDelete(newf, FRUITS, FRUIT)
|
|
|
|
|
|
|
|
guiTableCustom(newf, FRUITS, fRUITS, FRUIT, fRUIT)
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fmt.Fprintf(newf, "\n")
|
|
|
|
fmt.Fprintf(newf, "\n")
|
|
|
|
fmt.Fprintf(newf, "// END GUI\n")
|
|
|
|
fmt.Fprintf(newf, "// END GUI\n")
|
|
|
@ -141,6 +111,7 @@ func headerGui(w io.Writer, pf *File) {
|
|
|
|
fmt.Fprintln(w, " \"go.wit.com/gui\"")
|
|
|
|
fmt.Fprintln(w, " \"go.wit.com/gui\"")
|
|
|
|
fmt.Fprintln(w, " \"go.wit.com/lib/protobuf/guipb\"")
|
|
|
|
fmt.Fprintln(w, " \"go.wit.com/lib/protobuf/guipb\"")
|
|
|
|
fmt.Fprintln(w, " \"go.wit.com/log\"")
|
|
|
|
fmt.Fprintln(w, " \"go.wit.com/log\"")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " anypb \"google.golang.org/protobuf/types/known/anypb\"")
|
|
|
|
fmt.Fprintln(w, " timestamppb \"google.golang.org/protobuf/types/known/timestamppb\"")
|
|
|
|
fmt.Fprintln(w, " timestamppb \"google.golang.org/protobuf/types/known/timestamppb\"")
|
|
|
|
fmt.Fprintln(w, ")")
|
|
|
|
fmt.Fprintln(w, ")")
|
|
|
|
fmt.Fprintln(w, "")
|
|
|
|
fmt.Fprintln(w, "")
|
|
|
@ -156,61 +127,77 @@ func guiMain(w io.Writer, FRUITS string, FRUIT string) {
|
|
|
|
fmt.Fprintln(w, " return t")
|
|
|
|
fmt.Fprintln(w, " return t")
|
|
|
|
fmt.Fprintln(w, "}")
|
|
|
|
fmt.Fprintln(w, "}")
|
|
|
|
fmt.Fprintln(w, "")
|
|
|
|
fmt.Fprintln(w, "")
|
|
|
|
fmt.Fprintln(w, "func (t *"+FRUITS+"Table) AddStringFunc(title string, f func(*"+FRUIT+") string) *"+FRUIT+"StringFunc {")
|
|
|
|
fmt.Fprintln(w, "// force the application to choose the type of data. this allows the GUI plugin to be smarter")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, "func (t *"+FRUITS+"Table) AddStringFunc(title string, f func(*"+FRUIT+") string) *"+FRUIT+"AnyFunc {")
|
|
|
|
fmt.Fprintln(w, " t.pb.Order = append(t.pb.Order, title)")
|
|
|
|
fmt.Fprintln(w, " t.pb.Order = append(t.pb.Order, title)")
|
|
|
|
fmt.Fprintln(w, "")
|
|
|
|
fmt.Fprintln(w, "")
|
|
|
|
fmt.Fprintln(w, " sf := new("+FRUIT+"StringFunc)")
|
|
|
|
fmt.Fprintln(w, " sf := new("+FRUIT+"AnyFunc)")
|
|
|
|
fmt.Fprintln(w, " sf.title = title")
|
|
|
|
fmt.Fprintln(w, " sf.title = title")
|
|
|
|
fmt.Fprintln(w, " sf.f = f")
|
|
|
|
fmt.Fprintln(w, " sf.f = func(x *"+FRUIT+") any {")
|
|
|
|
fmt.Fprintln(w, " sf.order = t.order")
|
|
|
|
fmt.Fprintln(w, " return f(x)")
|
|
|
|
fmt.Fprintln(w, " t.order += 1")
|
|
|
|
fmt.Fprintln(w, " }")
|
|
|
|
fmt.Fprintln(w, " t.stringFuncs = append(t.stringFuncs, sf)")
|
|
|
|
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.anyFuncs = append(t.anyFuncs, sf)")
|
|
|
|
fmt.Fprintln(w, " return sf")
|
|
|
|
fmt.Fprintln(w, " return sf")
|
|
|
|
fmt.Fprintln(w, "}")
|
|
|
|
fmt.Fprintln(w, "}")
|
|
|
|
fmt.Fprintln(w, "")
|
|
|
|
fmt.Fprintln(w, "")
|
|
|
|
fmt.Fprintln(w, "func (t *"+FRUITS+"Table) AddButtonFunc(title string, f func(*"+FRUIT+") string) *"+FRUIT+"ButtonFunc {")
|
|
|
|
fmt.Fprintln(w, "// force the application to choose the type of data. this allows the GUI plugin to be smarter")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, "func (t *"+FRUITS+"Table) AddButtonFunc(title string, f func(*"+FRUIT+") string) *"+FRUIT+"AnyFunc {")
|
|
|
|
fmt.Fprintln(w, " t.pb.Order = append(t.pb.Order, title)")
|
|
|
|
fmt.Fprintln(w, " t.pb.Order = append(t.pb.Order, title)")
|
|
|
|
fmt.Fprintln(w, "")
|
|
|
|
fmt.Fprintln(w, "")
|
|
|
|
fmt.Fprintln(w, " sf := new("+FRUIT+"ButtonFunc)")
|
|
|
|
fmt.Fprintln(w, " sf := new("+FRUIT+"AnyFunc)")
|
|
|
|
fmt.Fprintln(w, " sf.title = title")
|
|
|
|
fmt.Fprintln(w, " sf.title = title")
|
|
|
|
fmt.Fprintln(w, " sf.f = f")
|
|
|
|
fmt.Fprintln(w, " sf.f = func(x *"+FRUIT+") any {")
|
|
|
|
fmt.Fprintln(w, " sf.order = t.order")
|
|
|
|
fmt.Fprintln(w, " return f(x)")
|
|
|
|
fmt.Fprintln(w, " t.order += 1")
|
|
|
|
fmt.Fprintln(w, " }")
|
|
|
|
fmt.Fprintln(w, " t.buttonFuncs = append(t.buttonFuncs, sf)")
|
|
|
|
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.anyFuncs = append(t.anyFuncs, sf)")
|
|
|
|
fmt.Fprintln(w, " return sf")
|
|
|
|
fmt.Fprintln(w, " return sf")
|
|
|
|
fmt.Fprintln(w, "}")
|
|
|
|
fmt.Fprintln(w, "}")
|
|
|
|
fmt.Fprintln(w, "")
|
|
|
|
fmt.Fprintln(w, "")
|
|
|
|
fmt.Fprintln(w, "func (t *"+FRUITS+"Table) AddIntFunc(title string, f func(*"+FRUIT+") int) *"+FRUIT+"IntFunc {")
|
|
|
|
fmt.Fprintln(w, "// force the application to choose the type of data. this allows the GUI plugin to be smarter")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, "func (t *"+FRUITS+"Table) AddIntFunc(title string, f func(*"+FRUIT+") int) *"+FRUIT+"AnyFunc {")
|
|
|
|
fmt.Fprintln(w, " t.pb.Order = append(t.pb.Order, title)")
|
|
|
|
fmt.Fprintln(w, " t.pb.Order = append(t.pb.Order, title)")
|
|
|
|
fmt.Fprintln(w, "")
|
|
|
|
fmt.Fprintln(w, "")
|
|
|
|
fmt.Fprintln(w, " sf := new("+FRUIT+"IntFunc)")
|
|
|
|
fmt.Fprintln(w, " sf := new("+FRUIT+"AnyFunc)")
|
|
|
|
fmt.Fprintln(w, " sf.title = title")
|
|
|
|
fmt.Fprintln(w, " sf.title = title")
|
|
|
|
fmt.Fprintln(w, " sf.f = f")
|
|
|
|
fmt.Fprintln(w, " sf.f = func(x *"+FRUIT+") any {")
|
|
|
|
fmt.Fprintln(w, " sf.order = t.order")
|
|
|
|
fmt.Fprintln(w, " return f(x)")
|
|
|
|
fmt.Fprintln(w, " t.order += 1")
|
|
|
|
fmt.Fprintln(w, " }")
|
|
|
|
fmt.Fprintln(w, " t.intFuncs = append(t.intFuncs, sf)")
|
|
|
|
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.anyFuncs = append(t.anyFuncs, sf)")
|
|
|
|
fmt.Fprintln(w, " return sf")
|
|
|
|
fmt.Fprintln(w, " return sf")
|
|
|
|
fmt.Fprintln(w, "}")
|
|
|
|
fmt.Fprintln(w, "}")
|
|
|
|
fmt.Fprintln(w, "")
|
|
|
|
fmt.Fprintln(w, "")
|
|
|
|
fmt.Fprintln(w, "func (t *"+FRUITS+"Table) AddTimeFunc(title string, f func(*"+FRUIT+") time.Time) *"+FRUIT+"TimeFunc {")
|
|
|
|
fmt.Fprintln(w, "// force the application to choose the type of data. this allows the GUI plugin to be smarter")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, "func (t *"+FRUITS+"Table) AddTimeFunc(title string, f func(*"+FRUIT+") time.Time) *"+FRUIT+"AnyFunc {")
|
|
|
|
fmt.Fprintln(w, " t.pb.Order = append(t.pb.Order, title)")
|
|
|
|
fmt.Fprintln(w, " t.pb.Order = append(t.pb.Order, title)")
|
|
|
|
fmt.Fprintln(w, "")
|
|
|
|
fmt.Fprintln(w, "")
|
|
|
|
fmt.Fprintln(w, " sf := new("+FRUIT+"TimeFunc)")
|
|
|
|
fmt.Fprintln(w, " sf := new("+FRUIT+"AnyFunc)")
|
|
|
|
fmt.Fprintln(w, " sf.title = title")
|
|
|
|
fmt.Fprintln(w, " sf.title = title")
|
|
|
|
fmt.Fprintln(w, " sf.f = f")
|
|
|
|
fmt.Fprintln(w, " sf.f = func(x *"+FRUIT+") any {")
|
|
|
|
fmt.Fprintln(w, " sf.order = t.order")
|
|
|
|
fmt.Fprintln(w, " return f(x)")
|
|
|
|
fmt.Fprintln(w, " t.order += 1")
|
|
|
|
fmt.Fprintln(w, " }")
|
|
|
|
fmt.Fprintln(w, " t.timeFuncs = append(t.timeFuncs, sf)")
|
|
|
|
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.timeFuncs = append(t.timeFuncs, sf)")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " t.anyFuncs = append(t.anyFuncs, sf)")
|
|
|
|
fmt.Fprintln(w, " return sf")
|
|
|
|
fmt.Fprintln(w, " return sf")
|
|
|
|
fmt.Fprintln(w, "}")
|
|
|
|
fmt.Fprintln(w, "}")
|
|
|
|
fmt.Fprintln(w, "")
|
|
|
|
fmt.Fprintln(w, "")
|
|
|
|
fmt.Fprintln(w, "func (sf *"+FRUIT+"StringFunc) SetTitle(title string) {")
|
|
|
|
fmt.Fprintln(w, "func (sf *"+FRUIT+"AnyFunc) SetTitle(title string) {")
|
|
|
|
fmt.Fprintln(w, " sf.title = title")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, "}")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, "func (sf *"+FRUIT+"IntFunc) SetTitle(title string) {")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " sf.title = title")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, "}")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, "func (sf *"+FRUIT+"TimeFunc) SetTitle(title string) {")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " sf.title = title")
|
|
|
|
fmt.Fprintln(w, " sf.title = title")
|
|
|
|
fmt.Fprintln(w, "}")
|
|
|
|
fmt.Fprintln(w, "}")
|
|
|
|
fmt.Fprintln(w, "")
|
|
|
|
fmt.Fprintln(w, "")
|
|
|
@ -230,36 +217,12 @@ func guiMain(w io.Writer, FRUITS string, FRUIT string) {
|
|
|
|
fmt.Fprintln(w, " mt.parent.ShowTable(mt.pb)")
|
|
|
|
fmt.Fprintln(w, " mt.parent.ShowTable(mt.pb)")
|
|
|
|
fmt.Fprintln(w, "}")
|
|
|
|
fmt.Fprintln(w, "}")
|
|
|
|
fmt.Fprintln(w, "")
|
|
|
|
fmt.Fprintln(w, "")
|
|
|
|
fmt.Fprintln(w, "type "+FRUIT+"StringFunc struct {")
|
|
|
|
fmt.Fprintln(w, "type "+FRUIT+"AnyFunc struct {")
|
|
|
|
fmt.Fprintln(w, " title string")
|
|
|
|
fmt.Fprintln(w, " title string")
|
|
|
|
fmt.Fprintln(w, " f func(*"+FRUIT+") string")
|
|
|
|
fmt.Fprintln(w, " f func(*"+FRUIT+") any")
|
|
|
|
fmt.Fprintln(w, " Custom func(*"+FRUIT+")")
|
|
|
|
fmt.Fprintln(w, " Custom func(*"+FRUIT+")")
|
|
|
|
fmt.Fprintln(w, " order int")
|
|
|
|
fmt.Fprintln(w, " Width int")
|
|
|
|
fmt.Fprintln(w, " Width int")
|
|
|
|
fmt.Fprintln(w, " attr *guipb.ColAttr")
|
|
|
|
fmt.Fprintln(w, "}")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, "")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, "type "+FRUIT+"ButtonFunc struct {")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " title string")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " f func(*"+FRUIT+") string")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " Custom func(*"+FRUIT+")")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " order int")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " Width int")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, "}")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, "")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, "type "+FRUIT+"IntFunc struct {")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " title string")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " f func(*"+FRUIT+") int")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " Custom func(*"+FRUIT+")")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " order int")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " Width int")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, "}")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, "")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, "type "+FRUIT+"TimeFunc struct {")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " title string")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " f func(*"+FRUIT+") time.Time")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " Custom func(*"+FRUIT+")")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " order int")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " Width int")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, "}")
|
|
|
|
fmt.Fprintln(w, "}")
|
|
|
|
fmt.Fprintln(w, "")
|
|
|
|
fmt.Fprintln(w, "")
|
|
|
|
fmt.Fprintln(w, "type "+FRUITS+"Table struct {")
|
|
|
|
fmt.Fprintln(w, "type "+FRUITS+"Table struct {")
|
|
|
@ -267,122 +230,65 @@ func guiMain(w io.Writer, FRUITS string, FRUIT string) {
|
|
|
|
fmt.Fprintln(w, " parent *gui.Node")
|
|
|
|
fmt.Fprintln(w, " parent *gui.Node")
|
|
|
|
fmt.Fprintln(w, " x *"+FRUITS+"")
|
|
|
|
fmt.Fprintln(w, " x *"+FRUITS+"")
|
|
|
|
fmt.Fprintln(w, " hostnames []string")
|
|
|
|
fmt.Fprintln(w, " hostnames []string")
|
|
|
|
fmt.Fprintln(w, " stringFuncs []*"+FRUIT+"StringFunc")
|
|
|
|
fmt.Fprintln(w, " anyFuncs []*"+FRUIT+"AnyFunc")
|
|
|
|
fmt.Fprintln(w, " intFuncs []*"+FRUIT+"IntFunc")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " timeFuncs []*"+FRUIT+"TimeFunc")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " buttonFuncs []*"+FRUIT+"ButtonFunc")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " CustomFunc func(*"+FRUIT+")")
|
|
|
|
fmt.Fprintln(w, " CustomFunc func(*"+FRUIT+")")
|
|
|
|
fmt.Fprintln(w, " order int")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, "}")
|
|
|
|
fmt.Fprintln(w, "}")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func guiStringFuncs(w io.Writer, ZOOPB string, FRUITS string, FRUIT string) {
|
|
|
|
func guiStringFuncs(w io.Writer, ZOOPB string, FRUITS string, FRUIT string) {
|
|
|
|
fmt.Fprintln(w, "func (mt *"+FRUITS+"Table) doStringFunc(name string) bool {")
|
|
|
|
fmt.Fprintln(w, "func (mt *"+FRUITS+"Table) doAnyFuncNew(sf *"+FRUIT+"AnyFunc) bool {")
|
|
|
|
fmt.Fprintln(w, " for _, sf := range mt.stringFuncs {")
|
|
|
|
fmt.Fprintln(w, " r := new(guipb.AnyCol)")
|
|
|
|
fmt.Fprintln(w, " if sf.title != name {")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " continue")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " }")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " // log.Info(\""+ZOOPB+": found stringfunc name:\", name)")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " r := new(guipb.StringRow)")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " r.Header = new(guipb.Widget)")
|
|
|
|
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, "")
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " all := mt.x.All()")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " for all.Scan() {")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " m := all.Next()")
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " for m := range mt.x.IterAll() {")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " r.Vals = append(r.Vals, sf.f(m))")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " // log.Info(\""+ZOOPB+": adding\", name, r.Vals)")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " }")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " mt.pb.StringRows = append(mt.pb.StringRows, 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) doButtonFunc(name string) bool {")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " for _, sf := range mt.buttonFuncs {")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " if sf.title != name {")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " continue")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " }")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " // log.Info(\""+ZOOPB+": found stringfunc name:\", name)")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " r := new(guipb.ButtonRow)")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " r.Header = new(guipb.Widget)")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " r.Header.Name = name")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " for m := range mt.x.IterAll() {")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " r.Vals = append(r.Vals, sf.f(m))")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " // log.Info(\""+ZOOPB+": adding\", name, r.Vals)")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " }")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " mt.pb.ButtonRows = append(mt.pb.ButtonRows, 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) doIntFunc(name string) bool {")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " for _, sf := range mt.intFuncs {")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " if sf.title != name {")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " continue")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " }")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " // log.Info(\""+ZOOPB+": found intfunc name:\", name)")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " r := new(guipb.IntRow)")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " r.Header = new(guipb.Widget)")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " r.Header.Name = name")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " for m := range mt.x.IterAll() {")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " r.Vals = append(r.Vals, int64(sf.f(m)))")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " // log.Info(\""+ZOOPB+": adding\", name, r.Vals)")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " }")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " mt.pb.IntRows = append(mt.pb.IntRows, 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) doTimeFunc(name string) bool {")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " for _, sf := range mt.timeFuncs {")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " if sf.title != name {")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " continue")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " }")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " // log.Info(\""+ZOOPB+": found timefunc name:\", name)")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " r := new(guipb.TimeRow)")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " r.Header = new(guipb.Widget)")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " r.Header.Name = name")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " for m := range mt.x.IterAll() {")
|
|
|
|
fmt.Fprintln(w, " for m := range mt.x.IterAll() {")
|
|
|
|
fmt.Fprintln(w, " t := sf.f(m)")
|
|
|
|
fmt.Fprintln(w, " t := sf.f(m)")
|
|
|
|
fmt.Fprintln(w, " r.Vals = append(r.Vals, timestamppb.New(t)) // convert to protobuf time")
|
|
|
|
fmt.Fprintln(w, " switch r.Attr.Type {")
|
|
|
|
fmt.Fprintln(w, " // log.Info(\""+ZOOPB+": adding\", name, r.Vals)")
|
|
|
|
fmt.Fprintln(w, " case guipb.ColAttr_STRING:")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " // anyProto, err := anypb.New(tsProto)")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " stringValue := wrapperspb.String(t.(string))")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " anyProto, err := anypb.New(stringValue)")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " _ = err // do something with err someday (?)")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " r.Vals = append(r.Vals, anyProto)")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " // return col.Vals[row] true")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " case guipb.ColAttr_INT:")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " var finalInt int")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " finalInt = t.(int)")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " intVal := wrapperspb.Int32(int32(finalInt))")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " anyProto, _ := anypb.New(intVal)")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " r.Vals = append(r.Vals, anyProto)")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " case guipb.ColAttr_DURATION:")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " case guipb.ColAttr_TIME:")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " var goTime time.Time")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " goTime = t.(time.Time)")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " tsProto := timestamppb.New(goTime)")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " anyProto, err := anypb.New(tsProto)")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " _ = err // do something with err someday (?)")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " r.Vals = append(r.Vals, anyProto)")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " default:")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " log.Info(\"cell unhandled type\", r.Attr.Type)")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " }")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " // cellTime := r.Vals[row]")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " // s := shell.FormatDuration(time.Since(cellTime.AsTime()))")
|
|
|
|
fmt.Fprintln(w, " }")
|
|
|
|
fmt.Fprintln(w, " }")
|
|
|
|
fmt.Fprintln(w, " mt.pb.TimeRows = append(mt.pb.TimeRows, r)")
|
|
|
|
fmt.Fprintln(w, "")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " mt.pb.AnyCols = append(mt.pb.AnyCols, r)")
|
|
|
|
fmt.Fprintln(w, " return true")
|
|
|
|
fmt.Fprintln(w, " return true")
|
|
|
|
fmt.Fprintln(w, " }")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " return false")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, "}")
|
|
|
|
fmt.Fprintln(w, "}")
|
|
|
|
fmt.Fprintln(w, "")
|
|
|
|
fmt.Fprintln(w, "")
|
|
|
|
fmt.Fprintln(w, "func (mt *"+FRUITS+"Table) MakeTable() {")
|
|
|
|
fmt.Fprintln(w, "func (mt *"+FRUITS+"Table) MakeTable() {")
|
|
|
|
fmt.Fprintln(w, " for _, name := range mt.pb.Order {")
|
|
|
|
fmt.Fprintln(w, " for _, sf := range mt.anyFuncs {")
|
|
|
|
fmt.Fprintln(w, " // log.Info(\""+ZOOPB+": looking for row name()\", name)")
|
|
|
|
fmt.Fprintln(w, " mt.doAnyFuncNew(sf)")
|
|
|
|
fmt.Fprintln(w, " if mt.doStringFunc(name) {")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " continue")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " }")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " if mt.doIntFunc(name) {")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " continue")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " }")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " if mt.doTimeFunc(name) {")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " continue")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " }")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " if mt.doButtonFunc(name) {")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " continue")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " }")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " }")
|
|
|
|
fmt.Fprintln(w, " }")
|
|
|
|
fmt.Fprintln(w, "}")
|
|
|
|
fmt.Fprintln(w, "}")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func guiAddStringFunc(w io.Writer, FRUITS string, FRUIT string, BRAND string) {
|
|
|
|
func guiAddStringFunc(w io.Writer, FRUITS string, FRUIT string, BRAND string) {
|
|
|
|
fmt.Fprintln(w, "")
|
|
|
|
fmt.Fprintln(w, "")
|
|
|
|
fmt.Fprintln(w, "func (t *"+FRUITS+"Table) Add"+BRAND+"() *"+FRUIT+"StringFunc {")
|
|
|
|
fmt.Fprintln(w, "func (t *"+FRUITS+"Table) Add"+BRAND+"() *"+FRUIT+"AnyFunc {")
|
|
|
|
fmt.Fprintln(w, " sf := t.AddStringFunc(\""+BRAND+"\", func(m *"+FRUIT+") string {")
|
|
|
|
fmt.Fprintln(w, " sf := t.AddStringFunc(\""+BRAND+"\", func(m *"+FRUIT+") string {")
|
|
|
|
fmt.Fprintln(w, " return m."+BRAND+"")
|
|
|
|
fmt.Fprintln(w, " return m."+BRAND+"")
|
|
|
|
fmt.Fprintln(w, " })")
|
|
|
|
fmt.Fprintln(w, " })")
|
|
|
@ -392,22 +298,12 @@ func guiAddStringFunc(w io.Writer, FRUITS string, FRUIT string, BRAND string) {
|
|
|
|
|
|
|
|
|
|
|
|
func guiAddIntFunc(w io.Writer, FRUITS string, FRUIT string, BRAND string) {
|
|
|
|
func guiAddIntFunc(w io.Writer, FRUITS string, FRUIT string, BRAND string) {
|
|
|
|
fmt.Fprintln(w, "")
|
|
|
|
fmt.Fprintln(w, "")
|
|
|
|
fmt.Fprintln(w, "func (t *"+FRUITS+"Table) Add"+BRAND+"() {")
|
|
|
|
fmt.Fprintln(w, "func (t *"+FRUITS+"Table) Add"+BRAND+"() *"+FRUIT+"AnyFunc {")
|
|
|
|
fmt.Fprintln(w, " t.AddIntFunc(\""+BRAND+"\", func(m *"+FRUIT+") int {")
|
|
|
|
fmt.Fprintln(w, " custf := t.AddIntFunc(\""+BRAND+"\", func(m *"+FRUIT+") int {")
|
|
|
|
fmt.Fprintln(w, " return int(m."+BRAND+")")
|
|
|
|
fmt.Fprintln(w, " return int(m."+BRAND+")")
|
|
|
|
fmt.Fprintln(w, " })")
|
|
|
|
fmt.Fprintln(w, " })")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " return custf")
|
|
|
|
fmt.Fprintln(w, "}")
|
|
|
|
fmt.Fprintln(w, "}")
|
|
|
|
/*
|
|
|
|
|
|
|
|
// examples of what these look like
|
|
|
|
|
|
|
|
fmt.Fprintln(w, "func (t *"+FRUITS+"Table) AddMemory() {")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " t.pb.Order = append(t.pb.Order, \"Memory\")")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, "}")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, "")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, "func (t *"+FRUITS+"Table) AddCpus() {")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " t.pb.Order = append(t.pb.Order, \"Cpus\")")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, "}")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, "")
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func guiUpdate(w io.Writer, FRUITS string, FRUIT string) {
|
|
|
|
func guiUpdate(w io.Writer, FRUITS string, FRUIT string) {
|
|
|
@ -416,28 +312,10 @@ func guiUpdate(w io.Writer, FRUITS string, FRUIT string) {
|
|
|
|
fmt.Fprintln(w, "}")
|
|
|
|
fmt.Fprintln(w, "}")
|
|
|
|
fmt.Fprintln(w, "")
|
|
|
|
fmt.Fprintln(w, "")
|
|
|
|
|
|
|
|
|
|
|
|
fmt.Fprintln(w, "// START TABLE UPDATE")
|
|
|
|
fmt.Fprintln(w, "// START TABLE UPDATE (doesn't work yet)")
|
|
|
|
fmt.Fprintln(w, "func (mt *"+FRUITS+"Table) todoUpdate() {")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " for _, name := range mt.pb.Order {")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " // log.Info(\""+FRUIT+"pb: trying to update row()\", name)")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " if mt.updateStringFunc(name) {")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " continue")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " }")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " if mt.updateTimeFunc(name) {")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " continue")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " }")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " /*")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " if mt.updateIntFunc(name) {")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " continue")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " }")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " */")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " }")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " // mt.dumpStringFunc(\"Hostname\")")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " mt.parent.UpdateTable(mt.pb)")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, "}")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, "")
|
|
|
|
fmt.Fprintln(w, "")
|
|
|
|
fmt.Fprintln(w, "func (mt *"+FRUITS+"Table) dumpStringFunc(name string) {")
|
|
|
|
fmt.Fprintln(w, "func (mt *"+FRUITS+"Table) dumpStringFunc(name string) {")
|
|
|
|
fmt.Fprintln(w, " for i, r := range mt.pb.StringRows {")
|
|
|
|
fmt.Fprintln(w, " for i, r := range mt.pb.StringCols {")
|
|
|
|
fmt.Fprintln(w, " // log.Info(\"could use\", i, r.Header.Name, \"for name =\", name)")
|
|
|
|
fmt.Fprintln(w, " // log.Info(\"could use\", i, r.Header.Name, \"for name =\", name)")
|
|
|
|
fmt.Fprintln(w, " if r.Header.Name == name {")
|
|
|
|
fmt.Fprintln(w, " if r.Header.Name == name {")
|
|
|
|
fmt.Fprintln(w, " log.Info(\"dump Strings row\", i, r.Header.Name, r.Vals)")
|
|
|
|
fmt.Fprintln(w, " log.Info(\"dump Strings row\", i, r.Header.Name, r.Vals)")
|
|
|
@ -446,70 +324,6 @@ func guiUpdate(w io.Writer, FRUITS string, FRUIT string) {
|
|
|
|
fmt.Fprintln(w, " }")
|
|
|
|
fmt.Fprintln(w, " }")
|
|
|
|
fmt.Fprintln(w, "}")
|
|
|
|
fmt.Fprintln(w, "}")
|
|
|
|
fmt.Fprintln(w, "")
|
|
|
|
fmt.Fprintln(w, "")
|
|
|
|
fmt.Fprintln(w, "func (mt *"+FRUITS+"Table) updateStringFunc(name string) bool {")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " // log.Info(\"LOOKING FOR STRING row\", name)")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " var found *guipb.StringRow")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " for _, r := range mt.pb.StringRows {")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " // log.Info(\"could use\", i, r.Header.Name, \"for name =\", name)")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " if r.Header.Name == name {")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " // log.Info(\"found row\", i, r.Header.Name)")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " found = r")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " break")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " }")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " }")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " if found == nil {")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " log.Info(\"did not find string row\", name)")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " return false")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " }")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " for _, sf := range mt.stringFuncs {")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " if sf.title != name {")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " continue")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " }")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " // log.Info(\""+FRUIT+"pb: starting\", name, found.Vals)")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " for i, _ := range found.Vals {")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " tmp := sf.f(mt.x."+FRUITS+"[i])")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " if tmp == \"www.wit.com\" {")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " log.Info(\"virtpb: FOUND WWW\", i)")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " tmp = \"new.www\"")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " }")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " found.Vals[i] = tmp")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " }")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " // log.Info(\""+FRUIT+"pb: ending\", name, found.Vals)")
|
|
|
|
|
|
|
|
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) updateTimeFunc(name string) bool {")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " log.Info(\"LOOKING FOR TIME row\", name)")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " var found *guipb.TimeRow")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " for i, r := range mt.pb.TimeRows {")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " // log.Info(\"could use\", i, r.Header.Name, \"for name =\", name)")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " if r.Header.Name == name {")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " log.Info(\"found row\", i, r.Header.Name)")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " found = r")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " break")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " }")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " }")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " if found == nil {")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " log.Info(\"did not find time row\", name)")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " return false")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " }")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " for _, sf := range mt.timeFuncs {")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " if sf.title != name {")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " continue")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " }")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " // log.Info(\"updateTimeFunc() has row len =\", len(mt.x."+FRUITS+"))")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " // log.Info(\"virtpb: starting\", name, found.Vals)")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " for i, _ := range found.Vals {")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " newt := sf.f(mt.x."+FRUITS+"[i])")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " found.Vals[i] = timestamppb.New(newt) // convert to protobuf time")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " }")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " // log.Info(\"virtpb: ending\", name, found.Vals)")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " return true")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " }")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " return false")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, "}")
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func guiTableDelete(w io.Writer, FRUITS string, FRUIT string) {
|
|
|
|
func guiTableDelete(w io.Writer, FRUITS string, FRUIT string) {
|
|
|
@ -530,9 +344,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, " 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, " // log.Info(\"got to "+fRUITS+"Custom() with\", w.Location.X, w.Location.Y-1)")
|
|
|
|
fmt.Fprintln(w, "")
|
|
|
|
fmt.Fprintln(w, "")
|
|
|
|
fmt.Fprintln(w, " for _, sf := range mt.buttonFuncs {")
|
|
|
|
fmt.Fprintln(w, " for i, sf := range mt.anyFuncs {")
|
|
|
|
fmt.Fprintln(w, " if sf.order == int(w.Location.X) {")
|
|
|
|
fmt.Fprintln(w, " if i == int(w.Location.X) {")
|
|
|
|
fmt.Fprintln(w, " // log.Info(\"found order\", sf.order)")
|
|
|
|
|
|
|
|
fmt.Fprintln(w, " if sf.Custom != nil {")
|
|
|
|
fmt.Fprintln(w, " if sf.Custom != nil {")
|
|
|
|
fmt.Fprintln(w, " log.Info(\"doing Custom() func for button\")")
|
|
|
|
fmt.Fprintln(w, " log.Info(\"doing Custom() func for button\")")
|
|
|
|
fmt.Fprintln(w, " sf.Custom(row)")
|
|
|
|
fmt.Fprintln(w, " sf.Custom(row)")
|
|
|
|