Minor refactoring

This commit is contained in:
Junegunn Choi 2017-01-23 12:51:31 +09:00
parent deccdb1ec5
commit a5ad8fd3bd
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627

View File

@ -20,6 +20,7 @@ const (
defaultWidth = 80 defaultWidth = 80
defaultHeight = 24 defaultHeight = 24
defaultEscDelay = 100
escPollInterval = 5 escPollInterval = 5
offsetPollTries = 10 offsetPollTries = 10
) )
@ -164,15 +165,7 @@ func atoi(s string, defaultValue int) int {
} }
func (r *LightRenderer) Init() { func (r *LightRenderer) Init() {
delay := 100 r.escDelay = atoi(os.Getenv("ESCDELAY"), defaultEscDelay)
delayEnv := os.Getenv("ESCDELAY")
if len(delayEnv) > 0 {
num, err := strconv.Atoi(delayEnv)
if err == nil && num >= 0 {
delay = num
}
}
r.escDelay = delay
fd := r.fd() fd := r.fd()
origState, err := terminal.GetState(fd) origState, err := terminal.GetState(fd)