From 74ecb3f7b885f53e799c020355402c254868a686 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 1 Aug 2014 12:25:08 +0200 Subject: Command += DeleteEntireLine --- src/Main.hs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Main.hs b/src/Main.hs index 139b478..11b246c 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -154,6 +154,7 @@ data Command | MulCount Int | SetCount Int | SetRegister Char + | DeleteEntireLine instance Monoid Command where mempty = Nop @@ -324,6 +325,18 @@ execCommand (SetCount i) = modify $ \q -> q { count = i } execCommand (SetRegister c) = modify $ \q -> q { register = c } +execCommand DeleteEntireLine = modify $ \q -> + -- TODO Numbered registers "0 to "9 + -- Small delete register "- + let s = showBuffer $ buffer q + r = register q + in q { registers = Map.insert r s + $ Map.insert defaultRegister + $ registers q + , buffer = emptyBuffer + , register = defaultRegister + } + reform :: Int -> Char -> String reform colorCode c = @@ -422,6 +435,7 @@ charToCode c = "\\x" ++ showIntAtBase 16 intToDigit (ord c) "" dmap :: Keymap dmap = [ ("\x1b", ChangeMode NormalMode) + , ("d", DeleteEntireLine <> ChangeMode NormalMode) ] -- cgit v1.2.3