hmp3-ng 2.17.0 → 2.17.1
raw patch · 4 files changed
+22/−8 lines, 4 files
Files
- Core.hs +2/−4
- Keymap.hs +1/−1
- UI.hs +18/−2
- hmp3-ng.cabal +1/−1
Core.hs view
@@ -271,10 +271,8 @@ run :: IO () run = runForever $ sequence_ . keymap =<< getKeys where- getKeys = unsafeInterleaveIO $ do- c <- UI.getKey- cs <- getKeys- pure (c:cs) -- A lazy list of curses keys+ -- A lazy list of curses keys+ getKeys = unsafeInterleaveIO $ (:) <$> UI.getKey <*> getKeys ------------------------------------------------------------------------
Keymap.hs view
@@ -33,7 +33,7 @@ module Keymap where import Prelude ()-import Base hiding (all, delete)+import Base hiding (all, delete, (!?)) import Core import Config (package)
UI.hs view
@@ -59,6 +59,7 @@ import Foreign.C.String import Foreign.C.Types+import Foreign.C.Error (Errno(..), getErrno) import qualified Data.ByteString.Char8 as P import qualified Data.ByteString as B@@ -133,19 +134,34 @@ screenSize = Curses.scrSize --+-- | Rewrite of Curses.getCh to avoid looping on terminal crash+-- | (also no unget support since I don't need it)+--+getCh :: IO Curses.Key+getCh = do+ threadWaitRead 0+ v <- Curses.getch+ case v of+ -1 -> do+ Errno e <- getErrno+ putStrLn $ "Error " ++ show e ++ "; terminal has gone away? Hard-exiting now."+ exitFailure+ k -> pure $ Curses.decodeKey k++-- -- | Read a key. UIs need to define a method for getting events. -- We only need to refresh if we don't have no SIGWINCH support. -- getKey :: IO Char getKey = do- k <- Curses.getCh+ k <- getCh if k == Curses.KeyResize then do when (isNothing Curses.cursesSigWinch) do runDraw $ redraw <> resizeui getKey else pure $ unkey k- + -- | Resize the window -- From "Writing Programs with NCURSES", by Eric S. Raymond and Zeyd M. Ben-Halim --
hmp3-ng.cabal view
@@ -1,7 +1,7 @@ cabal-version: 2.2 name: hmp3-ng-version: 2.17.0+version: 2.17.1 synopsis: A 2019 fork of an ncurses mp3 player written in Haskell description: An mp3 player with a curses frontend. Playlists are populated by passing file and directory names on the command line. 'h' displays