summaryrefslogtreecommitdiff
path: root/src/GF
diff options
context:
space:
mode:
authoraarne <aarne@cs.chalmers.se>2006-06-01 08:16:21 +0000
committeraarne <aarne@cs.chalmers.se>2006-06-01 08:16:21 +0000
commit34ca8208ac9ca06b2a5c1005cfab860e5697071d (patch)
tree358f24aabee51874d5df7dcb956722b6a1a070f6 /src/GF
parent5e665fa2ac63ee0739f787cc2fb7744d40721b7a (diff)
reload = r command
Diffstat (limited to 'src/GF')
-rw-r--r--src/GF/GFModes.hs15
-rw-r--r--src/GF/Shell/HelpFile.hs3
-rw-r--r--src/GF/Shell/PShell.hs2
-rw-r--r--src/GF/Shell/ShellCommands.hs8
4 files changed, 24 insertions, 4 deletions
diff --git a/src/GF/GFModes.hs b/src/GF/GFModes.hs
index dd25d1e49..faab3cede 100644
--- a/src/GF/GFModes.hs
+++ b/src/GF/GFModes.hs
@@ -28,7 +28,7 @@ import Data.Char (isSpace)
-- separated from GF Main 24/6/2003
gfInteract :: HState -> IO HState
-gfInteract st@(env,hist) = do
+gfInteract st@(env,hist@(his,_,_,_)) = do
-- putStrFlush "> " M.F 25/01-02 prompt moved to Arch.
(s,cs) <- getCommandLines st
case ifImpure cs of
@@ -48,6 +48,15 @@ gfInteract st@(env,hist) = do
st' <- execLinesH line [co] st -- s would not work in execLinesH
gfInteract st'
+ Just (ICReload,_) -> case dropWhile (not . isImport) his of
+ line:_ -> do
+ let co = pCommandLine st $ words line
+ st' <- execLinesH line [co] st
+ gfInteract st'
+ _ -> do
+ putStrLn "No previous import"
+ gfInteract st
+
Just (ICEditSession,os) -> case getOptVal os useFile of
Just file -> do
s <- readFileIf file
@@ -66,6 +75,10 @@ gfInteract st@(env,hist) = do
opts = globalOptions env
ifNotSilent c =
if oElem beSilent opts then return () else putStrLnFlush c
+ isImport l = case words l of
+ "i":_ -> True
+ "import":_ -> True
+ _ -> False
gfBatch :: HState -> IO HState
gfBatch st@(sh,_) = do
diff --git a/src/GF/Shell/HelpFile.hs b/src/GF/Shell/HelpFile.hs
index 29f25aef8..a8423979c 100644
--- a/src/GF/Shell/HelpFile.hs
+++ b/src/GF/Shell/HelpFile.hs
@@ -81,6 +81,9 @@ txtHelpFile =
"\n examples:" ++
"\n i English.gf -- ordinary import of Concrete" ++
"\n i -retain german/ParadigmsGer.gf -- import of Resource to test" ++
+ "\n" ++
+ "\nr, reload: r" ++
+ "\n Executes the previous import (i) command." ++
"\n " ++
"\nrl, remove_language: rl Language" ++
"\n Takes away the language from the state." ++
diff --git a/src/GF/Shell/PShell.hs b/src/GF/Shell/PShell.hs
index 159910755..68cb4d629 100644
--- a/src/GF/Shell/PShell.hs
+++ b/src/GF/Shell/PShell.hs
@@ -157,7 +157,7 @@ pCommand ws = case ws of
"es" : [] -> aImpure ICEditSession
"ts" : [] -> aImpure ICTranslateSession
-
+ "r" : [] -> aImpure ICReload
_ -> (CVoid, [])
where
diff --git a/src/GF/Shell/ShellCommands.hs b/src/GF/Shell/ShellCommands.hs
index a3a0139ea..5c35e3c31 100644
--- a/src/GF/Shell/ShellCommands.hs
+++ b/src/GF/Shell/ShellCommands.hs
@@ -97,8 +97,12 @@ data Command =
-- to isolate the commands that are executed on top level
data ImpureCommand =
- ICQuit | ICExecuteHistory FilePath | ICEarlierCommand Int
- | ICEditSession | ICTranslateSession
+ ICQuit
+ | ICExecuteHistory FilePath
+ | ICEarlierCommand Int
+ | ICEditSession
+ | ICTranslateSession
+ | ICReload
type CommandOpt = (Command, Options)