diff options
-rw-r--r-- | Main.hs | 21 |
1 files changed, 10 insertions, 11 deletions
@@ -103,9 +103,9 @@ uiThread modeRef lock = do data Command = AlertBadInput String - | InsertChar Char + | InsertString String | InsertNextCharVerbatim - | InsertCharThenChangeMode Char Mode + | InsertStringThenChangeMode String Mode | KillLastWord | KillLastChar | KillNextChar @@ -187,7 +187,7 @@ runExecCommand st (ExecM ex) = -insertChar c (ls, rs) = (ls ++ [c], rs) +insertString s (ls, rs) = (ls ++ s, rs) execCommand :: Command -> ExecM () @@ -201,16 +201,16 @@ execCommand (MotionCommand x) = do modifyBuffer (gotoLeft 1) -execCommand (InsertChar c) = - modifyBuffer (insertChar c) - execCommand (ChangeMode m) = modify $ \ q -> q { mode = m } -execCommand (InsertCharThenChangeMode c m) = +execCommand (InsertString s) = + modifyBuffer (insertString s) + +execCommand (InsertStringThenChangeMode s m) = modify $ \ q -> q { mode = m - , buffer = insertChar c (buffer q) + , buffer = insertString s (buffer q) } execCommand InsertNextCharVerbatim = @@ -459,7 +459,7 @@ instance Show Mode where getCommand :: Mode -> IO Command -getCommand InsertMode = getMappedCommand imap InsertChar +getCommand InsertMode = getMappedCommand imap (InsertString . (:[])) getCommand NormalMode = getMappedCommand nmap (AlertBadInput . (:[])) getCommand VerbatimMode = verbatimKeymap @@ -490,8 +490,7 @@ getMappedCommand xs defCmd = do verbatimKeymap :: IO Command verbatimKeymap = do c <- getChar - --return $ InsertCharThenChangeMode c defaultGetCommand - return $ InsertCharThenChangeMode c NormalMode + return $ InsertStringThenChangeMode [c] NormalMode -- TODO Control.Monad.whenLeft |