2024-01-16 11:14:30 -06:00
|
|
|
// This is a simple example
|
|
|
|
package main
|
|
|
|
|
2024-01-18 00:58:14 -06:00
|
|
|
import (
|
2024-02-06 04:03:17 -06:00
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
|
2024-01-18 05:03:04 -06:00
|
|
|
"go.wit.com/gui"
|
2024-01-20 17:17:48 -06:00
|
|
|
"go.wit.com/lib/debugger"
|
2024-02-07 13:04:25 -06:00
|
|
|
"go.wit.com/lib/gadgets"
|
2024-01-20 16:09:15 -06:00
|
|
|
"go.wit.com/lib/gui/logsettings"
|
2024-02-06 04:03:17 -06:00
|
|
|
"go.wit.com/log"
|
2024-01-16 11:14:30 -06:00
|
|
|
// "go.wit.com/gui/gadgets"
|
|
|
|
)
|
|
|
|
|
2024-01-26 09:34:42 -06:00
|
|
|
func globalDisplaySetRepoState() {
|
2024-01-25 13:09:33 -06:00
|
|
|
for _, repo := range me.allrepos {
|
|
|
|
if me.autoHideReadOnly.Checked() {
|
|
|
|
if repo.status.ReadOnly() {
|
|
|
|
repo.Hide()
|
2024-01-26 09:34:42 -06:00
|
|
|
continue
|
2024-01-25 13:09:33 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if me.autoHidePerfect.Checked() {
|
|
|
|
if repo.dirtyLabel.String() == "PERFECT" {
|
|
|
|
repo.Hide()
|
2024-01-26 09:34:42 -06:00
|
|
|
continue
|
2024-01-25 13:09:33 -06:00
|
|
|
}
|
|
|
|
}
|
2024-01-26 09:34:42 -06:00
|
|
|
repo.Show()
|
2024-01-25 13:09:33 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func globalDisplayShow() {
|
|
|
|
for _, repo := range me.allrepos {
|
|
|
|
if me.autoHideReadOnly.Checked() {
|
|
|
|
if repo.status.ReadOnly() {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if me.autoHidePerfect.Checked() {
|
|
|
|
if repo.dirtyLabel.String() == "PERFECT" {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
}
|
|
|
|
repo.Show()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-16 11:14:30 -06:00
|
|
|
func globalDisplayOptions(box *gui.Node) {
|
2024-01-20 17:17:48 -06:00
|
|
|
vbox := box.NewVerticalBox("DISPLAYVBOX")
|
2024-01-16 11:14:30 -06:00
|
|
|
|
2024-01-20 17:17:48 -06:00
|
|
|
group1 := vbox.NewGroup("Global Display Options")
|
|
|
|
|
|
|
|
group1.NewButton("Show Repository Window", func() {
|
2024-01-26 09:34:42 -06:00
|
|
|
globalDisplaySetRepoState()
|
2024-01-19 18:37:27 -06:00
|
|
|
reposwin.Toggle()
|
2024-01-17 01:55:22 -06:00
|
|
|
})
|
2024-01-20 16:09:15 -06:00
|
|
|
|
2024-01-25 02:40:59 -06:00
|
|
|
me.autoHideReadOnly = group1.NewCheckbox("Hide read-only repos").SetChecked(true)
|
2024-01-25 11:11:43 -06:00
|
|
|
me.autoHideReadOnly.Custom = func() {
|
2024-01-25 02:50:16 -06:00
|
|
|
if me.autoHideReadOnly.Checked() {
|
2024-01-26 09:34:42 -06:00
|
|
|
globalDisplaySetRepoState()
|
2024-01-25 13:09:33 -06:00
|
|
|
} else {
|
|
|
|
globalDisplayShow()
|
2024-01-25 02:50:16 -06:00
|
|
|
}
|
|
|
|
}
|
2024-01-25 02:40:59 -06:00
|
|
|
|
2024-01-30 13:09:24 -06:00
|
|
|
me.autoHidePerfect = group1.NewCheckbox("Hide Perfectly clean repos").SetChecked(true)
|
2024-01-20 16:09:15 -06:00
|
|
|
me.autoHidePerfect.Custom = func() {
|
|
|
|
if me.autoHidePerfect.Checked() {
|
2024-01-26 09:34:42 -06:00
|
|
|
globalDisplaySetRepoState()
|
2024-01-20 16:09:15 -06:00
|
|
|
} else {
|
2024-01-25 13:09:33 -06:00
|
|
|
globalDisplayShow()
|
2024-01-16 11:14:30 -06:00
|
|
|
}
|
2024-01-20 16:09:15 -06:00
|
|
|
}
|
2024-01-26 02:04:19 -06:00
|
|
|
me.scanEveryMinute = group1.NewCheckbox("Scan every minute").SetChecked(false)
|
2024-01-16 11:56:55 -06:00
|
|
|
|
2024-02-06 04:03:17 -06:00
|
|
|
group1.NewButton("make go.work file", func() {
|
|
|
|
me.autotypistWindow.Disable()
|
|
|
|
defer me.autotypistWindow.Enable()
|
|
|
|
|
|
|
|
goSrcDir := me.goSrcPwd.String()
|
|
|
|
filename := filepath.Join(goSrcDir, "go.work")
|
|
|
|
|
|
|
|
f, err := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE, 0600)
|
2024-02-06 17:48:15 -06:00
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
2024-02-06 04:03:17 -06:00
|
|
|
defer f.Close()
|
|
|
|
fmt.Fprintln(f, "go 1.21.4")
|
|
|
|
fmt.Fprintln(f, "")
|
|
|
|
fmt.Fprintln(f, "use (")
|
|
|
|
for _, repo := range me.allrepos {
|
|
|
|
if repo.status.Exists("go.mod") {
|
|
|
|
fmt.Fprintln(f, "\t"+repo.String())
|
|
|
|
} else {
|
|
|
|
log.Info("missing go.mod for", repo.String())
|
|
|
|
repo.status.MakeRedomod()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fmt.Fprintln(f, ")")
|
|
|
|
})
|
|
|
|
|
2024-02-07 13:04:25 -06:00
|
|
|
var tagsW *tagWindow
|
|
|
|
group1.NewButton("tag Window", func() {
|
|
|
|
if tagsW == nil {
|
|
|
|
tagsW = makeTagWindow()
|
|
|
|
} else {
|
|
|
|
tagsW.win.Toggle()
|
2024-02-06 17:48:15 -06:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2024-02-07 13:04:25 -06:00
|
|
|
var listallB *gui.Node
|
|
|
|
var listW *gadgets.BasicWindow
|
|
|
|
listallB = group1.NewButton("go.wit.com Window", func() {
|
|
|
|
listallB.Disable()
|
|
|
|
if listW == nil {
|
|
|
|
listW = listWindow()
|
|
|
|
} else {
|
|
|
|
listW.Toggle()
|
2024-02-06 17:48:15 -06:00
|
|
|
}
|
2024-02-07 13:04:25 -06:00
|
|
|
listallB.Enable()
|
2024-02-06 17:48:15 -06:00
|
|
|
})
|
|
|
|
|
2024-01-20 17:17:48 -06:00
|
|
|
group2 := vbox.NewGroup("Debugger")
|
|
|
|
group2.NewButton("logging Window", func() {
|
2024-01-20 16:09:15 -06:00
|
|
|
logsettings.LogWindow()
|
|
|
|
})
|
2024-01-20 17:17:48 -06:00
|
|
|
|
|
|
|
group2.NewButton("Debugger Window", func() {
|
|
|
|
debugger.DebugWindow()
|
|
|
|
})
|
2024-01-16 11:14:30 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
func hidePerfect() {
|
2024-01-24 22:22:34 -06:00
|
|
|
for _, repo := range me.allrepos {
|
2024-01-17 03:57:17 -06:00
|
|
|
if repo.dirtyLabel.String() == "PERFECT" {
|
2024-01-16 11:14:30 -06:00
|
|
|
if repo.hidden {
|
|
|
|
continue
|
|
|
|
}
|
2024-01-19 18:37:27 -06:00
|
|
|
repo.Hide()
|
2024-01-16 11:14:30 -06:00
|
|
|
// return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|