From: sof Date: Fri, 14 Feb 2003 17:12:00 +0000 (+0000) Subject: [project @ 2003-02-14 17:11:59 by sof] X-Git-Tag: nhc98-1-18-release~736 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=8e8f729096d28f18512e33d90c5ccb2b79d0f1f0;p=ghc-base.git [project @ 2003-02-14 17:11:59 by sof] - add missing config.h include to Handle.hs - Handle.hSetBuffering: don't bother putting the handle's FD into 'raw' mode under Win32. 'raw' mode is just too specialised and potentially confusing (see comments.) --- diff --git a/GHC/Handle.hs b/GHC/Handle.hs index c7ebee0..6760b1f 100644 --- a/GHC/Handle.hs +++ b/GHC/Handle.hs @@ -47,6 +47,8 @@ module GHC.Handle ( ) where +#include "config.h" + import Control.Monad import Data.Bits import Data.Maybe @@ -939,7 +941,11 @@ hSetBuffering handle mode = is_tty <- fdIsTTY (haFD handle_) when (is_tty && isReadableHandleType (haType handle_)) $ case mode of +#ifndef mingw32_TARGET_OS + -- 'raw' mode under win32 is a bit too specialised (and troublesome + -- for most common uses), so simply disable its use here. NoBuffering -> setCooked (haFD handle_) False +#endif _ -> setCooked (haFD handle_) True -- throw away spare buffers, they might be the wrong size diff --git a/GHC/Posix.hs b/GHC/Posix.hs index 53b0902..ca7dc2f 100644 --- a/GHC/Posix.hs +++ b/GHC/Posix.hs @@ -218,7 +218,14 @@ tcSetAttr fd options p_tios = do #else --- bogus defns for win32 +-- 'raw' mode for Win32 means turn off 'line input' (=> buffering and +-- character translation for the console.) The Win32 API for doing +-- this is GetConsoleMode(), which also requires echoing to be disabled +-- when turning off 'line input' processing. Notice that turning off +-- 'line input' implies enter/return is reported as '\r' (and it won't +-- report that character until another character is input..odd.) This +-- latter feature doesn't sit too well with IO actions like IO.hGetLine.. +-- consider yourself warned. setCooked :: Int -> Bool -> IO () setCooked fd cooked = do x <- set_console_buffering (fromIntegral fd) (if cooked then 1 else 0) @@ -229,6 +236,8 @@ setCooked fd cooked = do ioe_unk_error loc msg = IOError Nothing OtherError loc msg Nothing +-- Note: echoing goes hand in hand with enabling 'line input' / raw-ness +-- for Win32 consoles, hence setEcho ends up being the inverse of setCooked. setEcho :: Int -> Bool -> IO () setEcho fd on = do x <- set_console_echo (fromIntegral fd) (if on then 1 else 0)