From 8922b92d32e69e73292a55e813a37ff857f60a83 Mon Sep 17 00:00:00 2001 From: Nguyễn Thái Ngọc Duy Date: Tue, 13 Apr 2010 22:05:30 +0200 Subject: win32: Config.in: CYGWIN MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Nguyễn Thái Ngọc Duy --- editors/vi.c | 27 +++++++++++++++++++++++++++ libbb/Config.in | 1 + 2 files changed, 28 insertions(+) diff --git a/editors/vi.c b/editors/vi.c index 28612508f..238d42b9c 100644 --- a/editors/vi.c +++ b/editors/vi.c @@ -23,6 +23,10 @@ #include "libbb.h" +#ifdef __MINGW32__ +#include "cygwin_termios.h" +#endif + /* the CRASHME code is unmaintained, and doesn't currently build */ #define ENABLE_FEATURE_VI_CRASHME 0 @@ -2200,6 +2204,27 @@ static void catch_sig(int sig) } #endif /* FEATURE_VI_USE_SIGNALS */ +#ifdef __MINGW32__ +static int mysleep(int hund) // sleep for 'h' 1/100 seconds +{ + HANDLE h = GetStdHandle(STD_INPUT_HANDLE); + + fflush(stdout); + + /* In case of cygwin, it's a named pipe and won't work with WaitForSingleObject */ + if (is_cygwin_tty(0) || !h) { + if (hund) + Sleep(hund*10); + return 0; + } + else { + DWORD ret; + + ret = WaitForSingleObject(h, hund*10); + return ret != WAIT_TIMEOUT; + } +} +#else static int mysleep(int hund) // sleep for 'hund' 1/100 seconds or stdin ready { struct pollfd pfd[1]; @@ -2208,6 +2233,8 @@ static int mysleep(int hund) // sleep for 'hund' 1/100 seconds or stdin ready pfd[0].events = POLLIN; return safe_poll(pfd, 1, hund*10) > 0; } +#endif + //----- IO Routines -------------------------------------------- static int readit(void) // read (maybe cursor) key from stdin diff --git a/libbb/Config.in b/libbb/Config.in index 7a2d922ed..c255693d8 100644 --- a/libbb/Config.in +++ b/libbb/Config.in @@ -55,6 +55,7 @@ config FEATURE_CYGWIN_TTY config FEATURE_EDITING bool "Command line editing" default n + depends on FEATURE_CYGWIN_TTY help Enable line editing (mainly for shell command line). -- cgit v1.2.3-55-g6feb