diff --git a/main.go b/main.go index a15cefcc..d216d5be 100644 --- a/main.go +++ b/main.go @@ -342,6 +342,30 @@ func makeWidgets(app *tview.Application, pages *tview.Pages) []wtf.Wtfable { return widgets } +func enableAppRefresh(app *tview.Application) { + defaultInterval := 100 + + refreshInterval := Config.UInt("wtf.refreshInterval", defaultInterval) + if refreshInterval < defaultInterval { + refreshInterval = defaultInterval + } + + interval := time.Duration(refreshInterval) * time.Millisecond + + tick := time.NewTicker(interval) + quit := make(chan struct{}) + + for { + select { + case <-tick.C: + app.Draw() + case <-quit: + tick.Stop() + return + } + } +} + /* -------------------- Main -------------------- */ func main() { @@ -376,6 +400,7 @@ func main() { app.SetInputCapture(keyboardIntercept) go watchForConfigChanges(app, flags.Config, display.Grid, pages) + go enableAppRefresh(app) if err := app.SetRoot(pages, true).Run(); err != nil { fmt.Printf("Error: %v\n", err) diff --git a/modules/todo/widget.go b/modules/todo/widget.go index efc6c158..342e1076 100644 --- a/modules/todo/widget.go +++ b/modules/todo/widget.go @@ -265,7 +265,6 @@ func (widget *Widget) modalFocus(form *tview.Form) { frame := widget.modalFrame(form) widget.pages.AddPage("modal", frame, false, true) widget.app.SetFocus(frame) - widget.app.Draw() } func (widget *Widget) modalForm(lbl, text string) *tview.Form { diff --git a/wtf/focus_tracker.go b/wtf/focus_tracker.go index b7296f01..c2539e9d 100644 --- a/wtf/focus_tracker.go +++ b/wtf/focus_tracker.go @@ -150,9 +150,7 @@ func (tracker *FocusTracker) focus(idx int) { view := widget.TextView() view.SetBorderColor(ColorFor(Config.UString("wtf.colors.border.focused", "gray"))) - tracker.App.SetFocus(view) - tracker.App.Draw() } func (tracker *FocusTracker) focusables() []Wtfable { diff --git a/wtf/helpful_widget.go b/wtf/helpful_widget.go index dd253dae..ac9cee1c 100644 --- a/wtf/helpful_widget.go +++ b/wtf/helpful_widget.go @@ -33,5 +33,4 @@ func (widget *HelpfulWidget) ShowHelp() { widget.pages.AddPage("help", modal, false, true) widget.app.SetFocus(modal) - widget.app.Draw() } diff --git a/wtf/text_widget.go b/wtf/text_widget.go index 81c9ba6f..62310cf9 100644 --- a/wtf/text_widget.go +++ b/wtf/text_widget.go @@ -45,10 +45,6 @@ func NewTextWidget(app *tview.Application, commonSettings *cfg.Common, focusable widget.View = widget.addView() - widget.View.SetChangedFunc(func() { - app.Draw() - }) - return widget }