1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

Merge branch 'another_ipinfo_api_187' of https://github.com/Fengyalv/wtf into another_ipinfo_api_187

This commit is contained in:
FengYa 2018-06-08 14:22:37 +08:00
commit 4661b2f67b
3 changed files with 13 additions and 0 deletions

8
wtf.go
View File

@ -122,6 +122,8 @@ func watchForConfigChanges(app *tview.Application, configFlag string, grid *tvie
select {
case <-watch.Event:
loadConfig(configFlag)
// Disable all widgets to stop scheduler goroutines and rmeove widgets from memory.
disableAllWidgets()
makeWidgets(app, pages)
grid = buildGrid(Widgets)
pages.AddPage("grid", grid, true, true)
@ -156,6 +158,12 @@ var (
version = "dev"
)
func disableAllWidgets() {
for _, widget := range Widgets {
widget.Disable()
}
}
func addWidget(app *tview.Application, pages *tview.Pages, widgetName string) {
// Always in alphabetical order
switch widgetName {

View File

@ -3,4 +3,5 @@ package wtf
type Enabler interface {
Disabled() bool
Enabled() bool
Disable()
}

View File

@ -61,6 +61,10 @@ func (widget *TextWidget) Enabled() bool {
return widget.enabled
}
func (widget *TextWidget) Disable() {
widget.enabled = false
}
func (widget *TextWidget) Focusable() bool {
return widget.enabled && widget.focusable
}