diff options
| author | aarne <aarne@cs.chalmers.se> | 2008-12-09 14:52:12 +0000 |
|---|---|---|
| committer | aarne <aarne@cs.chalmers.se> | 2008-12-09 14:52:12 +0000 |
| commit | d925bb35c1a801f0cecee753fea714e279f0ecbd (patch) | |
| tree | 998f6b655ac6540fc53bafa0852099d936b5a0f6 /src/exper | |
| parent | a6097ccee650885d7146c6fbdbafa34b0297ac7e (diff) | |
Editor with some commands, using PGF API, with demo shell in exper/EditShell; still buggy
Diffstat (limited to 'src/exper')
| -rw-r--r-- | src/exper/EditShell.hs | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/exper/EditShell.hs b/src/exper/EditShell.hs new file mode 100644 index 000000000..a50317d47 --- /dev/null +++ b/src/exper/EditShell.hs @@ -0,0 +1,39 @@ +module Main where + +import PGF.Editor +import PGF + +import System (getArgs) + +main = do + putStrLn "Hi, I'm the Editor!" + file:_ <- getArgs + pgf <- readPGF file + let dict = pgf2dict pgf + let st0 = new (startCat pgf) + editLoop pgf dict st0 + +editLoop :: PGF -> Dict -> State -> IO State +editLoop pgf dict st = do + putStrLn ("I want something of type " ++ prCId (focusType st)) + c <- getLine + st' <- interpret pgf dict st c + let t = etree2tree (tree st') + putStrLn (unlines ([ + "Now I have", + showTree t] ++ + linearizeAll pgf t)) + editLoop pgf dict st' + +interpret :: PGF -> Dict -> State -> String -> IO State +interpret pgf dict st c = case words c of + "r":f:_ -> do + return $ goNextMeta (refine dict (mkCId f) st) + "m":_ -> do + putStrLn (unwords (map (prCId . fst) (refineMenu dict st))) + return st + _ -> do + putStrLn "command not understood" + return st + + |
