summaryrefslogtreecommitdiff
path: root/src/GF/UseGrammar/Session.hs
diff options
context:
space:
mode:
authoraarne <unknown>2003-09-24 14:26:35 +0000
committeraarne <unknown>2003-09-24 14:26:35 +0000
commit6e9258558a9bcb8c9df4bee0382b5136c95f516a (patch)
tree99475ee58ba264780403480ce29c9ee40beee1ec /src/GF/UseGrammar/Session.hs
parentb1402e8bd6a68a891b00a214d6cf184d66defe19 (diff)
Improvements in hte editor.
Diffstat (limited to 'src/GF/UseGrammar/Session.hs')
-rw-r--r--src/GF/UseGrammar/Session.hs24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/GF/UseGrammar/Session.hs b/src/GF/UseGrammar/Session.hs
index bf2dd30ab..051630149 100644
--- a/src/GF/UseGrammar/Session.hs
+++ b/src/GF/UseGrammar/Session.hs
@@ -2,8 +2,9 @@ module Session where
import Abstract
import Option
----- import Custom
+import Custom
import Editing
+import ShellState ---- grammar
import Operations
@@ -50,6 +51,9 @@ changeMsg m ((s,ts,(_,b)):ss) = (s,ts,(m,b)) : ss -- just change message
changeView :: ECommand
changeView ((s,ts,(m,(v,b))):ss) = (s,ts,(m,(v+1,b))) : ss -- toggle view
+withMsg :: [String] -> ECommand -> ECommand
+withMsg m c = changeMsg m . c
+
changeStOptions :: (Options -> Options) -> ECommand
changeStOptions f ((s,ts,(m,(v,o))):ss) = (s,ts,(m,(v, f o))) : ss
@@ -90,21 +94,25 @@ refineByExps der gr trees = case trees of
[t] -> action2commandNext (refineWithExpTC der gr t)
_ -> changeCands trees
+refineByTrees :: Bool -> CGrammar -> [Tree] -> ECommand
+refineByTrees der gr trees = case trees of
+ [t] -> action2commandNext (refineWithTree der gr t)
+ _ -> changeCands $ map tree2exp trees
+
replaceByTrees :: CGrammar -> [Exp] -> ECommand
replaceByTrees gr trees = case trees of
[t] -> action2commandNext (\s ->
annotateExpInState gr t s >>= flip replaceSubTree s)
_ -> changeCands trees
-{- ----
-replaceByEditCommand :: CGrammar -> String -> ECommand
+replaceByEditCommand :: StateGrammar -> String -> ECommand
replaceByEditCommand gr co =
action2command $
maybe return ($ gr) $
lookupCustom customEditCommand (strCI co)
-replaceByTermCommand :: CGrammar -> String -> Exp -> ECommand
-replaceByTermCommand gr co exp =
- replaceByTrees gr $ maybe [exp] (\f -> f (abstractOf gr) exp) $
- lookupCustom customTermCommand (strCI co)
--}
+replaceByTermCommand :: Bool -> StateGrammar -> String -> Tree -> ECommand ----
+replaceByTermCommand der gr co exp =
+ let g = grammar gr in
+ refineByTrees der g $ maybe [exp] (\f -> f gr exp) $
+ lookupCustom customTermCommand (strCI co)