mushu 0.1.0 → 0.1.1
raw patch · 8 files changed
+133/−48 lines, 8 filesdep −QuickCheckdep −asyncdep −attoparsec
Dependencies removed: QuickCheck, async, attoparsec, quickcheck-text, tasty, tasty-hunit, tasty-quickcheck
Files
- app/Types.hs +11/−0
- app/UI.hs +0/−2
- app/UI/Views/Main.hs +0/−2
- app/UI/Widgets/Command.hs +0/−14
- app/UI/Widgets/Filter.hs +85/−0
- app/UI/Widgets/Notification.hs +30/−0
- mushu.cabal +6/−17
- test/Spec.hs +1/−13
+ app/Types.hs view
@@ -0,0 +1,11 @@+module Types+( AppException(..)+) where+++import ClassyPrelude++import Control.Exception.Safe (Exception(..))++data AppException = MPDException | UnknownException deriving (Show, Typeable)+instance Exception AppException
app/UI.hs view
@@ -6,8 +6,6 @@ import Library import UI.Types -import Control.Concurrent.Async (async)- import Lens.Micro.Platform ((^.), (&), (.~), (%~)) import qualified UI.Utils as Utils
app/UI/Views/Main.hs view
@@ -14,7 +14,6 @@ import qualified UI.Widgets.Status as Status import qualified UI.Widgets.Help as Help-import qualified UI.Widgets.Command as Command import qualified UI.Widgets.Notification as Notification import UI.Widgets.Playlist (playingSongL) @@ -34,6 +33,5 @@ , hCenter widget , view , Notification.mkWidget (state^.notificationState)- -- , Command.mkWidget ]
− app/UI/Widgets/Command.hs
@@ -1,14 +0,0 @@-module UI.Widgets.Command-( mkWidget-) where--import ClassyPrelude--import Brick.Types (Widget)-import Brick.Widgets.Core (str)-import Brick.Widgets.Center (hCenter)--import UI.Types (UIName)--mkWidget :: Widget UIName-mkWidget = hCenter $ str "Command"
+ app/UI/Widgets/Filter.hs view
@@ -0,0 +1,85 @@+{-# LANGUAGE TemplateHaskell #-}+module UI.Widgets.Filter+( FilterState+, mkState+, mkWidget+, handleEvent+, attrs+, isActiveL+, isFocusedL+, focus+, blur+, reset+, getValue+) where++import ClassyPrelude+import TH (makeSuffixLenses)++import Lens.Micro.Platform ((^.), (%~), (&), (.~))++import Data.Text.Zipper (textZipper)++import Brick.Types (Widget, BrickEvent, EventM, Next, Padding(..))+import Brick.AttrMap (AttrName)+import Brick.Widgets.Core (str, withAttr, padLeft, (<+>))+import Brick.Util (fg)+import Brick.Widgets.Edit+ ( Editor+ , editorText+ , applyEdit+ , renderEditor+ , handleEditorEvent+ , getEditContents+ , editAttr+ )++import qualified Graphics.Vty as Vty++data FilterState n = FilterState+ { _editor :: Editor Text n+ , _isFocused :: Bool+ , _isActive :: Bool+ }++makeSuffixLenses ''FilterState++mkState :: n -> FilterState n+mkState name = FilterState+ { _editor = editorText name (str . (concatMap unpack)) (Just 1) ""+ , _isFocused = False+ , _isActive = False+ }++mkWidget :: (Show n, Ord n) => FilterState n -> Widget n+mkWidget state = str "Filter: " <+> (withAttr filterAttrName (renderEditor (state^.isFocusedL) (state^.editorL))) <+> (padLeft Max (str "Enter: apply | Esc: disable "))++handleEvent :: Vty.Event -> FilterState n -> EventM n (FilterState n)+handleEvent event state = do+ newEditorState <- handleEditorEvent event (state^.editorL)+ return $ state & editorL .~ newEditorState++focus :: FilterState n -> FilterState n+focus state = state & isActiveL .~ True+ & isFocusedL .~ True++blur :: FilterState n -> FilterState n+blur state = state & isFocusedL .~ False++reset :: FilterState n -> FilterState n+reset state = state & isActiveL .~ False+ & isFocusedL .~ False+ & editorL %~ clearEditor++getValue :: FilterState n -> Text+getValue state = concat $ getEditContents (state^.editorL)++filterAttrName :: AttrName+filterAttrName = editAttr++clearEditor :: Editor Text n -> Editor Text n+clearEditor editor = applyEdit (\_ -> textZipper [""] (Just 1)) editor++attrs :: [(AttrName, Vty.Attr)]+attrs = [ (filterAttrName, fg Vty.yellow)+ ]
+ app/UI/Widgets/Notification.hs view
@@ -0,0 +1,30 @@+{-# LANGUAGE TemplateHaskell #-}+module UI.Widgets.Notification+( NotificationState+, mkState+, mkWidget+, setNotification+) where++import ClassyPrelude+import TH (makeSuffixLenses)++import Lens.Micro.Platform ((^.), (&), (.~))++import Brick.Types (Widget)+import Brick.Widgets.Core (str)++data NotificationState = NotificationState+ { _notification :: Maybe Text+ } deriving Show++makeSuffixLenses ''NotificationState++mkState :: NotificationState+mkState = NotificationState Nothing++mkWidget :: NotificationState -> Widget n+mkWidget state = str . unpack $ fromMaybe "" (state^.notificationL)++setNotification :: Text -> NotificationState -> NotificationState+setNotification txt state = state & notificationL .~ (Just txt)
mushu.cabal view
@@ -1,7 +1,7 @@ name: mushu-version: 0.1.0-synopsis: Mushu is a minimalist MPD client with a TUI and an incremental fuzzy finder for your music library-description: Please see README.md+version: 0.1.1+synopsis: Minimalist MPD client+description: Mushu is a minimalist MPD client with a TUI and an incremental fuzzy finder for your music library homepage: https://github.com/elaye/mushu#README.md license: BSD3 license-file: LICENSE@@ -20,15 +20,15 @@ other-modules: Library , MPD , TH+ , Types , UI, UI.Types, UI.Utils , UI.Views.Help, UI.Views.Library, UI.Views.Main, UI.Views.Playlist- , UI.Widgets.Command, UI.Widgets.Help, UI.Widgets.Library, UI.Widgets.Playlist, UI.Widgets.Status+ , UI.Widgets.Help, UI.Widgets.Library, UI.Widgets.Playlist, UI.Widgets.Status, UI.Widgets.Filter, UI.Widgets.Notification build-depends: base >= 4 && < 5 ,classy-prelude ,safe-exceptions ,containers ,network- ,async ,libmpd ,text ,fuzzy@@ -62,21 +62,10 @@ hs-source-dirs: test, app main-is: Spec.hs build-depends: base- ,attoparsec- ,bytestring ,classy-prelude- ,microlens-platform >= 0.3.1.0- ,unordered-containers- ,text- ,time- ,QuickCheck- ,quickcheck-text- ,tasty- ,tasty-quickcheck- ,tasty-hunit ghc-options: -threaded -rtsopts -with-rtsopts=-N default-language: Haskell2010- default-extensions: NoImplicitPrelude+ default-extensions: NoImplicitPrelude, OverloadedStrings source-repository head type: git
test/Spec.hs view
@@ -1,16 +1,4 @@ import ClassyPrelude -import Test.Tasty-import qualified MIME.Parser.Test as MP-import Test.Tasty.QuickCheck-import Mail (Target)--tests :: TestTree-tests = testGroup "Tests"- [ MP.tests- ]- main :: IO ()-main = do- {-sample $ (MP.arbitrary :: Gen Target)-}- defaultMain tests+main = putStrLn "Test suite not yet implemented"