2 * (c) The University of Glasgow 2002
4 * Win32 Console API support
7 #if defined(mingw32_TARGET_OS) || defined(cygwin32_TARGET_OS)
10 #include "consUtils.h"
14 #if defined(cygwin32_TARGET_OS)
15 #define _get_osfhandle get_osfhandle
19 set_console_buffering__(int fd, int cooked)
23 /* According to GetConsoleMode() docs, it is not possible to
24 leave ECHO_INPUT enabled without also having LINE_INPUT,
25 so we have to turn both off here. */
26 DWORD flgs = ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT;
28 if ( (h = (HANDLE)_get_osfhandle(fd)) != INVALID_HANDLE_VALUE ) {
29 if ( GetConsoleMode(h,&st) &&
30 SetConsoleMode(h, cooked ? (st | ENABLE_LINE_INPUT) : st & ~flgs) ) {
38 set_console_echo__(int fd, int on)
42 DWORD flgs = ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT;
44 if ( (h = (HANDLE)_get_osfhandle(fd)) != INVALID_HANDLE_VALUE ) {
45 if ( GetConsoleMode(h,&st) &&
46 SetConsoleMode(h,( on ? (st | flgs) : (st & ~ENABLE_ECHO_INPUT))) ) {
54 get_console_echo__(int fd)
59 if ( (h = (HANDLE)_get_osfhandle(fd)) != INVALID_HANDLE_VALUE ) {
60 if ( GetConsoleMode(h,&st) ) {
61 return (st & ENABLE_ECHO_INPUT ? 1 : 0);
67 #endif /* defined(mingw32_TARGET_OS) || defined(cygwin32_TARGET_OS) */