mirror of
https://github.com/Llewellynvdm/fzf.git
synced 2025-01-23 23:28:31 +00:00
Make escape delay configurable via ncurses standard $ESCDELAY
Also reduce the default delay to 50ms. We should not set it to 0ms as it breaks escape sequences on WSL. If 50ms is not enough, one can increase the delay by setting $ESCDELAY to a larger value.
This commit is contained in:
parent
8524ea7441
commit
43425158f4
@ -23,6 +23,7 @@ import "C"
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
"unicode/utf8"
|
"unicode/utf8"
|
||||||
@ -103,8 +104,16 @@ func Init(theme *ColorTheme, black bool, mouse bool) {
|
|||||||
C.raw() // stty dsusp undef
|
C.raw() // stty dsusp undef
|
||||||
C.nonl()
|
C.nonl()
|
||||||
C.keypad(C.stdscr, true)
|
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
|
_color = theme != nil
|
||||||
if _color {
|
if _color {
|
||||||
@ -293,8 +302,10 @@ func consume(expects ...rune) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func escSequence() Event {
|
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()
|
c := C.getch()
|
||||||
switch c {
|
switch c {
|
||||||
case C.ERR:
|
case C.ERR:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user