parent
939e87c2e9
commit
f3d6daa29e
6
args.go
6
args.go
|
@ -27,11 +27,11 @@ func ArgDebug() bool {
|
||||||
func init() {
|
func init() {
|
||||||
arg.Register(&argDebugger)
|
arg.Register(&argDebugger)
|
||||||
|
|
||||||
full := "go.wit.com/gui/debugger"
|
full := "go.wit.com/bug/debugger"
|
||||||
short := "bugger"
|
short := "bugger"
|
||||||
|
|
||||||
INFO = log.NewFlag("INFO", false, full, short, "simple debugging Info()")
|
INFO = log.NewFlag("INFO", false, full, short, "simple debugging Info()")
|
||||||
POLL = log.NewFlag("POLL", false, full, short, "watch the debugger poll things")
|
POLL = log.NewFlag("POLL", false, full, short, "watch the debugger poll things")
|
||||||
CHAN = log.NewFlag("CHAN", true, full, short, "chan() test code output")
|
CHAN = log.NewFlag("CHAN", true, full, short, "chan() test code output")
|
||||||
WARN = log.NewFlag("WARN", true, full, short, "should warn the user")
|
WARN = log.NewFlag("WARN", true, full, short, "should warn the user")
|
||||||
}
|
}
|
||||||
|
|
110
chan.go
110
chan.go
|
@ -7,11 +7,11 @@ package debugger
|
||||||
import (
|
import (
|
||||||
// "regexp"
|
// "regexp"
|
||||||
// "go.wit.com/gui/toolkit"
|
// "go.wit.com/gui/toolkit"
|
||||||
"sync"
|
|
||||||
"runtime"
|
|
||||||
"github.com/sourcegraph/conc"
|
"github.com/sourcegraph/conc"
|
||||||
"github.com/sourcegraph/conc/stream"
|
|
||||||
"github.com/sourcegraph/conc/panics"
|
"github.com/sourcegraph/conc/panics"
|
||||||
|
"github.com/sourcegraph/conc/stream"
|
||||||
|
"runtime"
|
||||||
|
"sync"
|
||||||
|
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
@ -60,65 +60,65 @@ func ExampleCatcher(f func()) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func mapStream(
|
func mapStream(
|
||||||
in chan int,
|
in chan int,
|
||||||
out chan int,
|
out chan int,
|
||||||
f func(int) int,
|
f func(int) int,
|
||||||
) {
|
) {
|
||||||
tasks := make(chan func())
|
tasks := make(chan func())
|
||||||
taskResults := make(chan chan int)
|
taskResults := make(chan chan int)
|
||||||
|
|
||||||
// Worker goroutines
|
// Worker goroutines
|
||||||
var workerWg sync.WaitGroup
|
var workerWg sync.WaitGroup
|
||||||
for i := 0; i < 10; i++ {
|
for i := 0; i < 10; i++ {
|
||||||
workerWg.Add(1)
|
workerWg.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
defer workerWg.Done()
|
defer workerWg.Done()
|
||||||
for task := range tasks {
|
for task := range tasks {
|
||||||
task()
|
task()
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ordered reader goroutines
|
// Ordered reader goroutines
|
||||||
var readerWg sync.WaitGroup
|
var readerWg sync.WaitGroup
|
||||||
readerWg.Add(1)
|
readerWg.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
defer readerWg.Done()
|
defer readerWg.Done()
|
||||||
for result := range taskResults {
|
for result := range taskResults {
|
||||||
item := <-result
|
item := <-result
|
||||||
out <- item
|
out <- item
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// Feed the workers with tasks
|
// Feed the workers with tasks
|
||||||
for elem := range in {
|
for elem := range in {
|
||||||
resultCh := make(chan int, 1)
|
resultCh := make(chan int, 1)
|
||||||
taskResults <- resultCh
|
taskResults <- resultCh
|
||||||
tasks <- func() {
|
tasks <- func() {
|
||||||
resultCh <- f(elem)
|
resultCh <- f(elem)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// We've exhausted input.
|
// We've exhausted input.
|
||||||
// Wait for everything to finish
|
// Wait for everything to finish
|
||||||
close(tasks)
|
close(tasks)
|
||||||
workerWg.Wait()
|
workerWg.Wait()
|
||||||
close(taskResults)
|
close(taskResults)
|
||||||
readerWg.Wait()
|
readerWg.Wait()
|
||||||
}
|
}
|
||||||
|
|
||||||
func mapStream2(
|
func mapStream2(
|
||||||
in chan int,
|
in chan int,
|
||||||
out chan int,
|
out chan int,
|
||||||
f func(int) int,
|
f func(int) int,
|
||||||
) {
|
) {
|
||||||
s := stream.New().WithMaxGoroutines(10)
|
s := stream.New().WithMaxGoroutines(10)
|
||||||
for elem := range in {
|
for elem := range in {
|
||||||
elem := elem
|
elem := elem
|
||||||
s.Go(func() stream.Callback {
|
s.Go(func() stream.Callback {
|
||||||
res := f(elem)
|
res := f(elem)
|
||||||
return func() { out <- res }
|
return func() { out <- res }
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
s.Wait()
|
s.Wait()
|
||||||
}
|
}
|
||||||
|
|
34
gochan.go
34
gochan.go
|
@ -7,9 +7,9 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"go.wit.com/log"
|
|
||||||
"go.wit.com/gui/gui"
|
"go.wit.com/gui/gui"
|
||||||
"go.wit.com/gui/gadgets"
|
"go.wit.com/lib/gadgets"
|
||||||
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
var debugWG *sync.WaitGroup
|
var debugWG *sync.WaitGroup
|
||||||
|
@ -24,8 +24,8 @@ func DebugGoChannels(p *gui.Node) *gadgets.BasicWindow {
|
||||||
g = w.Box().NewGroup("Channel stuff").Pad()
|
g = w.Box().NewGroup("Channel stuff").Pad()
|
||||||
|
|
||||||
// var debugWG sync.WaitGroup
|
// var debugWG sync.WaitGroup
|
||||||
g.NewButton("init()", func () {
|
g.NewButton("init()", func() {
|
||||||
if (debugNumberChan == nil) {
|
if debugNumberChan == nil {
|
||||||
log.Log(CHAN, "making debugNumberChan channel")
|
log.Log(CHAN, "making debugNumberChan channel")
|
||||||
debugNumberChan = make(chan int)
|
debugNumberChan = make(chan int)
|
||||||
} else {
|
} else {
|
||||||
|
@ -33,35 +33,35 @@ func DebugGoChannels(p *gui.Node) *gadgets.BasicWindow {
|
||||||
}
|
}
|
||||||
debugWG = new(sync.WaitGroup)
|
debugWG = new(sync.WaitGroup)
|
||||||
})
|
})
|
||||||
g.NewButton("go printInt(x) (read x values off the channel)", func () {
|
g.NewButton("go printInt(x) (read x values off the channel)", func() {
|
||||||
debugWG.Add(1)
|
debugWG.Add(1)
|
||||||
go printInt(2, "routine1")
|
go printInt(2, "routine1")
|
||||||
debugWG.Add(1)
|
debugWG.Add(1)
|
||||||
go printInt(2, "routine2")
|
go printInt(2, "routine2")
|
||||||
})
|
})
|
||||||
g.NewButton("sendNumber(2) (chan <- 2, 4)", func () {
|
g.NewButton("sendNumber(2) (chan <- 2, 4)", func() {
|
||||||
debugWG.Add(1)
|
debugWG.Add(1)
|
||||||
debugWG.Add(1)
|
debugWG.Add(1)
|
||||||
go sendNumber(2)
|
go sendNumber(2)
|
||||||
go sendNumber(4)
|
go sendNumber(4)
|
||||||
})
|
})
|
||||||
g.NewButton("sendNumber(1) (chan <- 7)", func () {
|
g.NewButton("sendNumber(1) (chan <- 7)", func() {
|
||||||
debugWG.Add(1)
|
debugWG.Add(1)
|
||||||
go sendNumber(7)
|
go sendNumber(7)
|
||||||
})
|
})
|
||||||
g.NewButton("send 4 numbers (chan <- int)", func () {
|
g.NewButton("send 4 numbers (chan <- int)", func() {
|
||||||
log.Log(CHAN, "generateNumbers(4)")
|
log.Log(CHAN, "generateNumbers(4)")
|
||||||
go generateNumbers(4)
|
go generateNumbers(4)
|
||||||
})
|
})
|
||||||
g.NewButton("debugWG.Done()", func () {
|
g.NewButton("debugWG.Done()", func() {
|
||||||
log.Log(CHAN, "ran debugWG.Done()")
|
log.Log(CHAN, "ran debugWG.Done()")
|
||||||
debugWG.Done()
|
debugWG.Done()
|
||||||
})
|
})
|
||||||
g.NewButton("close chan", func () {
|
g.NewButton("close chan", func() {
|
||||||
log.Log(CHAN, "close() on", debugNumberChan)
|
log.Log(CHAN, "close() on", debugNumberChan)
|
||||||
close(debugNumberChan)
|
close(debugNumberChan)
|
||||||
})
|
})
|
||||||
g.NewButton("print", func () {
|
g.NewButton("print", func() {
|
||||||
log.Log(CHAN, "waitgroup counter is ?")
|
log.Log(CHAN, "waitgroup counter is ?")
|
||||||
})
|
})
|
||||||
return w
|
return w
|
||||||
|
@ -92,9 +92,9 @@ func printInt(i int, name string) {
|
||||||
tmp := 1
|
tmp := 1
|
||||||
log.Log(CHAN, "START printInt", name, "read debugNumberChan()")
|
log.Log(CHAN, "START printInt", name, "read debugNumberChan()")
|
||||||
for num := range debugNumberChan {
|
for num := range debugNumberChan {
|
||||||
log.Log(CHAN, "printInt()",name, "read", num, "from channel")
|
log.Log(CHAN, "printInt()", name, "read", num, "from channel")
|
||||||
debugWG.Done()
|
debugWG.Done()
|
||||||
if (tmp == i) {
|
if tmp == i {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
tmp += 1
|
tmp += 1
|
||||||
|
|
46
golang.go
46
golang.go
|
@ -1,16 +1,16 @@
|
||||||
package debugger
|
package debugger
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"fmt"
|
||||||
// "os"
|
// "os"
|
||||||
"runtime"
|
"runtime"
|
||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
"runtime/pprof"
|
"runtime/pprof"
|
||||||
|
|
||||||
"go.wit.com/log"
|
|
||||||
"go.wit.com/gui/gui"
|
"go.wit.com/gui/gui"
|
||||||
"go.wit.com/gui/gadgets"
|
"go.wit.com/lib/gadgets"
|
||||||
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
func DebugGolangWindow(p *gui.Node) *gadgets.BasicWindow {
|
func DebugGolangWindow(p *gui.Node) *gadgets.BasicWindow {
|
||||||
|
@ -21,46 +21,46 @@ func DebugGolangWindow(p *gui.Node) *gadgets.BasicWindow {
|
||||||
w.Draw()
|
w.Draw()
|
||||||
g = w.Box().NewGroup("Language Internals").Pad()
|
g = w.Box().NewGroup("Language Internals").Pad()
|
||||||
|
|
||||||
g.NewButton("ReadModuleInfo()", func () {
|
g.NewButton("ReadModuleInfo()", func() {
|
||||||
tmp, _ := debug.ReadBuildInfo()
|
tmp, _ := debug.ReadBuildInfo()
|
||||||
outputTextbox.SetText(tmp.String())
|
outputTextbox.SetText(tmp.String())
|
||||||
})
|
})
|
||||||
g.NewButton("runtime.NumGoroutine()", func () {
|
g.NewButton("runtime.NumGoroutine()", func() {
|
||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
pprof.Lookup("goroutine").WriteTo(buf, 1)
|
pprof.Lookup("goroutine").WriteTo(buf, 1)
|
||||||
outputTextbox.SetText(buf.String())
|
outputTextbox.SetText(buf.String())
|
||||||
|
|
||||||
outputTextbox.AppendText(fmt.Sprintln("runtime.NumGoroutine() = ", runtime.NumGoroutine()))
|
outputTextbox.AppendText(fmt.Sprintln("runtime.NumGoroutine() = ", runtime.NumGoroutine()))
|
||||||
})
|
})
|
||||||
g.NewButton("pprof.Lookup(heap)", func () {
|
g.NewButton("pprof.Lookup(heap)", func() {
|
||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
pprof.Lookup("heap").WriteTo(buf, 1)
|
pprof.Lookup("heap").WriteTo(buf, 1)
|
||||||
outputTextbox.SetText(buf.String())
|
outputTextbox.SetText(buf.String())
|
||||||
})
|
})
|
||||||
g.NewButton("debug.PrintStack(current)", func () {
|
g.NewButton("debug.PrintStack(current)", func() {
|
||||||
outputTextbox.SetText(string(debug.Stack()))
|
outputTextbox.SetText(string(debug.Stack()))
|
||||||
})
|
})
|
||||||
g.NewButton("pprof.Lookup(goroutine)", func () {
|
g.NewButton("pprof.Lookup(goroutine)", func() {
|
||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
pprof.Lookup("goroutine").WriteTo(buf, 1)
|
pprof.Lookup("goroutine").WriteTo(buf, 1)
|
||||||
outputTextbox.SetText(buf.String())
|
outputTextbox.SetText(buf.String())
|
||||||
})
|
})
|
||||||
g.NewButton("pprof.Lookup(block)", func () {
|
g.NewButton("pprof.Lookup(block)", func() {
|
||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
pprof.Lookup("block").WriteTo(buf, 1)
|
pprof.Lookup("block").WriteTo(buf, 1)
|
||||||
outputTextbox.SetText(buf.String())
|
outputTextbox.SetText(buf.String())
|
||||||
})
|
})
|
||||||
g.NewButton("pprof.Lookup threadcreate", func () {
|
g.NewButton("pprof.Lookup threadcreate", func() {
|
||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
pprof.Lookup("threadcreate").WriteTo(buf, 1)
|
pprof.Lookup("threadcreate").WriteTo(buf, 1)
|
||||||
outputTextbox.SetText(buf.String())
|
outputTextbox.SetText(buf.String())
|
||||||
})
|
})
|
||||||
|
|
||||||
g.NewButton("runtime.ReadMemStats()", func () {
|
g.NewButton("runtime.ReadMemStats()", func() {
|
||||||
outputTextbox.SetText(runtimeReadMemStats())
|
outputTextbox.SetText(runtimeReadMemStats())
|
||||||
})
|
})
|
||||||
|
|
||||||
g.NewButton("debug.FreeOSMemory()", func () {
|
g.NewButton("debug.FreeOSMemory()", func() {
|
||||||
var out string = "Before debug.FreeOSMemory():\n\n"
|
var out string = "Before debug.FreeOSMemory():\n\n"
|
||||||
out += runtimeReadMemStats()
|
out += runtimeReadMemStats()
|
||||||
debug.FreeOSMemory()
|
debug.FreeOSMemory()
|
||||||
|
@ -69,7 +69,7 @@ func DebugGolangWindow(p *gui.Node) *gadgets.BasicWindow {
|
||||||
outputTextbox.SetText(out)
|
outputTextbox.SetText(out)
|
||||||
})
|
})
|
||||||
|
|
||||||
g.NewButton("debug.ReadGCStats()", func () {
|
g.NewButton("debug.ReadGCStats()", func() {
|
||||||
var tmp debug.GCStats
|
var tmp debug.GCStats
|
||||||
var out string
|
var out string
|
||||||
debug.ReadGCStats(&tmp)
|
debug.ReadGCStats(&tmp)
|
||||||
|
@ -83,11 +83,11 @@ func DebugGolangWindow(p *gui.Node) *gadgets.BasicWindow {
|
||||||
outputTextbox.SetText(out)
|
outputTextbox.SetText(out)
|
||||||
})
|
})
|
||||||
|
|
||||||
g.NewButton("debug.SetTraceback('all')", func () {
|
g.NewButton("debug.SetTraceback('all')", func() {
|
||||||
debug.SetTraceback("all")
|
debug.SetTraceback("all")
|
||||||
})
|
})
|
||||||
|
|
||||||
g.NewButton("panic()", func () {
|
g.NewButton("panic()", func() {
|
||||||
panic("test")
|
panic("test")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -95,36 +95,36 @@ func DebugGolangWindow(p *gui.Node) *gadgets.BasicWindow {
|
||||||
|
|
||||||
// g.NewLabel("TODO:")
|
// g.NewLabel("TODO:")
|
||||||
|
|
||||||
g.NewButton("runtime.Stack(true)", func () {
|
g.NewButton("runtime.Stack(true)", func() {
|
||||||
// TODO: https://stackoverflow.com/questions/61127053/how-to-list-all-the-running-goroutines-in-a-go-program
|
// TODO: https://stackoverflow.com/questions/61127053/how-to-list-all-the-running-goroutines-in-a-go-program
|
||||||
// func Stack(buf []byte, all bool) int
|
// func Stack(buf []byte, all bool) int
|
||||||
})
|
})
|
||||||
|
|
||||||
g.NewButton("debug.SetMemoryLimit(int)", func () {
|
g.NewButton("debug.SetMemoryLimit(int)", func() {
|
||||||
// TODO:
|
// TODO:
|
||||||
//debug.SetMemoryLimit(1024 * 1024 * 100)
|
//debug.SetMemoryLimit(1024 * 1024 * 100)
|
||||||
})
|
})
|
||||||
|
|
||||||
g.NewButton("debug.SetMaxStack(int bytes)", func () {
|
g.NewButton("debug.SetMaxStack(int bytes)", func() {
|
||||||
// default is apparently 1GB
|
// default is apparently 1GB
|
||||||
})
|
})
|
||||||
|
|
||||||
g.NewButton("debug.SetMaxThreads(int)", func () {
|
g.NewButton("debug.SetMaxThreads(int)", func() {
|
||||||
// default is apparently 10,000
|
// default is apparently 10,000
|
||||||
})
|
})
|
||||||
|
|
||||||
g.NewButton("debug.SetTraceback('all')", func () {
|
g.NewButton("debug.SetTraceback('all')", func() {
|
||||||
debug.SetTraceback("all")
|
debug.SetTraceback("all")
|
||||||
})
|
})
|
||||||
|
|
||||||
// deprecated (probably) by String() implementation within golang
|
// deprecated (probably) by String() implementation within golang
|
||||||
g.NewButton("dumpModuleInfo() (deprecate)", func () {
|
g.NewButton("dumpModuleInfo() (deprecate)", func() {
|
||||||
outputTextbox.SetText(dumpModuleInfo())
|
outputTextbox.SetText(dumpModuleInfo())
|
||||||
})
|
})
|
||||||
|
|
||||||
og = w.Box().NewGroup("output").Pad()
|
og = w.Box().NewGroup("output").Pad()
|
||||||
outputTextbox = og.NewTextbox("outputBox")
|
outputTextbox = og.NewTextbox("outputBox")
|
||||||
outputTextbox.Custom = func () {
|
outputTextbox.Custom = func() {
|
||||||
log.Log(INFO, "custom TextBox() for golang output a =", outputTextbox.String())
|
log.Log(INFO, "custom TextBox() for golang output a =", outputTextbox.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,7 +143,7 @@ func runtimeReadMemStats() string {
|
||||||
out += fmt.Sprintln("frees:", s.Frees)
|
out += fmt.Sprintln("frees:", s.Frees)
|
||||||
out += fmt.Sprintln("heap-alloc:", s.HeapAlloc, "bytes")
|
out += fmt.Sprintln("heap-alloc:", s.HeapAlloc, "bytes")
|
||||||
out += fmt.Sprintln("heap-sys:", s.HeapSys, "bytes")
|
out += fmt.Sprintln("heap-sys:", s.HeapSys, "bytes")
|
||||||
out += fmt.Sprintln("heap-idle:", s.HeapIdle,"bytes")
|
out += fmt.Sprintln("heap-idle:", s.HeapIdle, "bytes")
|
||||||
out += fmt.Sprintln("heap-in-use:", s.HeapInuse, "bytes")
|
out += fmt.Sprintln("heap-in-use:", s.HeapInuse, "bytes")
|
||||||
out += fmt.Sprintln("heap-released:", s.HeapReleased, "bytes")
|
out += fmt.Sprintln("heap-released:", s.HeapReleased, "bytes")
|
||||||
out += fmt.Sprintln("heap-objects:", s.HeapObjects)
|
out += fmt.Sprintln("heap-objects:", s.HeapObjects)
|
||||||
|
|
58
main.go
58
main.go
|
@ -1,12 +1,12 @@
|
||||||
package debugger
|
package debugger
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"go.wit.com/log"
|
|
||||||
"go.wit.com/gui/gui"
|
"go.wit.com/gui/gui"
|
||||||
"go.wit.com/gui/gadgets"
|
"go.wit.com/lib/gadgets"
|
||||||
"go.wit.com/gui/lib/logsettings"
|
"go.wit.com/lib/gui/logsettings"
|
||||||
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -14,7 +14,7 @@ import (
|
||||||
*/
|
*/
|
||||||
|
|
||||||
func DebugWindow(p *gui.Node) {
|
func DebugWindow(p *gui.Node) {
|
||||||
if (me != nil) {
|
if me != nil {
|
||||||
log.Warn("Draw then Toggle() debuging window here")
|
log.Warn("Draw then Toggle() debuging window here")
|
||||||
me.bugWin.Toggle()
|
me.bugWin.Toggle()
|
||||||
return
|
return
|
||||||
|
@ -22,7 +22,7 @@ func DebugWindow(p *gui.Node) {
|
||||||
me = new(debuggerSettings)
|
me = new(debuggerSettings)
|
||||||
me.myGui = p
|
me.myGui = p
|
||||||
|
|
||||||
me.bugWin = gadgets.NewBasicWindow(p,"go.wit.com/gui debug window")
|
me.bugWin = gadgets.NewBasicWindow(p, "go.wit.com/gui debug window")
|
||||||
me.bugWin.Draw()
|
me.bugWin.Draw()
|
||||||
DebugWindow2(me.bugWin.Box(), "Debug Tab")
|
DebugWindow2(me.bugWin.Box(), "Debug Tab")
|
||||||
|
|
||||||
|
@ -37,13 +37,13 @@ func DebugWindow(p *gui.Node) {
|
||||||
func DebugWindow2(newB *gui.Node, title string) *gui.Node {
|
func DebugWindow2(newB *gui.Node, title string) *gui.Node {
|
||||||
var gr *gui.Node
|
var gr *gui.Node
|
||||||
|
|
||||||
//////////////////////// main debug things //////////////////////////////////
|
//////////////////////// main debug things //////////////////////////////////
|
||||||
gr = newB.NewGroup("Debugging Windows:")
|
gr = newB.NewGroup("Debugging Windows:")
|
||||||
|
|
||||||
gr.NewButton("logging", func () {
|
gr.NewButton("logging", func() {
|
||||||
me.myLS.Toggle()
|
me.myLS.Toggle()
|
||||||
})
|
})
|
||||||
gr.NewButton("Widgets Window", func () {
|
gr.NewButton("Widgets Window", func() {
|
||||||
if me.widgets == nil {
|
if me.widgets == nil {
|
||||||
me.widgets = DebugWidgetWindow(me.myGui)
|
me.widgets = DebugWidgetWindow(me.myGui)
|
||||||
return
|
return
|
||||||
|
@ -53,58 +53,58 @@ func DebugWindow2(newB *gui.Node, title string) *gui.Node {
|
||||||
|
|
||||||
gr.NewLabel("Force Quit:")
|
gr.NewLabel("Force Quit:")
|
||||||
|
|
||||||
gr.NewButton("os.Exit()", func () {
|
gr.NewButton("os.Exit()", func() {
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
})
|
})
|
||||||
|
|
||||||
//////////////////////// window debugging things //////////////////////////////////
|
//////////////////////// window debugging things //////////////////////////////////
|
||||||
gr = newB.NewGroup("list things")
|
gr = newB.NewGroup("list things")
|
||||||
|
|
||||||
gr.NewButton("List toolkits", func () {
|
gr.NewButton("List toolkits", func() {
|
||||||
dropdownWindow(gr)
|
dropdownWindow(gr)
|
||||||
bugWin.ListToolkits()
|
bugWin.ListToolkits()
|
||||||
})
|
})
|
||||||
gr.NewButton("List Windows", func () {
|
gr.NewButton("List Windows", func() {
|
||||||
dropdownWindow(gr)
|
dropdownWindow(gr)
|
||||||
})
|
})
|
||||||
gr.NewButton("List Window Widgets", func () {
|
gr.NewButton("List Window Widgets", func() {
|
||||||
dropdownWindowWidgets(gr)
|
dropdownWindowWidgets(gr)
|
||||||
})
|
})
|
||||||
|
|
||||||
gr = newB.NewGroup("more things")
|
gr = newB.NewGroup("more things")
|
||||||
|
|
||||||
gr.NewButton("Node.ListChildren(true)", func () {
|
gr.NewButton("Node.ListChildren(true)", func() {
|
||||||
if (activeWidget == nil) {
|
if activeWidget == nil {
|
||||||
activeWidget = bugWin
|
activeWidget = bugWin
|
||||||
}
|
}
|
||||||
activeWidget.ListChildren(true)
|
activeWidget.ListChildren(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
gr.NewButton("test conc", func () {
|
gr.NewButton("test conc", func() {
|
||||||
log.Log(WARN, "TODO: fix me")
|
log.Log(WARN, "TODO: fix me")
|
||||||
// makeConc()
|
// makeConc()
|
||||||
})
|
})
|
||||||
|
|
||||||
gr.NewButton("List Plugins", func () {
|
gr.NewButton("List Plugins", func() {
|
||||||
log.Log(WARN, "TODO: fix me")
|
log.Log(WARN, "TODO: fix me")
|
||||||
/*
|
/*
|
||||||
for _, aplug := range allPlugins {
|
for _, aplug := range allPlugins {
|
||||||
log.Log(true, "Loaded plugin:", aplug.name, aplug.filename)
|
log.Log(true, "Loaded plugin:", aplug.name, aplug.filename)
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
})
|
})
|
||||||
|
|
||||||
gr.NewButton("load toolkit 'gocui'", func () {
|
gr.NewButton("load toolkit 'gocui'", func() {
|
||||||
bugWin.LoadToolkit("gocui")
|
bugWin.LoadToolkit("gocui")
|
||||||
})
|
})
|
||||||
|
|
||||||
gr.NewButton("load toolkit 'andlabs'", func () {
|
gr.NewButton("load toolkit 'andlabs'", func() {
|
||||||
bugWin.LoadToolkit("andlabs")
|
bugWin.LoadToolkit("andlabs")
|
||||||
})
|
})
|
||||||
|
|
||||||
gr = newB.NewGroup("Learn GO")
|
gr = newB.NewGroup("Learn GO")
|
||||||
|
|
||||||
gr.NewButton("GO Language Internals", func () {
|
gr.NewButton("GO Language Internals", func() {
|
||||||
if me.golang == nil {
|
if me.golang == nil {
|
||||||
me.golang = DebugGolangWindow(me.myGui)
|
me.golang = DebugGolangWindow(me.myGui)
|
||||||
return
|
return
|
||||||
|
@ -114,7 +114,7 @@ func DebugWindow2(newB *gui.Node, title string) *gui.Node {
|
||||||
me.golang.Toggle()
|
me.golang.Toggle()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
gr.NewButton("GO Channels debug", func () {
|
gr.NewButton("GO Channels debug", func() {
|
||||||
if me.gochan == nil {
|
if me.gochan == nil {
|
||||||
me.gochan = DebugGoChannels(me.myGui)
|
me.gochan = DebugGoChannels(me.myGui)
|
||||||
return
|
return
|
||||||
|
@ -140,7 +140,7 @@ func dropdownWindow(p *gui.Node) {
|
||||||
log.Log(INFO, "The Window was set to", name)
|
log.Log(INFO, "The Window was set to", name)
|
||||||
}
|
}
|
||||||
log.Log(INFO, "dd =", dd)
|
log.Log(INFO, "dd =", dd)
|
||||||
if (activeWidget == nil) {
|
if activeWidget == nil {
|
||||||
// the debug window doesn't exist yet so you can't display the change
|
// the debug window doesn't exist yet so you can't display the change
|
||||||
// TODO: make a fake binary tree for this(?)
|
// TODO: make a fake binary tree for this(?)
|
||||||
return
|
return
|
||||||
|
@ -152,7 +152,7 @@ func dropdownWindow(p *gui.Node) {
|
||||||
dd.AddText(child.GetProgName())
|
dd.AddText(child.GetProgName())
|
||||||
// last = child.Name
|
// last = child.Name
|
||||||
mapWindows[child.GetProgName()] = child
|
mapWindows[child.GetProgName()] = child
|
||||||
if (activeWidget == nil) {
|
if activeWidget == nil {
|
||||||
activeWidget = child
|
activeWidget = child
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -173,8 +173,8 @@ func dropdownWindowWidgets(p *gui.Node) {
|
||||||
|
|
||||||
// log.Log("dumpWidget() ", b, listChildrenDepth, defaultPadding, n.id, info)
|
// log.Log("dumpWidget() ", b, listChildrenDepth, defaultPadding, n.id, info)
|
||||||
|
|
||||||
var addDropdowns func (*gui.Node)
|
var addDropdowns func(*gui.Node)
|
||||||
addDropdowns = func (n *gui.Node) {
|
addDropdowns = func(n *gui.Node) {
|
||||||
// s := n.dumpWidget(true)
|
// s := n.dumpWidget(true)
|
||||||
s := n.GetProgName()
|
s := n.GetProgName()
|
||||||
dd.AddText(s)
|
dd.AddText(s)
|
||||||
|
|
17
structs.go
17
structs.go
|
@ -2,23 +2,23 @@ package debugger
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"go.wit.com/gui/gui"
|
"go.wit.com/gui/gui"
|
||||||
"go.wit.com/gui/gadgets"
|
"go.wit.com/lib/gadgets"
|
||||||
"go.wit.com/gui/lib/logsettings"
|
"go.wit.com/lib/gui/logsettings"
|
||||||
)
|
)
|
||||||
|
|
||||||
var me *debuggerSettings
|
var me *debuggerSettings
|
||||||
|
|
||||||
type debuggerSettings struct {
|
type debuggerSettings struct {
|
||||||
ready bool
|
ready bool
|
||||||
hidden bool
|
hidden bool
|
||||||
err error
|
err error
|
||||||
|
|
||||||
myGui *gui.Node
|
myGui *gui.Node
|
||||||
|
|
||||||
bugWin *gadgets.BasicWindow
|
bugWin *gadgets.BasicWindow
|
||||||
widgets *gadgets.BasicWindow
|
widgets *gadgets.BasicWindow
|
||||||
golang *gadgets.BasicWindow
|
golang *gadgets.BasicWindow
|
||||||
gochan *gadgets.BasicWindow
|
gochan *gadgets.BasicWindow
|
||||||
|
|
||||||
myLS *logsettings.LogSettings
|
myLS *logsettings.LogSettings
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@ type debuggerSettings struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
var bugWin *gui.Node
|
var bugWin *gui.Node
|
||||||
|
|
||||||
/*
|
/*
|
||||||
// main debugging window
|
// main debugging window
|
||||||
var bugTab *gui.Node
|
var bugTab *gui.Node
|
||||||
|
|
100
widget.go
100
widget.go
|
@ -1,16 +1,15 @@
|
||||||
package debugger
|
package debugger
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strconv"
|
|
||||||
"errors"
|
"errors"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"go.wit.com/log"
|
|
||||||
"go.wit.com/gui/gui"
|
"go.wit.com/gui/gui"
|
||||||
"go.wit.com/gui/widget"
|
"go.wit.com/lib/gadgets"
|
||||||
"go.wit.com/gui/gadgets"
|
"go.wit.com/lib/widget"
|
||||||
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
func setActiveWidget(w *gui.Node) {
|
func setActiveWidget(w *gui.Node) {
|
||||||
if (w == nil) {
|
if (w == nil) {
|
||||||
|
@ -59,22 +58,21 @@ func DebugWidgetWindow(p *gui.Node) *gadgets.BasicWindow {
|
||||||
g2 = g.NewGroup("bool B:")
|
g2 = g.NewGroup("bool B:")
|
||||||
activeLabelNewB = g2.NewCheckbox("tmp bool")
|
activeLabelNewB = g2.NewCheckbox("tmp bool")
|
||||||
|
|
||||||
|
|
||||||
// common things that should work against each widget
|
// common things that should work against each widget
|
||||||
g = w.Box().NewGroup("common things")
|
g = w.Box().NewGroup("common things")
|
||||||
g.NewButton("Enable()", func () {
|
g.NewButton("Enable()", func() {
|
||||||
activeWidget.Enable()
|
activeWidget.Enable()
|
||||||
})
|
})
|
||||||
g.NewButton("Disable()", func () {
|
g.NewButton("Disable()", func() {
|
||||||
activeWidget.Disable()
|
activeWidget.Disable()
|
||||||
})
|
})
|
||||||
g.NewButton("Show()", func () {
|
g.NewButton("Show()", func() {
|
||||||
activeWidget.Show()
|
activeWidget.Show()
|
||||||
})
|
})
|
||||||
g.NewButton("Hide()", func () {
|
g.NewButton("Hide()", func() {
|
||||||
activeWidget.Hide()
|
activeWidget.Hide()
|
||||||
})
|
})
|
||||||
g.NewButton("Dump()", func () {
|
g.NewButton("Dump()", func() {
|
||||||
activeWidget.Dump()
|
activeWidget.Dump()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -84,42 +82,42 @@ func DebugWidgetWindow(p *gui.Node) *gadgets.BasicWindow {
|
||||||
debugAddWidgetButtons(g)
|
debugAddWidgetButtons(g)
|
||||||
|
|
||||||
g = w.Box().NewGroup("change things")
|
g = w.Box().NewGroup("change things")
|
||||||
g.NewButton("AddText()", func () {
|
g.NewButton("AddText()", func() {
|
||||||
activeWidget.AddText(activeLabelNewName.String())
|
activeWidget.AddText(activeLabelNewName.String())
|
||||||
/*
|
/*
|
||||||
activeWidget.S = activeLabelNewName.S
|
activeWidget.S = activeLabelNewName.S
|
||||||
a := newAction(activeWidget, toolkit.AddText)
|
a := newAction(activeWidget, toolkit.AddText)
|
||||||
sendAction(a)
|
sendAction(a)
|
||||||
*/
|
*/
|
||||||
})
|
})
|
||||||
g.NewButton("SetText()", func () {
|
g.NewButton("SetText()", func() {
|
||||||
activeWidget.SetText(activeLabelNewName.String())
|
activeWidget.SetText(activeLabelNewName.String())
|
||||||
/*
|
/*
|
||||||
activeWidget.S = activeLabelNewName.String()
|
activeWidget.S = activeLabelNewName.String()
|
||||||
a := newAction(activeWidget, toolkit.SetText)
|
a := newAction(activeWidget, toolkit.SetText)
|
||||||
sendAction(a)
|
sendAction(a)
|
||||||
*/
|
*/
|
||||||
})
|
})
|
||||||
g.NewButton("Margin()", func () {
|
g.NewButton("Margin()", func() {
|
||||||
activeWidget.Margin()
|
activeWidget.Margin()
|
||||||
/*
|
/*
|
||||||
a := newAction(activeWidget, toolkit.Margin)
|
a := newAction(activeWidget, toolkit.Margin)
|
||||||
sendAction(a)
|
sendAction(a)
|
||||||
*/
|
*/
|
||||||
})
|
})
|
||||||
g.NewButton("Unmargin()", func () {
|
g.NewButton("Unmargin()", func() {
|
||||||
activeWidget.Unmargin()
|
activeWidget.Unmargin()
|
||||||
})
|
})
|
||||||
g.NewButton("Pad()", func () {
|
g.NewButton("Pad()", func() {
|
||||||
activeWidget.Pad()
|
activeWidget.Pad()
|
||||||
})
|
})
|
||||||
g.NewButton("Unpad()", func () {
|
g.NewButton("Unpad()", func() {
|
||||||
activeWidget.Unpad()
|
activeWidget.Unpad()
|
||||||
})
|
})
|
||||||
g.NewButton("Move(junk)", func () {
|
g.NewButton("Move(junk)", func() {
|
||||||
log.Warn("gui.Node Move() not implemented yet")
|
log.Warn("gui.Node Move() not implemented yet")
|
||||||
})
|
})
|
||||||
g.NewButton("Delete()", func () {
|
g.NewButton("Delete()", func() {
|
||||||
activeWidget.Delete(activeWidget)
|
activeWidget.Delete(activeWidget)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -127,7 +125,7 @@ func DebugWidgetWindow(p *gui.Node) *gadgets.BasicWindow {
|
||||||
activeJunk = w.Box().NewGroup("junk:")
|
activeJunk = w.Box().NewGroup("junk:")
|
||||||
activeJunk.NewLabel("test junk")
|
activeJunk.NewLabel("test junk")
|
||||||
|
|
||||||
if (activeWidget == nil) {
|
if activeWidget == nil {
|
||||||
setActiveWidget(me.myGui)
|
setActiveWidget(me.myGui)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,24 +133,24 @@ func DebugWidgetWindow(p *gui.Node) *gadgets.BasicWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
func debugAddWidgetButtons(n *gui.Node) {
|
func debugAddWidgetButtons(n *gui.Node) {
|
||||||
n.NewButton("Dropdown", func () {
|
n.NewButton("Dropdown", func() {
|
||||||
a := activeWidget.NewDropdown()
|
a := activeWidget.NewDropdown()
|
||||||
a.AddText("this is better than tcl/tk")
|
a.AddText("this is better than tcl/tk")
|
||||||
a.AddText("make something for tim for qflow")
|
a.AddText("make something for tim for qflow")
|
||||||
a.AddText("and for riscv")
|
a.AddText("and for riscv")
|
||||||
a.Custom = func () {
|
a.Custom = func() {
|
||||||
log.Log(WARN, "custom dropdown() a =", a.GetProgName(), a.String())
|
log.Log(WARN, "custom dropdown() a =", a.GetProgName(), a.String())
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
n.NewButton("Combobox", func () {
|
n.NewButton("Combobox", func() {
|
||||||
a := activeWidget.NewCombobox()
|
a := activeWidget.NewCombobox()
|
||||||
a.AddText("mirrors.wit.com")
|
a.AddText("mirrors.wit.com")
|
||||||
a.AddText("go.wit.com")
|
a.AddText("go.wit.com")
|
||||||
a.Custom = func () {
|
a.Custom = func() {
|
||||||
log.Log(WARN, "custom combobox() a =", a.GetProgName(), a.String())
|
log.Log(WARN, "custom combobox() a =", a.GetProgName(), a.String())
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
n.NewButton("Grid", func () {
|
n.NewButton("Grid", func() {
|
||||||
// Grid numbering by (X,Y)
|
// Grid numbering by (X,Y)
|
||||||
// -----------------------------
|
// -----------------------------
|
||||||
// -- (1,1) -- (2,1) -- (3,1) --
|
// -- (1,1) -- (2,1) -- (3,1) --
|
||||||
|
@ -163,25 +161,25 @@ func debugAddWidgetButtons(n *gui.Node) {
|
||||||
debugGrid = activeWidget.NewGrid("tmp grid", 2, 3)
|
debugGrid = activeWidget.NewGrid("tmp grid", 2, 3)
|
||||||
debugGridLabel = debugGrid.NewLabel("mirrors.wit.com")
|
debugGridLabel = debugGrid.NewLabel("mirrors.wit.com")
|
||||||
/*
|
/*
|
||||||
debugGrid.SetNext(0,1)
|
debugGrid.SetNext(0,1)
|
||||||
debugGrid.NewLabel("foo (0,1)")
|
debugGrid.NewLabel("foo (0,1)")
|
||||||
debugGrid.SetNext(1,1)
|
debugGrid.SetNext(1,1)
|
||||||
debugGrid.NewLabel("foo (1,1)")
|
debugGrid.NewLabel("foo (1,1)")
|
||||||
debugGrid.SetNext(2,1)
|
debugGrid.SetNext(2,1)
|
||||||
debugGrid.NewLabel("foo (2,1)")
|
debugGrid.NewLabel("foo (2,1)")
|
||||||
*/
|
*/
|
||||||
// SetDebug(false)
|
// SetDebug(false)
|
||||||
DebugWidgetWindow(debugGrid)
|
DebugWidgetWindow(debugGrid)
|
||||||
})
|
})
|
||||||
n.NewButton("Image", func () {
|
n.NewButton("Image", func() {
|
||||||
activeWidget.NewImage("image")
|
activeWidget.NewImage("image")
|
||||||
})
|
})
|
||||||
n.NewButton("Box(horizontal)", func () {
|
n.NewButton("Box(horizontal)", func() {
|
||||||
a := activeWidget.NewBox("hBox", true)
|
a := activeWidget.NewBox("hBox", true)
|
||||||
a.NewLabel("hBox")
|
a.NewLabel("hBox")
|
||||||
a.NewLabel("hBox 2")
|
a.NewLabel("hBox 2")
|
||||||
})
|
})
|
||||||
n.NewButton("Box(vertical)", func () {
|
n.NewButton("Box(vertical)", func() {
|
||||||
a := activeWidget.NewBox("vBox", false)
|
a := activeWidget.NewBox("vBox", false)
|
||||||
a.NewLabel("vBox")
|
a.NewLabel("vBox")
|
||||||
a.NewLabel("vBox 2")
|
a.NewLabel("vBox 2")
|
||||||
|
@ -211,13 +209,13 @@ func debugAddWidgetButton(n *gui.Node) {
|
||||||
activeLabelNewType.AddText("Color")
|
activeLabelNewType.AddText("Color")
|
||||||
activeLabelNewType.AddText("Dialog")
|
activeLabelNewType.AddText("Dialog")
|
||||||
|
|
||||||
n.NewButton("Add", func () {
|
n.NewButton("Add", func() {
|
||||||
name := activeLabelNewName.String()
|
name := activeLabelNewName.String()
|
||||||
newX := widget.GetInt(activeLabelNewX.String())
|
newX := widget.GetInt(activeLabelNewX.String())
|
||||||
newY := widget.GetInt(activeLabelNewY.String())
|
newY := widget.GetInt(activeLabelNewY.String())
|
||||||
newB := widget.GetBool(activeLabelNewB.String())
|
newB := widget.GetBool(activeLabelNewB.String())
|
||||||
|
|
||||||
if (newY == -1) {
|
if newY == -1 {
|
||||||
name = name + " (" + strconv.Itoa(activeWidget.NextW) + "," + strconv.Itoa(activeWidget.NextH) + ")"
|
name = name + " (" + strconv.Itoa(activeWidget.NextW) + "," + strconv.Itoa(activeWidget.NextH) + ")"
|
||||||
} else {
|
} else {
|
||||||
// activeWidget.SetNext(newX, newY)
|
// activeWidget.SetNext(newX, newY)
|
||||||
|
@ -243,19 +241,19 @@ func debugAddWidgetButton(n *gui.Node) {
|
||||||
case "Box":
|
case "Box":
|
||||||
activeWidget.NewBox(name, newB)
|
activeWidget.NewBox(name, newB)
|
||||||
case "Button":
|
case "Button":
|
||||||
activeWidget.NewButton(name, func () {
|
activeWidget.NewButton(name, func() {
|
||||||
log.Log(WARN, "got to button", name)
|
log.Log(WARN, "got to button", name)
|
||||||
})
|
})
|
||||||
case "Checkbox":
|
case "Checkbox":
|
||||||
a := activeWidget.NewCheckbox("DBG")
|
a := activeWidget.NewCheckbox("DBG")
|
||||||
a.Custom = func () {
|
a.Custom = func() {
|
||||||
log.Log(WARN, "custom checkox func a=", a.String())
|
log.Log(WARN, "custom checkox func a=", a.String())
|
||||||
}
|
}
|
||||||
case "Dropdown":
|
case "Dropdown":
|
||||||
a := activeWidget.NewDropdown()
|
a := activeWidget.NewDropdown()
|
||||||
a.AddText(name + " yay")
|
a.AddText(name + " yay")
|
||||||
a.AddText(name + " haha")
|
a.AddText(name + " haha")
|
||||||
a.Custom = func () {
|
a.Custom = func() {
|
||||||
log.Log(WARN, "WTF a=", a.String())
|
log.Log(WARN, "WTF a=", a.String())
|
||||||
}
|
}
|
||||||
case "Combobox":
|
case "Combobox":
|
||||||
|
|
Loading…
Reference in New Issue