[project @ 2003-08-27 12:29:21 by simonmar]
authorsimonmar <unknown>
Wed, 27 Aug 2003 12:29:21 +0000 (12:29 +0000)
committersimonmar <unknown>
Wed, 27 Aug 2003 12:29:21 +0000 (12:29 +0000)
Always display the prompt if verbosity > 0, previously it was only
displayed if stdin was a tty.  This fixes problems with running GHCi
under Emacs, which expects to see a prompt.

ghc/compiler/ghci/InteractiveUI.hs

index 5c014be..257c219 100644 (file)
@@ -1,6 +1,6 @@
 {-# OPTIONS -#include "Linker.h" #-}
 -----------------------------------------------------------------------------
--- $Id: InteractiveUI.hs,v 1.157 2003/07/21 14:33:19 simonmar Exp $
+-- $Id: InteractiveUI.hs,v 1.158 2003/08/27 12:29:21 simonmar Exp $
 --
 -- GHC Interactive User Interface
 --
@@ -229,33 +229,31 @@ runGHCi paths dflags = do
      ghciHandle showException $
        loadModule paths
 
-  -- enter the interactive loop
-#if defined(mingw32_HOST_OS)
-   -- Always show prompt, since hIsTerminalDevice returns True for Consoles
-   -- only, which we may or may not be running under (cf. Emacs sub-shells.)
-  interactiveLoop True
-#else
+  -- if verbosity is greater than 0, or we are connected to a
+  -- terminal, display the prompt in the interactive loop.
   is_tty <- io (hIsTerminalDevice stdin)
-  interactiveLoop is_tty
-#endif
+  let show_prompt = verbosity dflags > 0 || is_tty
+
+  -- enter the interactive loop
+  interactiveLoop is_tty show_prompt
 
   -- and finally, exit
   io $ do when (verbosity dflags > 0) $ putStrLn "Leaving GHCi."
 
 
-interactiveLoop is_tty = do
+interactiveLoop is_tty show_prompt = do
   -- Ignore ^C exceptions caught here
   ghciHandleDyn (\e -> case e of 
-                       Interrupted -> ghciUnblock (interactiveLoop is_tty)
+                       Interrupted -> ghciUnblock (interactiveLoop is_tty show_prompt)
                        _other      -> return ()) $ do
 
   -- read commands from stdin
 #if HAVE_READLINE_HEADERS && HAVE_READLINE_LIBS
   if (is_tty) 
        then readlineLoop
-       else fileLoop stdin False  -- turn off prompt for non-TTY input
+       else fileLoop stdin show_prompt
 #else
-  fileLoop stdin is_tty
+  fileLoop stdin show_prompt
 #endif