module XMonad.Actions.TagWindows (
addTag, delTag, unTag,
setTags, getTags, hasTag,
withTaggedP, withTaggedGlobalP, withFocusedP,
withTagged , withTaggedGlobal ,
focusUpTagged, focusUpTaggedGlobal,
focusDownTagged, focusDownTaggedGlobal,
shiftHere, shiftToScreen,
tagPrompt,
tagDelPrompt,
TagPrompt,
) where
import Control.Exception as E
import XMonad hiding (workspaces)
import XMonad.Prelude
import XMonad.Prompt
import XMonad.StackSet hiding (filter)
econst :: Monad m => a -> IOException -> m a
econst :: forall (m :: * -> *) a. Monad m => a -> IOException -> m a
econst = m a -> IOException -> m a
forall a b. a -> b -> a
const (m a -> IOException -> m a)
-> (a -> m a) -> a -> IOException -> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> m a
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return
setTags :: [String] -> Window -> X ()
setTags :: [[Char]] -> Window -> X ()
setTags = [Char] -> Window -> X ()
setTag ([Char] -> Window -> X ())
-> ([[Char]] -> [Char]) -> [[Char]] -> Window -> X ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [[Char]] -> [Char]
unwords
setTag :: String -> Window -> X ()
setTag :: [Char] -> Window -> X ()
setTag [Char]
s Window
w = (Display -> X ()) -> X ()
forall a. (Display -> X a) -> X a
withDisplay ((Display -> X ()) -> X ()) -> (Display -> X ()) -> X ()
forall a b. (a -> b) -> a -> b
$ \Display
d ->
IO () -> X ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
io (IO () -> X ()) -> IO () -> X ()
forall a b. (a -> b) -> a -> b
$ Display -> [Char] -> Bool -> IO Window
internAtom Display
d [Char]
"_XMONAD_TAGS" Bool
False IO Window -> (Window -> IO ()) -> IO ()
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Display -> Window -> [Char] -> Window -> IO ()
setTextProperty Display
d Window
w [Char]
s
getTags :: Window -> X [String]
getTags :: Window -> X [[Char]]
getTags Window
w = (Display -> X [[Char]]) -> X [[Char]]
forall a. (Display -> X a) -> X a
withDisplay ((Display -> X [[Char]]) -> X [[Char]])
-> (Display -> X [[Char]]) -> X [[Char]]
forall a b. (a -> b) -> a -> b
$ \Display
d ->
IO [[Char]] -> X [[Char]]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
io (IO [[Char]] -> X [[Char]]) -> IO [[Char]] -> X [[Char]]
forall a b. (a -> b) -> a -> b
$ IO [[Char]] -> (IOException -> IO [[Char]]) -> IO [[Char]]
forall e a. Exception e => IO a -> (e -> IO a) -> IO a
E.catch (Display -> [Char] -> Bool -> IO Window
internAtom Display
d [Char]
"_XMONAD_TAGS" Bool
False IO Window -> (Window -> IO TextProperty) -> IO TextProperty
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=
Display -> Window -> Window -> IO TextProperty
getTextProperty Display
d Window
w IO TextProperty -> (TextProperty -> IO [[Char]]) -> IO [[Char]]
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=
Display -> TextProperty -> IO [[Char]]
wcTextPropertyToTextList Display
d)
([[Char]] -> IOException -> IO [[Char]]
forall (m :: * -> *) a. Monad m => a -> IOException -> m a
econst [[]]) IO [[Char]] -> ([[Char]] -> [[Char]]) -> IO [[Char]]
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> ([Char] -> [[Char]]
words ([Char] -> [[Char]])
-> ([[Char]] -> [Char]) -> [[Char]] -> [[Char]]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [[Char]] -> [Char]
unwords)
hasTag :: String -> Window -> X Bool
hasTag :: [Char] -> Window -> X Bool
hasTag [Char]
s Window
w = ([Char]
s [Char] -> [[Char]] -> Bool
forall a. Eq a => a -> [a] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem`) ([[Char]] -> Bool) -> X [[Char]] -> X Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Window -> X [[Char]]
getTags Window
w
addTag :: String -> Window -> X ()
addTag :: [Char] -> Window -> X ()
addTag [Char]
s Window
w = do
tags <- Window -> X [[Char]]
getTags Window
w
when (s `notElem` tags) $ setTags (s:tags) w
delTag :: String -> Window -> X ()
delTag :: [Char] -> Window -> X ()
delTag [Char]
s Window
w = do
tags <- Window -> X [[Char]]
getTags Window
w
setTags (filter (/= s) tags) w
unTag :: Window -> X ()
unTag :: Window -> X ()
unTag = [Char] -> Window -> X ()
setTag [Char]
""
focusUpTagged, focusDownTagged, focusUpTaggedGlobal, focusDownTaggedGlobal :: String -> X ()
focusUpTagged :: [Char] -> X ()
focusUpTagged = (WindowSet -> [Window]) -> [Char] -> X ()
focusTagged' ([Window] -> [Window]
forall a. [a] -> [a]
reverse ([Window] -> [Window])
-> (WindowSet -> [Window]) -> WindowSet -> [Window]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WindowSet -> [Window]
forall i l a s sd. Ord i => StackSet i l a s sd -> [a]
wsToList)
focusDownTagged :: [Char] -> X ()
focusDownTagged = (WindowSet -> [Window]) -> [Char] -> X ()
focusTagged' WindowSet -> [Window]
forall i l a s sd. Ord i => StackSet i l a s sd -> [a]
wsToList
focusUpTaggedGlobal :: [Char] -> X ()
focusUpTaggedGlobal = (WindowSet -> [Window]) -> [Char] -> X ()
focusTagged' ([Window] -> [Window]
forall a. [a] -> [a]
reverse ([Window] -> [Window])
-> (WindowSet -> [Window]) -> WindowSet -> [Window]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WindowSet -> [Window]
forall i l a s sd. Ord i => StackSet i l a s sd -> [a]
wsToListGlobal)
focusDownTaggedGlobal :: [Char] -> X ()
focusDownTaggedGlobal = (WindowSet -> [Window]) -> [Char] -> X ()
focusTagged' WindowSet -> [Window]
forall i l a s sd. Ord i => StackSet i l a s sd -> [a]
wsToListGlobal
wsToList :: (Ord i) => StackSet i l a s sd -> [a]
wsToList :: forall i l a s sd. Ord i => StackSet i l a s sd -> [a]
wsToList StackSet i l a s sd
ws = [a]
crs [a] -> [a] -> [a]
forall a. [a] -> [a] -> [a]
++ [a]
cls
where
([a]
crs, [a]
cls) = ((Stack a -> [a]) -> [a]
forall {a}. (Stack a -> [a]) -> [a]
cms Stack a -> [a]
forall a. Stack a -> [a]
down, (Stack a -> [a]) -> [a]
forall {a}. (Stack a -> [a]) -> [a]
cms ([a] -> [a]
forall a. [a] -> [a]
reverse ([a] -> [a]) -> (Stack a -> [a]) -> Stack a -> [a]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Stack a -> [a]
forall a. Stack a -> [a]
up))
cms :: (Stack a -> [a]) -> [a]
cms Stack a -> [a]
f = [a] -> (Stack a -> [a]) -> Maybe (Stack a) -> [a]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] Stack a -> [a]
f (Workspace i l a -> Maybe (Stack a)
forall i l a. Workspace i l a -> Maybe (Stack a)
stack (Workspace i l a -> Maybe (Stack a))
-> (StackSet i l a s sd -> Workspace i l a)
-> StackSet i l a s sd
-> Maybe (Stack a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Screen i l a s sd -> Workspace i l a
forall i l a sid sd. Screen i l a sid sd -> Workspace i l a
workspace (Screen i l a s sd -> Workspace i l a)
-> (StackSet i l a s sd -> Screen i l a s sd)
-> StackSet i l a s sd
-> Workspace i l a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. StackSet i l a s sd -> Screen i l a s sd
forall i l a sid sd. StackSet i l a sid sd -> Screen i l a sid sd
current (StackSet i l a s sd -> Maybe (Stack a))
-> StackSet i l a s sd -> Maybe (Stack a)
forall a b. (a -> b) -> a -> b
$ StackSet i l a s sd
ws)
wsToListGlobal :: (Ord i) => StackSet i l a s sd -> [a]
wsToListGlobal :: forall i l a s sd. Ord i => StackSet i l a s sd -> [a]
wsToListGlobal StackSet i l a s sd
ws = [[a]] -> [a]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat ([[a]
crs] [[a]] -> [[a]] -> [[a]]
forall a. [a] -> [a] -> [a]
++ [[a]]
rws [[a]] -> [[a]] -> [[a]]
forall a. [a] -> [a] -> [a]
++ [[a]]
lws [[a]] -> [[a]] -> [[a]]
forall a. [a] -> [a] -> [a]
++ [[a]
cls])
where
curtag :: i
curtag = StackSet i l a s sd -> i
forall i l a s sd. StackSet i l a s sd -> i
currentTag StackSet i l a s sd
ws
([a]
crs, [a]
cls) = ((Stack a -> [a]) -> [a]
forall {a}. (Stack a -> [a]) -> [a]
cms Stack a -> [a]
forall a. Stack a -> [a]
down, (Stack a -> [a]) -> [a]
forall {a}. (Stack a -> [a]) -> [a]
cms ([a] -> [a]
forall a. [a] -> [a]
reverse ([a] -> [a]) -> (Stack a -> [a]) -> Stack a -> [a]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Stack a -> [a]
forall a. Stack a -> [a]
up))
cms :: (Stack a -> [a]) -> [a]
cms Stack a -> [a]
f = [a] -> (Stack a -> [a]) -> Maybe (Stack a) -> [a]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] Stack a -> [a]
f (Workspace i l a -> Maybe (Stack a)
forall i l a. Workspace i l a -> Maybe (Stack a)
stack (Workspace i l a -> Maybe (Stack a))
-> (StackSet i l a s sd -> Workspace i l a)
-> StackSet i l a s sd
-> Maybe (Stack a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Screen i l a s sd -> Workspace i l a
forall i l a sid sd. Screen i l a sid sd -> Workspace i l a
workspace (Screen i l a s sd -> Workspace i l a)
-> (StackSet i l a s sd -> Screen i l a s sd)
-> StackSet i l a s sd
-> Workspace i l a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. StackSet i l a s sd -> Screen i l a s sd
forall i l a sid sd. StackSet i l a sid sd -> Screen i l a sid sd
current (StackSet i l a s sd -> Maybe (Stack a))
-> StackSet i l a s sd -> Maybe (Stack a)
forall a b. (a -> b) -> a -> b
$ StackSet i l a s sd
ws)
([[a]]
lws, [[a]]
rws) = ((i -> i -> Bool) -> [[a]]
mws i -> i -> Bool
forall a. Ord a => a -> a -> Bool
(<), (i -> i -> Bool) -> [[a]]
mws i -> i -> Bool
forall a. Ord a => a -> a -> Bool
(>))
mws :: (i -> i -> Bool) -> [[a]]
mws i -> i -> Bool
cmp = (Workspace i l a -> [a]) -> [Workspace i l a] -> [[a]]
forall a b. (a -> b) -> [a] -> [b]
map (Maybe (Stack a) -> [a]
forall a. Maybe (Stack a) -> [a]
integrate' (Maybe (Stack a) -> [a])
-> (Workspace i l a -> Maybe (Stack a)) -> Workspace i l a -> [a]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Workspace i l a -> Maybe (Stack a)
forall i l a. Workspace i l a -> Maybe (Stack a)
stack) ([Workspace i l a] -> [[a]])
-> (StackSet i l a s sd -> [Workspace i l a])
-> StackSet i l a s sd
-> [[a]]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Workspace i l a] -> [Workspace i l a]
forall {l} {a}. [Workspace i l a] -> [Workspace i l a]
sortByTag ([Workspace i l a] -> [Workspace i l a])
-> (StackSet i l a s sd -> [Workspace i l a])
-> StackSet i l a s sd
-> [Workspace i l a]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Workspace i l a -> Bool) -> [Workspace i l a] -> [Workspace i l a]
forall a. (a -> Bool) -> [a] -> [a]
filter (\Workspace i l a
w -> Workspace i l a -> i
forall i l a. Workspace i l a -> i
tag Workspace i l a
w i -> i -> Bool
`cmp` i
curtag) ([Workspace i l a] -> [Workspace i l a])
-> (StackSet i l a s sd -> [Workspace i l a])
-> StackSet i l a s sd
-> [Workspace i l a]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. StackSet i l a s sd -> [Workspace i l a]
forall i l a s sd. StackSet i l a s sd -> [Workspace i l a]
workspaces (StackSet i l a s sd -> [[a]]) -> StackSet i l a s sd -> [[a]]
forall a b. (a -> b) -> a -> b
$ StackSet i l a s sd
ws
sortByTag :: [Workspace i l a] -> [Workspace i l a]
sortByTag = (Workspace i l a -> Workspace i l a -> Ordering)
-> [Workspace i l a] -> [Workspace i l a]
forall a. (a -> a -> Ordering) -> [a] -> [a]
sortBy (\Workspace i l a
x Workspace i l a
y -> i -> i -> Ordering
forall a. Ord a => a -> a -> Ordering
compare (Workspace i l a -> i
forall i l a. Workspace i l a -> i
tag Workspace i l a
x) (Workspace i l a -> i
forall i l a. Workspace i l a -> i
tag Workspace i l a
y))
focusTagged' :: (WindowSet -> [Window]) -> String -> X ()
focusTagged' :: (WindowSet -> [Window]) -> [Char] -> X ()
focusTagged' WindowSet -> [Window]
wl [Char]
t = (XState -> WindowSet) -> X WindowSet
forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a
gets XState -> WindowSet
windowset X WindowSet -> (WindowSet -> X (Maybe Window)) -> X (Maybe Window)
forall a b. X a -> (a -> X b) -> X b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (Window -> X Bool) -> [Window] -> X (Maybe Window)
forall (m :: * -> *) a.
Monad m =>
(a -> m Bool) -> [a] -> m (Maybe a)
findM ([Char] -> Window -> X Bool
hasTag [Char]
t) ([Window] -> X (Maybe Window))
-> (WindowSet -> [Window]) -> WindowSet -> X (Maybe Window)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WindowSet -> [Window]
wl X (Maybe Window) -> (Maybe Window -> X ()) -> X ()
forall a b. X a -> (a -> X b) -> X b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=
X () -> (Window -> X ()) -> Maybe Window -> X ()
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (() -> X ()
forall a. a -> X a
forall (m :: * -> *) a. Monad m => a -> m a
return ()) ((WindowSet -> WindowSet) -> X ()
windows ((WindowSet -> WindowSet) -> X ())
-> (Window -> WindowSet -> WindowSet) -> Window -> X ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Window -> WindowSet -> WindowSet
forall s a i l sd.
(Eq s, Eq a, Eq i) =>
a -> StackSet i l a s sd -> StackSet i l a s sd
focusWindow)
withTaggedP, withTaggedGlobalP :: String -> (Window -> WindowSet -> WindowSet) -> X ()
withTaggedP :: [Char] -> (Window -> WindowSet -> WindowSet) -> X ()
withTaggedP [Char]
t Window -> WindowSet -> WindowSet
f = [Char] -> ([Window] -> X ()) -> X ()
withTagged' [Char]
t ((Window -> WindowSet -> WindowSet) -> [Window] -> X ()
winMap Window -> WindowSet -> WindowSet
f)
withTaggedGlobalP :: [Char] -> (Window -> WindowSet -> WindowSet) -> X ()
withTaggedGlobalP [Char]
t Window -> WindowSet -> WindowSet
f = [Char] -> ([Window] -> X ()) -> X ()
withTaggedGlobal' [Char]
t ((Window -> WindowSet -> WindowSet) -> [Window] -> X ()
winMap Window -> WindowSet -> WindowSet
f)
winMap :: (Window -> WindowSet -> WindowSet) -> [Window] -> X ()
winMap :: (Window -> WindowSet -> WindowSet) -> [Window] -> X ()
winMap Window -> WindowSet -> WindowSet
f [Window]
tw = Bool -> X () -> X ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when ([Window]
tw [Window] -> [Window] -> Bool
forall a. Eq a => a -> a -> Bool
/= []) ((WindowSet -> WindowSet) -> X ()
windows ((WindowSet -> WindowSet) -> X ())
-> (WindowSet -> WindowSet) -> X ()
forall a b. (a -> b) -> a -> b
$ ((WindowSet -> WindowSet)
-> (WindowSet -> WindowSet) -> WindowSet -> WindowSet)
-> [WindowSet -> WindowSet] -> WindowSet -> WindowSet
forall a. (a -> a -> a) -> [a] -> a
forall (t :: * -> *) a. Foldable t => (a -> a -> a) -> t a -> a
foldl1 (WindowSet -> WindowSet)
-> (WindowSet -> WindowSet) -> WindowSet -> WindowSet
forall b c a. (b -> c) -> (a -> b) -> a -> c
(.) ((Window -> WindowSet -> WindowSet)
-> [Window] -> [WindowSet -> WindowSet]
forall a b. (a -> b) -> [a] -> [b]
map Window -> WindowSet -> WindowSet
f [Window]
tw))
withTagged, withTaggedGlobal :: String -> (Window -> X ()) -> X ()
withTagged :: [Char] -> (Window -> X ()) -> X ()
withTagged [Char]
t Window -> X ()
f = [Char] -> ([Window] -> X ()) -> X ()
withTagged' [Char]
t ((Window -> X ()) -> [Window] -> X ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ Window -> X ()
f)
withTaggedGlobal :: [Char] -> (Window -> X ()) -> X ()
withTaggedGlobal [Char]
t Window -> X ()
f = [Char] -> ([Window] -> X ()) -> X ()
withTaggedGlobal' [Char]
t ((Window -> X ()) -> [Window] -> X ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ Window -> X ()
f)
withTagged' :: String -> ([Window] -> X ()) -> X ()
withTagged' :: [Char] -> ([Window] -> X ()) -> X ()
withTagged' [Char]
t [Window] -> X ()
m = (XState -> WindowSet) -> X WindowSet
forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a
gets XState -> WindowSet
windowset X WindowSet -> (WindowSet -> X [Window]) -> X [Window]
forall a b. X a -> (a -> X b) -> X b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (Window -> X Bool) -> [Window] -> X [Window]
forall (m :: * -> *) a.
Applicative m =>
(a -> m Bool) -> [a] -> m [a]
filterM ([Char] -> Window -> X Bool
hasTag [Char]
t) ([Window] -> X [Window])
-> (WindowSet -> [Window]) -> WindowSet -> X [Window]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WindowSet -> [Window]
forall i l a s sd. StackSet i l a s sd -> [a]
index X [Window] -> ([Window] -> X ()) -> X ()
forall a b. X a -> (a -> X b) -> X b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= [Window] -> X ()
m
withTaggedGlobal' :: String -> ([Window] -> X ()) -> X ()
withTaggedGlobal' :: [Char] -> ([Window] -> X ()) -> X ()
withTaggedGlobal' [Char]
t [Window] -> X ()
m = (XState -> WindowSet) -> X WindowSet
forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a
gets XState -> WindowSet
windowset X WindowSet -> (WindowSet -> X [Window]) -> X [Window]
forall a b. X a -> (a -> X b) -> X b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=
(Window -> X Bool) -> [Window] -> X [Window]
forall (m :: * -> *) a.
Applicative m =>
(a -> m Bool) -> [a] -> m [a]
filterM ([Char] -> Window -> X Bool
hasTag [Char]
t) ([Window] -> X [Window])
-> (WindowSet -> [Window]) -> WindowSet -> X [Window]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Workspace [Char] (Layout Window) Window -> [Window])
-> [Workspace [Char] (Layout Window) Window] -> [Window]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (Maybe (Stack Window) -> [Window]
forall a. Maybe (Stack a) -> [a]
integrate' (Maybe (Stack Window) -> [Window])
-> (Workspace [Char] (Layout Window) Window
-> Maybe (Stack Window))
-> Workspace [Char] (Layout Window) Window
-> [Window]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Workspace [Char] (Layout Window) Window -> Maybe (Stack Window)
forall i l a. Workspace i l a -> Maybe (Stack a)
stack) ([Workspace [Char] (Layout Window) Window] -> [Window])
-> (WindowSet -> [Workspace [Char] (Layout Window) Window])
-> WindowSet
-> [Window]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WindowSet -> [Workspace [Char] (Layout Window) Window]
forall i l a s sd. StackSet i l a s sd -> [Workspace i l a]
workspaces X [Window] -> ([Window] -> X ()) -> X ()
forall a b. X a -> (a -> X b) -> X b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= [Window] -> X ()
m
withFocusedP :: (Window -> WindowSet -> WindowSet) -> X ()
withFocusedP :: (Window -> WindowSet -> WindowSet) -> X ()
withFocusedP Window -> WindowSet -> WindowSet
f = (Window -> X ()) -> X ()
withFocused ((Window -> X ()) -> X ()) -> (Window -> X ()) -> X ()
forall a b. (a -> b) -> a -> b
$ (WindowSet -> WindowSet) -> X ()
windows ((WindowSet -> WindowSet) -> X ())
-> (Window -> WindowSet -> WindowSet) -> Window -> X ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Window -> WindowSet -> WindowSet
f
shiftHere :: (Ord a, Eq s, Eq i) => a -> StackSet i l a s sd -> StackSet i l a s sd
shiftHere :: forall a s i l sd.
(Ord a, Eq s, Eq i) =>
a -> StackSet i l a s sd -> StackSet i l a s sd
shiftHere a
w StackSet i l a s sd
s = i -> a -> StackSet i l a s sd -> StackSet i l a s sd
forall a s i l sd.
(Ord a, Eq s, Eq i) =>
i -> a -> StackSet i l a s sd -> StackSet i l a s sd
shiftWin (StackSet i l a s sd -> i
forall i l a s sd. StackSet i l a s sd -> i
currentTag StackSet i l a s sd
s) a
w StackSet i l a s sd
s
shiftToScreen :: (Ord a, Eq s, Eq i) => s -> a -> StackSet i l a s sd -> StackSet i l a s sd
shiftToScreen :: forall a s i l sd.
(Ord a, Eq s, Eq i) =>
s -> a -> StackSet i l a s sd -> StackSet i l a s sd
shiftToScreen s
sid a
w StackSet i l a s sd
s = case (Screen i l a s sd -> Bool)
-> [Screen i l a s sd] -> [Screen i l a s sd]
forall a. (a -> Bool) -> [a] -> [a]
filter (\Screen i l a s sd
m -> s
sid s -> s -> Bool
forall a. Eq a => a -> a -> Bool
/= Screen i l a s sd -> s
forall i l a sid sd. Screen i l a sid sd -> sid
screen Screen i l a s sd
m) (StackSet i l a s sd -> Screen i l a s sd
forall i l a sid sd. StackSet i l a sid sd -> Screen i l a sid sd
current StackSet i l a s sd
sScreen i l a s sd -> [Screen i l a s sd] -> [Screen i l a s sd]
forall a. a -> [a] -> [a]
:StackSet i l a s sd -> [Screen i l a s sd]
forall i l a sid sd. StackSet i l a sid sd -> [Screen i l a sid sd]
visible StackSet i l a s sd
s) of
[] -> StackSet i l a s sd
s
(Screen i l a s sd
t:[Screen i l a s sd]
_) -> i -> a -> StackSet i l a s sd -> StackSet i l a s sd
forall a s i l sd.
(Ord a, Eq s, Eq i) =>
i -> a -> StackSet i l a s sd -> StackSet i l a s sd
shiftWin (Workspace i l a -> i
forall i l a. Workspace i l a -> i
tag (Workspace i l a -> i)
-> (Screen i l a s sd -> Workspace i l a) -> Screen i l a s sd -> i
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Screen i l a s sd -> Workspace i l a
forall i l a sid sd. Screen i l a sid sd -> Workspace i l a
workspace (Screen i l a s sd -> i) -> Screen i l a s sd -> i
forall a b. (a -> b) -> a -> b
$ Screen i l a s sd
t) a
w StackSet i l a s sd
s
data TagPrompt = TagPrompt
instance XPrompt TagPrompt where
showXPrompt :: TagPrompt -> [Char]
showXPrompt TagPrompt
TagPrompt = [Char]
"Select Tag: "
tagPrompt :: XPConfig -> (String -> X ()) -> X ()
tagPrompt :: XPConfig -> ([Char] -> X ()) -> X ()
tagPrompt XPConfig
c [Char] -> X ()
f = do
sc <- X [[Char]]
tagComplList
mkXPrompt TagPrompt c (mkComplFunFromList' c sc) f
tagComplList :: X [String]
tagComplList :: X [[Char]]
tagComplList = (XState -> [Window]) -> X [Window]
forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a
gets ((Workspace [Char] (Layout Window) Window -> [Window])
-> [Workspace [Char] (Layout Window) Window] -> [Window]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (Maybe (Stack Window) -> [Window]
forall a. Maybe (Stack a) -> [a]
integrate' (Maybe (Stack Window) -> [Window])
-> (Workspace [Char] (Layout Window) Window
-> Maybe (Stack Window))
-> Workspace [Char] (Layout Window) Window
-> [Window]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Workspace [Char] (Layout Window) Window -> Maybe (Stack Window)
forall i l a. Workspace i l a -> Maybe (Stack a)
stack) ([Workspace [Char] (Layout Window) Window] -> [Window])
-> (XState -> [Workspace [Char] (Layout Window) Window])
-> XState
-> [Window]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WindowSet -> [Workspace [Char] (Layout Window) Window]
forall i l a s sd. StackSet i l a s sd -> [Workspace i l a]
workspaces (WindowSet -> [Workspace [Char] (Layout Window) Window])
-> (XState -> WindowSet)
-> XState
-> [Workspace [Char] (Layout Window) Window]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. XState -> WindowSet
windowset)
X [Window] -> ([Window] -> X [[[Char]]]) -> X [[[Char]]]
forall a b. X a -> (a -> X b) -> X b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (Window -> X [[Char]]) -> [Window] -> X [[[Char]]]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM Window -> X [[Char]]
getTags
X [[[Char]]] -> ([[[Char]]] -> [[Char]]) -> X [[Char]]
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> [[Char]] -> [[Char]]
forall a. Eq a => [a] -> [a]
nub ([[Char]] -> [[Char]])
-> ([[[Char]]] -> [[Char]]) -> [[[Char]]] -> [[Char]]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [[[Char]]] -> [[Char]]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat
tagDelPrompt :: XPConfig -> X ()
tagDelPrompt :: XPConfig -> X ()
tagDelPrompt XPConfig
c = do
sc <- X [[Char]]
tagDelComplList
when (sc /= []) $
mkXPrompt TagPrompt c (mkComplFunFromList' c sc) (withFocused . delTag)
tagDelComplList :: X [String]
tagDelComplList :: X [[Char]]
tagDelComplList = (XState -> WindowSet) -> X WindowSet
forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a
gets XState -> WindowSet
windowset X WindowSet -> (WindowSet -> X [[Char]]) -> X [[Char]]
forall a b. X a -> (a -> X b) -> X b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= X [[Char]] -> (Window -> X [[Char]]) -> Maybe Window -> X [[Char]]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe ([[Char]] -> X [[Char]]
forall a. a -> X a
forall (m :: * -> *) a. Monad m => a -> m a
return []) Window -> X [[Char]]
getTags (Maybe Window -> X [[Char]])
-> (WindowSet -> Maybe Window) -> WindowSet -> X [[Char]]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WindowSet -> Maybe Window
forall i l a s sd. StackSet i l a s sd -> Maybe a
peek