From 9b7f31877d04f6687facd084bed4a55d499a463e Mon Sep 17 00:00:00 2001 From: Hossein Mehrabi Date: Fri, 8 Jun 2018 05:28:45 +0430 Subject: [PATCH 1/3] added Disable method --- wtf/enabler.go | 1 + wtf/text_widget.go | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/wtf/enabler.go b/wtf/enabler.go index 26ec5a21..c7a5b973 100644 --- a/wtf/enabler.go +++ b/wtf/enabler.go @@ -3,4 +3,5 @@ package wtf type Enabler interface { Disabled() bool Enabled() bool + Disable() } diff --git a/wtf/text_widget.go b/wtf/text_widget.go index 8c7f864d..b62868ef 100644 --- a/wtf/text_widget.go +++ b/wtf/text_widget.go @@ -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 } From e00a0a81a06ea2ccd427b2d5b9fa8b54e197ecbe Mon Sep 17 00:00:00 2001 From: Hossein Mehrabi Date: Fri, 8 Jun 2018 05:31:59 +0430 Subject: [PATCH 2/3] disable all widgets before live-reloading --- wtf.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/wtf.go b/wtf.go index f0df2b06..da5e5afd 100644 --- a/wtf.go +++ b/wtf.go @@ -121,6 +121,8 @@ func watchForConfigChanges(app *tview.Application, configFlag string, grid *tvie select { case <-watch.Event: loadConfig(configFlag) + // Disable all widgets to stop scheduler goroutines and widgets from memory. + disableAllWidgets() makeWidgets(app, pages) grid = buildGrid(Widgets) pages.AddPage("grid", grid, true, true) @@ -155,6 +157,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 { From 2c4cf578ae3d7599bc5da3a124fcbf94e0876a88 Mon Sep 17 00:00:00 2001 From: Hossein Mehrabi Date: Fri, 8 Jun 2018 05:38:45 +0430 Subject: [PATCH 3/3] fixed comment --- wtf.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wtf.go b/wtf.go index da5e5afd..b9627490 100644 --- a/wtf.go +++ b/wtf.go @@ -121,7 +121,7 @@ func watchForConfigChanges(app *tview.Application, configFlag string, grid *tvie select { case <-watch.Event: loadConfig(configFlag) - // Disable all widgets to stop scheduler goroutines and widgets from memory. + // Disable all widgets to stop scheduler goroutines and rmeove widgets from memory. disableAllWidgets() makeWidgets(app, pages) grid = buildGrid(Widgets)