diff options
| author | aarne <unknown> | 2005-06-11 19:27:05 +0000 |
|---|---|---|
| committer | aarne <unknown> | 2005-06-11 19:27:05 +0000 |
| commit | e2cc1184d40f1c4996143f205da8a9c23d2a87d4 (patch) | |
| tree | 4c48475e0852ac70cbb4e542606f8d327afc66b7 /src/GF/UseGrammar/Session.hs | |
| parent | 6a66fc5d71747c1009590e68887a9bbd6f44e598 (diff) | |
undo k and keep position in editor
Diffstat (limited to 'src/GF/UseGrammar/Session.hs')
| -rw-r--r-- | src/GF/UseGrammar/Session.hs | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/GF/UseGrammar/Session.hs b/src/GF/UseGrammar/Session.hs index 4aabe9f60..4271a0034 100644 --- a/src/GF/UseGrammar/Session.hs +++ b/src/GF/UseGrammar/Session.hs @@ -5,9 +5,9 @@ -- Stability : (stable) -- Portability : (portable) -- --- > CVS $Date: 2005/06/10 15:59:59 $ +-- > CVS $Date: 2005/06/11 20:27:05 $ -- > CVS $Author: aarne $ --- > CVS $Revision: 1.10 $ +-- > CVS $Revision: 1.11 $ -- -- (Description of the module) ----------------------------------------------------------------------------- @@ -21,6 +21,7 @@ import GF.UseGrammar.Editing import GF.Compile.ShellState ---- grammar import GF.Data.Operations +import GF.Data.Zipper (keepPosition) --- -- First version 8/2001. Adapted to GFC with modules 19/6/2003. -- Nothing had to be changed, which is a sign of good modularity. @@ -118,9 +119,15 @@ action2command act state = case act (stateSState state) of action2commandNext :: Action -> ECommand -- move to next meta after execution action2commandNext act = action2command (\s -> act s >>= goNextMetaIfCan) -undoCommand :: ECommand -undoCommand ss@[_] = changeMsg ["cannot go back"] ss -undoCommand (_:ss) = changeMsg ["successful undo"] ss +action2commandKeep :: Action -> ECommand -- keep old position after execution +action2commandKeep act = action2command (\s -> keepPosition act s) + +undoCommand :: Int -> ECommand +undoCommand n ss = + let k = length ss in + if k < n + then changeMsg ["cannot go all the way back"] [] + else changeMsg ["successful undo"] (drop n ss) selectCand :: CGrammar -> Int -> ECommand selectCand gr i state = err (\m -> changeMsg [m] state) id $ do @@ -149,7 +156,7 @@ replaceByTrees gr trees = case trees of replaceByEditCommand :: StateGrammar -> String -> ECommand replaceByEditCommand gr co = - action2command $ + action2commandKeep $ maybe return ($ gr) $ lookupCustom customEditCommand (strCI co) |
