summaryrefslogtreecommitdiffstats
path: root/Main.hs
diff options
context:
space:
mode:
authortv <tv@shackspace.de>2014-07-27 20:58:33 +0200
committertv <tv@shackspace.de>2014-07-27 20:58:33 +0200
commit1be6510aa16cefe17438caf88aa0b74627ae90b6 (patch)
tree02afab402fe3c883ee2a0d174a036dc89d5fe870 /Main.hs
parent6160fbfd34179b660586f88d4dec5dfe14173fbf (diff)
constrain MotionCommand in NormalMode
Diffstat (limited to 'Main.hs')
-rw-r--r--Main.hs8
1 files changed, 7 insertions, 1 deletions
diff --git a/Main.hs b/Main.hs
index 465610d..2a29fb2 100644
--- a/Main.hs
+++ b/Main.hs
@@ -192,8 +192,14 @@ insertChar c (ls, rs) = (ls ++ [c], rs)
execCommand :: Command -> ExecM ()
-execCommand (MotionCommand x) =
+execCommand (MotionCommand x) = do
modifyBuffer (move x)
+ -- TODO apply mode constraints somewhere else
+ q <- get
+ when (mode q == NormalMode) $
+ when (null $ snd $ buffer q) $
+ modifyBuffer (gotoLeft 1)
+
execCommand (InsertChar c) =
modifyBuffer (insertChar c)