From 71532ce9d550ba40ef3e8019cc0f93c655792ae6 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 1 Aug 2014 12:22:23 +0200 Subject: add DeleteMode --- src/Main.hs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Main.hs b/src/Main.hs index 3af0d5f..139b478 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -358,6 +358,7 @@ renderInputLine m (lhs, rhs) = do InsertMode -> "> " VerbatimMode -> "\x1b[34;1m^\x1b[m " SelectRegisterMode -> "\" " + DeleteMode -> "\x1b[31;1m>\x1b[m " putStr $ promptString ++ (lhs >>= reform') ++ (rhs >>= reform') moveCursorLeft (length $ rhs >>= reformVis) @@ -418,6 +419,12 @@ charToCode :: Char -> String charToCode c = "\\x" ++ showIntAtBase 16 intToDigit (ord c) "" +dmap :: Keymap +dmap = + [ ("\x1b", ChangeMode NormalMode) + ] + + selectRegisterMap :: Keymap selectRegisterMap = [ ("\x1b", ChangeMode NormalMode) @@ -438,6 +445,7 @@ nmap = , ("l", MotionCommand $ GotoRight 1) , ("b", MotionCommand $ WordsBackward 1) , ("w", MotionCommand $ WordsForward 1) + , ("d", ChangeMode DeleteMode) , ("\"", ChangeMode SelectRegisterMode) , ("\x1b[C", MotionCommand $ GotoRight 1) , ("\x1b[D", MotionCommand $ GotoLeft 1) @@ -472,6 +480,7 @@ data Mode | NormalMode | VerbatimMode | SelectRegisterMode + | DeleteMode deriving (Eq) instance Show Mode where @@ -479,6 +488,7 @@ instance Show Mode where show InsertMode = "insert" show VerbatimMode = "verbatim" show SelectRegisterMode = "select register" + show DeleteMode = "delete" getCommand :: Mode -> String -> Command @@ -488,6 +498,7 @@ getCommand VerbatimMode s = InsertString s <> ChangeMode InsertMode getCommand SelectRegisterMode s = maybe (AlertBadInput s) id $ lookup s selectRegisterMap -- ^ TODO clear bad input +getCommand DeleteMode s = maybe (AlertBadInput s) id $ lookup s dmap -- TODO Control.Monad.whenLeft -- cgit v1.2.3