module Hum.Views.Playlists where
import Hum.Types
import Brick.Types
import Brick.Widgets.Edit hiding ( decodeUtf8 )
import Graphics.Vty.Input.Events
import Brick.Main
import Brick.Widgets.Core
import Brick.Widgets.Center
import Brick.Widgets.Border
import Brick.Widgets.Border.Style
import Control.Lens
import Brick.Widgets.List
import Hum.Attributes
import Hum.Views.Common
import Hum.Rebuild
import qualified Data.Text as T
import qualified Data.Text.Zipper as Z
import Network.MPD ( withMPD )
import qualified Network.MPD as MPD
import Hum.Utils
drawPlaylistLeft :: HumState -> Widget Name
drawPlaylistLeft :: HumState -> Widget Name
drawPlaylistLeft HumState
st = Name -> Widget Name -> Widget Name
forall n. n -> Widget n -> Widget n
reportExtent Name
PlaylistLeft (Widget Name -> Widget Name) -> Widget Name -> Widget Name
forall a b. (a -> b) -> a -> b
$
Size -> Size -> RenderM Name (Result Name) -> Widget Name
forall n. Size -> Size -> RenderM n (Result n) -> Widget n
Widget Size
Greedy Size
Greedy (RenderM Name (Result Name) -> Widget Name)
-> RenderM Name (Result Name) -> Widget Name
forall a b. (a -> b) -> a -> b
$ do
Context
ctx <- RenderM Name Context
forall n. RenderM n Context
getContext
let vsize :: Int
vsize = Context
ctx Context -> Getting Int Context Int -> Int
forall s a. s -> Getting a s a -> a
^. Getting Int Context Int
Lens' Context Int
windowHeightL Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
6
Widget Name -> RenderM Name (Result Name)
forall n. Widget n -> RenderM n (Result n)
render (Widget Name -> RenderM Name (Result Name))
-> Widget Name -> RenderM Name (Result Name)
forall a b. (a -> b) -> a -> b
$ Widget Name -> Widget Name
forall n. Widget n -> Widget n
hCenter
( Widget Name -> Widget Name
forall n. Widget n -> Widget n
visible
(Widget Name -> Widget Name)
-> (Widget Name -> Widget Name) -> Widget Name -> Widget Name
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Widget Name -> Widget Name
forall n. Int -> Widget n -> Widget n
vLimit Int
vsize
(Widget Name -> Widget Name)
-> (Widget Name -> Widget Name) -> Widget Name -> Widget Name
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Widget Name -> Widget Name
forall n. Widget n -> Widget n
center
(Widget Name -> Widget Name) -> Widget Name -> Widget Name
forall a b. (a -> b) -> a -> b
$ Widget Name
forall n. Widget n
hBorder
Widget Name -> Widget Name -> Widget Name
forall n. Widget n -> Widget n -> Widget n
<=> Widget Name -> Widget Name
forall n. Widget n -> Widget n
hCenter
((Bool -> Text -> Widget Name)
-> Bool -> GenericList Name Vector Text -> Widget Name
forall (t :: * -> *) n e.
(Traversable t, Splittable t, Ord n, Show n) =>
(Bool -> e -> Widget n) -> Bool -> GenericList n t e -> Widget n
renderList ((Text -> Widget Name) -> Bool -> Text -> Widget Name
forall a b. a -> b -> a
const ((Text -> Widget Name) -> Bool -> Text -> Widget Name)
-> (Text -> Widget Name) -> Bool -> Text -> Widget Name
forall a b. (a -> b) -> a -> b
$ HumState -> Text -> Widget Name
forall n. HumState -> Text -> Widget n
playlistRow HumState
st)
((Focus -> FocPlay
focPlay (Focus -> FocPlay) -> (HumState -> Focus) -> HumState -> FocPlay
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HumState -> Focus
focus (HumState -> FocPlay) -> HumState -> FocPlay
forall a b. (a -> b) -> a -> b
$ HumState
st) FocPlay -> FocPlay -> Bool
forall a. Eq a => a -> a -> Bool
== FocPlay
FocPlaylists)
(PlaylistName -> Text
forall a. ToString a => a -> Text
MPD.toText (PlaylistName -> Text)
-> GenericList Name Vector PlaylistName
-> GenericList Name Vector Text
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> HumState
st HumState
-> Getting
(GenericList Name Vector PlaylistName)
HumState
(GenericList Name Vector PlaylistName)
-> GenericList Name Vector PlaylistName
forall s a. s -> Getting a s a -> a
^. (PlaylistsState
-> Const (GenericList Name Vector PlaylistName) PlaylistsState)
-> HumState
-> Const (GenericList Name Vector PlaylistName) HumState
Lens' HumState PlaylistsState
playlistsL ((PlaylistsState
-> Const (GenericList Name Vector PlaylistName) PlaylistsState)
-> HumState
-> Const (GenericList Name Vector PlaylistName) HumState)
-> ((GenericList Name Vector PlaylistName
-> Const
(GenericList Name Vector PlaylistName)
(GenericList Name Vector PlaylistName))
-> PlaylistsState
-> Const (GenericList Name Vector PlaylistName) PlaylistsState)
-> Getting
(GenericList Name Vector PlaylistName)
HumState
(GenericList Name Vector PlaylistName)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (GenericList Name Vector PlaylistName
-> Const
(GenericList Name Vector PlaylistName)
(GenericList Name Vector PlaylistName))
-> PlaylistsState
-> Const (GenericList Name Vector PlaylistName) PlaylistsState
Lens' PlaylistsState (GenericList Name Vector PlaylistName)
plListL)
)
)
drawPlaylistRight :: HumState -> Widget Name
drawPlaylistRight :: HumState -> Widget Name
drawPlaylistRight HumState
st = Name -> Widget Name -> Widget Name
forall n. n -> Widget n -> Widget n
reportExtent Name
PlaylistRight (Widget Name -> Widget Name) -> Widget Name -> Widget Name
forall a b. (a -> b) -> a -> b
$
Size -> Size -> RenderM Name (Result Name) -> Widget Name
forall n. Size -> Size -> RenderM n (Result n) -> Widget n
Widget Size
Greedy Size
Greedy (RenderM Name (Result Name) -> Widget Name)
-> RenderM Name (Result Name) -> Widget Name
forall a b. (a -> b) -> a -> b
$ do
Context
ctx <- RenderM Name Context
forall n. RenderM n Context
getContext
let vsize :: Int
vsize = Context
ctx Context -> Getting Int Context Int -> Int
forall s a. s -> Getting a s a -> a
^. Getting Int Context Int
Lens' Context Int
windowHeightL Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
6
Widget Name -> RenderM Name (Result Name)
forall n. Widget n -> RenderM n (Result n)
render (Widget Name -> RenderM Name (Result Name))
-> Widget Name -> RenderM Name (Result Name)
forall a b. (a -> b) -> a -> b
$ Widget Name -> Widget Name
forall n. Widget n -> Widget n
hCenter
( Widget Name -> Widget Name
forall n. Widget n -> Widget n
visible
(Widget Name -> Widget Name)
-> (Widget Name -> Widget Name) -> Widget Name -> Widget Name
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Widget Name -> Widget Name
forall n. Int -> Widget n -> Widget n
vLimit Int
vsize
(Widget Name -> Widget Name)
-> (Widget Name -> Widget Name) -> Widget Name -> Widget Name
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Widget Name -> Widget Name
forall n. Widget n -> Widget n
center
(Widget Name -> Widget Name) -> Widget Name -> Widget Name
forall a b. (a -> b) -> a -> b
$ (if HumState
st HumState -> Getting Bool HumState Bool -> Bool
forall s a. s -> Getting a s a -> a
^. Getting Bool HumState Bool
Lens' HumState Bool
editableL
then
AttrName -> Widget Name -> Widget Name
forall n. AttrName -> Widget n -> Widget n
withDefAttr AttrName
listHighlightedAttr
(Widget Name -> Widget Name)
-> (Widget Name -> Widget Name) -> Widget Name -> Widget Name
forall b c a. (b -> c) -> (a -> b) -> a -> c
. BorderStyle -> Widget Name -> Widget Name
forall n. BorderStyle -> Widget n -> Widget n
withBorderStyle (Char -> BorderStyle
borderStyleFromChar Char
'=')
(Widget Name -> Widget Name) -> Widget Name -> Widget Name
forall a b. (a -> b) -> a -> b
$ Widget Name -> Widget Name
forall n. Widget n -> Widget n
hBorderWithLabel
(Widget Name -> Widget Name) -> Widget Name -> Widget Name
forall a b. (a -> b) -> a -> b
$ Text -> Widget Name
forall n. Text -> Widget n
txt Text
"editing"
else Widget Name
forall n. Widget n
hBorder
)
Widget Name -> Widget Name -> Widget Name
forall n. Widget n -> Widget n -> Widget n
<=> Widget Name -> Widget Name
forall n. Widget n -> Widget n
hCenter
((Bool -> (Song, Bool) -> Widget Name)
-> Bool -> GenericList Name Vector (Song, Bool) -> Widget Name
forall (t :: * -> *) n e.
(Traversable t, Splittable t, Ord n, Show n) =>
(Bool -> e -> Widget n) -> Bool -> GenericList n t e -> Widget n
renderList (((Song, Bool) -> Widget Name)
-> Bool -> (Song, Bool) -> Widget Name
forall a b. a -> b -> a
const (((Song, Bool) -> Widget Name)
-> Bool -> (Song, Bool) -> Widget Name)
-> ((Song, Bool) -> Widget Name)
-> Bool
-> (Song, Bool)
-> Widget Name
forall a b. (a -> b) -> a -> b
$ HumState -> (Song, Bool) -> Widget Name
forall n. HumState -> (Song, Bool) -> Widget n
playlistSongRow HumState
st)
((Focus -> FocPlay
focPlay (Focus -> FocPlay) -> (HumState -> Focus) -> HumState -> FocPlay
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HumState -> Focus
focus (HumState -> FocPlay) -> HumState -> FocPlay
forall a b. (a -> b) -> a -> b
$ HumState
st) FocPlay -> FocPlay -> Bool
forall a. Eq a => a -> a -> Bool
== FocPlay
FocPSongs)
(HumState
st HumState
-> Getting
(GenericList Name Vector (Song, Bool))
HumState
(GenericList Name Vector (Song, Bool))
-> GenericList Name Vector (Song, Bool)
forall s a. s -> Getting a s a -> a
^. (PlaylistsState
-> Const (GenericList Name Vector (Song, Bool)) PlaylistsState)
-> HumState
-> Const (GenericList Name Vector (Song, Bool)) HumState
Lens' HumState PlaylistsState
playlistsL ((PlaylistsState
-> Const (GenericList Name Vector (Song, Bool)) PlaylistsState)
-> HumState
-> Const (GenericList Name Vector (Song, Bool)) HumState)
-> ((GenericList Name Vector (Song, Bool)
-> Const
(GenericList Name Vector (Song, Bool))
(GenericList Name Vector (Song, Bool)))
-> PlaylistsState
-> Const (GenericList Name Vector (Song, Bool)) PlaylistsState)
-> Getting
(GenericList Name Vector (Song, Bool))
HumState
(GenericList Name Vector (Song, Bool))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (GenericList Name Vector (Song, Bool)
-> Const
(GenericList Name Vector (Song, Bool))
(GenericList Name Vector (Song, Bool)))
-> PlaylistsState
-> Const (GenericList Name Vector (Song, Bool)) PlaylistsState
Lens' PlaylistsState (GenericList Name Vector (Song, Bool))
plSongsL)
)
)
playlistRow :: HumState -> T.Text -> Widget n
playlistRow :: HumState -> Text -> Widget n
playlistRow HumState
_ Text
val =
AttrName -> Widget n -> Widget n
forall n. AttrName -> Widget n -> Widget n
withAttr AttrName
albumAttr (Widget n -> Widget n) -> Widget n -> Widget n
forall a b. (a -> b) -> a -> b
$ Maybe PerCol -> Padding -> Padding -> Widget n -> Widget n
forall n.
Maybe PerCol -> Padding -> Padding -> Widget n -> Widget n
column Maybe PerCol
forall a. Maybe a
Nothing (Int -> Padding
Pad Int
1) Padding
Max (Widget n -> Widget n) -> Widget n -> Widget n
forall a b. (a -> b) -> a -> b
$ Text -> Widget n
forall n. Text -> Widget n
txt Text
val
playlistSongRow :: HumState -> (MPD.Song,Highlight) -> Widget n
playlistSongRow :: HumState -> (Song, Bool) -> Widget n
playlistSongRow HumState
st (Song
song,Bool
hl) =
let pathsInQueue :: Vector Path
pathsInQueue =
(Song -> Path
MPD.sgFilePath (Song -> Path) -> Vector Song -> Vector Path
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>) (Vector Song -> Vector Path)
-> (HumState -> Vector Song) -> HumState -> Vector Path
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((Song, Bool) -> Song
forall a b. (a, b) -> a
fst ((Song, Bool) -> Song) -> Vector (Song, Bool) -> Vector Song
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>) (Vector (Song, Bool) -> Vector Song)
-> (HumState -> Vector (Song, Bool)) -> HumState -> Vector Song
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GenericList Name Vector (Song, Bool) -> Vector (Song, Bool)
forall n (t :: * -> *) e. GenericList n t e -> t e
listElements (GenericList Name Vector (Song, Bool) -> Vector (Song, Bool))
-> (HumState -> GenericList Name Vector (Song, Bool))
-> HumState
-> Vector (Song, Bool)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HumState -> GenericList Name Vector (Song, Bool)
queue (HumState -> Vector Path) -> HumState -> Vector Path
forall a b. (a -> b) -> a -> b
$ HumState
st
in (if Bool
hl then Widget n -> Widget n
forall n. Widget n -> Widget n
highlightOverAttrs else Widget n -> Widget n
forall a. a -> a
id) (Widget n -> Widget n)
-> (Widget n -> Widget n) -> Widget n -> Widget n
forall b c a. (b -> c) -> (a -> b) -> a -> c
. AttrName -> Widget n -> Widget n
forall n. AttrName -> Widget n -> Widget n
withAttr
(if Song -> Path
MPD.sgFilePath Song
song Path -> Vector Path -> Bool
forall (f :: * -> *) a.
(Foldable f, DisallowElem f, Eq a) =>
a -> f a -> Bool
`elem` Vector Path
pathsInQueue
then AttrName
titleBoldAttr
else AttrName
titleAttr
)
(Widget n -> Widget n) -> Widget n -> Widget n
forall a b. (a -> b) -> a -> b
$ Maybe PerCol -> Padding -> Padding -> Widget n -> Widget n
forall n.
Maybe PerCol -> Padding -> Padding -> Widget n -> Widget n
column Maybe PerCol
forall a. Maybe a
Nothing (Int -> Padding
Pad Int
1) Padding
Max
(Widget n -> Widget n) -> Widget n -> Widget n
forall a b. (a -> b) -> a -> b
$ Text -> Widget n
forall n. Text -> Widget n
txt (Text -> Metadata -> Song -> Text
meta (Path -> Text
forall a. ToString a => a -> Text
MPD.toText (Path -> Text) -> (Song -> Path) -> Song -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Song -> Path
MPD.sgFilePath (Song -> Text) -> Song -> Text
forall a b. (a -> b) -> a -> b
$ Song
song) Metadata
MPD.Title Song
song)
drawViewPlaylists :: HumState -> Widget Name
drawViewPlaylists :: HumState -> Widget Name
drawViewPlaylists HumState
st =
Int -> Widget Name -> Widget Name
forall n. Int -> Widget n -> Widget n
hLimitPercent Int
25 (HumState -> Widget Name
drawPlaylistLeft HumState
st) Widget Name -> Widget Name -> Widget Name
forall n. Widget n -> Widget n -> Widget n
<+> HumState -> Widget Name
drawPlaylistRight HumState
st
playlistsMove
:: (forall e . List Name e -> List Name e)
-> HumState
-> EventM Name HumState
playlistsMove :: (forall e. List Name e -> List Name e)
-> HumState -> EventM Name HumState
playlistsMove forall e. List Name e -> List Name e
moveFunc HumState
s =
let playfoc :: FocPlay
playfoc = HumState
s HumState -> Getting FocPlay HumState FocPlay -> FocPlay
forall s a. s -> Getting a s a -> a
^. (Focus -> Const FocPlay Focus)
-> HumState -> Const FocPlay HumState
Lens' HumState Focus
focusL ((Focus -> Const FocPlay Focus)
-> HumState -> Const FocPlay HumState)
-> ((FocPlay -> Const FocPlay FocPlay)
-> Focus -> Const FocPlay Focus)
-> Getting FocPlay HumState FocPlay
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (FocPlay -> Const FocPlay FocPlay) -> Focus -> Const FocPlay Focus
Lens' Focus FocPlay
focPlayL
in case FocPlay
playfoc of
FocPlay
FocPlaylists -> HumState -> EventM Name HumState
forall (m :: * -> *). MonadIO m => HumState -> m HumState
rebuildPlList (HumState -> EventM Name HumState)
-> HumState -> EventM Name HumState
forall a b. (a -> b) -> a -> b
$ HumState
s HumState -> (HumState -> HumState) -> HumState
forall a b. a -> (a -> b) -> b
& (PlaylistsState -> Identity PlaylistsState)
-> HumState -> Identity HumState
Lens' HumState PlaylistsState
playlistsL ((PlaylistsState -> Identity PlaylistsState)
-> HumState -> Identity HumState)
-> ((GenericList Name Vector PlaylistName
-> Identity (GenericList Name Vector PlaylistName))
-> PlaylistsState -> Identity PlaylistsState)
-> (GenericList Name Vector PlaylistName
-> Identity (GenericList Name Vector PlaylistName))
-> HumState
-> Identity HumState
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (GenericList Name Vector PlaylistName
-> Identity (GenericList Name Vector PlaylistName))
-> PlaylistsState -> Identity PlaylistsState
Lens' PlaylistsState (GenericList Name Vector PlaylistName)
plListL ((GenericList Name Vector PlaylistName
-> Identity (GenericList Name Vector PlaylistName))
-> HumState -> Identity HumState)
-> (GenericList Name Vector PlaylistName
-> GenericList Name Vector PlaylistName)
-> HumState
-> HumState
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
%~ GenericList Name Vector PlaylistName
-> GenericList Name Vector PlaylistName
forall e. List Name e -> List Name e
moveFunc
FocPlay
FocPSongs -> do
HumState -> EventM Name HumState
forall (f :: * -> *) a. Applicative f => a -> f a
pure (HumState -> EventM Name HumState)
-> HumState -> EventM Name HumState
forall a b. (a -> b) -> a -> b
$ HumState
s HumState -> (HumState -> HumState) -> HumState
forall a b. a -> (a -> b) -> b
& (PlaylistsState -> Identity PlaylistsState)
-> HumState -> Identity HumState
Lens' HumState PlaylistsState
playlistsL ((PlaylistsState -> Identity PlaylistsState)
-> HumState -> Identity HumState)
-> ((GenericList Name Vector (Song, Bool)
-> Identity (GenericList Name Vector (Song, Bool)))
-> PlaylistsState -> Identity PlaylistsState)
-> (GenericList Name Vector (Song, Bool)
-> Identity (GenericList Name Vector (Song, Bool)))
-> HumState
-> Identity HumState
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (GenericList Name Vector (Song, Bool)
-> Identity (GenericList Name Vector (Song, Bool)))
-> PlaylistsState -> Identity PlaylistsState
Lens' PlaylistsState (GenericList Name Vector (Song, Bool))
plSongsL ((GenericList Name Vector (Song, Bool)
-> Identity (GenericList Name Vector (Song, Bool)))
-> HumState -> Identity HumState)
-> (GenericList Name Vector (Song, Bool)
-> GenericList Name Vector (Song, Bool))
-> HumState
-> HumState
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
%~ GenericList Name Vector (Song, Bool)
-> GenericList Name Vector (Song, Bool)
forall e. List Name e -> List Name e
moveFunc
playlistsAddtoQ
:: Bool
-> HumState
-> EventM Name HumState
playlistsAddtoQ :: Bool -> HumState -> EventM Name HumState
playlistsAddtoQ Bool
play HumState
s =
let playfoc :: FocPlay
playfoc = HumState
s HumState -> Getting FocPlay HumState FocPlay -> FocPlay
forall s a. s -> Getting a s a -> a
^. (Focus -> Const FocPlay Focus)
-> HumState -> Const FocPlay HumState
Lens' HumState Focus
focusL ((Focus -> Const FocPlay Focus)
-> HumState -> Const FocPlay HumState)
-> ((FocPlay -> Const FocPlay FocPlay)
-> Focus -> Const FocPlay Focus)
-> Getting FocPlay HumState FocPlay
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (FocPlay -> Const FocPlay FocPlay) -> Focus -> Const FocPlay Focus
Lens' Focus FocPlay
focPlayL
in case FocPlay
playfoc of
FocPlay
FocPlaylists -> do
Bool -> Vector Song -> HumState -> EventM Name HumState
forall n. Bool -> Vector Song -> HumState -> EventM n HumState
songBulkAddtoQ Bool
play ((Song, Bool) -> Song
forall a b. (a, b) -> a
fst ((Song, Bool) -> Song) -> Vector (Song, Bool) -> Vector Song
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> GenericList Name Vector (Song, Bool) -> Vector (Song, Bool)
forall n (t :: * -> *) e. GenericList n t e -> t e
listElements (HumState
s HumState
-> Getting
(GenericList Name Vector (Song, Bool))
HumState
(GenericList Name Vector (Song, Bool))
-> GenericList Name Vector (Song, Bool)
forall s a. s -> Getting a s a -> a
^. (PlaylistsState
-> Const (GenericList Name Vector (Song, Bool)) PlaylistsState)
-> HumState
-> Const (GenericList Name Vector (Song, Bool)) HumState
Lens' HumState PlaylistsState
playlistsL ((PlaylistsState
-> Const (GenericList Name Vector (Song, Bool)) PlaylistsState)
-> HumState
-> Const (GenericList Name Vector (Song, Bool)) HumState)
-> ((GenericList Name Vector (Song, Bool)
-> Const
(GenericList Name Vector (Song, Bool))
(GenericList Name Vector (Song, Bool)))
-> PlaylistsState
-> Const (GenericList Name Vector (Song, Bool)) PlaylistsState)
-> Getting
(GenericList Name Vector (Song, Bool))
HumState
(GenericList Name Vector (Song, Bool))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (GenericList Name Vector (Song, Bool)
-> Const
(GenericList Name Vector (Song, Bool))
(GenericList Name Vector (Song, Bool)))
-> PlaylistsState
-> Const (GenericList Name Vector (Song, Bool)) PlaylistsState
Lens' PlaylistsState (GenericList Name Vector (Song, Bool))
plSongsL)) HumState
s
FocPlay
FocPSongs -> do
let maybeFilePath :: Maybe Path
maybeFilePath = Song -> Path
MPD.sgFilePath (Song -> Path)
-> ((Int, (Song, Bool)) -> Song) -> (Int, (Song, Bool)) -> Path
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Song, Bool) -> Song
forall a b. (a, b) -> a
fst ((Song, Bool) -> Song)
-> ((Int, (Song, Bool)) -> (Song, Bool))
-> (Int, (Song, Bool))
-> Song
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int, (Song, Bool)) -> (Song, Bool)
forall a b. (a, b) -> b
snd ((Int, (Song, Bool)) -> Path)
-> Maybe (Int, (Song, Bool)) -> Maybe Path
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> GenericList Name Vector (Song, Bool) -> Maybe (Int, (Song, Bool))
forall (t :: * -> *) n e.
(Splittable t, Foldable t) =>
GenericList n t e -> Maybe (Int, e)
listSelectedElement
(HumState
s HumState
-> Getting
(GenericList Name Vector (Song, Bool))
HumState
(GenericList Name Vector (Song, Bool))
-> GenericList Name Vector (Song, Bool)
forall s a. s -> Getting a s a -> a
^. (PlaylistsState
-> Const (GenericList Name Vector (Song, Bool)) PlaylistsState)
-> HumState
-> Const (GenericList Name Vector (Song, Bool)) HumState
Lens' HumState PlaylistsState
playlistsL ((PlaylistsState
-> Const (GenericList Name Vector (Song, Bool)) PlaylistsState)
-> HumState
-> Const (GenericList Name Vector (Song, Bool)) HumState)
-> ((GenericList Name Vector (Song, Bool)
-> Const
(GenericList Name Vector (Song, Bool))
(GenericList Name Vector (Song, Bool)))
-> PlaylistsState
-> Const (GenericList Name Vector (Song, Bool)) PlaylistsState)
-> Getting
(GenericList Name Vector (Song, Bool))
HumState
(GenericList Name Vector (Song, Bool))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (GenericList Name Vector (Song, Bool)
-> Const
(GenericList Name Vector (Song, Bool))
(GenericList Name Vector (Song, Bool)))
-> PlaylistsState
-> Const (GenericList Name Vector (Song, Bool)) PlaylistsState
Lens' PlaylistsState (GenericList Name Vector (Song, Bool))
plSongsL)
(Path -> EventM Name (Response ())) -> Maybe Path -> EventM Name ()
forall (t :: * -> *) (f :: * -> *) a b.
(Foldable t, Applicative f) =>
(a -> f b) -> t a -> f ()
traverse_
(\Path
sel -> IO (Response ()) -> EventM Name (Response ())
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO
(MPD () -> IO (Response ())
forall a. MPD a -> IO (Response a)
withMPD (MPD () -> IO (Response ())) -> MPD () -> IO (Response ())
forall a b. (a -> b) -> a -> b
$ Path -> Maybe Int -> MPD Id
forall (m :: * -> *). MonadMPD m => Path -> Maybe Int -> m Id
MPD.addId Path
sel Maybe Int
forall a. Maybe a
Nothing MPD Id -> (Id -> MPD ()) -> MPD ()
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= if Bool
play
then Id -> MPD ()
forall (m :: * -> *). MonadMPD m => Id -> m ()
MPD.playId
else MPD () -> Id -> MPD ()
forall a b. a -> b -> a
const MPD ()
forall (f :: * -> *). Applicative f => f ()
pass
)
)
Maybe Path
maybeFilePath
Response (Maybe Song)
song <- IO (Response (Maybe Song)) -> EventM Name (Response (Maybe Song))
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (MPD (Maybe Song) -> IO (Response (Maybe Song))
forall a. MPD a -> IO (Response a)
withMPD MPD (Maybe Song)
forall (m :: * -> *). MonadMPD m => m (Maybe Song)
MPD.currentSong)
HumState -> EventM Name HumState
forall (f :: * -> *) a. Applicative f => a -> f a
pure HumState
s { currentSong :: Maybe Song
currentSong = Maybe Song -> Response (Maybe Song) -> Maybe Song
forall b a. b -> Either a b -> b
fromRight Maybe Song
forall a. Maybe a
Nothing Response (Maybe Song)
song, queue :: GenericList Name Vector (Song, Bool)
queue = HumState -> GenericList Name Vector (Song, Bool)
queue HumState
s }
playlistsSearch
:: Bool
-> HumState
-> EventM Name HumState
playlistsSearch :: Bool -> HumState -> EventM Name HumState
playlistsSearch Bool
direction HumState
s =
let playfoc :: FocPlay
playfoc = HumState
s HumState -> Getting FocPlay HumState FocPlay -> FocPlay
forall s a. s -> Getting a s a -> a
^. (Focus -> Const FocPlay Focus)
-> HumState -> Const FocPlay HumState
Lens' HumState Focus
focusL ((Focus -> Const FocPlay Focus)
-> HumState -> Const FocPlay HumState)
-> ((FocPlay -> Const FocPlay FocPlay)
-> Focus -> Const FocPlay Focus)
-> Getting FocPlay HumState FocPlay
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (FocPlay -> Const FocPlay FocPlay) -> Focus -> Const FocPlay Focus
Lens' Focus FocPlay
focPlayL
dir :: GenericList n Vector e -> GenericList n Vector e
dir = if Bool
direction then GenericList n Vector e -> GenericList n Vector e
forall a. a -> a
id else GenericList n Vector e -> GenericList n Vector e
forall (t :: * -> *) n e.
(Reversible t, Foldable t) =>
GenericList n t e -> GenericList n t e
listReverse
searchkey :: Text
searchkey = Text -> Maybe Text -> Text
forall a. a -> Maybe a -> a
fromMaybe Text
"" ((HumState
s HumState -> Getting [Text] HumState [Text] -> [Text]
forall s a. s -> Getting a s a -> a
^. (ExState -> Const [Text] ExState)
-> HumState -> Const [Text] HumState
Lens' HumState ExState
exL ((ExState -> Const [Text] ExState)
-> HumState -> Const [Text] HumState)
-> (([Text] -> Const [Text] [Text])
-> ExState -> Const [Text] ExState)
-> Getting [Text] HumState [Text]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Text] -> Const [Text] [Text]) -> ExState -> Const [Text] ExState
Lens' ExState [Text]
searchHistoryL) [Text] -> Int -> Maybe Text
forall a. [a] -> Int -> Maybe a
!!? Int
0)
in if Text
searchkey Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text
""
then HumState -> EventM Name HumState
forall (f :: * -> *) a. Applicative f => a -> f a
pure HumState
s
else case FocPlay
playfoc of
FocPlay
FocPlaylists -> do
HumState -> EventM Name HumState
forall (m :: * -> *). MonadIO m => HumState -> m HumState
rebuildPlList
(HumState -> EventM Name HumState)
-> HumState -> EventM Name HumState
forall a b. (a -> b) -> a -> b
$ HumState
s
HumState -> (HumState -> HumState) -> HumState
forall a b. a -> (a -> b) -> b
& (PlaylistsState -> Identity PlaylistsState)
-> HumState -> Identity HumState
Lens' HumState PlaylistsState
playlistsL
((PlaylistsState -> Identity PlaylistsState)
-> HumState -> Identity HumState)
-> ((GenericList Name Vector PlaylistName
-> Identity (GenericList Name Vector PlaylistName))
-> PlaylistsState -> Identity PlaylistsState)
-> (GenericList Name Vector PlaylistName
-> Identity (GenericList Name Vector PlaylistName))
-> HumState
-> Identity HumState
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (GenericList Name Vector PlaylistName
-> Identity (GenericList Name Vector PlaylistName))
-> PlaylistsState -> Identity PlaylistsState
Lens' PlaylistsState (GenericList Name Vector PlaylistName)
plListL
((GenericList Name Vector PlaylistName
-> Identity (GenericList Name Vector PlaylistName))
-> HumState -> Identity HumState)
-> (GenericList Name Vector PlaylistName
-> GenericList Name Vector PlaylistName)
-> HumState
-> HumState
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
%~ (GenericList Name Vector PlaylistName
-> GenericList Name Vector PlaylistName
forall n e. GenericList n Vector e -> GenericList n Vector e
dir (GenericList Name Vector PlaylistName
-> GenericList Name Vector PlaylistName)
-> (GenericList Name Vector PlaylistName
-> GenericList Name Vector PlaylistName)
-> GenericList Name Vector PlaylistName
-> GenericList Name Vector PlaylistName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (PlaylistName -> Bool)
-> GenericList Name Vector PlaylistName
-> GenericList Name Vector PlaylistName
forall (t :: * -> *) e n.
(Foldable t, Splittable t) =>
(e -> Bool) -> GenericList n t e -> GenericList n t e
listFindBy (Text -> PlaylistName -> Bool
forall a. ToString a => Text -> a -> Bool
stringySearch Text
searchkey) (GenericList Name Vector PlaylistName
-> GenericList Name Vector PlaylistName)
-> (GenericList Name Vector PlaylistName
-> GenericList Name Vector PlaylistName)
-> GenericList Name Vector PlaylistName
-> GenericList Name Vector PlaylistName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GenericList Name Vector PlaylistName
-> GenericList Name Vector PlaylistName
forall n e. GenericList n Vector e -> GenericList n Vector e
dir)
FocPlay
FocPSongs -> do
HumState -> EventM Name HumState
forall (f :: * -> *) a. Applicative f => a -> f a
pure
(HumState -> EventM Name HumState)
-> HumState -> EventM Name HumState
forall a b. (a -> b) -> a -> b
$ HumState
s
HumState -> (HumState -> HumState) -> HumState
forall a b. a -> (a -> b) -> b
& (PlaylistsState -> Identity PlaylistsState)
-> HumState -> Identity HumState
Lens' HumState PlaylistsState
playlistsL
((PlaylistsState -> Identity PlaylistsState)
-> HumState -> Identity HumState)
-> ((GenericList Name Vector (Song, Bool)
-> Identity (GenericList Name Vector (Song, Bool)))
-> PlaylistsState -> Identity PlaylistsState)
-> (GenericList Name Vector (Song, Bool)
-> Identity (GenericList Name Vector (Song, Bool)))
-> HumState
-> Identity HumState
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (GenericList Name Vector (Song, Bool)
-> Identity (GenericList Name Vector (Song, Bool)))
-> PlaylistsState -> Identity PlaylistsState
Lens' PlaylistsState (GenericList Name Vector (Song, Bool))
plSongsL
((GenericList Name Vector (Song, Bool)
-> Identity (GenericList Name Vector (Song, Bool)))
-> HumState -> Identity HumState)
-> (GenericList Name Vector (Song, Bool)
-> GenericList Name Vector (Song, Bool))
-> HumState
-> HumState
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
%~ (GenericList Name Vector (Song, Bool)
-> GenericList Name Vector (Song, Bool)
forall n e. GenericList n Vector e -> GenericList n Vector e
dir (GenericList Name Vector (Song, Bool)
-> GenericList Name Vector (Song, Bool))
-> (GenericList Name Vector (Song, Bool)
-> GenericList Name Vector (Song, Bool))
-> GenericList Name Vector (Song, Bool)
-> GenericList Name Vector (Song, Bool)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((Song, Bool) -> Bool)
-> GenericList Name Vector (Song, Bool)
-> GenericList Name Vector (Song, Bool)
forall (t :: * -> *) e n.
(Foldable t, Splittable t) =>
(e -> Bool) -> GenericList n t e -> GenericList n t e
listFindBy (Text -> [Metadata] -> Song -> Bool
songSearch Text
searchkey [Metadata
MPD.Title] (Song -> Bool) -> ((Song, Bool) -> Song) -> (Song, Bool) -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Song, Bool) -> Song
forall a b. (a, b) -> a
fst) (GenericList Name Vector (Song, Bool)
-> GenericList Name Vector (Song, Bool))
-> (GenericList Name Vector (Song, Bool)
-> GenericList Name Vector (Song, Bool))
-> GenericList Name Vector (Song, Bool)
-> GenericList Name Vector (Song, Bool)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GenericList Name Vector (Song, Bool)
-> GenericList Name Vector (Song, Bool)
forall n e. GenericList n Vector e -> GenericList n Vector e
dir)
renamePl
:: T.Text -> Bool -> HumState -> EventM n HumState
renamePl :: Text -> Bool -> HumState -> EventM n HumState
renamePl Text
oldname Bool
bl HumState
st = if Bool
bl
then
let newname :: PlaylistName
newname = String -> PlaylistName
forall a. IsString a => String -> a
fromString (Text -> String
forall a. ToString a => a -> String
toString (Text -> String) -> Text -> String
forall a b. (a -> b) -> a -> b
$ HumState
st HumState
-> Getting (TextZipper Text) HumState (TextZipper Text)
-> TextZipper Text
forall s a. s -> Getting a s a -> a
^. (Prompts -> Const (TextZipper Text) Prompts)
-> HumState -> Const (TextZipper Text) HumState
Lens' HumState Prompts
promptsL ((Prompts -> Const (TextZipper Text) Prompts)
-> HumState -> Const (TextZipper Text) HumState)
-> ((TextZipper Text -> Const (TextZipper Text) (TextZipper Text))
-> Prompts -> Const (TextZipper Text) Prompts)
-> Getting (TextZipper Text) HumState (TextZipper Text)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Editor Text Name -> Const (TextZipper Text) (Editor Text Name))
-> Prompts -> Const (TextZipper Text) Prompts
Lens' Prompts (Editor Text Name)
textPromptL ((Editor Text Name -> Const (TextZipper Text) (Editor Text Name))
-> Prompts -> Const (TextZipper Text) Prompts)
-> ((TextZipper Text -> Const (TextZipper Text) (TextZipper Text))
-> Editor Text Name -> Const (TextZipper Text) (Editor Text Name))
-> (TextZipper Text -> Const (TextZipper Text) (TextZipper Text))
-> Prompts
-> Const (TextZipper Text) Prompts
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TextZipper Text -> Const (TextZipper Text) (TextZipper Text))
-> Editor Text Name -> Const (TextZipper Text) (Editor Text Name)
forall t1 n t2.
Lens (Editor t1 n) (Editor t2 n) (TextZipper t1) (TextZipper t2)
editContentsL TextZipper Text -> (TextZipper Text -> Text) -> Text
forall a b. a -> (a -> b) -> b
& TextZipper Text -> Text
forall a. Monoid a => TextZipper a -> a
Z.currentLine)
oldname' :: PlaylistName
oldname' = String -> PlaylistName
forall a. IsString a => String -> a
fromString (String -> PlaylistName)
-> (Text -> String) -> Text -> PlaylistName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> String
T.unpack (Text -> PlaylistName) -> Text -> PlaylistName
forall a b. (a -> b) -> a -> b
$ Text
oldname
in do
Response ()
_ <- IO (Response ()) -> EventM n (Response ())
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Response ()) -> EventM n (Response ()))
-> (MPD () -> IO (Response ())) -> MPD () -> EventM n (Response ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MPD () -> IO (Response ())
forall a. MPD a -> IO (Response a)
withMPD (MPD () -> EventM n (Response ()))
-> MPD () -> EventM n (Response ())
forall a b. (a -> b) -> a -> b
$PlaylistName -> PlaylistName -> MPD ()
forall (m :: * -> *).
MonadMPD m =>
PlaylistName -> PlaylistName -> m ()
MPD.rename PlaylistName
oldname' PlaylistName
newname
HumState -> EventM n HumState
forall (m :: * -> *). MonadIO m => HumState -> m HumState
rebuildPl HumState
st
else HumState -> EventM n HumState
forall (f :: * -> *) a. Applicative f => a -> f a
pure HumState
st
handleEventPlaylists
:: HumState -> BrickEvent Name HumEvent -> EventM Name (Next HumState)
handleEventPlaylists :: HumState -> BrickEvent Name HumEvent -> EventM Name (Next HumState)
handleEventPlaylists HumState
s BrickEvent Name HumEvent
e = case BrickEvent Name HumEvent
e of
VtyEvent Event
vtye -> case Event
vtye of
EvKey (KChar Char
'j') [] -> HumState -> EventM Name (Next HumState)
forall s n. s -> EventM n (Next s)
continue (HumState -> EventM Name (Next HumState))
-> EventM Name HumState -> EventM Name (Next HumState)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< (forall e. List Name e -> List Name e)
-> HumState -> EventM Name HumState
playlistsMove forall e. List Name e -> List Name e
forall (t :: * -> *) n e.
(Foldable t, Splittable t) =>
GenericList n t e -> GenericList n t e
listMoveDown HumState
s
EvKey (KChar Char
'k') [] -> HumState -> EventM Name (Next HumState)
forall s n. s -> EventM n (Next s)
continue (HumState -> EventM Name (Next HumState))
-> EventM Name HumState -> EventM Name (Next HumState)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< (forall e. List Name e -> List Name e)
-> HumState -> EventM Name HumState
playlistsMove forall e. List Name e -> List Name e
forall (t :: * -> *) n e.
(Foldable t, Splittable t) =>
GenericList n t e -> GenericList n t e
listMoveUp HumState
s
EvKey (KChar Char
'l') [] -> HumState -> EventM Name (Next HumState)
forall s n. s -> EventM n (Next s)
continue (HumState -> EventM Name (Next HumState))
-> HumState -> EventM Name (Next HumState)
forall a b. (a -> b) -> a -> b
$ HumState
s HumState -> (HumState -> HumState) -> HumState
forall a b. a -> (a -> b) -> b
& (Focus -> Identity Focus) -> HumState -> Identity HumState
Lens' HumState Focus
focusL ((Focus -> Identity Focus) -> HumState -> Identity HumState)
-> ((FocPlay -> Identity FocPlay) -> Focus -> Identity Focus)
-> (FocPlay -> Identity FocPlay)
-> HumState
-> Identity HumState
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (FocPlay -> Identity FocPlay) -> Focus -> Identity Focus
Lens' Focus FocPlay
focPlayL ((FocPlay -> Identity FocPlay) -> HumState -> Identity HumState)
-> FocPlay -> HumState -> HumState
forall s t a b. ASetter s t a b -> b -> s -> t
.~ FocPlay
FocPSongs
EvKey (KChar Char
'h') [] -> HumState -> EventM Name (Next HumState)
forall s n. s -> EventM n (Next s)
continue (HumState -> EventM Name (Next HumState))
-> HumState -> EventM Name (Next HumState)
forall a b. (a -> b) -> a -> b
$ HumState
s HumState -> (HumState -> HumState) -> HumState
forall a b. a -> (a -> b) -> b
& (Focus -> Identity Focus) -> HumState -> Identity HumState
Lens' HumState Focus
focusL ((Focus -> Identity Focus) -> HumState -> Identity HumState)
-> ((FocPlay -> Identity FocPlay) -> Focus -> Identity Focus)
-> (FocPlay -> Identity FocPlay)
-> HumState
-> Identity HumState
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (FocPlay -> Identity FocPlay) -> Focus -> Identity Focus
Lens' Focus FocPlay
focPlayL ((FocPlay -> Identity FocPlay) -> HumState -> Identity HumState)
-> FocPlay -> HumState -> HumState
forall s t a b. ASetter s t a b -> b -> s -> t
.~ FocPlay
FocPlaylists
EvKey (KChar Char
'n') [] ->
HumState -> EventM Name (Next HumState)
forall s n. s -> EventM n (Next s)
continue (HumState -> EventM Name (Next HumState))
-> EventM Name HumState -> EventM Name (Next HumState)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Bool -> HumState -> EventM Name HumState
playlistsSearch (HumState
s HumState -> Getting Bool HumState Bool -> Bool
forall s a. s -> Getting a s a -> a
^. (ExState -> Const Bool ExState) -> HumState -> Const Bool HumState
Lens' HumState ExState
exL ((ExState -> Const Bool ExState)
-> HumState -> Const Bool HumState)
-> ((Bool -> Const Bool Bool) -> ExState -> Const Bool ExState)
-> Getting Bool HumState Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Bool -> Const Bool Bool) -> ExState -> Const Bool ExState
Lens' ExState Bool
searchDirectionL) HumState
s
EvKey (KChar Char
'N') [] ->
HumState -> EventM Name (Next HumState)
forall s n. s -> EventM n (Next s)
continue (HumState -> EventM Name (Next HumState))
-> EventM Name HumState -> EventM Name (Next HumState)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Bool -> HumState -> EventM Name HumState
playlistsSearch (HumState
s HumState -> Getting Bool HumState Bool -> Bool
forall s a. s -> Getting a s a -> a
^. (ExState -> Const Bool ExState) -> HumState -> Const Bool HumState
Lens' HumState ExState
exL ((ExState -> Const Bool ExState)
-> HumState -> Const Bool HumState)
-> ((Bool -> Const Bool Bool) -> ExState -> Const Bool ExState)
-> Getting Bool HumState Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Bool -> Const Bool Bool) -> ExState -> Const Bool ExState
Lens' ExState Bool
searchDirectionL Bool -> (Bool -> Bool) -> Bool
forall a b. a -> (a -> b) -> b
& Bool -> Bool
not) HumState
s
EvKey Key
KEnter [] ->
HumState -> EventM Name (Next HumState)
forall s n. s -> EventM n (Next s)
continue (HumState -> EventM Name (Next HumState))
-> EventM Name HumState -> EventM Name (Next HumState)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< (forall e. List Name e -> List Name e)
-> HumState -> EventM Name HumState
playlistsMove forall e. List Name e -> List Name e
forall (t :: * -> *) n e.
(Foldable t, Splittable t) =>
GenericList n t e -> GenericList n t e
listMoveDown (HumState -> EventM Name HumState)
-> EventM Name HumState -> EventM Name HumState
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Bool -> HumState -> EventM Name HumState
playlistsAddtoQ Bool
True HumState
s
EvKey (KChar Char
' ') [] -> if HumState
s HumState -> Getting Bool HumState Bool -> Bool
forall s a. s -> Getting a s a -> a
^. Getting Bool HumState Bool
Lens' HumState Bool
editableL then
HumState -> EventM Name (Next HumState)
forall s n. s -> EventM n (Next s)
continue (HumState -> EventM Name (Next HumState))
-> HumState -> EventM Name (Next HumState)
forall a b. (a -> b) -> a -> b
$ HumState
s HumState -> (HumState -> HumState) -> HumState
forall a b. a -> (a -> b) -> b
& (PlaylistsState -> Identity PlaylistsState)
-> HumState -> Identity HumState
Lens' HumState PlaylistsState
playlistsL ((PlaylistsState -> Identity PlaylistsState)
-> HumState -> Identity HumState)
-> ((GenericList Name Vector (Song, Bool)
-> Identity (GenericList Name Vector (Song, Bool)))
-> PlaylistsState -> Identity PlaylistsState)
-> (GenericList Name Vector (Song, Bool)
-> Identity (GenericList Name Vector (Song, Bool)))
-> HumState
-> Identity HumState
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (GenericList Name Vector (Song, Bool)
-> Identity (GenericList Name Vector (Song, Bool)))
-> PlaylistsState -> Identity PlaylistsState
Lens' PlaylistsState (GenericList Name Vector (Song, Bool))
plSongsL ((GenericList Name Vector (Song, Bool)
-> Identity (GenericList Name Vector (Song, Bool)))
-> HumState -> Identity HumState)
-> (GenericList Name Vector (Song, Bool)
-> GenericList Name Vector (Song, Bool))
-> HumState
-> HumState
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
%~ (GenericList Name Vector (Song, Bool)
-> GenericList Name Vector (Song, Bool)
forall (t :: * -> *) n e.
(Foldable t, Splittable t) =>
GenericList n t e -> GenericList n t e
listMoveDown (GenericList Name Vector (Song, Bool)
-> GenericList Name Vector (Song, Bool))
-> (GenericList Name Vector (Song, Bool)
-> GenericList Name Vector (Song, Bool))
-> GenericList Name Vector (Song, Bool)
-> GenericList Name Vector (Song, Bool)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GenericList Name Vector (Song, Bool)
-> GenericList Name Vector (Song, Bool)
forall (t :: * -> *) n e.
Traversable t =>
GenericList n t (e, Bool) -> GenericList n t (e, Bool)
listToggleHighlight)
else
HumState -> EventM Name (Next HumState)
forall s n. s -> EventM n (Next s)
continue (HumState -> EventM Name (Next HumState))
-> EventM Name HumState -> EventM Name (Next HumState)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< (forall e. List Name e -> List Name e)
-> HumState -> EventM Name HumState
playlistsMove forall e. List Name e -> List Name e
forall (t :: * -> *) n e.
(Foldable t, Splittable t) =>
GenericList n t e -> GenericList n t e
listMoveDown (HumState -> EventM Name HumState)
-> EventM Name HumState -> EventM Name HumState
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Bool -> HumState -> EventM Name HumState
playlistsAddtoQ Bool
False HumState
s
EvKey (KChar Char
'd') []
| HumState
s HumState -> Getting Bool HumState Bool -> Bool
forall s a. s -> Getting a s a -> a
^. Getting Bool HumState Bool
Lens' HumState Bool
editableL
-> HumState -> EventM Name (Next HumState)
forall s n. s -> EventM n (Next s)
continue (HumState -> EventM Name (Next HumState))
-> HumState -> EventM Name (Next HumState)
forall a b. (a -> b) -> a -> b
$ HumState
-> Lens' HumState (GenericList Name Vector (Song, Bool))
-> HumState
deleteHighlighted HumState
s ((PlaylistsState -> f PlaylistsState) -> HumState -> f HumState
Lens' HumState PlaylistsState
playlistsL ((PlaylistsState -> f PlaylistsState) -> HumState -> f HumState)
-> ((GenericList Name Vector (Song, Bool)
-> f (GenericList Name Vector (Song, Bool)))
-> PlaylistsState -> f PlaylistsState)
-> (GenericList Name Vector (Song, Bool)
-> f (GenericList Name Vector (Song, Bool)))
-> HumState
-> f HumState
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (GenericList Name Vector (Song, Bool)
-> f (GenericList Name Vector (Song, Bool)))
-> PlaylistsState -> f PlaylistsState
Lens' PlaylistsState (GenericList Name Vector (Song, Bool))
plSongsL)
| HumState
s HumState -> Getting FocPlay HumState FocPlay -> FocPlay
forall s a. s -> Getting a s a -> a
^. (Focus -> Const FocPlay Focus)
-> HumState -> Const FocPlay HumState
Lens' HumState Focus
focusL ((Focus -> Const FocPlay Focus)
-> HumState -> Const FocPlay HumState)
-> ((FocPlay -> Const FocPlay FocPlay)
-> Focus -> Const FocPlay Focus)
-> Getting FocPlay HumState FocPlay
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (FocPlay -> Const FocPlay FocPlay) -> Focus -> Const FocPlay Focus
Lens' Focus FocPlay
focPlayL FocPlay -> FocPlay -> Bool
forall a. Eq a => a -> a -> Bool
== FocPlay
FocPlaylists
-> HumState -> EventM Name (Next HumState)
forall s n. s -> EventM n (Next s)
continue (HumState -> EventM Name (Next HumState))
-> HumState -> EventM Name (Next HumState)
forall a b. (a -> b) -> a -> b
$ HumState
s HumState -> (HumState -> HumState) -> HumState
forall a b. a -> (a -> b) -> b
& (Mode -> Identity Mode) -> HumState -> Identity HumState
Lens' HumState Mode
modeL ((Mode -> Identity Mode) -> HumState -> Identity HumState)
-> Mode -> HumState -> HumState
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Mode
PromptMode
HumState -> (HumState -> HumState) -> HumState
forall a b. a -> (a -> b) -> b
& (Prompts -> Identity Prompts) -> HumState -> Identity HumState
Lens' HumState Prompts
promptsL ((Prompts -> Identity Prompts) -> HumState -> Identity HumState)
-> ((PromptType -> Identity PromptType)
-> Prompts -> Identity Prompts)
-> (PromptType -> Identity PromptType)
-> HumState
-> Identity HumState
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (PromptType -> Identity PromptType) -> Prompts -> Identity Prompts
Lens' Prompts PromptType
currentPromptL ((PromptType -> Identity PromptType)
-> HumState -> Identity HumState)
-> PromptType -> HumState -> HumState
forall s t a b. ASetter s t a b -> b -> s -> t
.~ PromptType
YNPrompt
HumState -> (HumState -> HumState) -> HumState
forall a b. a -> (a -> b) -> b
& (Prompts -> Identity Prompts) -> HumState -> Identity HumState
Lens' HumState Prompts
promptsL ((Prompts -> Identity Prompts) -> HumState -> Identity HumState)
-> ((Text -> Identity Text) -> Prompts -> Identity Prompts)
-> (Text -> Identity Text)
-> HumState
-> Identity HumState
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Text -> Identity Text) -> Prompts -> Identity Prompts
Lens' Prompts Text
promptTitleL ((Text -> Identity Text) -> HumState -> Identity HumState)
-> Text -> HumState -> HumState
forall s t a b. ASetter s t a b -> b -> s -> t
.~ (Text
"DELETE " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
selectedPl Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"?\nYou can't paste it back yet")
HumState -> (HumState -> HumState) -> HumState
forall a b. a -> (a -> b) -> b
& (Prompts -> Identity Prompts) -> HumState -> Identity HumState
Lens' HumState Prompts
promptsL ((Prompts -> Identity Prompts) -> HumState -> Identity HumState)
-> (((Bool -> HumState -> EventM Name HumState)
-> Identity (Bool -> HumState -> EventM Name HumState))
-> Prompts -> Identity Prompts)
-> ((Bool -> HumState -> EventM Name HumState)
-> Identity (Bool -> HumState -> EventM Name HumState))
-> HumState
-> Identity HumState
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((Bool -> HumState -> EventM Name HumState)
-> Identity (Bool -> HumState -> EventM Name HumState))
-> Prompts -> Identity Prompts
Lens' Prompts (Bool -> HumState -> EventM Name HumState)
exitPromptFuncL (((Bool -> HumState -> EventM Name HumState)
-> Identity (Bool -> HumState -> EventM Name HumState))
-> HumState -> Identity HumState)
-> (Bool -> HumState -> EventM Name HumState)
-> HumState
-> HumState
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Bool -> HumState -> EventM Name HumState
forall n. Bool -> HumState -> EventM n HumState
deleteSelectedPl
| Bool
otherwise -> HumState -> EventM Name (Next HumState)
forall s n. s -> EventM n (Next s)
continue HumState
s
EvKey (KChar Char
'y') []
| HumState
s HumState -> Getting Bool HumState Bool -> Bool
forall s a. s -> Getting a s a -> a
^. Getting Bool HumState Bool
Lens' HumState Bool
editableL
-> HumState -> EventM Name (Next HumState)
forall s n. s -> EventM n (Next s)
continue (HumState -> EventM Name (Next HumState))
-> HumState -> EventM Name (Next HumState)
forall a b. (a -> b) -> a -> b
$ HumState
s HumState -> (HumState -> HumState) -> HumState
forall a b. a -> (a -> b) -> b
& (Clipboard -> Identity Clipboard) -> HumState -> Identity HumState
Lens' HumState Clipboard
clipboardL ((Clipboard -> Identity Clipboard)
-> HumState -> Identity HumState)
-> ((GenericList Name Vector (Song, Bool)
-> Identity (GenericList Name Vector (Song, Bool)))
-> Clipboard -> Identity Clipboard)
-> (GenericList Name Vector (Song, Bool)
-> Identity (GenericList Name Vector (Song, Bool)))
-> HumState
-> Identity HumState
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (GenericList Name Vector (Song, Bool)
-> Identity (GenericList Name Vector (Song, Bool)))
-> Clipboard -> Identity Clipboard
Lens' Clipboard (GenericList Name Vector (Song, Bool))
clSongsL ((GenericList Name Vector (Song, Bool)
-> Identity (GenericList Name Vector (Song, Bool)))
-> HumState -> Identity HumState)
-> GenericList Name Vector (Song, Bool) -> HumState -> HumState
forall s t a b. ASetter s t a b -> b -> s -> t
.~ (HumState
s HumState
-> Getting
(GenericList Name Vector (Song, Bool))
HumState
(GenericList Name Vector (Song, Bool))
-> GenericList Name Vector (Song, Bool)
forall s a. s -> Getting a s a -> a
^. (PlaylistsState
-> Const (GenericList Name Vector (Song, Bool)) PlaylistsState)
-> HumState
-> Const (GenericList Name Vector (Song, Bool)) HumState
Lens' HumState PlaylistsState
playlistsL ((PlaylistsState
-> Const (GenericList Name Vector (Song, Bool)) PlaylistsState)
-> HumState
-> Const (GenericList Name Vector (Song, Bool)) HumState)
-> ((GenericList Name Vector (Song, Bool)
-> Const
(GenericList Name Vector (Song, Bool))
(GenericList Name Vector (Song, Bool)))
-> PlaylistsState
-> Const (GenericList Name Vector (Song, Bool)) PlaylistsState)
-> Getting
(GenericList Name Vector (Song, Bool))
HumState
(GenericList Name Vector (Song, Bool))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (GenericList Name Vector (Song, Bool)
-> Const
(GenericList Name Vector (Song, Bool))
(GenericList Name Vector (Song, Bool)))
-> PlaylistsState
-> Const (GenericList Name Vector (Song, Bool)) PlaylistsState
Lens' PlaylistsState (GenericList Name Vector (Song, Bool))
plSongsL GenericList Name Vector (Song, Bool)
-> (GenericList Name Vector (Song, Bool)
-> GenericList Name Vector (Song, Bool))
-> GenericList Name Vector (Song, Bool)
forall a b. a -> (a -> b) -> b
& GenericList Name Vector (Song, Bool)
-> GenericList Name Vector (Song, Bool)
forall (t :: * -> *) n e.
(Filterable t, Traversable t) =>
GenericList n t (e, Bool) -> GenericList n t (e, Bool)
getHighlighted)
| HumState
s HumState -> Getting FocPlay HumState FocPlay -> FocPlay
forall s a. s -> Getting a s a -> a
^. (Focus -> Const FocPlay Focus)
-> HumState -> Const FocPlay HumState
Lens' HumState Focus
focusL ((Focus -> Const FocPlay Focus)
-> HumState -> Const FocPlay HumState)
-> ((FocPlay -> Const FocPlay FocPlay)
-> Focus -> Const FocPlay Focus)
-> Getting FocPlay HumState FocPlay
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (FocPlay -> Const FocPlay FocPlay) -> Focus -> Const FocPlay Focus
Lens' Focus FocPlay
focPlayL FocPlay -> FocPlay -> Bool
forall a. Eq a => a -> a -> Bool
== FocPlay
FocPlaylists
-> HumState -> EventM Name (Next HumState)
forall s n. s -> EventM n (Next s)
continue (HumState -> EventM Name (Next HumState))
-> HumState -> EventM Name (Next HumState)
forall a b. (a -> b) -> a -> b
$ HumState
s HumState -> (HumState -> HumState) -> HumState
forall a b. a -> (a -> b) -> b
& (Clipboard -> Identity Clipboard) -> HumState -> Identity HumState
Lens' HumState Clipboard
clipboardL ((Clipboard -> Identity Clipboard)
-> HumState -> Identity HumState)
-> ((Maybe PlaylistName -> Identity (Maybe PlaylistName))
-> Clipboard -> Identity Clipboard)
-> (Maybe PlaylistName -> Identity (Maybe PlaylistName))
-> HumState
-> Identity HumState
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Maybe PlaylistName -> Identity (Maybe PlaylistName))
-> Clipboard -> Identity Clipboard
Lens' Clipboard (Maybe PlaylistName)
clPlNameL ((Maybe PlaylistName -> Identity (Maybe PlaylistName))
-> HumState -> Identity HumState)
-> Maybe PlaylistName -> HumState -> HumState
forall s t a b. ASetter s t a b -> b -> s -> t
.~ (HumState
s HumState
-> Getting
(GenericList Name Vector PlaylistName)
HumState
(GenericList Name Vector PlaylistName)
-> GenericList Name Vector PlaylistName
forall s a. s -> Getting a s a -> a
^. (PlaylistsState
-> Const (GenericList Name Vector PlaylistName) PlaylistsState)
-> HumState
-> Const (GenericList Name Vector PlaylistName) HumState
Lens' HumState PlaylistsState
playlistsL ((PlaylistsState
-> Const (GenericList Name Vector PlaylistName) PlaylistsState)
-> HumState
-> Const (GenericList Name Vector PlaylistName) HumState)
-> ((GenericList Name Vector PlaylistName
-> Const
(GenericList Name Vector PlaylistName)
(GenericList Name Vector PlaylistName))
-> PlaylistsState
-> Const (GenericList Name Vector PlaylistName) PlaylistsState)
-> Getting
(GenericList Name Vector PlaylistName)
HumState
(GenericList Name Vector PlaylistName)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (GenericList Name Vector PlaylistName
-> Const
(GenericList Name Vector PlaylistName)
(GenericList Name Vector PlaylistName))
-> PlaylistsState
-> Const (GenericList Name Vector PlaylistName) PlaylistsState
Lens' PlaylistsState (GenericList Name Vector PlaylistName)
plListL GenericList Name Vector PlaylistName
-> (GenericList Name Vector PlaylistName
-> Maybe (Int, PlaylistName))
-> Maybe (Int, PlaylistName)
forall a b. a -> (a -> b) -> b
& GenericList Name Vector PlaylistName -> Maybe (Int, PlaylistName)
forall (t :: * -> *) n e.
(Splittable t, Foldable t) =>
GenericList n t e -> Maybe (Int, e)
listSelectedElement Maybe (Int, PlaylistName)
-> ((Int, PlaylistName) -> PlaylistName) -> Maybe PlaylistName
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> (Int, PlaylistName) -> PlaylistName
forall a b. (a, b) -> b
snd)
| Bool
otherwise -> HumState -> EventM Name (Next HumState)
forall s n. s -> EventM n (Next s)
continue HumState
s
EvKey (KChar Char
'p') []
| HumState
s HumState -> Getting Bool HumState Bool -> Bool
forall s a. s -> Getting a s a -> a
^. Getting Bool HumState Bool
Lens' HumState Bool
editableL
-> HumState -> EventM Name (Next HumState)
forall s n. s -> EventM n (Next s)
continue (HumState -> EventM Name (Next HumState))
-> HumState -> EventM Name (Next HumState)
forall a b. (a -> b) -> a -> b
$ HumState
s HumState -> (HumState -> HumState) -> HumState
forall a b. a -> (a -> b) -> b
& (PlaylistsState -> Identity PlaylistsState)
-> HumState -> Identity HumState
Lens' HumState PlaylistsState
playlistsL ((PlaylistsState -> Identity PlaylistsState)
-> HumState -> Identity HumState)
-> ((GenericList Name Vector (Song, Bool)
-> Identity (GenericList Name Vector (Song, Bool)))
-> PlaylistsState -> Identity PlaylistsState)
-> (GenericList Name Vector (Song, Bool)
-> Identity (GenericList Name Vector (Song, Bool)))
-> HumState
-> Identity HumState
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (GenericList Name Vector (Song, Bool)
-> Identity (GenericList Name Vector (Song, Bool)))
-> PlaylistsState -> Identity PlaylistsState
Lens' PlaylistsState (GenericList Name Vector (Song, Bool))
plSongsL ((GenericList Name Vector (Song, Bool)
-> Identity (GenericList Name Vector (Song, Bool)))
-> HumState -> Identity HumState)
-> (GenericList Name Vector (Song, Bool)
-> GenericList Name Vector (Song, Bool))
-> HumState
-> HumState
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
%~ GenericList Name Vector (Song, Bool)
-> GenericList Name Vector (Song, Bool)
-> GenericList Name Vector (Song, Bool)
forall (t :: * -> *) e n.
(Splittable t, Semigroup (t e)) =>
GenericList n t e -> GenericList n t e -> GenericList n t e
listPaste (HumState
sHumState
-> Getting
(GenericList Name Vector (Song, Bool))
HumState
(GenericList Name Vector (Song, Bool))
-> GenericList Name Vector (Song, Bool)
forall s a. s -> Getting a s a -> a
^. (Clipboard
-> Const (GenericList Name Vector (Song, Bool)) Clipboard)
-> HumState
-> Const (GenericList Name Vector (Song, Bool)) HumState
Lens' HumState Clipboard
clipboardL((Clipboard
-> Const (GenericList Name Vector (Song, Bool)) Clipboard)
-> HumState
-> Const (GenericList Name Vector (Song, Bool)) HumState)
-> ((GenericList Name Vector (Song, Bool)
-> Const
(GenericList Name Vector (Song, Bool))
(GenericList Name Vector (Song, Bool)))
-> Clipboard
-> Const (GenericList Name Vector (Song, Bool)) Clipboard)
-> Getting
(GenericList Name Vector (Song, Bool))
HumState
(GenericList Name Vector (Song, Bool))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (GenericList Name Vector (Song, Bool)
-> Const
(GenericList Name Vector (Song, Bool))
(GenericList Name Vector (Song, Bool)))
-> Clipboard
-> Const (GenericList Name Vector (Song, Bool)) Clipboard
Lens' Clipboard (GenericList Name Vector (Song, Bool))
clSongsL)
| HumState
s HumState -> Getting FocPlay HumState FocPlay -> FocPlay
forall s a. s -> Getting a s a -> a
^. (Focus -> Const FocPlay Focus)
-> HumState -> Const FocPlay HumState
Lens' HumState Focus
focusL ((Focus -> Const FocPlay Focus)
-> HumState -> Const FocPlay HumState)
-> ((FocPlay -> Const FocPlay FocPlay)
-> Focus -> Const FocPlay Focus)
-> Getting FocPlay HumState FocPlay
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (FocPlay -> Const FocPlay FocPlay) -> Focus -> Const FocPlay Focus
Lens' Focus FocPlay
focPlayL FocPlay -> FocPlay -> Bool
forall a. Eq a => a -> a -> Bool
== FocPlay
FocPlaylists
-> HumState -> EventM Name (Next HumState)
forall s n. s -> EventM n (Next s)
continue (HumState -> EventM Name (Next HumState))
-> EventM Name HumState -> EventM Name (Next HumState)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< HumState -> EventM Name HumState
forall n. HumState -> EventM n HumState
pastePlaylist HumState
s
| Bool
otherwise -> HumState -> EventM Name (Next HumState)
forall s n. s -> EventM n (Next s)
continue HumState
s
EvKey (KChar Char
'G') [] -> HumState -> EventM Name (Next HumState)
forall s n. s -> EventM n (Next s)
continue (HumState -> EventM Name (Next HumState))
-> EventM Name HumState -> EventM Name (Next HumState)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< (forall e. List Name e -> List Name e)
-> HumState -> EventM Name HumState
playlistsMove (Int -> GenericList Name Vector e -> GenericList Name Vector e
forall (t :: * -> *) n e.
(Foldable t, Splittable t) =>
Int -> GenericList n t e -> GenericList n t e
listMoveTo (-Int
1)) HumState
s
EvKey (KChar Char
'g') [] -> HumState -> EventM Name (Next HumState)
forall s n. s -> EventM n (Next s)
continue (HumState -> EventM Name (Next HumState))
-> EventM Name HumState -> EventM Name (Next HumState)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< (forall e. List Name e -> List Name e)
-> HumState -> EventM Name HumState
playlistsMove (Int -> GenericList Name Vector e -> GenericList Name Vector e
forall (t :: * -> *) n e.
(Foldable t, Splittable t) =>
Int -> GenericList n t e -> GenericList n t e
listMoveTo Int
0) HumState
s
EvKey (KChar Char
'e') [] -> case HumState
s HumState -> Getting FocPlay HumState FocPlay -> FocPlay
forall s a. s -> Getting a s a -> a
^. (Focus -> Const FocPlay Focus)
-> HumState -> Const FocPlay HumState
Lens' HumState Focus
focusL ((Focus -> Const FocPlay Focus)
-> HumState -> Const FocPlay HumState)
-> ((FocPlay -> Const FocPlay FocPlay)
-> Focus -> Const FocPlay Focus)
-> Getting FocPlay HumState FocPlay
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (FocPlay -> Const FocPlay FocPlay) -> Focus -> Const FocPlay Focus
Lens' Focus FocPlay
focPlayL of
FocPlay
FocPlaylists
-> HumState -> EventM Name (Next HumState)
forall s n. s -> EventM n (Next s)
continue (HumState -> EventM Name (Next HumState))
-> HumState -> EventM Name (Next HumState)
forall a b. (a -> b) -> a -> b
$ HumState
s HumState -> (HumState -> HumState) -> HumState
forall a b. a -> (a -> b) -> b
& (Mode -> Identity Mode) -> HumState -> Identity HumState
Lens' HumState Mode
modeL ((Mode -> Identity Mode) -> HumState -> Identity HumState)
-> Mode -> HumState -> HumState
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Mode
PromptMode
HumState -> (HumState -> HumState) -> HumState
forall a b. a -> (a -> b) -> b
& (Prompts -> Identity Prompts) -> HumState -> Identity HumState
Lens' HumState Prompts
promptsL ((Prompts -> Identity Prompts) -> HumState -> Identity HumState)
-> ((PromptType -> Identity PromptType)
-> Prompts -> Identity Prompts)
-> (PromptType -> Identity PromptType)
-> HumState
-> Identity HumState
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (PromptType -> Identity PromptType) -> Prompts -> Identity Prompts
Lens' Prompts PromptType
currentPromptL ((PromptType -> Identity PromptType)
-> HumState -> Identity HumState)
-> PromptType -> HumState -> HumState
forall s t a b. ASetter s t a b -> b -> s -> t
.~ PromptType
TextPrompt
HumState -> (HumState -> HumState) -> HumState
forall a b. a -> (a -> b) -> b
& (Prompts -> Identity Prompts) -> HumState -> Identity HumState
Lens' HumState Prompts
promptsL ((Prompts -> Identity Prompts) -> HumState -> Identity HumState)
-> ((Text -> Identity Text) -> Prompts -> Identity Prompts)
-> (Text -> Identity Text)
-> HumState
-> Identity HumState
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Text -> Identity Text) -> Prompts -> Identity Prompts
Lens' Prompts Text
promptTitleL ((Text -> Identity Text) -> HumState -> Identity HumState)
-> Text -> HumState -> HumState
forall s t a b. ASetter s t a b -> b -> s -> t
.~ (Text
"Rename " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
selectedPl Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
" to:")
HumState -> (HumState -> HumState) -> HumState
forall a b. a -> (a -> b) -> b
& (Prompts -> Identity Prompts) -> HumState -> Identity HumState
Lens' HumState Prompts
promptsL ((Prompts -> Identity Prompts) -> HumState -> Identity HumState)
-> (((Bool -> HumState -> EventM Name HumState)
-> Identity (Bool -> HumState -> EventM Name HumState))
-> Prompts -> Identity Prompts)
-> ((Bool -> HumState -> EventM Name HumState)
-> Identity (Bool -> HumState -> EventM Name HumState))
-> HumState
-> Identity HumState
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((Bool -> HumState -> EventM Name HumState)
-> Identity (Bool -> HumState -> EventM Name HumState))
-> Prompts -> Identity Prompts
Lens' Prompts (Bool -> HumState -> EventM Name HumState)
exitPromptFuncL (((Bool -> HumState -> EventM Name HumState)
-> Identity (Bool -> HumState -> EventM Name HumState))
-> HumState -> Identity HumState)
-> (Bool -> HumState -> EventM Name HumState)
-> HumState
-> HumState
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Text -> Bool -> HumState -> EventM Name HumState
forall n. Text -> Bool -> HumState -> EventM n HumState
renamePl Text
selectedPl
FocPlay
FocPSongs -> if HumState
s HumState -> Getting Bool HumState Bool -> Bool
forall s a. s -> Getting a s a -> a
^. Getting Bool HumState Bool
Lens' HumState Bool
editableL then
HumState -> EventM Name (Next HumState)
forall s n. s -> EventM n (Next s)
continue (HumState -> EventM Name (Next HumState))
-> HumState -> EventM Name (Next HumState)
forall a b. (a -> b) -> a -> b
$ HumState
s HumState -> (HumState -> HumState) -> HumState
forall a b. a -> (a -> b) -> b
& (Bool -> Identity Bool) -> HumState -> Identity HumState
Lens' HumState Bool
editableL ((Bool -> Identity Bool) -> HumState -> Identity HumState)
-> (Bool -> Bool) -> HumState -> HumState
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
%~ Bool -> Bool
not
HumState -> (HumState -> HumState) -> HumState
forall a b. a -> (a -> b) -> b
& (Mode -> Identity Mode) -> HumState -> Identity HumState
Lens' HumState Mode
modeL ((Mode -> Identity Mode) -> HumState -> Identity HumState)
-> Mode -> HumState -> HumState
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Mode
PromptMode
HumState -> (HumState -> HumState) -> HumState
forall a b. a -> (a -> b) -> b
& (Prompts -> Identity Prompts) -> HumState -> Identity HumState
Lens' HumState Prompts
promptsL ((Prompts -> Identity Prompts) -> HumState -> Identity HumState)
-> ((PromptType -> Identity PromptType)
-> Prompts -> Identity Prompts)
-> (PromptType -> Identity PromptType)
-> HumState
-> Identity HumState
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (PromptType -> Identity PromptType) -> Prompts -> Identity Prompts
Lens' Prompts PromptType
currentPromptL ((PromptType -> Identity PromptType)
-> HumState -> Identity HumState)
-> PromptType -> HumState -> HumState
forall s t a b. ASetter s t a b -> b -> s -> t
.~ PromptType
YNPrompt
HumState -> (HumState -> HumState) -> HumState
forall a b. a -> (a -> b) -> b
& (Prompts -> Identity Prompts) -> HumState -> Identity HumState
Lens' HumState Prompts
promptsL ((Prompts -> Identity Prompts) -> HumState -> Identity HumState)
-> ((Text -> Identity Text) -> Prompts -> Identity Prompts)
-> (Text -> Identity Text)
-> HumState
-> Identity HumState
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Text -> Identity Text) -> Prompts -> Identity Prompts
Lens' Prompts Text
promptTitleL ((Text -> Identity Text) -> HumState -> Identity HumState)
-> Text -> HumState -> HumState
forall s t a b. ASetter s t a b -> b -> s -> t
.~ (Text
"Save changes to " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
selectedPl Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"?")
HumState -> (HumState -> HumState) -> HumState
forall a b. a -> (a -> b) -> b
& (Prompts -> Identity Prompts) -> HumState -> Identity HumState
Lens' HumState Prompts
promptsL ((Prompts -> Identity Prompts) -> HumState -> Identity HumState)
-> (((Bool -> HumState -> EventM Name HumState)
-> Identity (Bool -> HumState -> EventM Name HumState))
-> Prompts -> Identity Prompts)
-> ((Bool -> HumState -> EventM Name HumState)
-> Identity (Bool -> HumState -> EventM Name HumState))
-> HumState
-> Identity HumState
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((Bool -> HumState -> EventM Name HumState)
-> Identity (Bool -> HumState -> EventM Name HumState))
-> Prompts -> Identity Prompts
Lens' Prompts (Bool -> HumState -> EventM Name HumState)
exitPromptFuncL (((Bool -> HumState -> EventM Name HumState)
-> Identity (Bool -> HumState -> EventM Name HumState))
-> HumState -> Identity HumState)
-> (Bool -> HumState -> EventM Name HumState)
-> HumState
-> HumState
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Bool -> HumState -> EventM Name HumState
forall n. Bool -> HumState -> EventM n HumState
saveEditedPl
else HumState -> EventM Name (Next HumState)
forall s n. s -> EventM n (Next s)
continue (HumState -> EventM Name (Next HumState))
-> EventM Name HumState -> EventM Name (Next HumState)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< HumState -> EventM Name HumState
forall (m :: * -> *). MonadIO m => HumState -> m HumState
reloadPlList (HumState
s HumState -> (HumState -> HumState) -> HumState
forall a b. a -> (a -> b) -> b
& (Bool -> Identity Bool) -> HumState -> Identity HumState
Lens' HumState Bool
editableL ((Bool -> Identity Bool) -> HumState -> Identity HumState)
-> (Bool -> Bool) -> HumState -> HumState
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
%~ Bool -> Bool
not)
Event
_ -> HumState -> EventM Name (Next HumState)
forall s n. s -> EventM n (Next s)
continue HumState
s
BrickEvent Name HumEvent
_ -> HumState -> EventM Name (Next HumState)
forall s n. s -> EventM n (Next s)
continue HumState
s
where selectedPl :: Text
selectedPl = HumState
s HumState
-> Getting
(GenericList Name Vector PlaylistName)
HumState
(GenericList Name Vector PlaylistName)
-> GenericList Name Vector PlaylistName
forall s a. s -> Getting a s a -> a
^. (PlaylistsState
-> Const (GenericList Name Vector PlaylistName) PlaylistsState)
-> HumState
-> Const (GenericList Name Vector PlaylistName) HumState
Lens' HumState PlaylistsState
playlistsL ((PlaylistsState
-> Const (GenericList Name Vector PlaylistName) PlaylistsState)
-> HumState
-> Const (GenericList Name Vector PlaylistName) HumState)
-> ((GenericList Name Vector PlaylistName
-> Const
(GenericList Name Vector PlaylistName)
(GenericList Name Vector PlaylistName))
-> PlaylistsState
-> Const (GenericList Name Vector PlaylistName) PlaylistsState)
-> Getting
(GenericList Name Vector PlaylistName)
HumState
(GenericList Name Vector PlaylistName)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (GenericList Name Vector PlaylistName
-> Const
(GenericList Name Vector PlaylistName)
(GenericList Name Vector PlaylistName))
-> PlaylistsState
-> Const (GenericList Name Vector PlaylistName) PlaylistsState
Lens' PlaylistsState (GenericList Name Vector PlaylistName)
plListL GenericList Name Vector PlaylistName
-> (GenericList Name Vector PlaylistName -> Text) -> Text
forall a b. a -> (a -> b) -> b
& GenericList Name Vector PlaylistName -> Maybe (Int, PlaylistName)
forall (t :: * -> *) n e.
(Splittable t, Foldable t) =>
GenericList n t e -> Maybe (Int, e)
listSelectedElement (GenericList Name Vector PlaylistName -> Maybe (Int, PlaylistName))
-> (Maybe (Int, PlaylistName) -> PlaylistName)
-> GenericList Name Vector PlaylistName
-> PlaylistName
forall a b c. (a -> b) -> (b -> c) -> a -> c
? PlaylistName
-> ((Int, PlaylistName) -> PlaylistName)
-> Maybe (Int, PlaylistName)
-> PlaylistName
forall b a. b -> (a -> b) -> Maybe a -> b
maybe PlaylistName
"<error>" (Int, PlaylistName) -> PlaylistName
forall a b. (a, b) -> b
snd (GenericList Name Vector PlaylistName -> PlaylistName)
-> (PlaylistName -> Text)
-> GenericList Name Vector PlaylistName
-> Text
forall a b c. (a -> b) -> (b -> c) -> a -> c
? PlaylistName -> Text
forall a. ToString a => a -> Text
MPD.toText