summaryrefslogtreecommitdiff
path: root/src/GF/Shell/SubShell.hs
blob: 1b8a647df9ca9d7ea3c66420a3ae0b7e550e85cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
module SubShell where

import Operations
import UseIO
import ShellState
import Option
import API

import CommandL
import ArchEdit

-- AR 20/4/2000 -- 12/11/2001

editSession :: Options -> ShellState -> IO ()
editSession opts st
  | oElem makeFudget opts = fudlogueEdit font st'
  | otherwise             = initEditLoop st' (return ())
 where
   st'   = addGlobalOptions opts st
   font  = maybe myUniFont mkOptFont $ getOptVal opts useFont

myUniFont = "-mutt-clearlyu-medium-r-normal--0-0-100-100-p-0-iso10646-1"
mkOptFont = id

translateSession :: Options -> ShellState -> IO ()
translateSession opts st = do
  let grs   = allStateGrammars st
      cat   = firstCatOpts opts (firstStateGrammar st)
      trans = unlines . translateBetweenAll grs cat
  translateLoop opts trans

translateLoop opts trans = do
  let fud  = oElem makeFudget opts
      font = maybe myUniFont mkOptFont $ getOptVal opts useFont
  if fud then fudlogueWrite font trans else loopLine
 where
   loopLine = do
     putStrFlush "trans> "
     s <- getLine
     if s == "." then return () else do
       putStrLnFlush $ trans s
       loopLine