summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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