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

+18
View File
@@ -6,6 +6,7 @@ import (
"os"
"strconv"
"strings"
"time"
"unicode"
"unicode/utf8"
)
@@ -96,6 +97,23 @@ func (e *setExpr) eval(app *app, args []string) {
gOpts.wrapscan = false
case "wrapscan!":
gOpts.wrapscan = !gOpts.wrapscan
case "period":
n, err := strconv.Atoi(e.val)
if err != nil {
app.ui.printf("period: %s", err)
return
}
if n < 0 {
app.ui.print("period: value should be a non-negative number")
return
}
gOpts.period = n
if n == 0 {
app.ticker.Stop()
} else {
app.ticker.Stop()
app.ticker = time.NewTicker(time.Duration(gOpts.period) * time.Second)
}
case "scrolloff":
n, err := strconv.Atoi(e.val)
if err != nil {