summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/Main.hs11
1 files changed, 11 insertions, 0 deletions
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