aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2010-09-14 15:36:28 +1000
committerNguyễn Thái Ngọc Duy <pclouds@gmail.com>2010-09-14 18:12:07 +1000
commitc2c28bd9eaf568f803136578cadad4d7cdf68f5e (patch)
treefb73963c531ebebfb72f32e81504f6e0735f9776
parent8ce742c7a2b95085f8d62b3f2e89fa07fcb84b84 (diff)
downloadbusybox-w32-c2c28bd9eaf568f803136578cadad4d7cdf68f5e.tar.gz
busybox-w32-c2c28bd9eaf568f803136578cadad4d7cdf68f5e.tar.bz2
busybox-w32-c2c28bd9eaf568f803136578cadad4d7cdf68f5e.zip
win32: read_key: implement timeout
will be needed by CONFIG_FEATURE_VI_ASK_TERMINAL
-rw-r--r--win32/termios.c6
1 files changed, 5 insertions, 1 deletions
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)
10 return -1; 10 return -1;
11} 11}
12 12
13int64_t FAST_FUNC read_key(int fd, char *buf, int timeout UNUSED_PARAM) 13int64_t FAST_FUNC read_key(int fd, char *buf, int timeout)
14{ 14{
15 static int initialized = 0; 15 static int initialized = 0;
16 HANDLE cin = GetStdHandle(STD_INPUT_HANDLE); 16 HANDLE cin = GetStdHandle(STD_INPUT_HANDLE);
@@ -26,6 +26,10 @@ int64_t FAST_FUNC read_key(int fd, char *buf, int timeout UNUSED_PARAM)
26 initialized = 1; 26 initialized = 1;
27 } 27 }
28 28
29 if (timeout > 0) {
30 if (WaitForSingleObject(cin, timeout) != WAIT_OBJECT_0)
31 goto done;
32 }
29 while (1) { 33 while (1) {
30 if (!ReadConsoleInput(cin, &record, 1, &nevent_out)) 34 if (!ReadConsoleInput(cin, &record, 1, &nevent_out))
31 return -1; 35 return -1;