summaryrefslogtreecommitdiff
path: root/src-3.0/GF/Shell/JGF.hs
diff options
context:
space:
mode:
authoraarne <aarne@cs.chalmers.se>2008-05-21 09:26:44 +0000
committeraarne <aarne@cs.chalmers.se>2008-05-21 09:26:44 +0000
commit055c0d0d5a5bb0dc75904fe53df7f2e4f5732a8f (patch)
tree0e63fb68c69c8f6ad0f78893c63420f0a3600e1c /src-3.0/GF/Shell/JGF.hs
parent915a1de71783ab8446b1af9e72c7ba7dfbc12d3f (diff)
GF/src is now for 2.9, and the new sources are in src-3.0 - keep it this way until the release of GF 3
Diffstat (limited to 'src-3.0/GF/Shell/JGF.hs')
-rw-r--r--src-3.0/GF/Shell/JGF.hs89
1 files changed, 89 insertions, 0 deletions
diff --git a/src-3.0/GF/Shell/JGF.hs b/src-3.0/GF/Shell/JGF.hs
new file mode 100644
index 000000000..0ff678809
--- /dev/null
+++ b/src-3.0/GF/Shell/JGF.hs
@@ -0,0 +1,89 @@
+----------------------------------------------------------------------
+-- |
+-- Module : JGF
+-- Maintainer : AR
+-- Stability : (stable)
+-- Portability : (portable)
+--
+-- > 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
+-----------------------------------------------------------------------------
+
+module GF.Shell.JGF where
+
+import GF.Data.Operations
+import GF.Infra.UseIO
+import GF.Text.Unicode
+
+import GF.API.IOGrammar
+import GF.Infra.Option
+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
+
+
+
+-- GF editing session controlled by e.g. a Java program. AR 16/11/2001
+
+-- | the Boolean is a temporary hack to have two parallel GUIs
+sessionLineJ :: Bool -> ShellState -> IO ()
+sessionLineJ isNew env = do
+ putStrLnFlush $ initEditMsgJavaX env
+ let env' = addGlobalOptions (options [sizeDisplay "short",beSilent]) env
+ editLoopJnewX isNew env' (initSState)
+
+-- | this is the real version, with XML
+--
+-- the Boolean is a temporary hack to have two parallel GUIs
+editLoopJnewX :: Bool -> CEnv -> SState -> IO ()
+editLoopJnewX isNew env state = do
+ 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 =
+ "An experimental GF Editor for Java." ++
+ "(c) Kristofer Johannisson, Janna Khegai, and Aarne Ranta 2002 under CNU GPL."
+
+initEditMsgJavaX :: CEnv -> String
+initEditMsgJavaX env = encodeUTF8 $ mkUnicode $ unlines $ tagXML "gfinit" $
+ tagsXML "newcat" [["n" +++ cat] | (_,cat) <- newCatMenu env] ++
+ tagXML "topic" [abstractName env] ++
+ tagXML "language" [prLanguage langAbstract] ++
+ concat [tagAttrXML "language" ("file",file) [prLanguage lang] |
+ (file,lang) <- zip (allGrammarFileNames env) (allLanguages env)]
+
+
+initAndEditMsgJavaX :: Bool -> CEnv -> SState -> String -> String
+initAndEditMsgJavaX isNew env state m =
+ initEditMsgJavaX env ++++ displaySStateJavaX isNew env state m