Skip to content

Commit f5e6266

Browse files
More minor code work.
1 parent 9f0002f commit f5e6266

1 file changed

Lines changed: 18 additions & 23 deletions

File tree

UI.hs

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ playScreen dd = [pPlaying dd, progressBar dd, pTimes dd]
178178

179179
-- | Info about the current track
180180
pPlaying :: DrawData -> StringA
181-
pPlaying dd = FancyS $ map (, defaultSty) $ " " : line where
181+
pPlaying dd = flip Fast defaultSty $ " " <> mconcat line where
182182
x = sizeW $ drawSize dd
183183
a = pId3 dd
184184
b = pInfo dd
@@ -333,10 +333,8 @@ playInfo dd = mconcat
333333
-- | The top title bar: cursor position + play indicator + uptime + version.
334334
playTitle :: DrawData -> StringA
335335
playTitle dd =
336-
FancyS $ map (, hl)
337-
if gap >= 2
338-
then [mconcat [" ", inf, spaces gapl], indic,
339-
mconcat [spaces gapr, time, " ", ver, " "]]
336+
flip Fast hl $ mconcat if gap >= 2
337+
then [" ", inf, spaces gapl, indic, spaces gapr, time, " ", ver, " "]
340338
else let gap' = x - indicl; gapl' = gap' `div` 2
341339
in if gap' >= 2
342340
then [spaces gapl', indic, spaces $ gap' - gapl']
@@ -396,26 +394,23 @@ playList dd@DD{ drawSize=Size y x, drawPos=Pos{posY=o}, drawState=st } =
396394

397395
indent = (round $ (0.334 :: Float) * fromIntegral x) :: Int
398396

397+
(sty1, sty2, sty3) = (selected cs, cursors cs, combined cs)
398+
where cs = config st
399+
399400
color :: ((Maybe Int, ByteString), Int)
400-
-> (Maybe Int, Style, [ByteString])
401-
color ((m, s), i)
402-
| i == select && i == playing = f sty3
403-
| i == select = f sty2
404-
| i == playing = f sty1
405-
| otherwise = (m, defaultSty, [s])
406-
where
407-
f sty = (m, sty,
408-
[s, spaces (x - indent - 1 - displayWidth s)])
409-
410-
sty1 = selected . config $ st
411-
sty2 = cursors . config $ st
412-
sty3 = combined . config $ st
413-
414-
drawIt :: (Maybe Int, Style, [ByteString]) -> StringA
415-
drawIt (Nothing, sty, v) =
416-
FancyS $ map (, sty) $ spaces (1 + indent) : v
401+
-> (Maybe Int, (Style, [ByteString]))
402+
color ((m, s), i) = (m,) case (i == select, i == playing) of
403+
(True, True) -> f sty3
404+
(True, _) -> f sty2
405+
(_ , True) -> f sty1
406+
_ -> (defaultSty, [s])
407+
where
408+
f sty = (sty, [s, spaces (x - indent - 1 - displayWidth s)])
417409

418-
drawIt (Just i, sty, v) = FancyS
410+
drawIt :: (Maybe Int, (Style, [ByteString])) -> StringA
411+
drawIt (Nothing, (sty, v)) =
412+
FancyS $ map (, sty) $ spaces (1 + indent) : v
413+
drawIt (Just i, (sty, v)) = FancyS
419414
$ (d, sty')
420415
: (spaces (indent + 1 - displayWidth d), sty')
421416
: map (, sty) v

0 commit comments

Comments
 (0)