add 'period' option for periodic refresh

Related #73
This commit is contained in:
Gokcehan committed 2018-06-09 22:02:09 +03:00
1 parent e025c68130
commit 723357fe3d
6 files changed
+30

No files matched your search

+7
View File
@@ -9,6 +9,7 @@ import (
"os/exec"
"strconv"
"strings"
"time"
)
type cmdItem struct {
@@ -19,6 +20,7 @@ type cmdItem struct {
type app struct {
ui *ui
nav *nav
ticker *time.Ticker
quitChan chan bool
cmd *exec.Cmd
cmdIn io.WriteCloser
@@ -34,6 +36,7 @@ func newApp() *app {
return &app{
ui: ui,
nav: nav,
ticker: new(time.Ticker),
quitChan: make(chan bool, 1),
}
}
@@ -132,6 +135,10 @@ func (app *app) loop() {
case e := <-serverChan:
e.eval(app, nil)
app.ui.draw(app.nav)
case <-app.ticker.C:
app.nav.renew()
app.ui.loadFile(app.nav)
app.ui.draw(app.nav)
}
}
}