projects
/
ghc-hetmet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
parsing tweak for :break
[ghc-hetmet.git]
/
compiler
/
ghci
/
InteractiveUI.hs
diff --git
a/compiler/ghci/InteractiveUI.hs
b/compiler/ghci/InteractiveUI.hs
index
6550c6d
..
c865943
100644
(file)
--- a/
compiler/ghci/InteractiveUI.hs
+++ b/
compiler/ghci/InteractiveUI.hs
@@
-54,7
+54,6
@@
import System.Posix hiding (getEnv)
#else
import GHC.ConsoleHandler ( flushConsole )
import qualified System.Win32
#else
import GHC.ConsoleHandler ( flushConsole )
import qualified System.Win32
-import System.FilePath
#endif
#ifdef USE_READLINE
#endif
#ifdef USE_READLINE
@@
-67,6
+66,7
@@
import System.Console.Readline as Readline
import Control.Exception as Exception
-- import Control.Concurrent
import Control.Exception as Exception
-- import Control.Concurrent
+import System.FilePath
import qualified Data.ByteString.Char8 as BS
import Data.List
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List
import Data.Maybe
@@
-316,6
+316,11
@@
interactiveUI session srcs maybe_exprs = do
is_tty <- hIsTerminalDevice stdin
when is_tty $ do
Readline.initialize
is_tty <- hIsTerminalDevice stdin
when is_tty $ do
Readline.initialize
+
+ withGhcAppData
+ (\dir -> Readline.readHistory (dir </> "ghci_history"))
+ (return True)
+
Readline.setAttemptedCompletionFunction (Just completeWord)
--Readline.parseAndBind "set show-all-if-ambiguous 1"
Readline.setAttemptedCompletionFunction (Just completeWord)
--Readline.parseAndBind "set show-all-if-ambiguous 1"
@@
-349,11
+354,22
@@
interactiveUI session srcs maybe_exprs = do
}
#ifdef USE_READLINE
}
#ifdef USE_READLINE
+ Readline.stifleHistory 100
+ withGhcAppData (\dir -> Readline.writeHistory (dir </> "ghci_history"))
+ (return True)
Readline.resetTerminal Nothing
#endif
return ()
Readline.resetTerminal Nothing
#endif
return ()
+withGhcAppData :: (FilePath -> IO a) -> IO a -> IO a
+withGhcAppData right left = do
+ either_dir <- IO.try (getAppUserDataDirectory "ghc")
+ case either_dir of
+ Right dir -> right dir
+ _ -> left
+
+
runGHCi :: [(FilePath, Maybe Phase)] -> Maybe [String] -> GHCi ()
runGHCi paths maybe_exprs = do
let
runGHCi :: [(FilePath, Maybe Phase)] -> Maybe [String] -> GHCi ()
runGHCi paths maybe_exprs = do
let
@@
-361,11
+377,9
@@
runGHCi paths maybe_exprs = do
current_dir = return (Just ".ghci")
current_dir = return (Just ".ghci")
- app_user_dir = do
- either_dir <- io $ IO.try (getAppUserDataDirectory "ghc")
- case either_dir of
- Right dir -> return (Just (dir </> "ghci.conf"))
- _ -> return Nothing
+ app_user_dir = io $ withGhcAppData
+ (\dir -> return (Just (dir </> "ghci.conf")))
+ (return Nothing)
home_dir = do
either_dir <- io $ IO.try (getEnv "HOME")
home_dir = do
either_dir <- io $ IO.try (getEnv "HOME")
@@
-599,6
+613,7
@@
readlineLoop = do
splatSavedSession
case l of
Nothing -> return Nothing
splatSavedSession
case l of
Nothing -> return Nothing
+ Just "" -> return (Just "") -- Don't put empty lines in the history
Just l -> do
io (addHistory l)
str <- io $ consoleInputToUnicode True l
Just l -> do
io (addHistory l)
str <- io $ consoleInputToUnicode True l
@@
-2025,7
+2040,7
@@
breakSwitch :: Session -> [String] -> GHCi ()
breakSwitch _session [] = do
io $ putStrLn "The break command requires at least one argument."
breakSwitch session (arg1:rest)
breakSwitch _session [] = do
io $ putStrLn "The break command requires at least one argument."
breakSwitch session (arg1:rest)
- | looksLikeModuleName arg1 = do
+ | looksLikeModuleName arg1 && not (null rest) = do
mod <- wantInterpretedModule arg1
breakByModule mod rest
| all isDigit arg1 = do
mod <- wantInterpretedModule arg1
breakByModule mod rest
| all isDigit arg1 = do