autotypist/main.go

91 lines
2.0 KiB
Go
Raw Normal View History

package main
import (
"embed"
"time"
"go.wit.com/lib/debugger"
"go.wit.com/log"
"go.wit.com/gui"
)
//go:embed resources/*
var resToolkit embed.FS
func main() {
me = new(autoType)
me.allrepos = make(map[string]*repo)
me.myGui = gui.New()
me.myGui.InitEmbed(resToolkit)
me.myGui.Default()
me.autotypistWindow = me.myGui.NewWindow("autotypist: it types faster than you can.")
2024-02-13 16:18:37 -06:00
me.mainbox = me.autotypistWindow.NewBox("bw hbox", true)
2024-02-13 16:18:37 -06:00
vbox1 := me.mainbox.NewVerticalBox("BOX1")
globalDisplayOptions(vbox1)
docsBox(vbox1)
if debugger.ArgDebug() {
debuggerBox(vbox1)
}
2024-02-13 16:18:37 -06:00
// disable the interface while everything is scanned
me.Disable()
2024-02-13 16:18:37 -06:00
vbox2 := me.mainbox.NewVerticalBox("BOX2")
globalBuildOptions(vbox2)
me.summary = submitPatchesBox(vbox2)
2024-02-13 16:18:37 -06:00
globalResetOptions(me.mainbox)
repolistWindow()
// process everything on the command line
handleCmdLine()
for _, repo := range me.allrepos {
repo.newScan()
}
2024-02-13 16:18:37 -06:00
me.Enable()
2024-02-14 13:43:43 -06:00
// processing is done. update the repo summary box
me.summary.Update()
2024-02-16 17:55:53 -06:00
// scan repos every i seconds
// check every 'delay seconds for the checkbox changing
// this logic is unintuitive because I want it to fluidly
// never tricker quickly but also want to print something
// out that the app is alive since, technically
// the GUI is *NOT* this app and could be alive when
// the application is actually stalled somewhere
// plus these things are fun for me and a distraction when
// I've been working 50 days in a row on this gui code
// this also means that if you click the checkbox after
// the delay, then the scan will run right away, but if
// you check the checkbox twice in 5 seconds, it won't
// rerun until the delay again
var delay int = 99
var i int = delay
myTicker(1*time.Second, "newScan()", func() {
i += 1
2024-02-16 17:55:53 -06:00
// check if the checkbox is checked
if !me.autoScanReposCB.Checked() {
if i < delay {
i = delay
}
2024-02-16 17:55:53 -06:00
// print every 'delay' seconds
if i%delay == 0 {
log.Info("Not auto scanning", i)
}
return
}
2024-02-16 17:55:53 -06:00
if i < delay {
return
}
i = 0
2024-02-16 17:55:53 -06:00
scanRepositories()
})
}