diff options
author | tv <tv@shackspace.de> | 2014-08-01 14:39:28 +0200 |
---|---|---|
committer | tv <tv@shackspace.de> | 2014-08-01 14:39:28 +0200 |
commit | ae7dc0431d3e89d1918d9c8b2caba9e1eb93b140 (patch) | |
tree | 501dffd717362444aab7d58d213e11fe36fa402c | |
parent | 7a4f697f7bdce5ab0f2d2dd62ace652056cfc1be (diff) |
s/SilentMotionCommand/MotionCommandWarn/
-rw-r--r-- | src/Main.hs | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/src/Main.hs b/src/Main.hs index 328c641..f217310 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -105,30 +105,16 @@ uiThread cf putState getState = forever $ do --withOutput cf $ do -- putStrLn $ show cmd - ((_, lns), q1) <- runVT cf q0 (execCommand cmd) + ((eitCmd, lns), q1) <- runVT cf q0 (execCommand cmd) -- TODO only putState if it has changed (?) putState q1 - -- XXX dummy for following legacy code - let eitCmd = Right cmd - - let mbErr = case eitCmd of - Left err -> Just err - Right c -> - -- TODO move this to execCommand / throwError - case c of - MotionCommand motion | buffer q0 == buffer q1 -> - Just (OtherError $ "motion failed: " ++ show motion) - _ -> - Nothing - withOutput cf $ do forM_ lns putStrLn - case mbErr of - Just err -> ringBell >> putStrLn (prettyError err) - Nothing -> return () + whenLeft eitCmd $ \err -> + ringBell >> putStrLn (prettyError err) --when (mode st /= mode st') $ do -- putStrLn $ "change mode: " ++ (show $ mode st') @@ -143,6 +129,7 @@ data Command | KillNextChar | ExecuteInputBuffer | MotionCommand LeftRightMotion + | MotionCommandWarn LeftRightMotion | ChangeMode Mode -- TODO Move Count Motion -- Delete Count Register Motion @@ -238,6 +225,15 @@ execCommand (MotionCommand x) = do when (null $ snd $ buffer q) $ modifyBuffer (gotoLeft 1) +execCommand (MotionCommandWarn x) = do + b0 <- gets buffer + execCommand (MotionCommand x) + b1 <- gets buffer + + -- TODO make this a warning or else ... + when (b0 == b1) $ + throwError (OtherError $ "your motion has no effect: " ++ show x) + execCommand (ChangeMode m) = modify $ \ q -> q { mode = m } |