mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Make global variables local and pass as params instead
This commit is contained in:
parent
6b39deb3bf
commit
6437eff165
26
wtf.go
26
wtf.go
@ -107,7 +107,7 @@ func refreshAllWidgets() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func watchForConfigChanges(app *tview.Application, configFlag *string) {
|
func watchForConfigChanges(app *tview.Application, configFlag *string, grid *tview.Grid, pages *tview.Pages) {
|
||||||
watch := watcher.New()
|
watch := watcher.New()
|
||||||
|
|
||||||
// notify write events.
|
// notify write events.
|
||||||
@ -118,9 +118,9 @@ func watchForConfigChanges(app *tview.Application, configFlag *string) {
|
|||||||
select {
|
select {
|
||||||
case <-watch.Event:
|
case <-watch.Event:
|
||||||
loadConfig(configFlag)
|
loadConfig(configFlag)
|
||||||
makeWidgets(app)
|
makeWidgets(app, pages)
|
||||||
mainPage = buildGrid(Widgets)
|
grid = buildGrid(Widgets)
|
||||||
pages.AddPage("grid", mainPage, true, true)
|
pages.AddPage("grid", grid, true, true)
|
||||||
case err := <-watch.Error:
|
case err := <-watch.Error:
|
||||||
log.Fatalln(err)
|
log.Fatalln(err)
|
||||||
case <-watch.Closed:
|
case <-watch.Closed:
|
||||||
@ -145,8 +145,6 @@ func watchForConfigChanges(app *tview.Application, configFlag *string) {
|
|||||||
var Config *config.Config
|
var Config *config.Config
|
||||||
var FocusTracker wtf.FocusTracker
|
var FocusTracker wtf.FocusTracker
|
||||||
var Widgets []wtf.Wtfable
|
var Widgets []wtf.Wtfable
|
||||||
var pages *tview.Pages
|
|
||||||
var mainPage *tview.Grid
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
commit = "dev"
|
commit = "dev"
|
||||||
@ -154,7 +152,7 @@ var (
|
|||||||
version = "dev"
|
version = "dev"
|
||||||
)
|
)
|
||||||
|
|
||||||
func makeWidgets(app *tview.Application) {
|
func makeWidgets(app *tview.Application, pages *tview.Pages) {
|
||||||
bamboohr.Config = Config
|
bamboohr.Config = Config
|
||||||
clocks.Config = Config
|
clocks.Config = Config
|
||||||
cmdrunner.Config = Config
|
cmdrunner.Config = Config
|
||||||
@ -234,9 +232,9 @@ func main() {
|
|||||||
loadConfig(flagConf)
|
loadConfig(flagConf)
|
||||||
|
|
||||||
app := tview.NewApplication()
|
app := tview.NewApplication()
|
||||||
pages = tview.NewPages()
|
pages := tview.NewPages()
|
||||||
|
|
||||||
makeWidgets(app)
|
makeWidgets(app, pages)
|
||||||
|
|
||||||
FocusTracker = wtf.FocusTracker{
|
FocusTracker = wtf.FocusTracker{
|
||||||
App: app,
|
App: app,
|
||||||
@ -244,13 +242,13 @@ func main() {
|
|||||||
Widgets: Widgets,
|
Widgets: Widgets,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
grid := buildGrid(Widgets)
|
||||||
|
pages.AddPage("grid", grid, true, true)
|
||||||
|
app.SetInputCapture(keyboardIntercept)
|
||||||
|
|
||||||
// Loop in a routine to redraw the screen
|
// Loop in a routine to redraw the screen
|
||||||
go redrawApp(app)
|
go redrawApp(app)
|
||||||
go watchForConfigChanges(app, flagConf)
|
go watchForConfigChanges(app, flagConf, grid, pages)
|
||||||
|
|
||||||
mainPage = buildGrid(Widgets)
|
|
||||||
pages.AddPage("grid", mainPage, true, true)
|
|
||||||
app.SetInputCapture(keyboardIntercept)
|
|
||||||
|
|
||||||
if err := app.SetRoot(pages, true).Run(); err != nil {
|
if err := app.SetRoot(pages, true).Run(); err != nil {
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user