mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-15 21:37:09 +09:00
Add almost full option support
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user