diff --git a/Makefile b/Makefile index f78ec44..3b94bcf 100644 --- a/Makefile +++ b/Makefile @@ -5,9 +5,13 @@ stderr: build echo "writing to /tmp/autotypist.stderr" ./autotypist >/tmp/autotypist.stderr 2>&1 +goimports: + goimports -w *.go + # // to globally reset paths: + # // gofmt -w -r "go.wit.com/gui -> go.wit.com/gui/gui" . + build: echo "build it!" - goimports -w *.go -rm resources/*.so cp ~/go/src/go.wit.com/toolkits/*.so resources/ go build -v -x diff --git a/globalBuildOptions.go b/globalBuildOptions.go index a401e21..50ce353 100644 --- a/globalBuildOptions.go +++ b/globalBuildOptions.go @@ -194,9 +194,10 @@ func globalBuildOptions(box *gui.Node) { setGitCommands() }) groupvbox.NewButton("build all apps", func() { + listWindow() }) groupvbox.NewButton("Debugger", func() { - debugger.DebugWindow(me.myGui) + debugger.DebugWindow() }) } diff --git a/globalDisplayOptions.go b/globalDisplayOptions.go index f2595dd..dfa731e 100644 --- a/globalDisplayOptions.go +++ b/globalDisplayOptions.go @@ -3,37 +3,44 @@ package main import ( "go.wit.com/gui" + "go.wit.com/lib/gui/logsettings" // "go.wit.com/gui/gadgets" ) func globalDisplayOptions(box *gui.Node) { group1 := box.NewGroup("Global Display Options") groupvbox := group1.NewBox("bw vbox", false) - // grouphbox := groupvbox.NewBox("bw hbox", true) groupvbox.NewButton("Show Repository Window", func() { - // repoworld() reposwin.Toggle() }) + /* + groupvbox.NewButton("hide all", func() { + for repo, _ := range me.allrepos { + repo.Hide() + } + }) + groupvbox.NewButton("show all", func() { + for repo, _ := range me.allrepos { + repo.Show() + } + }) + */ + me.autoHidePerfect = groupvbox.NewCheckbox("Hide Perfectly clean repos").SetChecked(true) me.autoHidePerfect.Custom = func() { if me.autoHidePerfect.Checked() { - hidePerfect() - } else { - showAll() - } - } - - groupvbox.NewButton("show all", func() { - for repo, _ := range me.allrepos { - if repo.dirtyLabel.String() == "PERFECT" { - if repo.hidden { - repo.Show() + for repo, _ := range me.allrepos { + if repo.dirtyLabel.String() == "PERFECT" { + repo.Hide() } - // return + } + } else { + for repo, _ := range me.allrepos { + repo.Show() } } - }) + } groupvbox.NewButton("status.Update() all", func() { for repo, _ := range me.allrepos { @@ -46,6 +53,10 @@ func globalDisplayOptions(box *gui.Node) { repo.newScan() } }) + + groupvbox.NewButton("logging enable/disable", func() { + logsettings.LogWindow() + }) } func hidePerfect() { @@ -59,12 +70,3 @@ func hidePerfect() { } } } - -func showAll() { - for repo, _ := range me.allrepos { - if repo.hidden { - repo.Show() - repo.hidden = false - } - } -} diff --git a/globalResetOptions.go b/globalResetOptions.go index b75c776..fca623c 100644 --- a/globalResetOptions.go +++ b/globalResetOptions.go @@ -9,42 +9,6 @@ func globalResetOptions(box *gui.Node) { group2 := box.NewGroup("Global Destructive Options") buildOptions := group2.NewGrid("buildOptions", 2, 1) - buildOptions.NewLabel("global path reset") - // to globally reset paths: - // gofmt -w -r "go.wit.com/gui -> go.wit.com/gui/gui" . - buildOptions.NewButton("Find", func() { - log.Warn("delete every repo marked PERFECT") - var newCmds [][]string - for repo, _ := range me.allrepos { - status := repo.getStatus() - if status == "PERFECT" { - var line []string - line = append(line, "rm", "-rf", "go/src/"+repo.path) - newCmds = append(newCmds, line) - } - } - me.script = newCmds - doit.Enable() - setGitCommands() - }) - - buildOptions.NewLabel("delete PERFECT") - buildOptions.NewButton("Find", func() { - log.Warn("delete every repo marked PERFECT") - var newCmds [][]string - for repo, path := range me.allrepos { - status := repo.getStatus() - if status == "PERFECT" { - var line []string - line = append(line, "rm", "-rf", "go/src/"+path) - newCmds = append(newCmds, line) - } - } - me.script = newCmds - doit.Enable() - setGitCommands() - }) - buildOptions.NewLabel("start over") buildOptions.NewButton("rm ~/go/src & ~/go/pkg", func() { var newCmds [][]string diff --git a/listWindow.go b/listWindow.go new file mode 100644 index 0000000..5bcb9d7 --- /dev/null +++ b/listWindow.go @@ -0,0 +1,124 @@ +// This is a simple example +package main + +import ( + "io/ioutil" + "net/http" + "strings" + + "go.wit.com/gui" + "go.wit.com/log" + + "go.wit.com/lib/gadgets" +) + +var lw *gadgets.BasicWindow +var allsections []*section + +type section struct { + name string + parent *gui.Node + box *gui.Node + group *gui.Node + checkbox *gui.Node + repos []*gui.Node +} + +func listWindow() { + if lw != nil { + lw.Toggle() + return + } + lw = gadgets.NewBasicWindow(me.myGui, "go.wit.com repositories") + lw.Custom = func() { + log.Warn("got to close") + } + + lw.Make() + lw.StandardClose() + lw.Draw() + box := lw.Box() + group := box.NewGroup("list") + group.NewButton("blah", func() {}) + + var lines []string + var curs *section + + lines = dumpURL("https://go.wit.com/list") + for i, line := range lines { + if line == "" { + continue + } + if line[0] == '#' { + curs = NewSection(group, line) + log.Warn("new group:", line) + continue + } + log.Warn(i, line) + parts := strings.Split(line, " ") + if curs != nil { + curs.add(parts[0]) + } + } +} + +func (s *section) add(path string) { + if s == nil { + return + } + tmp := s.parent.NewLabel(path) + s.repos = append(s.repos, tmp) +} + +func NewSection(parent *gui.Node, path string) *section { + news := new(section) + news.parent = parent + news.box = news.parent.NewBox("bw vbox", true) + news.group = news.box.NewGroup(path) + news.checkbox = news.box.NewCheckbox("hide") + news.checkbox.Custom = func() { + news.toggle() + } + allsections = append(allsections, news) + return news +} + +func (s *section) toggle() { + log.Warn(s.name) + for i, n := range s.repos { + log.Warn(i, n.String()) + n.Hide() + } +} + +/* +func dumpURL(url string) string { + resp, err := http.Get(url) + if err != nil { + return "" + } + defer resp.Body.Close() + + return resp.Body.String() + + _, err = io.Copy(os.Stdout, resp.Body) + if err != nil { + return "" + } +} +*/ + +func dumpURL(url string) []string { + resp, err := http.Get(url) + if err != nil { + return nil + } + defer resp.Body.Close() + + bodyBytes, err := ioutil.ReadAll(resp.Body) + if err != nil { + return nil + } + + return strings.Split(string(bodyBytes), "\n") +}