autohide working well

log flags window
    debugging window
    Display buttons cleaned up
    get go.wit.com/list of repos

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-01-20 16:09:15 -06:00
parent db36cef85a
commit d67ace479a
5 changed files with 157 additions and 62 deletions

View File

@ -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

View File

@ -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()
})
}

View File

@ -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.Hide()
}
}
} else {
for repo, _ := range me.allrepos {
repo.Show()
}
// return
}
}
})
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
}
}
}

View File

@ -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

124
listWindow.go Normal file
View File

@ -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")
}