summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authortv <tv@shackspace.de>2014-08-01 12:22:23 +0200
committertv <tv@shackspace.de>2014-08-01 12:22:23 +0200
commit71532ce9d550ba40ef3e8019cc0f93c655792ae6 (patch)
tree132f91e43e4cf411c126fe7727cfee9fb7f9ee7c /src
parent49201e4fed91266953127588afd57853e612f996 (diff)
add DeleteMode
Diffstat (limited to 'src')
-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