-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A TUI MPD client, inspired by ncmpcpp -- -- A TUI MPD client, inspired by ncmpcpp. Built using brick and libmpd. @package hum @version 0.2.0.0 -- | Brick/Vty color attributes. module Hum.Attributes humAttrMap :: AttrMap wobAttr :: Attr queueAttr :: AttrName albumAttr :: AttrName titleAttr :: AttrName trackAttr :: AttrName artistAttr :: AttrName timeAttr :: AttrName dateAttr :: AttrName headerAttr :: AttrName listHighlightedAttr :: AttrName queueNowPlayingAttr :: AttrName titleBoldAttr :: AttrName editorAttr :: AttrName searchAttr :: AttrName searchFocusedAttr :: AttrName -- | Overwrites attributes for item to be highlighted. highlightOverAttrs :: Widget n -> Widget n module Brick.Widgets.Search searchW :: Int -> Text -> Text -> Widget n splitRegex :: Regex -> Text -> [[(Text, Text)]] regexW :: Int -> Regex -> Text -> Widget n module Hum.Orphans instance Witherable.Filterable t => Witherable.Filterable (Brick.Widgets.List.GenericList n t) instance (Data.Traversable.Traversable t, Witherable.Filterable t) => Witherable.Witherable (Brick.Widgets.List.GenericList n t) -- | Types! module Hum.Types -- | Describes the state of the app. data HumState HumState :: !BChan HumEvent -> !View -> !Maybe Status -> !Mode -> !ExState -> !Maybe Song -> !SongList -> !LibraryState -> !PlaylistsState -> !Clipboard -> !Focus -> !Bool -> !Prompts -> !HelpState -> HumState -- | The channel for MPD and time events [chan] :: HumState -> !BChan HumEvent -- | The current view: Queue, Library, etc. [hview] :: HumState -> !View -- | MPD's status [status] :: HumState -> !Maybe Status -- | Input mode [mode] :: HumState -> !Mode -- | The state of the ex mode style prompt at the bottom [ex] :: HumState -> !ExState [currentSong] :: HumState -> !Maybe Song -- | Also called the playlist in MPD [queue] :: HumState -> !SongList [library] :: HumState -> !LibraryState [playlists] :: HumState -> !PlaylistsState [clipboard] :: HumState -> !Clipboard -- | The current focus in each view [focus] :: HumState -> !Focus -- | Whether the selected stored playlist is editable [editable] :: HumState -> !Bool [prompts] :: HumState -> !Prompts -- | Help View [help] :: HumState -> !HelpState data LibraryState LibraryState :: !List Name Value -> !List Name (Value, Value) -> !Bool -> !List Name Song -> LibraryState -- | All album artists [artists] :: LibraryState -> !List Name Value -- | Year-Album pairs of the selected artist [yalbums] :: LibraryState -> !List Name (Value, Value) -- | Toggle sort of yalbums between years and alphabeitcal order [yalbumSort] :: LibraryState -> !Bool -- | Songs in selected album [songs] :: LibraryState -> !List Name Song -- | Stored playlists data PlaylistsState PlaylistsState :: !List Name PlaylistName -> !SongList -> PlaylistsState -- | List of stored playlists [plList] :: PlaylistsState -> !List Name PlaylistName -- | Songs in selected playlist [plSongs] :: PlaylistsState -> !SongList data HelpState HelpState :: !Text -> !Int -> HelpState -- | Contents of help screen [helpText] :: HelpState -> !Text -- | number of focused search match [helpSearchInt] :: HelpState -> !Int -- | Specific mode in the bottom prompt data ExSubMode -- | Function commands Cmd :: ExSubMode -- | Forward search FSearch :: ExSubMode -- | Backwards search BSearch :: ExSubMode data ExState ExState :: !ExSubMode -> !Editor Text Name -> !Bool -> ![Text] -> ![Text] -> ExState [exPrefix] :: ExState -> !ExSubMode [exEditor] :: ExState -> !Editor Text Name -- | Search direction of last search [searchDirection] :: ExState -> !Bool [searchHistory] :: ExState -> ![Text] [cmdHistory] :: ExState -> ![Text] data Prompts Prompts :: !PromptType -> Text -> !List Name (Maybe PlaylistName) -> !Editor Text Name -> (Bool -> HumState -> EventM Name HumState) -> Prompts [currentPrompt] :: Prompts -> !PromptType [promptTitle] :: Prompts -> Text -- | List to select playlist from [plSelectPrompt] :: Prompts -> !List Name (Maybe PlaylistName) -- | Editor if needed [textPrompt] :: Prompts -> !Editor Text Name -- | Executes on exit from prompt, True for execute and False for quit. [exitPromptFunc] :: Prompts -> Bool -> HumState -> EventM Name HumState data PromptType -- | Select playlist to add songs to PlSelectPrompt :: PromptType -- | General yes/no prompt YNPrompt :: PromptType -- | General enter text and do stuff prompt TextPrompt :: PromptType data Clipboard Clipboard :: !SongList -> !Maybe PlaylistName -> Clipboard -- | Last list of songs copied [clSongs] :: Clipboard -> !SongList -- | Last playlist name copied [clPlName] :: Clipboard -> !Maybe PlaylistName -- | General input mode data Mode -- | Vim normal mode style movement NormalMode :: Mode -- | Type ex style commands or search ExMode :: Mode -- | Interact with a prompt PromptMode :: Mode type Highlight = Bool type SongList = List Name (Song, Highlight) type HumEvent = Either Tick (Response [Subsystem]) -- | Brick widget names data Name NowPlaying :: Name ClSongs :: Name Queue :: Name QueueList :: Name Library :: Name ArtistsList :: Name LibraryLeft :: Name AlbumsList :: Name YalbumsList :: Name LibraryMid :: Name SongsList :: Name LibraryRight :: Name PlaylistList :: Name PlaylistLeft :: Name PlaylistSongs :: Name PlaylistRight :: Name Help :: Name ExEditor :: Name TextPromptEditor :: Name data Focus Focus :: FocQueue -> FocLib -> FocPlay -> Bool -> Focus [focQueue] :: Focus -> FocQueue [focLib] :: Focus -> FocLib [focPlay] :: Focus -> FocPlay [focEx] :: Focus -> Bool data FocQueue FocQueue :: FocQueue data FocLib FocArtists :: FocLib FocAlbums :: FocLib FocSongs :: FocLib data FocPlay FocPlaylists :: FocPlay FocPSongs :: FocPlay data View QueueView :: View LibraryView :: View PlaylistsView :: View HelpView :: View data Tick Tick :: Tick statusL :: Lens' HumState (Maybe Status) queueL :: Lens' HumState SongList promptsL :: Lens' HumState Prompts playlistsL :: Lens' HumState PlaylistsState modeL :: Lens' HumState Mode libraryL :: Lens' HumState LibraryState hviewL :: Lens' HumState View helpL :: Lens' HumState HelpState focusL :: Lens' HumState Focus exL :: Lens' HumState ExState editableL :: Lens' HumState Bool currentSongL :: Lens' HumState (Maybe Song) clipboardL :: Lens' HumState Clipboard chanL :: Lens' HumState (BChan HumEvent) focQueueL :: Lens' Focus FocQueue focPlayL :: Lens' Focus FocPlay focLibL :: Lens' Focus FocLib focExL :: Lens' Focus Bool yalbumsL :: Lens' LibraryState (List Name (Value, Value)) yalbumSortL :: Lens' LibraryState Bool songsL :: Lens' LibraryState (List Name Song) artistsL :: Lens' LibraryState (List Name Value) plSongsL :: Lens' PlaylistsState SongList plListL :: Lens' PlaylistsState (List Name PlaylistName) helpTextL :: Lens' HelpState Text helpSearchIntL :: Lens' HelpState Int searchHistoryL :: Lens' ExState [Text] searchDirectionL :: Lens' ExState Bool exPrefixL :: Lens' ExState ExSubMode exEditorL :: Lens' ExState (Editor Text Name) cmdHistoryL :: Lens' ExState [Text] textPromptL :: Lens' Prompts (Editor Text Name) promptTitleL :: Lens' Prompts Text plSelectPromptL :: Lens' Prompts (List Name (Maybe PlaylistName)) exitPromptFuncL :: Lens' Prompts (Bool -> HumState -> EventM Name HumState) currentPromptL :: Lens' Prompts PromptType clSongsL :: Lens' Clipboard SongList clPlNameL :: Lens' Clipboard (Maybe PlaylistName) instance GHC.Classes.Ord Hum.Types.ExSubMode instance GHC.Classes.Eq Hum.Types.ExSubMode instance GHC.Show.Show Hum.Types.ExSubMode instance GHC.Classes.Eq Hum.Types.PromptType instance GHC.Show.Show Hum.Types.PromptType instance GHC.Classes.Eq Hum.Types.Mode instance GHC.Show.Show Hum.Types.Mode instance GHC.Classes.Ord Hum.Types.Name instance GHC.Classes.Eq Hum.Types.Name instance GHC.Show.Show Hum.Types.Name instance GHC.Classes.Ord Hum.Types.FocQueue instance GHC.Classes.Eq Hum.Types.FocQueue instance GHC.Show.Show Hum.Types.FocQueue instance GHC.Enum.Enum Hum.Types.FocLib instance GHC.Classes.Ord Hum.Types.FocLib instance GHC.Classes.Eq Hum.Types.FocLib instance GHC.Show.Show Hum.Types.FocLib instance GHC.Enum.Enum Hum.Types.FocPlay instance GHC.Classes.Ord Hum.Types.FocPlay instance GHC.Classes.Eq Hum.Types.FocPlay instance GHC.Show.Show Hum.Types.FocPlay instance GHC.Classes.Ord Hum.Types.Focus instance GHC.Classes.Eq Hum.Types.Focus instance GHC.Show.Show Hum.Types.Focus instance GHC.Classes.Ord Hum.Types.View instance GHC.Classes.Eq Hum.Types.View instance GHC.Show.Show Hum.Types.View -- | Functions that rebuild the state after changes that require it, Or -- that have to be here to avoid dependency loops. module Hum.Rebuild -- | All songs of a given artist songsOfArtist :: Value -> IO (Vector Song) -- | All songs in a given album songsOfAlbum :: Value -> IO (Vector Song) -- | All albums of a given artist albumsOfArtist :: Value -> IO (Vector Value) -- | All year-album pairs of a given artist yalbumsOfArtist :: Bool -> Value -> IO (Vector (Value, Value)) -- | Earliest year of any song in the given album yearOfAlbum :: Value -> IO Value -- | Rebuild entire library state, keeping the index of the left column if -- possible. rebuildLib :: MonadIO m => HumState -> m HumState -- | Rebuild library state from selected artist. rebuildLibArtists :: MonadIO m => HumState -> m HumState -- | Rebuild library state from selected artist. reloadLibArtists :: MonadIO m => HumState -> m HumState -- | Rebuild library state from selected album. rebuildLibAlbums :: MonadIO m => HumState -> m HumState -- | Rebuild library state from selected album, keeping the selected song -- index if possible. reloadLibAlbums :: MonadIO m => HumState -> m HumState -- | Rebuild entire stored playlists state, keeping the index of the left -- column if possible. rebuildPl :: MonadIO m => HumState -> m HumState -- | Rebuild stored playlists state from selected playlist. rebuildPlList :: MonadIO m => HumState -> m HumState -- | Rebuild stored playlists state from selected playlist, keeping the -- selected song index if possible. reloadPlList :: MonadIO m => HumState -> m HumState -- | Rebuild queue state, keeping the index of the left column if possible. rebuildQueue :: MonadIO m => HumState -> m HumState -- | Rebuild status and current song state. rebuildStatus :: MonadIO m => HumState -> m HumState module Hum.Utils -- | A backwards function composition operator that I love with my whole -- heart. (?) :: (a -> b) -> (b -> c) -> a -> c infixl 8 ? -- | Get comma seperated metedata from tag. meta :: Text -> Metadata -> Song -> Text -- | Like meta, but returns a Maybe for future use. mmeta :: Metadata -> Song -> Maybe Text -- | Formats seconds to %M:%S. secondsToTime :: Integer -> Text -- | Deletes highlighted songs in list from queue, does not rebuild queue. deleteHighlightedfromQ :: MonadMPD m => SongList -> m () -- | Deletes list of songs from queue in MPD, does not rebuild queue. deleteBulkfromQ :: MonadMPD m => SongList -> m () -- | Adds songs to queue under the selected item in it in MPD, does not -- rebuild queue. pasteSongstoQ :: MonadMPD m => SongList -> SongList -> m () -- | Produce list of highligted elements (and selected element) in input -- list. getHighlighted :: (Filterable t, Traversable t) => GenericList n t (e, Highlight) -> GenericList n t (e, Highlight) -- | Paste one list into another under the selected item. listPaste :: (Splittable t, Semigroup (t e)) => GenericList n t e -> GenericList n t e -> GenericList n t e -- | Delete highlighted element (and selected element) from list. deleteHighlighted :: HumState -> Lens' HumState SongList -> HumState -- | Copy highlighted element (and selected element) from list to -- Clipboard. yankHighlighted :: HumState -> Lens' HumState SongList -> HumState -- | Toggle selected items highlight status. listToggleHighlight :: Traversable t => GenericList n t (e, Highlight) -> GenericList n t (e, Highlight) -- | Highlight selcted item. listHighlightSelected :: Traversable t => GenericList n t (e, Highlight) -> GenericList n t (e, Highlight) -- | Unhighlight selcted item. listUnhighlightAll :: Traversable t => GenericList n t (e, Highlight) -> GenericList n t (e, Highlight) -- | Save list of songs to a stored playlist. If exists does nothing. saveListToPl :: MonadMPD m => SongList -> Text -> m () -- | Overwrite stored playlist with new song list. overwriteListToPl :: MonadMPD m => SongList -> Text -> m () -- | Save edited playlist in Playlist view to disk. saveEditedPl :: Bool -> HumState -> EventM n HumState -- | Deletes selected playlist in Playlist view from disk. deleteSelectedPl :: Bool -> HumState -> EventM n HumState -- | Appends smallest number possible to playlist name for it to not be -- taken. Does nothing if name is untaken. unusedPlName :: PlaylistName -> IO PlaylistName -- | Duplicates stored playlist on disk (with nonconflicting name). duplicatePlaylist :: PlaylistName -> HumState -> EventM n HumState -- | Pastes playlist in clipboard to disk (with nonconflicting name). pastePlaylist :: HumState -> EventM n HumState -- | Adds list of songs to queue in MPD. Does not rebuild state. songBulkAddtoQ :: Bool -> Vector Song -> HumState -> EventM n HumState -- | Adds list of songs to stored playlist in MPD. Does not rebuild state. songBulkAddtoPl :: String -> Vector Song -> HumState -> EventM n HumState -- | Functions for prompts. module Hum.Modes.PromptMode -- | Prompt key event dispatch. handlePromptEvent :: HumState -> BrickEvent Name HumEvent -> EventM Name (Next HumState) -- | Handles key events for playlist select prompt. handlePlSelectPromptEvent :: HumState -> BrickEvent Name HumEvent -> EventM Name (Next HumState) -- | Add given songs to new playlist entered in prompt. songBulkAddtoNewPl :: Vector Song -> Bool -> HumState -> EventM n HumState -- | Handles key events for generic text prompt. handleTextPromptEvent :: HumState -> BrickEvent Name HumEvent -> EventM Name (Next HumState) -- | Handles key events for generic yes/no prompt. handleYNPromptEvent :: HumState -> BrickEvent Name HumEvent -> EventM Name (Next HumState) -- | Functions for the Help view. module Hum.Views.Common -- | Draw Now Playing box. drawNowPlaying :: HumState -> Widget Name -- | Draw progress bar for song time. drawProgressBar :: HumState -> Widget Name -- | Either a number or a percent. To be used for widget horizontal size. data PerCol -- | percent size Per :: Int -> PerCol -- | column number size Col :: Int -> PerCol -- | Helper function for drawing column rows. column :: Maybe PerCol -> Padding -> Padding -> Widget n -> Widget n -- | Returns True if text is substring of one of the given tags of the -- given song. songSearch :: Text -> [Metadata] -> Song -> Bool -- | Returns True if text is substring of the given strings. stringySearch :: ToString a => Text -> a -> Bool -- | Draws a prompt. drawPrompt :: HumState -> Widget Name -- | Draw row in playlist select prompt. drawPlSelectRow :: Int -> Bool -> Maybe PlaylistName -> Widget n -- | Shared functions for views. module Hum.Views.Help -- | Draws help. drawViewHelp :: HumState -> Widget Name -- | Help widget. Parses the last search as a case insensitive POSIX regex. helpW :: HumState -> Widget Name -- | Help widget. Parses the last search as an exact match. helpW' :: HumState -> Widget Name -- | Helper function that keeps Hum.UI tidy. helpText' :: Text -- | Updates which mathc is focused in the help buffer. helpSearch :: Bool -> HumState -> EventM Name HumState -- | handle key events in help view. handleEventHelp :: HumState -> BrickEvent Name HumEvent -> EventM Name (Next HumState) -- | Functions for the Library view. module Hum.Views.Library -- | Draw left column in Library view. drawLibraryLeft :: HumState -> Widget Name -- | Draw middle column in Library view. drawLibraryMid :: HumState -> Widget Name -- | Draw right column in Library view. drawLibraryRight :: HumState -> Widget Name -- | Draw generic column row in Library view. libraryRow :: HumState -> Name -> Text -> Widget n -- | Draw row in album column in Library view. libraryAlbumRow :: (Value, Value) -> Widget n -- | Draw row in song column in Library view. librarySongRow :: HumState -> Song -> Widget n -- | Move focus right in Library view. libraryMoveRight :: FocLib -> FocLib -- | Move focus left in Library view. libraryMoveLeft :: FocLib -> FocLib -- | Draw Library view. drawViewLibrary :: HumState -> Widget Name -- | Move focused library column by given function libraryMove :: (forall e. List Name e -> List Name e) -> HumState -> EventM Name HumState -- | Add selected element in Library view to queue. If the element is an -- album or artist add all songs under it. libraryAddtoQ :: Bool -> HumState -> EventM Name HumState -- | Search focused library column for next instance of last search. librarySearch :: Bool -> HumState -> EventM Name HumState -- | handle key inputs for Library view. handleEventLibrary :: HumState -> BrickEvent Name HumEvent -> EventM Name (Next HumState) -- | Functions for the Playlist view. module Hum.Views.Playlists -- | Draw left column in Playlist view. drawPlaylistLeft :: HumState -> Widget Name -- | Draw right column in Playlist view. drawPlaylistRight :: HumState -> Widget Name -- | Draw row in playlist column in Playlist view. playlistRow :: HumState -> Text -> Widget n -- | Draw row in song column in Playlist view. playlistSongRow :: HumState -> (Song, Highlight) -> Widget n -- | Draw Playlist view. drawViewPlaylists :: HumState -> Widget Name -- | Move focused playlist column by given function playlistsMove :: (forall e. List Name e -> List Name e) -> HumState -> EventM Name HumState -- | Add selected element in Playlist view to queue. If the element is a -- playlist adds entire playlist. playlistsAddtoQ :: Bool -> HumState -> EventM Name HumState -- | Search focused playlist column for next instance of last search. playlistsSearch :: Bool -> HumState -> EventM Name HumState -- | Rename the given playlist with input from the text prompt. renamePl :: Text -> Bool -> HumState -> EventM n HumState -- | handle key inputs for Playlist view. handleEventPlaylists :: HumState -> BrickEvent Name HumEvent -> EventM Name (Next HumState) -- | Functions for the Queue view. module Hum.Views.Queue -- | Draw the queue. drawViewQueue :: HumState -> Widget Name -- | Draw individual row in queue. queueRow :: HumState -> (Song, Highlight) -> Widget n -- | Search queue for next instance of last search. queueSearch :: Bool -> HumState -> EventM Name HumState -- | Add highlighted songs to given playlist. queueAddToPl :: HumState -> String -> EventM Name HumState -- | handle key inputs for Queue view. handleEventQueue :: HumState -> BrickEvent Name HumEvent -> EventM Name (Next HumState) module Hum.Views -- | Functions for the ex mode style prompt. module Hum.Modes.ExMode -- | Executed after pressing enter in the ex mode prompt. Either executes -- the command, or updates the search state for n/N to work. exEnd :: HumState -> EventM Name (Next HumState) -- | Handle key inputs for ex mode. handleExEvent :: HumState -> BrickEvent Name HumEvent -> EventM Name (Next HumState) -- | Prefix of ex mode prompt. exPrefixTxt :: ExSubMode -> Text -- | Executes ex mode command. exCmdExecute :: [Text] -> HumState -> EventM Name (Next HumState) module Hum.Modes -- | The starting point of Hum's logic. Contains things like building the -- initial state, shared keypresses, and the UI drawing function. module Hum.UI -- | The brick app record for Hum. app :: App HumState HumEvent Name -- | Draws shared UI elements and dispatches for view specific ones. drawUI :: HumState -> [Widget Name] -- | Make sure cursor is displayed when editing text. chooseCursor :: HumState -> [CursorLocation Name] -> Maybe (CursorLocation Name) -- | builds 'HumState for the first time. A lot of overlap with -- functions from | Hum.Rebuild, but they are hard to reuse -- because HumState is strict. buildInitialState :: BChan HumEvent -> IO HumState -- | Initial event. humStartEvent :: HumState -> EventM Name HumState -- | handles keypresses shared between views, and nonkeypress events from -- the channels (ticks every 0.1 seconds and mpd events). Dispatches for -- view specific keypresses. handleEvent :: HumState -> BrickEvent Name HumEvent -> EventM Name (Next HumState)