From c2c28bd9eaf568f803136578cadad4d7cdf68f5e Mon Sep 17 00:00:00 2001 From: Nguyễn Thái Ngọc Duy Date: Tue, 14 Sep 2010 15:36:28 +1000 Subject: win32: read_key: implement timeout will be needed by CONFIG_FEATURE_VI_ASK_TERMINAL --- win32/termios.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/win32/termios.c b/win32/termios.c index 6d85ff98e..97d67eebb 100644 --- a/win32/termios.c +++ b/win32/termios.c @@ -10,7 +10,7 @@ int tcgetattr(int fd UNUSED_PARAM, struct termios *t UNUSED_PARAM) return -1; } -int64_t FAST_FUNC read_key(int fd, char *buf, int timeout UNUSED_PARAM) +int64_t FAST_FUNC read_key(int fd, char *buf, int timeout) { static int initialized = 0; HANDLE cin = GetStdHandle(STD_INPUT_HANDLE); @@ -26,6 +26,10 @@ int64_t FAST_FUNC read_key(int fd, char *buf, int timeout UNUSED_PARAM) initialized = 1; } + if (timeout > 0) { + if (WaitForSingleObject(cin, timeout) != WAIT_OBJECT_0) + goto done; + } while (1) { if (!ReadConsoleInput(cin, &record, 1, &nevent_out)) return -1; -- cgit v1.2.3-55-g6feb