mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Remove extraneous app.Draw() calls by having app.Draw() in its own routine
This commit is contained in:
parent
f60ce6967d
commit
a18625f427
25
main.go
25
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)
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -33,5 +33,4 @@ func (widget *HelpfulWidget) ShowHelp() {
|
||||
|
||||
widget.pages.AddPage("help", modal, false, true)
|
||||
widget.app.SetFocus(modal)
|
||||
widget.app.Draw()
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user