Add almost full option support

This commit is contained in:
Zachary Yedidia
2019-01-13 21:06:58 -05:00
parent 163ca36eeb
commit 7a20c2db76
16 changed files with 285 additions and 279 deletions

View File

@@ -6,6 +6,7 @@ import (
"os/user"
"path/filepath"
"regexp"
"strconv"
"strings"
"time"
"unicode/utf8"
@@ -309,6 +310,19 @@ func GetCharPosInLine(b []byte, visualPos int, tabsize int) int {
return i
}
// ParseBool is almost exactly like strconv.ParseBool, except it also accepts 'on' and 'off'
// as 'true' and 'false' respectively
func ParseBool(str string) (bool, error) {
if str == "on" {
return true, nil
}
if str == "off" {
return false, nil
}
return strconv.ParseBool(str)
}
// Clamp clamps a value between min and max
func Clamp(val, min, max int) int {
if val < min {
val = min