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:
commit
4661b2f67b
8
wtf.go
8
wtf.go
@ -122,6 +122,8 @@ func watchForConfigChanges(app *tview.Application, configFlag string, grid *tvie
|
|||||||
select {
|
select {
|
||||||
case <-watch.Event:
|
case <-watch.Event:
|
||||||
loadConfig(configFlag)
|
loadConfig(configFlag)
|
||||||
|
// Disable all widgets to stop scheduler goroutines and rmeove widgets from memory.
|
||||||
|
disableAllWidgets()
|
||||||
makeWidgets(app, pages)
|
makeWidgets(app, pages)
|
||||||
grid = buildGrid(Widgets)
|
grid = buildGrid(Widgets)
|
||||||
pages.AddPage("grid", grid, true, true)
|
pages.AddPage("grid", grid, true, true)
|
||||||
@ -156,6 +158,12 @@ var (
|
|||||||
version = "dev"
|
version = "dev"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func disableAllWidgets() {
|
||||||
|
for _, widget := range Widgets {
|
||||||
|
widget.Disable()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func addWidget(app *tview.Application, pages *tview.Pages, widgetName string) {
|
func addWidget(app *tview.Application, pages *tview.Pages, widgetName string) {
|
||||||
// Always in alphabetical order
|
// Always in alphabetical order
|
||||||
switch widgetName {
|
switch widgetName {
|
||||||
|
@ -3,4 +3,5 @@ package wtf
|
|||||||
type Enabler interface {
|
type Enabler interface {
|
||||||
Disabled() bool
|
Disabled() bool
|
||||||
Enabled() bool
|
Enabled() bool
|
||||||
|
Disable()
|
||||||
}
|
}
|
||||||
|
@ -61,6 +61,10 @@ func (widget *TextWidget) Enabled() bool {
|
|||||||
return widget.enabled
|
return widget.enabled
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (widget *TextWidget) Disable() {
|
||||||
|
widget.enabled = false
|
||||||
|
}
|
||||||
|
|
||||||
func (widget *TextWidget) Focusable() bool {
|
func (widget *TextWidget) Focusable() bool {
|
||||||
return widget.enabled && widget.focusable
|
return widget.enabled && widget.focusable
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user