@@ -117,9 +117,8 @@ getKey = do
117117
118118-- | Resize the window
119119-- From "Writing Programs with NCURSES", by Eric S. Raymond and Zeyd M. Ben-Halim
120- --
121120resizeui :: Draw
122- resizeui = Draw $ void $ do
121+ resizeui = Draw do
123122 Curses. endWin
124123 Curses. resetParams
125124 do
@@ -131,7 +130,7 @@ resizeui = Draw $ void $ do
131130 -- Curses.meta stdScr True -- not in module
132131 -- not sure about intrFlush, raw - set in hscurses
133132 Curses. refresh
134- Curses. scrSize
133+ void Curses. scrSize
135134
136135refresh :: IO ()
137136refresh = runDraw $ redraw <> Draw Curses. refresh
@@ -203,18 +202,17 @@ playInfo DD{drawState=st} = mconcat
203202playTitle :: DrawData -> StringA
204203playTitle dd@ DD {drawWidth= w, drawState= st} =
205204 flip Fast hl $ mconcat if gap >= 2
206- then [" " , inf, spaces gapl, u indic, spaces gapr, uptime, " " , ver, " " ]
205+ then [" " , inf, spaces gapl, u indic, spaces gapr, st . uptime, " " , ver, " " ]
207206 else let gap' = w - indicl; gapl' = gap' `div` 2
208207 in if gap' >= 2
209208 then [spaces gapl', u indic, spaces $ gap' - gapl']
210209 else [" " , u $ take (w- 2 ) indic, " " ]
211210 where
212211 inf = playInfo dd
213- uptime = st. uptime
214212 indic = pState dd ++ ' ' : pMode dd
215213 ver = El. pVersion
216214 lsize = 1 + P. length inf
217- rsize = 2 + P. length uptime + P. length ver
215+ rsize = 2 + P. length st . uptime + P. length ver
218216 side = (w - indicl) `div` 2
219217 gap = w - indicl - lsize - rsize
220218 gapl = 1 `max` ((side - lsize) `min` (gap - 1 ))
@@ -241,13 +239,13 @@ playList buflen DD{ drawWidth=w, drawState=st } =
241239 loop _ [] = []
242240 loop n (v: vs) =
243241 let r = if v. fdir > n then Just v. fdir else Nothing
244- in (r, toWidth (w - indent - 1 ) v. fbase) : loop v. fdir vs
242+ in (r, toMaxWidth (w - indent - 1 ) v. fbase) : loop v. fdir vs
245243
246244 list = [ drawIt . color $ n | n <- zip visible' [0 .. ] ]
247245
248246 indent = (round $ (0.334 :: Float ) * fromIntegral w) :: Int
249247
250- (sty1, sty2, sty3) = (selected cs, cursors cs, combined cs )
248+ (sty1, sty2, sty3) = (cs . selected, cs . cursors, cs . combined )
251249 where cs = st. uiStyle
252250
253251 color :: ((Maybe Int , ByteString ), Int )
@@ -269,10 +267,10 @@ playList buflen DD{ drawWidth=w, drawState=st } =
269267 : map (, sty) v
270268 where
271269 sty' = if sty == sty2 || sty == sty3 then sty2 else sty1
272- d = toMaxWidth (indent - 1 ) $ takeFileName (folders st ! i). dname
270+ d = toMaxWidth (indent - 1 ) $ takeFileName (st . folders ! i). dname
273271
274272------------------------------------------------------------------------
275- -- | Now write out just the clock line
273+ -- | Write out only the clock lines.
276274redrawJustClock :: Draw
277275redrawJustClock = Draw do
278276 st <- getsHS id
@@ -307,10 +305,9 @@ redraw :: Draw
307305redraw = Draw do
308306 st <- getsHS id
309307 sz@ (h, w) <- screenSize
310- let dd = DD w st
311- tot = pPlaying dd : clockLines dd ++ playTitle dd : playList (h- 5 ) dd
312308 setXterm st
313- drawFullLines (h- 1 ) 0 tot
309+ drawFullLines (h- 1 ) 0 $ let dd = DD w st in
310+ pPlaying dd : clockLines dd ++ playTitle dd : playList (h- 5 ) dd
314311 renderModals st sz
315312 -- minibuffer
316313 Curses. wMove Curses. stdScr (h- 1 ) 0
@@ -319,7 +316,7 @@ redraw = Draw do
319316 drawLine $ Fast " " st. uiStyle. blockcursor
320317 fillLine
321318
322- -- | Render whole lines without going below height .
319+ -- | Render whole lines without going below limit .
323320drawFullLines :: Int -> Int -> [StringA ] -> IO ()
324321drawFullLines limit y ls =
325322 for_ (zip [y .. limit- 1 ] ls) \ (y', t) -> do
@@ -367,13 +364,11 @@ setXtermTitle strs = do
367364
368365-- set xterm title. Don't need to do this on each refresh...
369366setXterm :: HState -> IO ()
370- setXterm s = setXtermTitle $ case status s of
371- Playing -> case id3 s of
372- Nothing -> [fbase $ music s ! current s]
373- Just ti -> id3artist ti :
374- if P. null (id3title ti)
375- then []
376- else [" : " , id3title ti]
367+ setXterm st = setXtermTitle case st. status of
368+ Playing -> case st. id3 of
369+ Just id3 -> id3. id3artist :
370+ if P. null id3. id3title then [] else [" : " , id3. id3title]
371+ _ -> [(st. music ! st. current). fbase]
377372 Paused -> [" paused" ]
378373 Stopped -> [" stopped" ]
379374
0 commit comments