summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoraarne <unknown>2005-06-03 21:44:36 +0000
committeraarne <unknown>2005-06-03 21:44:36 +0000
commite6e29eab786a687223d42adc100a6a156b2b1807 (patch)
tree2987fe3003be97ba5095bb3a933cc20a4344beb3 /src
parent0bb4ffe0570e6a15955e9777e28b8f1aa346ba8f (diff)
editor command sequence
Diffstat (limited to 'src')
-rw-r--r--src/GF/Shell/CommandL.hs15
-rw-r--r--src/GF/Shell/JGF.hs50
2 files changed, 40 insertions, 25 deletions
diff --git a/src/GF/Shell/CommandL.hs b/src/GF/Shell/CommandL.hs
index 889af5b6f..62d3f9e87 100644
--- a/src/GF/Shell/CommandL.hs
+++ b/src/GF/Shell/CommandL.hs
@@ -5,9 +5,9 @@
-- Stability : (stable)
-- Portability : (portable)
--
--- > CVS $Date: 2005/04/21 16:23:19 $
--- > CVS $Author: bringert $
--- > CVS $Revision: 1.16 $
+-- > CVS $Date: 2005/06/03 22:44:36 $
+-- > CVS $Author: aarne $
+-- > CVS $Revision: 1.17 $
--
-- (Description of the module)
-----------------------------------------------------------------------------
@@ -25,6 +25,7 @@ import GF.Compile.ShellState
import GF.Infra.Option
import GF.UseGrammar.Session
import GF.Shell.Commands
+import GF.Shell.PShell (wordsLits)
import Data.Char
import Data.List (intersperse)
@@ -77,14 +78,18 @@ getCommand = do
-- | decodes UTF8 if u==False, i.e. if the grammar does not use UTF8;
-- used in the Java GUI, which always uses UTF8
-getCommandUTF :: Bool -> IO (String,Command)
+getCommandUTF :: Bool -> IO [(String,Command)]
getCommandUTF u = do
s <- getLine
- return $ pCommandMsg $ if u then s else decodeUTF8 s
+ return $ pCommandMsgs $ if u then s else decodeUTF8 s
+
+pCommandMsgs :: String -> [(String,Command)]
+pCommandMsgs = map (pCommandMsg . unwords) . concatMap (chunks ";;" . words) . lines
pCommand :: String -> Command
pCommand = snd . pCommandMsg
+
pCommandMsg :: String -> (String,Command)
pCommandMsg s = (m,pCommandWords $ words c) where
(m,c) = case s of
diff --git a/src/GF/Shell/JGF.hs b/src/GF/Shell/JGF.hs
index 58be7bfbf..0ff678809 100644
--- a/src/GF/Shell/JGF.hs
+++ b/src/GF/Shell/JGF.hs
@@ -5,9 +5,9 @@
-- Stability : (stable)
-- Portability : (portable)
--
--- > CVS $Date: 2005/04/21 16:23:21 $
--- > CVS $Author: bringert $
--- > CVS $Revision: 1.12 $
+-- > CVS $Date: 2005/06/03 22:44:36 $
+-- > CVS $Author: aarne $
+-- > CVS $Revision: 1.13 $
--
-- GF editing session controlled by e.g. a Java program. AR 16\/11\/2001
-----------------------------------------------------------------------------
@@ -24,9 +24,11 @@ import GF.Compile.ShellState
import GF.UseGrammar.Session
import GF.Shell.Commands
import GF.Shell.CommandL
+import GF.Text.UTF8
+import Control.Monad (foldM)
import System
-import GF.Text.UTF8
+
-- GF editing session controlled by e.g. a Java program. AR 16/11/2001
@@ -43,22 +45,30 @@ sessionLineJ isNew env = do
-- the Boolean is a temporary hack to have two parallel GUIs
editLoopJnewX :: Bool -> CEnv -> SState -> IO ()
editLoopJnewX isNew env state = do
- (m,c) <- getCommandUTF (isCEnvUTF8 env state) ----
- case c of
- CQuit -> return ()
-
- c -> do
- (env',state') <- execCommand env c state
- let inits = initAndEditMsgJavaX isNew env' state' m
- let package = case c of
- CCEnvImport _ -> inits
- CCEnvEmptyAndImport _ -> inits
- CCEnvOpenTerm _ -> inits
- CCEnvOpenString _ -> inits
- CCEnvEmpty -> initEditMsgJavaX env'
- _ -> displaySStateJavaX isNew env' state' m
- putStrLnFlush package
- editLoopJnewX isNew env' state'
+ mscs <- getCommandUTF (isCEnvUTF8 env state) ----
+ let (ms,cs) = unzip mscs
+ m = unlines ms --- ?
+ if null cs
+ then editLoopJnewX isNew env state
+ else
+ case cs of
+ [CQuit] -> return ()
+ _ -> do
+ (env',state') <- foldM exec (env,state) cs
+ let inits = initAndEditMsgJavaX isNew env' state' m
+ let
+ package = case last cs of
+ CCEnvImport _ -> inits
+ CCEnvEmptyAndImport _ -> inits
+ CCEnvOpenTerm _ -> inits
+ CCEnvOpenString _ -> inits
+ CCEnvEmpty -> initEditMsgJavaX env'
+ _ -> displaySStateJavaX isNew env' state' m
+ putStrLnFlush package
+ editLoopJnewX isNew env' state'
+ where
+ exec (env,state) c = do
+ execCommand env c state
welcome :: String
welcome =