hmp3-ng 2.7.0 → 2.7.1
raw patch · 5 files changed
+52/−71 lines, 5 files
Files
- Keymap.hs +1/−1
- README.md +1/−1
- Syntax.hs +1/−1
- UI.hs +47/−67
- hmp3-ng.cabal +2/−1
Keymap.hs view
@@ -182,7 +182,7 @@ ['q'], do b <- helpIsVisible ; if b then toggleHelp else quit Nothing) ,("Select and play next track", ['d'], playNext >> jumpToPlaying)- ,("Cycle through normal, random and loop modes",+ ,("Cycle through normal, random, and loop modes", ['m'], nextMode) ,("Refresh the display", ['\^L'], UI.resetui)
README.md view
@@ -24,7 +24,7 @@ writing) and libraries. Some code could not be directly ported, mainly low-level optimizations, and so was replaced. -* There is a Github issue tracker to cover other problems and+* There is a GitHub issue tracker to cover other problems and planned changes. * I have added support for building with Stack.
Syntax.hs view
@@ -136,7 +136,7 @@ data Status = Stopped | Paused | Playing- deriving Eq+ deriving (Eq, Show) data Mode = Normal | Loop | Random deriving (Eq,Bounded,Enum) -- for pred,succ
UI.hs view
@@ -205,8 +205,8 @@ newtype PPlaying = PPlaying StringA newtype PVersion = PVersion P.ByteString-newtype PMode = PMode P.ByteString-newtype PMode2 = PMode2 P.ByteString+newtype PMode = PMode String+newtype PMode2 = PMode2 String newtype ProgressBar = ProgressBar StringA newtype PTimes = PTimes StringA @@ -216,7 +216,7 @@ newtype PlayTitle = PlayTitle StringA newtype PlayInfo = PlayInfo P.ByteString-newtype PlayModes = PlayModes P.ByteString+newtype PlayModes = PlayModes String newtype HelpScreen = HelpScreen [StringA] ------------------------------------------------------------------------@@ -243,11 +243,16 @@ -- Info about the current track instance Element PPlaying where- draw w@(_,x') x st z = PPlaying . FancyS $ - map (, defaultSty) $ spc2 : alignLR (x'-4) (UTF8.toString a) b- where- PId3 a = draw w x st z- PInfo b = draw w x st z+ draw w@(_,x') x st z =+ PPlaying . FancyS $ map (, defaultSty) $ spc2 : line+ where+ PId3 a = draw w x st z+ PInfo b = draw w x st z+ s = UTF8.toString a+ line | gap >= 0 = [U s, B $ spaces $ gap+1, B b]+ | True = [U $ ellipsize lim s, B " ", B b]+ where lim = x' - 5 - P.length b+ gap = lim - displayWidth s -- | Id3 Info instance Element PId3 where@@ -364,33 +369,24 @@ -- | Play mode instance Element PMode where draw _ _ st _ = PMode $! case status st of - Stopped -> a- Paused -> b- Playing -> c-- where a = "stop"- b = "pause"- c = "play"+ Stopped -> "◼"+ Paused -> "Ⅱ"+ Playing -> "▶" --- | Loop, normal or random+-- | Loop, normal, or random instance Element PMode2 where draw _ _ st _ = PMode2 $ case mode st of - Random -> a- Loop -> b- Normal -> c-- where a = "random"- b = "loop"- c = ""+ Random -> "rand"+ Loop -> "loop"+ Normal -> "once" ------------------------------------------------------------------------ instance Element PlayModes where- draw a b c d = PlayModes $ - m `P.append` if m' == P.empty then P.empty else ' ' `P.cons` m'+ draw a b c d = PlayModes $ m ++ ' ' : m' where- (PMode m ) = draw a b c d :: PMode- (PMode2 m') = draw a b c d :: PMode2+ PMode m = draw a b c d+ PMode2 m' = draw a b c d instance Element PlayInfo where draw _ _ st _ = PlayInfo $ P.concat@@ -421,27 +417,22 @@ instance Element PlayTitle where draw a@(_,x) b c d =- PlayTitle $ flip Fast hl $ P.concat - [space- ,inf- ,spaces gapl- ,modes- ,spaces gapr- ,time- ,space- ,ver- ,space]+ PlayTitle $ FancyS [+ (B $ P.concat [space,inf,spaces gapl], hl),+ (U modes, hl),+ (B $ P.concat [spaces gapr,time,space,ver,space], hl)+ ] where- (PlayInfo inf) = draw a b c d :: PlayInfo- (PTime time) = draw a b c d :: PTime- (PlayModes modes) = draw a b c d :: PlayModes- (PVersion ver) = draw a b c d :: PVersion+ PlayInfo inf = draw a b c d+ PTime time = draw a b c d+ PlayModes modes = draw a b c d+ PVersion ver = draw a b c d gap = x - padding - P.length inf - modlen - P.length time - P.length ver gapl = gap `div` 2 gapr = gap - gapl padding = 3- modlen = P.length modes+ modlen = length modes space = spaces 1 hl = titlebar . config $ c @@ -453,7 +444,7 @@ ++ (replicate (height - length list - 2) (Fast P.empty defaultSty)) ++ [minibuffer st] where- (PlayTitle title) = draw p q st z :: PlayTitle+ PlayTitle title = draw p q st z songs = music st this = current st@@ -527,16 +518,6 @@ ------------------------------------------------------------------------ --- | Take two strings, and pad them in the middle-alignLR :: Int -> String -> P.ByteString -> [AmbiString]-alignLR w l r - | padding > 0 = [U l, B gap, B r]- -- | otherwise = [U P.take (w - P.length r - 4 - 1) l, ellipsis, spaces 1, r]- | otherwise = [U $ ellipsize (w - P.length r - 1) l, B " ", B r]-- where padding = w - displayWidth l - P.length r- gap = spaces padding- -- | Calculate whitespaces, very common, so precompute likely values spaces :: Int -> P.ByteString spaces n@@ -556,7 +537,7 @@ -- Speed things up a bit, just use read State. -- redrawJustClock :: Draw-redrawJustClock = Draw $ do+redrawJustClock = Draw do Control.Exception.handle (\ (_ :: SomeException) -> return ()) $ do st <- getsST id@@ -604,7 +585,7 @@ y = printPlayList (draw sz (length x,0) s f :: PlayList) a = x ++ y - when (xterm s) $ setXterm s sz f+ when (xterm s) $ setXterm s gotoTop mapM_ (\t -> do drawLine w t@@ -692,18 +673,17 @@ -- set xterm title (should have an instance Element) -- Don't need to do this on each refresh...-setXterm :: HState -> (Int,Int) -> Maybe Frame -> IO ()-setXterm s sz f = setXtermTitle $ - if status s == Playing- then case id3 s of- Nothing -> case size s of- 0 -> ["hmp3"]- _ -> [(fbase $ music s ! current s)]- Just ti -> id3artist ti :- if P.null (id3title ti) - then [] - else [": ", id3title ti]- else let (PMode pm) = draw sz (0,0) s f :: PMode in [pm]+setXterm :: HState -> IO ()+setXterm s = setXtermTitle $ case status s of+ Playing -> case id3 s of+ Nothing -> case size s of+ 0 -> ["hmp3"]+ _ -> [(fbase $ music s ! current s)]+ Just ti -> id3artist ti :+ if P.null (id3title ti)+ then []+ else [": ", id3title ti]+ x -> [P.pack $ show x] displayWidth :: String -> Int displayWidth = sum . map charWidth
hmp3-ng.cabal view
@@ -1,7 +1,7 @@ cabal-version: >= 1.6 name: hmp3-ng-version: 2.7.0+version: 2.7.1 homepage: https://github.com/galenhuntington/hmp3-ng license: GPL license-file: LICENSE@@ -47,3 +47,4 @@ extensions: ScopedTypeVariables, OverloadedStrings, BlockArguments, BangPatterns+ extra-libraries: ncursesw