From 49201e4fed91266953127588afd57853e612f996 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 1 Aug 2014 12:18:26 +0200 Subject: add count --- src/Main.hs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Main.hs b/src/Main.hs index 4a96cf0..3af0d5f 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -34,6 +34,7 @@ data VTState = VTState { buffer :: Buffer , mode :: Mode , processCount :: Int + , count :: Int , register :: Char , registers :: Map Char String } @@ -53,6 +54,7 @@ main = do { mode = InsertMode , buffer = ("!while date; do sleep 1; done", "") , processCount = 0 + , count = 0 , register = defaultRegister , registers = Map.empty } @@ -148,6 +150,9 @@ data Command | Combine Command Command | Nop | RingBell + | AddCount Int + | MulCount Int + | SetCount Int | SetRegister Char instance Monoid Command where @@ -313,6 +318,10 @@ execCommand Nop = return () execCommand RingBell = liftIO ringBell +execCommand (AddCount i) = modify $ \q -> q { count = i + count q } +execCommand (MulCount i) = modify $ \q -> q { count = i * count q } +execCommand (SetCount i) = modify $ \q -> q { count = i } + execCommand (SetRegister c) = modify $ \q -> q { register = c } @@ -435,6 +444,7 @@ nmap = , ("\x0a", ExecuteInputBuffer <> ChangeMode InsertMode) , ("\x1b", RingBell) -- TODO cancel any unfinished commands ] + ++ (map (\i -> (show i, MulCount 10 <> AddCount i)) [0..9]) imap :: Keymap -- cgit v1.2.3