summaryrefslogtreecommitdiff
path: root/src/Patat
diff options
context:
space:
mode:
Diffstat (limited to 'src/Patat')
-rw-r--r--src/Patat/Presentation/Display.hs7
-rw-r--r--src/Patat/Presentation/Interactive.hs20
2 files changed, 15 insertions, 12 deletions
diff --git a/src/Patat/Presentation/Display.hs b/src/Patat/Presentation/Display.hs
index 1738e23..cb562d7 100644
--- a/src/Patat/Presentation/Display.hs
+++ b/src/Patat/Presentation/Display.hs
@@ -26,10 +26,11 @@ import Patat.PrettyPrint ((<$$>), (<+>))
import qualified Patat.PrettyPrint as PP
import Patat.Theme (Theme (..))
import qualified Patat.Theme as Theme
+import Prelude
import qualified System.Console.ANSI as Ansi
import qualified System.Console.Terminal.Size as Terminal
+import qualified System.IO as IO
import qualified Text.Pandoc.Extended as Pandoc
-import Prelude
--------------------------------------------------------------------------------
@@ -69,11 +70,11 @@ displayWithBorders Presentation {..} f = do
active = show (sidx + 1) ++ " / " ++ show (length pSlides)
activeWidth = length active
- Ansi.setCursorPosition (rows - 2) 0
+ Ansi.setCursorPosition (rows - 1) 0
PP.putDoc $ " " <> borders (prettyInlines theme pAuthor)
Ansi.setCursorColumn (columns - activeWidth - 1)
PP.putDoc $ borders $ PP.string active
- putStrLn ""
+ IO.hFlush IO.stdout
--------------------------------------------------------------------------------
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)