File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -271,10 +271,8 @@ mpgInput field = runForever $ do
271271run :: IO ()
272272run = runForever $ sequence_ . keymap =<< getKeys
273273 where
274- getKeys = unsafeInterleaveIO $ do
275- c <- UI. getKey
276- cs <- getKeys
277- pure (c: cs) -- A lazy list of curses keys
274+ -- A lazy list of curses keys
275+ getKeys = unsafeInterleaveIO $ (:) <$> UI. getKey <*> getKeys
278276
279277------------------------------------------------------------------------
280278
Original file line number Diff line number Diff line change @@ -132,20 +132,34 @@ suspend = raiseSignal sigTSTP
132132screenSize :: IO (Int , Int )
133133screenSize = Curses. scrSize
134134
135+ --
136+ -- | Rewrite of Curses.getCh to avoid looping on terminal crash
137+ -- | (also no unget support since I don't need it)
138+ --
139+ getCh :: IO Curses. Key
140+ getCh = do
141+ threadWaitRead 0
142+ v <- Curses. getch
143+ case v of
144+ - 1 -> do
145+ putStrLn " Terminal has gone away? Hard-exiting now."
146+ exitFailure
147+ k -> pure $ Curses. decodeKey k
148+
135149--
136150-- | Read a key. UIs need to define a method for getting events.
137151-- We only need to refresh if we don't have no SIGWINCH support.
138152--
139153getKey :: IO Char
140154getKey = do
141- k <- Curses. getCh
155+ k <- getCh
142156 if k == Curses. KeyResize
143157 then do
144158 when (isNothing Curses. cursesSigWinch) do
145159 runDraw $ redraw <> resizeui
146160 getKey
147161 else pure $ unkey k
148-
162+
149163-- | Resize the window
150164-- From "Writing Programs with NCURSES", by Eric S. Raymond and Zeyd M. Ben-Halim
151165--
Original file line number Diff line number Diff line change 11cabal-version : 2.2
22
33name : hmp3-ng
4- version : 2.17.0
4+ version : 2.17.1
55synopsis : A 2019 fork of an ncurses mp3 player written in Haskell
66description : An mp3 player with a curses frontend. Playlists are populated by
77 passing file and directory names on the command line. 'h' displays
Original file line number Diff line number Diff line change 1- resolver : lts-23.9
1+ resolver : lts-23.28
22system-ghc : true
33compiler-check : newer-minor
44
You can’t perform that action at this time.
0 commit comments