From c00143ec9d932ac74dff2e9ae4d6d07928e4a857 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sat, 20 Jan 2024 20:04:05 -0600 Subject: [PATCH] general improvments better window open debugger works again new go mod Signed-off-by: Jeff Carr Signed-off-by: Jeff Carr --- Makefile | 3 +++ draw.go | 20 +++++++++----------- go.mod | 8 ++++---- go.sum | 16 ++++++++-------- settings.go | 16 ++++++++++++++-- structs.go | 1 + 6 files changed, 39 insertions(+), 25 deletions(-) diff --git a/Makefile b/Makefile index 18e55d2..9b0068f 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,9 @@ all: @echo @# ./myrepos >/tmp/myrepos.stderr 2>&1 +goimports: + goimports -w *.go + redomod: rm -f go.* goimports -w *.go diff --git a/draw.go b/draw.go index 6dc7405..99831a0 100644 --- a/draw.go +++ b/draw.go @@ -39,6 +39,8 @@ func (d *LogSettings) draw() { var g *gui.Node d.win = gadgets.NewBasicWindow(d.parent, "Debug Flags") + d.win.Make() + d.win.Draw() g = d.win.Box().NewGroup("Show").Pad() g = g.NewBox("bw vbox", false) d.buttonG = g @@ -50,7 +52,7 @@ func (d *LogSettings) draw() { g.NewButton("restore defaults", func() { for _, wg := range myLogGui.groups { for _, f := range wg.flags { - f.SetDefault() + f.RestoreDefault() } } }) @@ -58,7 +60,7 @@ func (d *LogSettings) draw() { g.NewButton("all on", func() { for _, wg := range myLogGui.groups { for _, f := range wg.flags { - f.Set(true) + f.SetValue(true) } } }) @@ -66,7 +68,7 @@ func (d *LogSettings) draw() { g.NewButton("all off", func() { for _, wg := range myLogGui.groups { for _, f := range wg.flags { - f.Set(false) + f.SetValue(false) } } }) @@ -77,7 +79,7 @@ func (d *LogSettings) draw() { for s, wg := range myLogGui.groups { log.Info("Dump Flags", s) for _, f := range wg.flags { - log.Info("Dump Flags\t", f.Get(), f.Name, ":", f.Desc) + log.Info("Dump Flags\t", f.Bool(), f.GetName(), ":", f.GetDesc()) } } }) @@ -112,13 +114,11 @@ func addFlag(p *gui.Node, newf *log.LogFlag) { } subsys := newf.GetSubsystem() - name := newf.GetName() if myLogGui.groups[subsys] == nil { flagWidgets = new(flagGroup) flagWidgets.parent = p - flagWidgets.name = subsys - flagWidgets.group = p.NewGroup(subsys) + flagWidgets.group = p.NewGroup(newf.GetSubsystem()) flagWidgets.grid = flagWidgets.group.NewGrid("flags grid", 3, 1) myLogGui.groups[subsys] = flagWidgets } else { @@ -126,19 +126,17 @@ func addFlag(p *gui.Node, newf *log.LogFlag) { } for _, f := range flagWidgets.flags { - if f.Name == name { + if f.GetName() == newf.GetName() { log.Info("addFlag() FOUND FLAG", f) return } } - log.Info("addFlag() Adding new flag:", subsys, name) + log.Info("addFlag() Adding new flag:", newf.GetSubsystem(), newf.GetName()) newWidget := gadgets.NewLogFlag(flagWidgets.grid, newf) flagWidgets.flags = append(flagWidgets.flags, newWidget) } type flagGroup struct { - name string // should be set to the flag.Subsystem - parent *gui.Node // where to draw our group group *gui.Node grid *gui.Node diff --git a/go.mod b/go.mod index 2441508..5521539 100644 --- a/go.mod +++ b/go.mod @@ -3,14 +3,14 @@ module go.wit.com/lib/gui/logsettings go 1.21.4 require ( - go.wit.com/gui v0.12.16 - go.wit.com/lib/gadgets v0.12.10 - go.wit.com/log v0.5.5 + go.wit.com/gui v0.12.19 + go.wit.com/lib/gadgets v0.12.13 + go.wit.com/log v0.5.6 ) require ( go.wit.com/dev/alexflint/arg v1.4.5 // indirect go.wit.com/dev/alexflint/scalar v1.2.1 // indirect go.wit.com/dev/davecgh/spew v1.1.4 // indirect - go.wit.com/widget v1.1.5 // indirect + go.wit.com/widget v1.1.6 // indirect ) diff --git a/go.sum b/go.sum index 7aaa747..db5adec 100644 --- a/go.sum +++ b/go.sum @@ -4,11 +4,11 @@ go.wit.com/dev/alexflint/scalar v1.2.1 h1:loXOcbVnd+8YeJRLey+XXidecBiedMDO00zQ26 go.wit.com/dev/alexflint/scalar v1.2.1/go.mod h1:+rYsfxqdI2cwA8kJ7GCMwWbNJvfvWUurOCXLiwdTtSs= go.wit.com/dev/davecgh/spew v1.1.4 h1:C9hj/rjlUpdK+E6aroyLjCbS5MFcyNUOuP1ICLWdNek= go.wit.com/dev/davecgh/spew v1.1.4/go.mod h1:sihvWmnQ/09FWplnEmozt90CCVqBtGuPXM811tgfhFA= -go.wit.com/gui v0.12.16 h1:GBiPiDyzkGCxwNegehHiONmNppaqyFZv7iteLUHJ/Po= -go.wit.com/gui v0.12.16/go.mod h1:27+THr2a84GZ61KKUuN30WYnYoSsBewllUKc+fnWLto= -go.wit.com/lib/gadgets v0.12.10 h1:zYKQurwuwACir6wTmiYgUprh3AvEX/b7SmEEweLaWOY= -go.wit.com/lib/gadgets v0.12.10/go.mod h1:Hb/vSiW22hPJjTVA1mShQ6HuqQ7dHGB95WLEfZlPO3M= -go.wit.com/log v0.5.5 h1:bK3b94uVKgev4jB5wg06FnvCFBEapQICTSH2YW+CWr4= -go.wit.com/log v0.5.5/go.mod h1:BaJBfHFqcJSJLXGQ9RHi3XVhPgsStxSMZRlaRxW4kAo= -go.wit.com/widget v1.1.5 h1:jx5hJ2WLZJnCcvMuaLHegzpNlzwo+0kOkzsRkzRiB30= -go.wit.com/widget v1.1.5/go.mod h1:I8tnD3x3ECbB/CRNnLCdC+uoyk7rK0AEkzK1bQYSqoQ= +go.wit.com/gui v0.12.19 h1:OEnsnZnec7Q2jZVjwl413V0wuVAAB4r2mGTY0IouBuw= +go.wit.com/gui v0.12.19/go.mod h1:v2VgnOL3dlZ13KclYeedZ1cd20nQdvwjyJTNKvFX3DA= +go.wit.com/lib/gadgets v0.12.13 h1:CEPUa+rH4VjmxtaWWSqvhgGEhpIjq8zuc01FIJ62xfA= +go.wit.com/lib/gadgets v0.12.13/go.mod h1:u+Syal5qdem7fEikOiEJdI+dO2zOybfa6vZ9ptF+bJ8= +go.wit.com/log v0.5.6 h1:rDC3ju95zfEads4f1Zm+QMkqjZ39CsYAT/UmQQs7VP4= +go.wit.com/log v0.5.6/go.mod h1:BaJBfHFqcJSJLXGQ9RHi3XVhPgsStxSMZRlaRxW4kAo= +go.wit.com/widget v1.1.6 h1:av2miF5vlohMfARA/QGPTPfgW/ADup1c+oeAOKgroPY= +go.wit.com/widget v1.1.6/go.mod h1:I8tnD3x3ECbB/CRNnLCdC+uoyk7rK0AEkzK1bQYSqoQ= diff --git a/settings.go b/settings.go index f7af7df..f3ab8ac 100644 --- a/settings.go +++ b/settings.go @@ -5,14 +5,26 @@ import ( "go.wit.com/log" ) +func LogWindow() *LogSettings { + if myLogGui != nil { + myLogGui.Toggle() + return myLogGui + } + myLogGui = NewWindow() + myLogGui.draw() + myLogGui.win.Toggle() + myLogGui.win.Toggle() + return myLogGui +} + // This initializes the main object // You can only have one of these -func New(p *gui.Node) *LogSettings { +func NewWindow() *LogSettings { if myLogGui != nil { return myLogGui } myLogGui = new(LogSettings) - myLogGui.parent = p + myLogGui.parent = gui.TreeRoot() myLogGui.groups = make(map[string]*flagGroup) myLogGui.ready = true myLogGui.hidden = true diff --git a/structs.go b/structs.go index c8323d1..54765b7 100644 --- a/structs.go +++ b/structs.go @@ -5,6 +5,7 @@ import ( "go.wit.com/lib/gadgets" ) +// there can be only one per application var myLogGui *LogSettings type LogSettings struct {