diff options
author | JasperVanDerJeugt <> | 2016-12-28 11:29:00 (GMT) |
---|---|---|
committer | hdiff <hdiff@hdiff.luite.com> | 2016-12-28 11:29:00 (GMT) |
commit | d4ae9e9a6f710b785a9783a06fa42a4e66b6e42b (patch) | |
tree | b07608def8d437225fd399c586ada4220bb9913b | |
parent | 01d0d0c2e1403303f86877415dd7a5488615ace1 (diff) |
version 0.4.6.00.4.6.0
-rw-r--r-- | CHANGELOG.md | 6 | ||||
-rw-r--r-- | patat.cabal | 2 | ||||
-rw-r--r-- | src/Main.hs | 5 | ||||
-rw-r--r-- | src/Patat/Presentation/Display.hs | 7 | ||||
-rw-r--r-- | src/Patat/Presentation/Interactive.hs | 20 |
5 files changed, 26 insertions, 14 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index baa720b..be9ad13 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +- 0.4.6.0 (2016-12-28) + * Redraw the screen on unknown commands to prevent accidental typing from + showing up. + * Make the cursor invisible during the presentation. + * Move the footer down one more line to gain some screen real estate. + - 0.4.5.0 (2016-12-05) * Render the date in a locale-independent manner (patch by Daniel Shahaf). diff --git a/patat.cabal b/patat.cabal index 6f75daf..fa1625b 100644 --- a/patat.cabal +++ b/patat.cabal @@ -1,5 +1,5 @@ Name: patat -Version: 0.4.5.0 +Version: 0.4.6.0 Synopsis: Terminal-based presentations using Pandoc Description: Terminal-based presentations using Pandoc License: GPL-2 diff --git a/src/Main.hs b/src/Main.hs index bfeca9c..0fccfde 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -9,6 +9,7 @@ module Main where import Control.Applicative ((<$>), (<*>)) import Control.Concurrent (forkIO, threadDelay) import qualified Control.Concurrent.Chan as Chan +import Control.Exception (finally) import Control.Monad (forever, unless, when) import qualified Data.Aeson.Extended as A import Data.Monoid (mempty, (<>)) @@ -131,8 +132,10 @@ main = do else interactiveLoop options pres where interactiveLoop :: Options -> Presentation -> IO () - interactiveLoop options pres0 = do + interactiveLoop options pres0 = (`finally` Ansi.showCursor) $ do IO.hSetBuffering IO.stdin IO.NoBuffering + Ansi.hideCursor + -- Spawn the initial channel that gives us commands based on user input. commandChan0 <- Chan.newChan _ <- forkIO $ forever $ 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) |