@@ -145,8 +145,8 @@ data DrawData = DD { drawWidth :: Int, drawState :: HState }
145145------------------------------------------------------------------------
146146
147147-- | Info about the current track
148- pPlaying :: DrawData -> StringA
149- pPlaying dd = flip Fast defaultSty $ " " <> mconcat line where
148+ pPlaying :: DrawData -> Line
149+ pPlaying dd = pure $ plainSeg $ " " <> mconcat line where
150150 x = dd. drawWidth
151151 a = pId3 dd
152152 b = fromMaybe " " dd. drawState. info -- mp3 info
@@ -164,17 +164,17 @@ pId3 DD{drawState=st} = maybe (st.music ! st.current).fbase (.str) st.id3
164164------------------------------------------------------------------------
165165
166166-- | Show progress bar.
167- progressBar :: DrawData -> StringA
168- progressBar (DD w st) = FancyS [
169- ( " " , defaultSty), (spaces x, Style fg fg), (spaces (w'- x), sty) ]
167+ progressBar :: DrawData -> Line
168+ progressBar (DD w st) = [
169+ plainSeg " " , Seg ( Style fg fg) (spaces x), Seg sty (spaces (w'- x)) ]
170170 where
171171 w' = w - 4
172172 x = El. progress w' st. clock
173173 sty@ (Style fg _) = st. uiStyle. progress
174174
175175-- | Two lines showing clock.
176- clockLines :: DrawData -> [StringA ]
177- clockLines dd@ (DD w st) = [progressBar dd, Fast (El. pTimes w st. clock) defaultSty ]
176+ clockLines :: DrawData -> [Line ]
177+ clockLines dd@ (DD w st) = [progressBar dd, [plainSeg (El. pTimes w st. clock)] ]
178178
179179------------------------------------------------------------------------
180180
@@ -206,19 +206,19 @@ playInfo DD{drawState=st} = mconcat
206206 numd = showInt $ length $ st. folders
207207
208208-- | The top title bar: cursor position + play indicator + uptime + version.
209- playTitle :: DrawData -> StringA
209+ playTitle :: DrawData -> Line
210210playTitle dd@ DD {drawWidth= w, drawState= st} =
211- Fast ( El. layoutLCR w (left, centerS, right)) st . uiStyle . titlebar
211+ [ Seg st . uiStyle . titlebar $ El. layoutLCR w (left, centerS, right)]
212212 where
213213 left = " " <> playInfo dd
214214 centerS = pState dd ++ ' ' : pMode dd -- always 6 chars
215215 right = st. uptime <> " " <> El. pVersion <> " "
216216
217217-- | The scrolling playlist (visible tracks).
218- playList :: Int -> DrawData -> [StringA ]
218+ playList :: Int -> DrawData -> [Line ]
219219playList buflen _ | buflen <= 0 = [] -- extra defense besides laziness
220220playList buflen DD { drawWidth= w, drawState= st } =
221- list ++ replicate (buflen - length list) ( Fast " " defaultSty)
221+ list ++ replicate (buflen - length list) []
222222
223223 where
224224 -- number of screens down, and then offset
@@ -253,13 +253,12 @@ playList buflen DD{ drawWidth=w, drawState=st } =
253253 where
254254 f sty = (sty, [s, spaces (w - indent - 1 - displayWidth s)])
255255
256- drawIt :: (Maybe Int , (Style , [ByteString ])) -> StringA
256+ drawIt :: (Maybe Int , (Style , [ByteString ])) -> Line
257257 drawIt (Nothing , (sty, v)) =
258- FancyS $ map (, sty) $ spaces (1 + indent) : v
259- drawIt (Just i, (sty, v)) = FancyS
260- $ (d, sty')
261- : (spaces (indent + 1 - displayWidth d), sty')
262- : map (, sty) v
258+ map (Seg sty) $ spaces (1 + indent) : v
259+ drawIt (Just i, (sty, v)) = Seg sty' d
260+ : Seg sty' (spaces (indent + 1 - displayWidth d))
261+ : map (Seg sty) v
263262 where
264263 sty' = if sty == sty2 || sty == sty3 then sty2 else sty1
265264 d = toMaxWidth (indent - 1 ) $ takeFileName (st. folders ! i). dname
@@ -282,7 +281,7 @@ renderModal st (h, w) mkr = do
282281 voffset = ((h - vislines) `div` 2 ) `max` 4
283282 Curses. wMove Curses. stdScr voffset hoffset
284283 for_ (take vislines modal') \ t -> do
285- drawLine $ Fast (toWidth mw t) st . uiStyle . modals
284+ drawSegment $ Seg st . uiStyle . modals (toWidth mw t)
286285 (y', _) <- Curses. getYX Curses. stdScr
287286 Curses. wMove Curses. stdScr (y'+ 1 ) hoffset
288287
@@ -309,25 +308,24 @@ redraw = Draw $ discardErrors do
309308 Curses. wMove Curses. stdScr (h- 1 ) 0
310309 drawLine st. minibuffer
311310 when st. miniFocused do -- a fake cursor
312- drawLine $ Fast " " st. uiStyle. blockcursor
311+ drawSegment $ Seg st. uiStyle. blockcursor " "
313312 fillLine
314313
315314-- | Render whole lines without going below limit.
316- drawFullLines :: Int -> Int -> [StringA ] -> IO ()
315+ drawFullLines :: Int -> Int -> [Line ] -> IO ()
317316drawFullLines limit y ls =
318317 for_ (zip [y .. limit- 1 ] ls) \ (y', t) -> do
319318 Curses. wMove Curses. stdScr y' 0
320319 drawLine t *> fillLine
321320
322321------------------------------------------------------------------------
323322-- | Draw a coloured (or not) string to the screen
324- drawLine :: StringA -> IO ()
325- drawLine (Fast ps sty) = drawSegment ps sty
326- drawLine (FancyS ls) = traverse_ (uncurry drawSegment) ls
323+ drawLine :: Line -> IO ()
324+ drawLine = traverse_ drawSegment
327325
328326-- | Write a single styled UTF-8 segment. Safe because C only reads the bytes.
329- drawSegment :: ByteString -> Style -> IO ()
330- drawSegment bs sty = withStyle sty $ void $
327+ drawSegment :: Segment -> IO ()
328+ drawSegment ( Seg sty bs) = withStyle sty $ void $
331329 P. unsafeUseAsCStringLen bs \ (cstr, len) ->
332330 waddnstr Curses. stdScr cstr (fromIntegral len)
333331
0 commit comments