From baff597a7b274db01419e4b4a0ba3f428c78d288 Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 28 Jul 2014 00:20:41 +0200 Subject: s/([iI]nsert)Char/\1String/ --- Main.hs | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'Main.hs') diff --git a/Main.hs b/Main.hs index 470d7fa..35df840 100644 --- a/Main.hs +++ b/Main.hs @@ -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 -- cgit v1.2.3