aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2009-05-09 16:58:40 +1000
committerNguyễn Thái Ngọc Duy <pclouds@gmail.com>2010-09-14 15:17:58 +1000
commit8ce742c7a2b95085f8d62b3f2e89fa07fcb84b84 (patch)
tree46dea9c0c940eea641fa8746635be9cb93eb0d7f
parent794076536fc4514278531242baa6a9ba1888fe75 (diff)
downloadbusybox-w32-8ce742c7a2b95085f8d62b3f2e89fa07fcb84b84.tar.gz
busybox-w32-8ce742c7a2b95085f8d62b3f2e89fa07fcb84b84.tar.bz2
busybox-w32-8ce742c7a2b95085f8d62b3f2e89fa07fcb84b84.zip
win32: vi: reimplement mysleep() because poll() won't work on stdin
This makes vi work on rxvt for Windows. There is work to do in winansi.c in order to make vim work on Windows console.
-rw-r--r--editors/vi.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/editors/vi.c b/editors/vi.c
index 602fc61d9..f59d5a706 100644
--- a/editors/vi.c
+++ b/editors/vi.c
@@ -2211,11 +2211,20 @@ static void catch_sig(int sig)
2211 2211
2212static int mysleep(int hund) // sleep for 'hund' 1/100 seconds or stdin ready 2212static int mysleep(int hund) // sleep for 'hund' 1/100 seconds or stdin ready
2213{ 2213{
2214#if ENABLE_PLATFORM_MINGW32
2215 HANDLE h = GetStdHandle(STD_INPUT_HANDLE);
2216 DWORD ret;
2217
2218 fflush(stdout);
2219 ret = WaitForSingleObject(h, hund*10);
2220 return ret != WAIT_TIMEOUT;
2221#else
2214 struct pollfd pfd[1]; 2222 struct pollfd pfd[1];
2215 2223
2216 pfd[0].fd = STDIN_FILENO; 2224 pfd[0].fd = STDIN_FILENO;
2217 pfd[0].events = POLLIN; 2225 pfd[0].events = POLLIN;
2218 return safe_poll(pfd, 1, hund*10) > 0; 2226 return safe_poll(pfd, 1, hund*10) > 0;
2227#endif
2219} 2228}
2220 2229
2221//----- IO Routines -------------------------------------------- 2230//----- IO Routines --------------------------------------------