summaryrefslogtreecommitdiff
path: root/src/Patat/Presentation/Interactive.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Patat/Presentation/Interactive.hs')
-rw-r--r--src/Patat/Presentation/Interactive.hs20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/Patat/Presentation/Interactive.hs b/src/Patat/Presentation/Interactive.hs
index d7d7d53..830f0ff 100644
--- a/src/Patat/Presentation/Interactive.hs
+++ b/src/Patat/Presentation/Interactive.hs
@@ -27,6 +27,7 @@ data PresentationCommand
| First
| Last
| Reload
+ | UnknownCommand String
--------------------------------------------------------------------------------
@@ -48,7 +49,7 @@ readPresentationCommand = do
"0" -> return First
"G" -> return Last
"r" -> return Reload
- _ -> readPresentationCommand
+ _ -> return (UnknownCommand k)
where
readKey :: IO String
readKey = do
@@ -77,14 +78,15 @@ updatePresentation
:: PresentationCommand -> Presentation -> IO UpdatedPresentation
updatePresentation cmd presentation = case cmd of
- Exit -> return ExitedPresentation
- Forward -> return $ goToSlide $ \(s, f) -> (s, f + 1)
- Backward -> return $ goToSlide $ \(s, f) -> (s, f - 1)
- SkipForward -> return $ goToSlide $ \(s, _) -> (s + 10, 0)
- SkipBackward -> return $ goToSlide $ \(s, _) -> (s - 10, 0)
- First -> return $ goToSlide $ \_ -> (0, 0)
- Last -> return $ goToSlide $ \_ -> (numSlides presentation, 0)
- Reload -> reloadPresentation
+ Exit -> return ExitedPresentation
+ Forward -> return $ goToSlide $ \(s, f) -> (s, f + 1)
+ Backward -> return $ goToSlide $ \(s, f) -> (s, f - 1)
+ SkipForward -> return $ goToSlide $ \(s, _) -> (s + 10, 0)
+ SkipBackward -> return $ goToSlide $ \(s, _) -> (s - 10, 0)
+ First -> return $ goToSlide $ \_ -> (0, 0)
+ Last -> return $ goToSlide $ \_ -> (numSlides presentation, 0)
+ Reload -> reloadPresentation
+ UnknownCommand _ -> return (UpdatedPresentation presentation)
where
numSlides :: Presentation -> Int
numSlides pres = length (pSlides pres)