diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/tui/ncurses.go | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/tui/ncurses.go b/src/tui/ncurses.go index 5a4d5382..8603fd32 100644 --- a/src/tui/ncurses.go +++ b/src/tui/ncurses.go @@ -23,6 +23,7 @@ import "C" import ( "fmt" "os" + "strconv" "strings" "time" "unicode/utf8" @@ -103,8 +104,16 @@ func Init(theme *ColorTheme, black bool, mouse bool) { C.raw() // stty dsusp undef C.nonl() C.keypad(C.stdscr, true) - C.set_escdelay(100) - C.timeout(100) // ESCDELAY 100ms + timeout 100ms + + delay := 50 + delayEnv := os.Getenv("ESCDELAY") + if len(delayEnv) > 0 { + num, err := strconv.Atoi(delayEnv) + if err == nil && num >= 0 { + delay = num + } + } + C.set_escdelay(C.int(delay)) _color = theme != nil if _color { @@ -293,8 +302,10 @@ func consume(expects ...rune) bool { } func escSequence() Event { - // nodelay is not thread-safe (e.g. <ESC><CTRL-P>) - // C.nodelay(C.stdscr, true) + C.nodelay(C.stdscr, true) + defer func() { + C.nodelay(C.stdscr, false) + }() c := C.getch() switch c { case C.ERR: |