summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authortv <tv@shackspace.de>2014-08-01 12:18:26 +0200
committertv <tv@shackspace.de>2014-08-01 12:18:26 +0200
commit49201e4fed91266953127588afd57853e612f996 (patch)
treebbd39380158f84b1e6739a6f21c650759c5e53eb /src
parentf029d6039fdf95200c548c5f3cc2c94447d5d8f2 (diff)
add count
Diffstat (limited to 'src')
-rw-r--r--src/Main.hs10
1 files changed, 10 insertions, 0 deletions
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