forked from GitHub/gf-core
editor command sequence
This commit is contained in:
@@ -14,6 +14,14 @@ Changes in functionality since May 17, 2005, release of GF Version 2.2
|
|||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
||||||
|
4/6 (AR) Sequence of commands in the Java editor GUI now possible.
|
||||||
|
The commands are separated by <tt> ;; </tt> (notice the space on
|
||||||
|
both sides of the two semicolons). Such a sequence can be sent
|
||||||
|
from the "GF Command" pop-up field, but is mostly intended
|
||||||
|
for external processes that communicate with GF.
|
||||||
|
|
||||||
|
<p>
|
||||||
|
|
||||||
3/6 (AR) The format <tt>.gfe</tt> defined to support
|
3/6 (AR) The format <tt>.gfe</tt> defined to support
|
||||||
<b>grammar writing by examples</b>. Files of this format are first
|
<b>grammar writing by examples</b>. Files of this format are first
|
||||||
converted to <tt>.gf</tt> files by the command
|
converted to <tt>.gf</tt> files by the command
|
||||||
|
|||||||
@@ -5,9 +5,9 @@
|
|||||||
-- Stability : (stable)
|
-- Stability : (stable)
|
||||||
-- Portability : (portable)
|
-- Portability : (portable)
|
||||||
--
|
--
|
||||||
-- > CVS $Date: 2005/04/21 16:23:19 $
|
-- > CVS $Date: 2005/06/03 22:44:36 $
|
||||||
-- > CVS $Author: bringert $
|
-- > CVS $Author: aarne $
|
||||||
-- > CVS $Revision: 1.16 $
|
-- > CVS $Revision: 1.17 $
|
||||||
--
|
--
|
||||||
-- (Description of the module)
|
-- (Description of the module)
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
@@ -25,6 +25,7 @@ import GF.Compile.ShellState
|
|||||||
import GF.Infra.Option
|
import GF.Infra.Option
|
||||||
import GF.UseGrammar.Session
|
import GF.UseGrammar.Session
|
||||||
import GF.Shell.Commands
|
import GF.Shell.Commands
|
||||||
|
import GF.Shell.PShell (wordsLits)
|
||||||
|
|
||||||
import Data.Char
|
import Data.Char
|
||||||
import Data.List (intersperse)
|
import Data.List (intersperse)
|
||||||
@@ -77,14 +78,18 @@ getCommand = do
|
|||||||
|
|
||||||
-- | decodes UTF8 if u==False, i.e. if the grammar does not use UTF8;
|
-- | decodes UTF8 if u==False, i.e. if the grammar does not use UTF8;
|
||||||
-- used in the Java GUI, which always uses UTF8
|
-- used in the Java GUI, which always uses UTF8
|
||||||
getCommandUTF :: Bool -> IO (String,Command)
|
getCommandUTF :: Bool -> IO [(String,Command)]
|
||||||
getCommandUTF u = do
|
getCommandUTF u = do
|
||||||
s <- getLine
|
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 :: String -> Command
|
||||||
pCommand = snd . pCommandMsg
|
pCommand = snd . pCommandMsg
|
||||||
|
|
||||||
|
|
||||||
pCommandMsg :: String -> (String,Command)
|
pCommandMsg :: String -> (String,Command)
|
||||||
pCommandMsg s = (m,pCommandWords $ words c) where
|
pCommandMsg s = (m,pCommandWords $ words c) where
|
||||||
(m,c) = case s of
|
(m,c) = case s of
|
||||||
|
|||||||
@@ -5,9 +5,9 @@
|
|||||||
-- Stability : (stable)
|
-- Stability : (stable)
|
||||||
-- Portability : (portable)
|
-- Portability : (portable)
|
||||||
--
|
--
|
||||||
-- > CVS $Date: 2005/04/21 16:23:21 $
|
-- > CVS $Date: 2005/06/03 22:44:36 $
|
||||||
-- > CVS $Author: bringert $
|
-- > CVS $Author: aarne $
|
||||||
-- > CVS $Revision: 1.12 $
|
-- > CVS $Revision: 1.13 $
|
||||||
--
|
--
|
||||||
-- GF editing session controlled by e.g. a Java program. AR 16\/11\/2001
|
-- GF editing session controlled by e.g. a Java program. AR 16\/11\/2001
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
@@ -24,10 +24,12 @@ import GF.Compile.ShellState
|
|||||||
import GF.UseGrammar.Session
|
import GF.UseGrammar.Session
|
||||||
import GF.Shell.Commands
|
import GF.Shell.Commands
|
||||||
import GF.Shell.CommandL
|
import GF.Shell.CommandL
|
||||||
|
|
||||||
import System
|
|
||||||
import GF.Text.UTF8
|
import GF.Text.UTF8
|
||||||
|
|
||||||
|
import Control.Monad (foldM)
|
||||||
|
import System
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- GF editing session controlled by e.g. a Java program. AR 16/11/2001
|
-- GF editing session controlled by e.g. a Java program. AR 16/11/2001
|
||||||
|
|
||||||
@@ -43,14 +45,19 @@ sessionLineJ isNew env = do
|
|||||||
-- the Boolean is a temporary hack to have two parallel GUIs
|
-- the Boolean is a temporary hack to have two parallel GUIs
|
||||||
editLoopJnewX :: Bool -> CEnv -> SState -> IO ()
|
editLoopJnewX :: Bool -> CEnv -> SState -> IO ()
|
||||||
editLoopJnewX isNew env state = do
|
editLoopJnewX isNew env state = do
|
||||||
(m,c) <- getCommandUTF (isCEnvUTF8 env state) ----
|
mscs <- getCommandUTF (isCEnvUTF8 env state) ----
|
||||||
case c of
|
let (ms,cs) = unzip mscs
|
||||||
CQuit -> return ()
|
m = unlines ms --- ?
|
||||||
|
if null cs
|
||||||
c -> do
|
then editLoopJnewX isNew env state
|
||||||
(env',state') <- execCommand env c state
|
else
|
||||||
|
case cs of
|
||||||
|
[CQuit] -> return ()
|
||||||
|
_ -> do
|
||||||
|
(env',state') <- foldM exec (env,state) cs
|
||||||
let inits = initAndEditMsgJavaX isNew env' state' m
|
let inits = initAndEditMsgJavaX isNew env' state' m
|
||||||
let package = case c of
|
let
|
||||||
|
package = case last cs of
|
||||||
CCEnvImport _ -> inits
|
CCEnvImport _ -> inits
|
||||||
CCEnvEmptyAndImport _ -> inits
|
CCEnvEmptyAndImport _ -> inits
|
||||||
CCEnvOpenTerm _ -> inits
|
CCEnvOpenTerm _ -> inits
|
||||||
@@ -59,6 +66,9 @@ editLoopJnewX isNew env state = do
|
|||||||
_ -> displaySStateJavaX isNew env' state' m
|
_ -> displaySStateJavaX isNew env' state' m
|
||||||
putStrLnFlush package
|
putStrLnFlush package
|
||||||
editLoopJnewX isNew env' state'
|
editLoopJnewX isNew env' state'
|
||||||
|
where
|
||||||
|
exec (env,state) c = do
|
||||||
|
execCommand env c state
|
||||||
|
|
||||||
welcome :: String
|
welcome :: String
|
||||||
welcome =
|
welcome =
|
||||||
|
|||||||
Reference in New Issue
Block a user