diff options
Diffstat (limited to 'src/tui/light_windows.go')
-rw-r--r-- | src/tui/light_windows.go | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/tui/light_windows.go b/src/tui/light_windows.go index aa15a8a9..06e77ba0 100644 --- a/src/tui/light_windows.go +++ b/src/tui/light_windows.go @@ -5,11 +5,16 @@ package tui import ( "os" "syscall" + "time" "github.com/junegunn/fzf/src/util" "golang.org/x/sys/windows" ) +const ( + timeoutInterval = 10 +) + var ( consoleFlagsInput = uint32(windows.ENABLE_VIRTUAL_TERMINAL_INPUT | windows.ENABLE_PROCESSED_INPUT | windows.ENABLE_EXTENDED_FLAGS) consoleFlagsOutput = uint32(windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING | windows.ENABLE_PROCESSED_OUTPUT | windows.DISABLE_NEWLINE_AUTO_RETURN) @@ -60,7 +65,7 @@ func (r *LightRenderer) initPlatform() error { // channel for non-blocking reads. Buffer to make sure // we get the ESC sets: - r.ttyinChannel = make(chan byte, 12) + r.ttyinChannel = make(chan byte, 1024) // the following allows for non-blocking IO. // syscall.SetNonblock() is a NOOP under Windows. @@ -68,9 +73,6 @@ func (r *LightRenderer) initPlatform() error { fd := int(r.inHandle) b := make([]byte, 1) for { - // HACK: if run from PSReadline, something resets ConsoleMode to remove ENABLE_VIRTUAL_TERMINAL_INPUT. - _ = windows.SetConsoleMode(windows.Handle(r.inHandle), consoleFlagsInput) - _, err := util.Read(fd, b) if err == nil { r.ttyinChannel <- b[0] @@ -130,7 +132,7 @@ func (r *LightRenderer) getch(nonblock bool) (int, bool) { select { case bc := <-r.ttyinChannel: return int(bc), true - default: + case <-time.After(timeoutInterval * time.Millisecond): return 0, false } } else { |