[project @ 2001-04-26 11:38:53 by qrczak]
[ghc-hetmet.git] / ghc / compiler / ghci / InteractiveUI.hs
index 6a7ffa5..be216e6 100644 (file)
@@ -1,5 +1,5 @@
 -----------------------------------------------------------------------------
--- $Id: InteractiveUI.hs,v 1.62 2001/04/24 13:05:51 simonmar Exp $
+-- $Id: InteractiveUI.hs,v 1.64 2001/04/26 11:38:53 qrczak Exp $
 --
 -- GHC Interactive User Interface
 --
 {-# OPTIONS -#include "Linker.h" #-}
 module InteractiveUI ( interactiveUI, ghciWelcomeMsg ) where
 
+#include "../includes/config.h"
 #include "HsVersions.h"
 
-#if HAVE_READLINE_4_2 == 1 || HAVE_READLINE_4 == 1
-#undef NO_READLINE
-#else
-#define NO_READLINE
-#endif
-
 import CompManager
 import CmStaticInfo
 import ByteCodeLink
@@ -34,8 +29,8 @@ import Config
 
 import Exception
 import Dynamic
-#ifndef NO_READLINE
-import Readline
+#if HAVE_READLINE_HEADERS && HAVE_READLINE_LIBS
+import Readline 
 #endif
 import IOExts
 
@@ -127,7 +122,7 @@ interactiveUI cmstate mod cmdline_libs = do
             Nothing  -> return (cmstate, True, [])
             Just m -> cmLoadModule cmstate m
 
-#ifndef NO_READLINE
+#if HAVE_READLINE_HEADERS && HAVE_READLINE_LIBS
    Readline.initialize
 #endif
 
@@ -172,7 +167,7 @@ runGHCi = do
             Right hdl -> fileLoop hdl False
 
   -- read commands from stdin
-#ifndef NO_READLINE
+#if HAVE_READLINE_HEADERS && HAVE_READLINE_LIBS
   readlineLoop
 #else
   fileLoop stdin True
@@ -186,7 +181,7 @@ fileLoop :: Handle -> Bool -> GHCi ()
 fileLoop hdl prompt = do
    st <- getGHCiState
    mod <- io (cmGetContext (cmstate st))
-   when prompt (io (hPutStr hdl (mod ++ "> ")))
+   when prompt (io (putStr (mod ++ "> ")))
    l <- io (IO.try (hGetLine hdl))
    case l of
        Left e | isEOFError e -> return ()
@@ -206,7 +201,7 @@ stringLoop (s:ss) = do
        l  -> do quit <- runCommand l
                  if quit then return () else stringLoop ss
 
-#ifndef NO_READLINE
+#if HAVE_READLINE_HEADERS && HAVE_READLINE_LIBS
 readlineLoop :: GHCi ()
 readlineLoop = do
    st <- getGHCiState