{-# LANGUAGE PatternGuards #-}
{-# LANGUAGE DeriveFunctor #-}
module XMonad.StackSet (
StackSet(..), Workspace(..), Screen(..), Stack(..), RationalRect(..),
new, view, greedyView,
lookupWorkspace,
screens, workspaces, allWindows, currentTag,
peek, index, integrate, integrate', differentiate,
focusUp, focusDown, focusUp', focusDown', focusMaster, focusWindow,
tagMember, renameTag, ensureTags, member, findTag, mapWorkspace, mapLayout,
insertUp, delete, delete', filter,
swapUp, swapDown, swapMaster, shiftMaster, modify, modify', float, sink,
shift, shiftWin,
abort
) where
import Prelude hiding (filter)
import Control.Applicative.Backwards (Backwards (Backwards, forwards))
import Data.Foldable (foldr, toList)
import Data.Maybe (listToMaybe,isJust,fromMaybe)
import qualified Data.List as L (deleteBy,find,splitAt,filter,nub)
import Data.List ( (\\) )
import qualified Data.List.NonEmpty as NE
import Data.List.NonEmpty (NonEmpty((:|)))
import qualified Data.Map as M (Map,insert,delete,empty)
data StackSet i l a sid sd =
StackSet { forall i l a sid sd. StackSet i l a sid sd -> Screen i l a sid sd
current :: !(Screen i l a sid sd)
, forall i l a sid sd. StackSet i l a sid sd -> [Screen i l a sid sd]
visible :: [Screen i l a sid sd]
, forall i l a sid sd. StackSet i l a sid sd -> [Workspace i l a]
hidden :: [Workspace i l a]
, forall i l a sid sd. StackSet i l a sid sd -> Map a RationalRect
floating :: M.Map a RationalRect
} deriving (Int -> StackSet i l a sid sd -> ShowS
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall i l a sid sd.
(Show i, Show l, Show sid, Show sd, Show a) =>
Int -> StackSet i l a sid sd -> ShowS
forall i l a sid sd.
(Show i, Show l, Show sid, Show sd, Show a) =>
[StackSet i l a sid sd] -> ShowS
forall i l a sid sd.
(Show i, Show l, Show sid, Show sd, Show a) =>
StackSet i l a sid sd -> String
showList :: [StackSet i l a sid sd] -> ShowS
$cshowList :: forall i l a sid sd.
(Show i, Show l, Show sid, Show sd, Show a) =>
[StackSet i l a sid sd] -> ShowS
show :: StackSet i l a sid sd -> String
$cshow :: forall i l a sid sd.
(Show i, Show l, Show sid, Show sd, Show a) =>
StackSet i l a sid sd -> String
showsPrec :: Int -> StackSet i l a sid sd -> ShowS
$cshowsPrec :: forall i l a sid sd.
(Show i, Show l, Show sid, Show sd, Show a) =>
Int -> StackSet i l a sid sd -> ShowS
Show, ReadPrec [StackSet i l a sid sd]
ReadPrec (StackSet i l a sid sd)
ReadS [StackSet i l a sid sd]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
forall i l a sid sd.
(Read i, Read l, Read sid, Read sd, Read a, Ord a) =>
ReadPrec [StackSet i l a sid sd]
forall i l a sid sd.
(Read i, Read l, Read sid, Read sd, Read a, Ord a) =>
ReadPrec (StackSet i l a sid sd)
forall i l a sid sd.
(Read i, Read l, Read sid, Read sd, Read a, Ord a) =>
Int -> ReadS (StackSet i l a sid sd)
forall i l a sid sd.
(Read i, Read l, Read sid, Read sd, Read a, Ord a) =>
ReadS [StackSet i l a sid sd]
readListPrec :: ReadPrec [StackSet i l a sid sd]
$creadListPrec :: forall i l a sid sd.
(Read i, Read l, Read sid, Read sd, Read a, Ord a) =>
ReadPrec [StackSet i l a sid sd]
readPrec :: ReadPrec (StackSet i l a sid sd)
$creadPrec :: forall i l a sid sd.
(Read i, Read l, Read sid, Read sd, Read a, Ord a) =>
ReadPrec (StackSet i l a sid sd)
readList :: ReadS [StackSet i l a sid sd]
$creadList :: forall i l a sid sd.
(Read i, Read l, Read sid, Read sd, Read a, Ord a) =>
ReadS [StackSet i l a sid sd]
readsPrec :: Int -> ReadS (StackSet i l a sid sd)
$creadsPrec :: forall i l a sid sd.
(Read i, Read l, Read sid, Read sd, Read a, Ord a) =>
Int -> ReadS (StackSet i l a sid sd)
Read, StackSet i l a sid sd -> StackSet i l a sid sd -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall i l a sid sd.
(Eq i, Eq l, Eq sid, Eq sd, Eq a) =>
StackSet i l a sid sd -> StackSet i l a sid sd -> Bool
/= :: StackSet i l a sid sd -> StackSet i l a sid sd -> Bool
$c/= :: forall i l a sid sd.
(Eq i, Eq l, Eq sid, Eq sd, Eq a) =>
StackSet i l a sid sd -> StackSet i l a sid sd -> Bool
== :: StackSet i l a sid sd -> StackSet i l a sid sd -> Bool
$c== :: forall i l a sid sd.
(Eq i, Eq l, Eq sid, Eq sd, Eq a) =>
StackSet i l a sid sd -> StackSet i l a sid sd -> Bool
Eq)
data Screen i l a sid sd = Screen { forall i l a sid sd. Screen i l a sid sd -> Workspace i l a
workspace :: !(Workspace i l a)
, forall i l a sid sd. Screen i l a sid sd -> sid
screen :: !sid
, forall i l a sid sd. Screen i l a sid sd -> sd
screenDetail :: !sd }
deriving (Int -> Screen i l a sid sd -> ShowS
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall i l a sid sd.
(Show i, Show l, Show a, Show sid, Show sd) =>
Int -> Screen i l a sid sd -> ShowS
forall i l a sid sd.
(Show i, Show l, Show a, Show sid, Show sd) =>
[Screen i l a sid sd] -> ShowS
forall i l a sid sd.
(Show i, Show l, Show a, Show sid, Show sd) =>
Screen i l a sid sd -> String
showList :: [Screen i l a sid sd] -> ShowS
$cshowList :: forall i l a sid sd.
(Show i, Show l, Show a, Show sid, Show sd) =>
[Screen i l a sid sd] -> ShowS
show :: Screen i l a sid sd -> String
$cshow :: forall i l a sid sd.
(Show i, Show l, Show a, Show sid, Show sd) =>
Screen i l a sid sd -> String
showsPrec :: Int -> Screen i l a sid sd -> ShowS
$cshowsPrec :: forall i l a sid sd.
(Show i, Show l, Show a, Show sid, Show sd) =>
Int -> Screen i l a sid sd -> ShowS
Show, ReadPrec [Screen i l a sid sd]
ReadPrec (Screen i l a sid sd)
ReadS [Screen i l a sid sd]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
forall i l a sid sd.
(Read i, Read l, Read a, Read sid, Read sd) =>
ReadPrec [Screen i l a sid sd]
forall i l a sid sd.
(Read i, Read l, Read a, Read sid, Read sd) =>
ReadPrec (Screen i l a sid sd)
forall i l a sid sd.
(Read i, Read l, Read a, Read sid, Read sd) =>
Int -> ReadS (Screen i l a sid sd)
forall i l a sid sd.
(Read i, Read l, Read a, Read sid, Read sd) =>
ReadS [Screen i l a sid sd]
readListPrec :: ReadPrec [Screen i l a sid sd]
$creadListPrec :: forall i l a sid sd.
(Read i, Read l, Read a, Read sid, Read sd) =>
ReadPrec [Screen i l a sid sd]
readPrec :: ReadPrec (Screen i l a sid sd)
$creadPrec :: forall i l a sid sd.
(Read i, Read l, Read a, Read sid, Read sd) =>
ReadPrec (Screen i l a sid sd)
readList :: ReadS [Screen i l a sid sd]
$creadList :: forall i l a sid sd.
(Read i, Read l, Read a, Read sid, Read sd) =>
ReadS [Screen i l a sid sd]
readsPrec :: Int -> ReadS (Screen i l a sid sd)
$creadsPrec :: forall i l a sid sd.
(Read i, Read l, Read a, Read sid, Read sd) =>
Int -> ReadS (Screen i l a sid sd)
Read, Screen i l a sid sd -> Screen i l a sid sd -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall i l a sid sd.
(Eq i, Eq l, Eq a, Eq sid, Eq sd) =>
Screen i l a sid sd -> Screen i l a sid sd -> Bool
/= :: Screen i l a sid sd -> Screen i l a sid sd -> Bool
$c/= :: forall i l a sid sd.
(Eq i, Eq l, Eq a, Eq sid, Eq sd) =>
Screen i l a sid sd -> Screen i l a sid sd -> Bool
== :: Screen i l a sid sd -> Screen i l a sid sd -> Bool
$c== :: forall i l a sid sd.
(Eq i, Eq l, Eq a, Eq sid, Eq sd) =>
Screen i l a sid sd -> Screen i l a sid sd -> Bool
Eq)
data Workspace i l a = Workspace { forall i l a. Workspace i l a -> i
tag :: !i, forall i l a. Workspace i l a -> l
layout :: l, forall i l a. Workspace i l a -> Maybe (Stack a)
stack :: Maybe (Stack a) }
deriving (Int -> Workspace i l a -> ShowS
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall i l a.
(Show i, Show l, Show a) =>
Int -> Workspace i l a -> ShowS
forall i l a.
(Show i, Show l, Show a) =>
[Workspace i l a] -> ShowS
forall i l a. (Show i, Show l, Show a) => Workspace i l a -> String
showList :: [Workspace i l a] -> ShowS
$cshowList :: forall i l a.
(Show i, Show l, Show a) =>
[Workspace i l a] -> ShowS
show :: Workspace i l a -> String
$cshow :: forall i l a. (Show i, Show l, Show a) => Workspace i l a -> String
showsPrec :: Int -> Workspace i l a -> ShowS
$cshowsPrec :: forall i l a.
(Show i, Show l, Show a) =>
Int -> Workspace i l a -> ShowS
Show, ReadPrec [Workspace i l a]
ReadPrec (Workspace i l a)
ReadS [Workspace i l a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
forall i l a.
(Read i, Read l, Read a) =>
ReadPrec [Workspace i l a]
forall i l a.
(Read i, Read l, Read a) =>
ReadPrec (Workspace i l a)
forall i l a.
(Read i, Read l, Read a) =>
Int -> ReadS (Workspace i l a)
forall i l a. (Read i, Read l, Read a) => ReadS [Workspace i l a]
readListPrec :: ReadPrec [Workspace i l a]
$creadListPrec :: forall i l a.
(Read i, Read l, Read a) =>
ReadPrec [Workspace i l a]
readPrec :: ReadPrec (Workspace i l a)
$creadPrec :: forall i l a.
(Read i, Read l, Read a) =>
ReadPrec (Workspace i l a)
readList :: ReadS [Workspace i l a]
$creadList :: forall i l a. (Read i, Read l, Read a) => ReadS [Workspace i l a]
readsPrec :: Int -> ReadS (Workspace i l a)
$creadsPrec :: forall i l a.
(Read i, Read l, Read a) =>
Int -> ReadS (Workspace i l a)
Read, Workspace i l a -> Workspace i l a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall i l a.
(Eq i, Eq l, Eq a) =>
Workspace i l a -> Workspace i l a -> Bool
/= :: Workspace i l a -> Workspace i l a -> Bool
$c/= :: forall i l a.
(Eq i, Eq l, Eq a) =>
Workspace i l a -> Workspace i l a -> Bool
== :: Workspace i l a -> Workspace i l a -> Bool
$c== :: forall i l a.
(Eq i, Eq l, Eq a) =>
Workspace i l a -> Workspace i l a -> Bool
Eq)
data RationalRect = RationalRect !Rational !Rational !Rational !Rational
deriving (Int -> RationalRect -> ShowS
[RationalRect] -> ShowS
RationalRect -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RationalRect] -> ShowS
$cshowList :: [RationalRect] -> ShowS
show :: RationalRect -> String
$cshow :: RationalRect -> String
showsPrec :: Int -> RationalRect -> ShowS
$cshowsPrec :: Int -> RationalRect -> ShowS
Show, ReadPrec [RationalRect]
ReadPrec RationalRect
Int -> ReadS RationalRect
ReadS [RationalRect]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RationalRect]
$creadListPrec :: ReadPrec [RationalRect]
readPrec :: ReadPrec RationalRect
$creadPrec :: ReadPrec RationalRect
readList :: ReadS [RationalRect]
$creadList :: ReadS [RationalRect]
readsPrec :: Int -> ReadS RationalRect
$creadsPrec :: Int -> ReadS RationalRect
Read, RationalRect -> RationalRect -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RationalRect -> RationalRect -> Bool
$c/= :: RationalRect -> RationalRect -> Bool
== :: RationalRect -> RationalRect -> Bool
$c== :: RationalRect -> RationalRect -> Bool
Eq)
data Stack a = Stack { forall a. Stack a -> a
focus :: !a
, forall a. Stack a -> [a]
up :: [a]
, forall a. Stack a -> [a]
down :: [a] }
deriving (Int -> Stack a -> ShowS
forall a. Show a => Int -> Stack a -> ShowS
forall a. Show a => [Stack a] -> ShowS
forall a. Show a => Stack a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Stack a] -> ShowS
$cshowList :: forall a. Show a => [Stack a] -> ShowS
show :: Stack a -> String
$cshow :: forall a. Show a => Stack a -> String
showsPrec :: Int -> Stack a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> Stack a -> ShowS
Show, ReadPrec [Stack a]
ReadPrec (Stack a)
ReadS [Stack a]
forall a. Read a => ReadPrec [Stack a]
forall a. Read a => ReadPrec (Stack a)
forall a. Read a => Int -> ReadS (Stack a)
forall a. Read a => ReadS [Stack a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Stack a]
$creadListPrec :: forall a. Read a => ReadPrec [Stack a]
readPrec :: ReadPrec (Stack a)
$creadPrec :: forall a. Read a => ReadPrec (Stack a)
readList :: ReadS [Stack a]
$creadList :: forall a. Read a => ReadS [Stack a]
readsPrec :: Int -> ReadS (Stack a)
$creadsPrec :: forall a. Read a => Int -> ReadS (Stack a)
Read, Stack a -> Stack a -> Bool
forall a. Eq a => Stack a -> Stack a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Stack a -> Stack a -> Bool
$c/= :: forall a. Eq a => Stack a -> Stack a -> Bool
== :: Stack a -> Stack a -> Bool
$c== :: forall a. Eq a => Stack a -> Stack a -> Bool
Eq, forall a b. a -> Stack b -> Stack a
forall a b. (a -> b) -> Stack a -> Stack b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: forall a b. a -> Stack b -> Stack a
$c<$ :: forall a b. a -> Stack b -> Stack a
fmap :: forall a b. (a -> b) -> Stack a -> Stack b
$cfmap :: forall a b. (a -> b) -> Stack a -> Stack b
Functor)
instance Foldable Stack where
toList :: forall a. Stack a -> [a]
toList = forall a. Stack a -> [a]
integrate
foldr :: forall a b. (a -> b -> b) -> b -> Stack a -> b
foldr a -> b -> b
f b
z = forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr a -> b -> b
f b
z forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) a. Foldable t => t a -> [a]
toList
instance Traversable Stack where
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Stack a -> f (Stack b)
traverse a -> f b
f Stack a
s =
forall a b c. (a -> b -> c) -> b -> a -> c
flip forall a. a -> [a] -> [a] -> Stack a
Stack
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall {k} (f :: k -> *) (a :: k). Backwards f a -> f a
forwards (forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (forall {k} (f :: k -> *) (a :: k). f a -> Backwards f a
Backwards forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> f b
f) (forall a. Stack a -> [a]
up Stack a
s))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> a -> f b
f (forall a. Stack a -> a
focus Stack a
s)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse a -> f b
f (forall a. Stack a -> [a]
down Stack a
s)
abort :: String -> a
abort :: forall a. String -> a
abort String
x = forall a. HasCallStack => String -> a
error forall a b. (a -> b) -> a -> b
$ String
"xmonad: StackSet: " forall a. [a] -> [a] -> [a]
++ String
x
new :: (Integral s) => l -> [i] -> [sd] -> StackSet i l a s sd
new :: forall s l i sd a.
Integral s =>
l -> [i] -> [sd] -> StackSet i l a s sd
new l
l (i
wid:[i]
wids) (sd
m:[sd]
ms) | forall (t :: * -> *) a. Foldable t => t a -> Int
length [sd]
ms forall a. Ord a => a -> a -> Bool
<= forall (t :: * -> *) a. Foldable t => t a -> Int
length [i]
wids
= forall i l a sid sd.
Screen i l a sid sd
-> [Screen i l a sid sd]
-> [Workspace i l a]
-> Map a RationalRect
-> StackSet i l a sid sd
StackSet forall {a}. Screen i l a s sd
cur forall {a}. [Screen i l a s sd]
visi (forall a b. (a -> b) -> [a] -> [b]
map forall {i} {a}. i -> Workspace i l a
ws [i]
unseen) forall k a. Map k a
M.empty
where ws :: i -> Workspace i l a
ws i
i = forall i l a. i -> l -> Maybe (Stack a) -> Workspace i l a
Workspace i
i l
l forall a. Maybe a
Nothing
([i]
seen, [i]
unseen) = forall a. Int -> [a] -> ([a], [a])
L.splitAt (forall (t :: * -> *) a. Foldable t => t a -> Int
length [sd]
ms) [i]
wids
Screen i l a s sd
cur:[Screen i l a s sd]
visi = forall i l a sid sd.
Workspace i l a -> sid -> sd -> Screen i l a sid sd
Screen (forall {i} {a}. i -> Workspace i l a
ws i
wid) s
0 sd
m forall a. a -> [a] -> [a]
: [ forall i l a sid sd.
Workspace i l a -> sid -> sd -> Screen i l a sid sd
Screen (forall {i} {a}. i -> Workspace i l a
ws i
i) s
s sd
sd | (i
i, s
s, sd
sd) <- forall a b c. [a] -> [b] -> [c] -> [(a, b, c)]
zip3 [i]
seen [s
1..] [sd]
ms ]
new l
_ [i]
_ [sd]
_ = forall a. String -> a
abort String
"non-positive argument to StackSet.new"
view :: (Eq s, Eq i) => i -> StackSet i l a s sd -> StackSet i l a s sd
view :: forall s i l a sd.
(Eq s, Eq i) =>
i -> StackSet i l a s sd -> StackSet i l a s sd
view i
i StackSet i l a s sd
s
| i
i forall a. Eq a => a -> a -> Bool
== forall i l a s sd. StackSet i l a s sd -> i
currentTag StackSet i l a s sd
s = StackSet i l a s sd
s
| Just Screen i l a s sd
x <- forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Maybe a
L.find ((i
iforall a. Eq a => a -> a -> Bool
==)forall b c a. (b -> c) -> (a -> b) -> a -> c
.forall i l a. Workspace i l a -> i
tagforall b c a. (b -> c) -> (a -> b) -> a -> c
.forall i l a sid sd. Screen i l a sid sd -> Workspace i l a
workspace) (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)
= StackSet i l a s sd
s { current :: Screen i l a s sd
current = Screen i l a s sd
x, visible :: [Screen i l a s sd]
visible = 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
s forall a. a -> [a] -> [a]
: forall a. (a -> a -> Bool) -> a -> [a] -> [a]
L.deleteBy (forall {a} {t}. Eq a => (t -> a) -> t -> t -> Bool
equating forall i l a sid sd. Screen i l a sid sd -> sid
screen) Screen i l a s sd
x (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) }
| Just Workspace i l a
x <- forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Maybe a
L.find ((i
iforall a. Eq a => a -> a -> Bool
==)forall b c a. (b -> c) -> (a -> b) -> a -> c
.forall i l a. Workspace i l a -> i
tag) (forall i l a sid sd. StackSet i l a sid sd -> [Workspace i l a]
hidden StackSet i l a s sd
s)
= StackSet i l a s sd
s { current :: Screen i l a s sd
current = (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
s) { workspace :: Workspace i l a
workspace = Workspace i l a
x }
, hidden :: [Workspace i l a]
hidden = forall i l a sid sd. Screen i l a sid sd -> Workspace i l a
workspace (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
s) forall a. a -> [a] -> [a]
: forall a. (a -> a -> Bool) -> a -> [a] -> [a]
L.deleteBy (forall {a} {t}. Eq a => (t -> a) -> t -> t -> Bool
equating forall i l a. Workspace i l a -> i
tag) Workspace i l a
x (forall i l a sid sd. StackSet i l a sid sd -> [Workspace i l a]
hidden StackSet i l a s sd
s) }
| Bool
otherwise = StackSet i l a s sd
s
where equating :: (t -> a) -> t -> t -> Bool
equating t -> a
f t
x t
y = t -> a
f t
x forall a. Eq a => a -> a -> Bool
== t -> a
f t
y
greedyView :: (Eq s, Eq i) => i -> StackSet i l a s sd -> StackSet i l a s sd
greedyView :: forall s i l a sd.
(Eq s, Eq i) =>
i -> StackSet i l a s sd -> StackSet i l a s sd
greedyView i
w StackSet i l a s sd
ws
| forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any forall {l} {a}. Workspace i l a -> Bool
wTag (forall i l a sid sd. StackSet i l a sid sd -> [Workspace i l a]
hidden StackSet i l a s sd
ws) = forall s i l a sd.
(Eq s, Eq i) =>
i -> StackSet i l a s sd -> StackSet i l a s sd
view i
w StackSet i l a s sd
ws
| (Just Screen i l a s sd
s) <- forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Maybe a
L.find (forall {l} {a}. Workspace i l a -> Bool
wTag forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall i l a sid sd. Screen i l a sid sd -> Workspace i l a
workspace) (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
ws)
= StackSet i l a s sd
ws { current :: Screen i l a s sd
current = (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
ws) { workspace :: Workspace i l a
workspace = forall i l a sid sd. Screen i l a sid sd -> Workspace i l a
workspace Screen i l a s sd
s }
, visible :: [Screen i l a s sd]
visible = Screen i l a s sd
s { workspace :: Workspace i l a
workspace = forall i l a sid sd. Screen i l a sid sd -> Workspace i l a
workspace (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
ws) }
forall a. a -> [a] -> [a]
: forall a. (a -> Bool) -> [a] -> [a]
L.filter (Bool -> Bool
not forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall {l} {a}. Workspace i l a -> Bool
wTag forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall i l a sid sd. Screen i l a sid sd -> Workspace i l a
workspace) (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
ws) }
| Bool
otherwise = StackSet i l a s sd
ws
where wTag :: Workspace i l a -> Bool
wTag = (i
w forall a. Eq a => a -> a -> Bool
== ) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall i l a. Workspace i l a -> i
tag
lookupWorkspace :: Eq s => s -> StackSet i l a s sd -> Maybe i
lookupWorkspace :: forall s i l a sd. Eq s => s -> StackSet i l a s sd -> Maybe i
lookupWorkspace s
sc StackSet i l a s sd
w = forall a. [a] -> Maybe a
listToMaybe [ forall i l a. Workspace i l a -> i
tag Workspace i l a
i | Screen Workspace i l a
i s
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
w forall a. a -> [a] -> [a]
: 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
w, s
s forall a. Eq a => a -> a -> Bool
== s
sc ]
with :: b -> (Stack a -> b) -> StackSet i l a s sd -> b
with :: forall b a i l s sd.
b -> (Stack a -> b) -> StackSet i l a s sd -> b
with b
dflt Stack a -> b
f = forall b a. b -> (a -> b) -> Maybe a -> b
maybe b
dflt Stack a -> b
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall i l a. Workspace i l a -> Maybe (Stack a)
stack forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall i l a sid sd. Screen i l a sid sd -> Workspace i l a
workspace forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall i l a sid sd. StackSet i l a sid sd -> Screen i l a sid sd
current
modify :: Maybe (Stack a) -> (Stack a -> Maybe (Stack a)) -> StackSet i l a s sd -> StackSet i l a s sd
modify :: forall a i l s sd.
Maybe (Stack a)
-> (Stack a -> Maybe (Stack a))
-> StackSet i l a s sd
-> StackSet i l a s sd
modify Maybe (Stack a)
d Stack a -> Maybe (Stack a)
f StackSet i l a s sd
s = StackSet i l a s sd
s { current :: Screen i l a s sd
current = (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
s)
{ workspace :: Workspace i l a
workspace = (forall i l a sid sd. Screen i l a sid sd -> Workspace i l a
workspace (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
s)) { stack :: Maybe (Stack a)
stack = forall b a i l s sd.
b -> (Stack a -> b) -> StackSet i l a s sd -> b
with Maybe (Stack a)
d Stack a -> Maybe (Stack a)
f StackSet i l a s sd
s }}}
modify' :: (Stack a -> Stack a) -> StackSet i l a s sd -> StackSet i l a s sd
modify' :: forall a i l s sd.
(Stack a -> Stack a) -> StackSet i l a s sd -> StackSet i l a s sd
modify' Stack a -> Stack a
f = forall a i l s sd.
Maybe (Stack a)
-> (Stack a -> Maybe (Stack a))
-> StackSet i l a s sd
-> StackSet i l a s sd
modify forall a. Maybe a
Nothing (forall a. a -> Maybe a
Just forall b c a. (b -> c) -> (a -> b) -> a -> c
. Stack a -> Stack a
f)
peek :: StackSet i l a s sd -> Maybe a
peek :: forall i l a s sd. StackSet i l a s sd -> Maybe a
peek = forall b a i l s sd.
b -> (Stack a -> b) -> StackSet i l a s sd -> b
with forall a. Maybe a
Nothing (forall (m :: * -> *) a. Monad m => a -> m a
return forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Stack a -> a
focus)
integrate :: Stack a -> [a]
integrate :: forall a. Stack a -> [a]
integrate (Stack a
x [a]
l [a]
r) = forall a. [a] -> [a]
reverse [a]
l forall a. [a] -> [a] -> [a]
++ a
x forall a. a -> [a] -> [a]
: [a]
r
integrate' :: Maybe (Stack a) -> [a]
integrate' :: forall a. Maybe (Stack a) -> [a]
integrate' = forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] forall a. Stack a -> [a]
integrate
differentiate :: [a] -> Maybe (Stack a)
differentiate :: forall a. [a] -> Maybe (Stack a)
differentiate [] = forall a. Maybe a
Nothing
differentiate (a
x:[a]
xs) = forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ forall a. a -> [a] -> [a] -> Stack a
Stack a
x [] [a]
xs
filter :: (a -> Bool) -> Stack a -> Maybe (Stack a)
filter :: forall a. (a -> Bool) -> Stack a -> Maybe (Stack a)
filter a -> Bool
p (Stack a
f [a]
ls [a]
rs) = case forall a. (a -> Bool) -> [a] -> [a]
L.filter a -> Bool
p (a
fforall a. a -> [a] -> [a]
:[a]
rs) of
a
f':[a]
rs' -> forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ forall a. a -> [a] -> [a] -> Stack a
Stack a
f' (forall a. (a -> Bool) -> [a] -> [a]
L.filter a -> Bool
p [a]
ls) [a]
rs'
[] -> case forall a. (a -> Bool) -> [a] -> [a]
L.filter a -> Bool
p [a]
ls of
a
f':[a]
ls' -> forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ forall a. a -> [a] -> [a] -> Stack a
Stack a
f' [a]
ls' []
[] -> forall a. Maybe a
Nothing
index :: StackSet i l a s sd -> [a]
index :: forall i l a s sd. StackSet i l a s sd -> [a]
index = forall b a i l s sd.
b -> (Stack a -> b) -> StackSet i l a s sd -> b
with [] forall a. Stack a -> [a]
integrate
focusUp :: StackSet i l a s sd -> StackSet i l a s sd
focusUp :: forall i l a s sd. StackSet i l a s sd -> StackSet i l a s sd
focusUp = forall a i l s sd.
(Stack a -> Stack a) -> StackSet i l a s sd -> StackSet i l a s sd
modify' forall a. Stack a -> Stack a
focusUp'
focusDown :: StackSet i l a s sd -> StackSet i l a s sd
focusDown :: forall i l a s sd. StackSet i l a s sd -> StackSet i l a s sd
focusDown = forall a i l s sd.
(Stack a -> Stack a) -> StackSet i l a s sd -> StackSet i l a s sd
modify' forall a. Stack a -> Stack a
focusDown'
swapUp :: StackSet i l a s sd -> StackSet i l a s sd
swapUp :: forall i l a s sd. StackSet i l a s sd -> StackSet i l a s sd
swapUp = forall a i l s sd.
(Stack a -> Stack a) -> StackSet i l a s sd -> StackSet i l a s sd
modify' forall a. Stack a -> Stack a
swapUp'
swapDown :: StackSet i l a s sd -> StackSet i l a s sd
swapDown :: forall i l a s sd. StackSet i l a s sd -> StackSet i l a s sd
swapDown = forall a i l s sd.
(Stack a -> Stack a) -> StackSet i l a s sd -> StackSet i l a s sd
modify' (forall a. Stack a -> Stack a
reverseStack forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Stack a -> Stack a
swapUp' forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Stack a -> Stack a
reverseStack)
focusUp' :: Stack a -> Stack a
focusUp' :: forall a. Stack a -> Stack a
focusUp' (Stack a
t (a
l:[a]
ls) [a]
rs) = forall a. a -> [a] -> [a] -> Stack a
Stack a
l [a]
ls (a
tforall a. a -> [a] -> [a]
:[a]
rs)
focusUp' (Stack a
t [] [a]
rs) = forall a. a -> [a] -> [a] -> Stack a
Stack a
x [a]
xs []
where (a
x :| [a]
xs) = forall a. NonEmpty a -> NonEmpty a
NE.reverse (a
t forall a. a -> [a] -> NonEmpty a
:| [a]
rs)
focusDown' :: Stack a -> Stack a
focusDown' :: forall a. Stack a -> Stack a
focusDown' = forall a. Stack a -> Stack a
reverseStack forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Stack a -> Stack a
focusUp' forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Stack a -> Stack a
reverseStack
swapUp' :: Stack a -> Stack a
swapUp' :: forall a. Stack a -> Stack a
swapUp' (Stack a
t (a
l:[a]
ls) [a]
rs) = forall a. a -> [a] -> [a] -> Stack a
Stack a
t [a]
ls (a
lforall a. a -> [a] -> [a]
:[a]
rs)
swapUp' (Stack a
t [] [a]
rs) = forall a. a -> [a] -> [a] -> Stack a
Stack a
t (forall a. [a] -> [a]
reverse [a]
rs) []
reverseStack :: Stack a -> Stack a
reverseStack :: forall a. Stack a -> Stack a
reverseStack (Stack a
t [a]
ls [a]
rs) = forall a. a -> [a] -> [a] -> Stack a
Stack a
t [a]
rs [a]
ls
focusWindow :: (Eq s, Eq a, Eq i) => a -> StackSet i l a s sd -> StackSet i l a s sd
focusWindow :: 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 a
w StackSet i l a s sd
s | forall a. a -> Maybe a
Just a
w forall a. Eq a => a -> a -> Bool
== forall i l a s sd. StackSet i l a s sd -> Maybe a
peek StackSet i l a s sd
s = StackSet i l a s sd
s
| Bool
otherwise = forall a. a -> Maybe a -> a
fromMaybe StackSet i l a s sd
s forall a b. (a -> b) -> a -> b
$ do
i
n <- forall a i l s sd. Eq a => a -> StackSet i l a s sd -> Maybe i
findTag a
w StackSet i l a s sd
s
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall a. (a -> Bool) -> (a -> a) -> a -> a
until ((forall a. a -> Maybe a
Just a
w forall a. Eq a => a -> a -> Bool
==) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall i l a s sd. StackSet i l a s sd -> Maybe a
peek) forall i l a s sd. StackSet i l a s sd -> StackSet i l a s sd
focusUp (forall s i l a sd.
(Eq s, Eq i) =>
i -> StackSet i l a s sd -> StackSet i l a s sd
view i
n StackSet i l a s sd
s)
screens :: StackSet i l a s sd -> [Screen i l a s sd]
screens :: forall i l a sid sd. StackSet i l a sid sd -> [Screen i l a sid sd]
screens StackSet i l a s sd
s = 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
s forall a. a -> [a] -> [a]
: 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
workspaces :: StackSet i l a s sd -> [Workspace i l a]
workspaces :: forall i l a sid sd. StackSet i l a sid sd -> [Workspace i l a]
workspaces StackSet i l a s sd
s = forall i l a sid sd. Screen i l a sid sd -> Workspace i l a
workspace (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
s) forall a. a -> [a] -> [a]
: forall a b. (a -> b) -> [a] -> [b]
map forall i l a sid sd. Screen i l a sid sd -> Workspace i l a
workspace (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) forall a. [a] -> [a] -> [a]
++ forall i l a sid sd. StackSet i l a sid sd -> [Workspace i l a]
hidden StackSet i l a s sd
s
allWindows :: Eq a => StackSet i l a s sd -> [a]
allWindows :: forall a i l s sd. Eq a => StackSet i l a s sd -> [a]
allWindows = forall a. Eq a => [a] -> [a]
L.nub forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (forall a. Maybe (Stack a) -> [a]
integrate' forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall i l a. Workspace i l a -> Maybe (Stack a)
stack) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall i l a sid sd. StackSet i l a sid sd -> [Workspace i l a]
workspaces
currentTag :: StackSet i l a s sd -> i
currentTag :: forall i l a s sd. StackSet i l a s sd -> i
currentTag = forall i l a. Workspace i l a -> i
tag forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall i l a sid sd. Screen i l a sid sd -> Workspace i l a
workspace forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall i l a sid sd. StackSet i l a sid sd -> Screen i l a sid sd
current
tagMember :: Eq i => i -> StackSet i l a s sd -> Bool
tagMember :: forall i l a s sd. Eq i => i -> StackSet i l a s sd -> Bool
tagMember i
t = forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
elem i
t forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a -> b) -> [a] -> [b]
map forall i l a. Workspace i l a -> i
tag forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall i l a sid sd. StackSet i l a sid sd -> [Workspace i l a]
workspaces
renameTag :: Eq i => i -> i -> StackSet i l a s sd -> StackSet i l a s sd
renameTag :: forall i l a s sd.
Eq i =>
i -> i -> StackSet i l a s sd -> StackSet i l a s sd
renameTag i
o i
n = forall i l a s sd.
(Workspace i l a -> Workspace i l a)
-> StackSet i l a s sd -> StackSet i l a s sd
mapWorkspace forall {l} {a}. Workspace i l a -> Workspace i l a
rename
where rename :: Workspace i l a -> Workspace i l a
rename Workspace i l a
w = if forall i l a. Workspace i l a -> i
tag Workspace i l a
w forall a. Eq a => a -> a -> Bool
== i
o then Workspace i l a
w { tag :: i
tag = i
n } else Workspace i l a
w
ensureTags :: Eq i => l -> [i] -> StackSet i l a s sd -> StackSet i l a s sd
ensureTags :: forall i l a s sd.
Eq i =>
l -> [i] -> StackSet i l a s sd -> StackSet i l a s sd
ensureTags l
l [i]
allt StackSet i l a s sd
st = forall {i} {a} {sid} {sd}.
Eq i =>
[i] -> [i] -> StackSet i l a sid sd -> StackSet i l a sid sd
et [i]
allt (forall a b. (a -> b) -> [a] -> [b]
map forall i l a. Workspace i l a -> i
tag (forall i l a sid sd. StackSet i l a sid sd -> [Workspace i l a]
workspaces StackSet i l a s sd
st) forall a. Eq a => [a] -> [a] -> [a]
\\ [i]
allt) StackSet i l a s sd
st
where et :: [i] -> [i] -> StackSet i l a sid sd -> StackSet i l a sid sd
et [] [i]
_ StackSet i l a sid sd
s = StackSet i l a sid sd
s
et (i
i:[i]
is) [i]
rn StackSet i l a sid sd
s | i
i forall i l a s sd. Eq i => i -> StackSet i l a s sd -> Bool
`tagMember` StackSet i l a sid sd
s = [i] -> [i] -> StackSet i l a sid sd -> StackSet i l a sid sd
et [i]
is [i]
rn StackSet i l a sid sd
s
et (i
i:[i]
is) [] StackSet i l a sid sd
s = [i] -> [i] -> StackSet i l a sid sd -> StackSet i l a sid sd
et [i]
is [] (StackSet i l a sid sd
s { hidden :: [Workspace i l a]
hidden = forall i l a. i -> l -> Maybe (Stack a) -> Workspace i l a
Workspace i
i l
l forall a. Maybe a
Nothing forall a. a -> [a] -> [a]
: forall i l a sid sd. StackSet i l a sid sd -> [Workspace i l a]
hidden StackSet i l a sid sd
s })
et (i
i:[i]
is) (i
r:[i]
rs) StackSet i l a sid sd
s = [i] -> [i] -> StackSet i l a sid sd -> StackSet i l a sid sd
et [i]
is [i]
rs forall a b. (a -> b) -> a -> b
$ forall i l a s sd.
Eq i =>
i -> i -> StackSet i l a s sd -> StackSet i l a s sd
renameTag i
r i
i StackSet i l a sid sd
s
mapWorkspace :: (Workspace i l a -> Workspace i l a) -> StackSet i l a s sd -> StackSet i l a s sd
mapWorkspace :: forall i l a s sd.
(Workspace i l a -> Workspace i l a)
-> StackSet i l a s sd -> StackSet i l a s sd
mapWorkspace Workspace i l a -> Workspace i l a
f StackSet i l a s sd
s = StackSet i l a s sd
s { current :: Screen i l a s sd
current = forall {sid} {sd}. Screen i l a sid sd -> Screen i l a sid sd
updScr (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
s)
, visible :: [Screen i l a s sd]
visible = forall a b. (a -> b) -> [a] -> [b]
map forall {sid} {sd}. Screen i l a sid sd -> Screen i l a sid sd
updScr (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)
, hidden :: [Workspace i l a]
hidden = forall a b. (a -> b) -> [a] -> [b]
map Workspace i l a -> Workspace i l a
f (forall i l a sid sd. StackSet i l a sid sd -> [Workspace i l a]
hidden StackSet i l a s sd
s) }
where updScr :: Screen i l a sid sd -> Screen i l a sid sd
updScr Screen i l a sid sd
scr = Screen i l a sid sd
scr { workspace :: Workspace i l a
workspace = Workspace i l a -> Workspace i l a
f (forall i l a sid sd. Screen i l a sid sd -> Workspace i l a
workspace Screen i l a sid sd
scr) }
mapLayout :: (l -> l') -> StackSet i l a s sd -> StackSet i l' a s sd
mapLayout :: forall l l' i a s sd.
(l -> l') -> StackSet i l a s sd -> StackSet i l' a s sd
mapLayout l -> l'
f (StackSet Screen i l a s sd
v [Screen i l a s sd]
vs [Workspace i l a]
hs Map a RationalRect
m) = forall i l a sid sd.
Screen i l a sid sd
-> [Screen i l a sid sd]
-> [Workspace i l a]
-> Map a RationalRect
-> StackSet i l a sid sd
StackSet (forall {i} {a} {sid} {sd}.
Screen i l a sid sd -> Screen i l' a sid sd
fScreen Screen i l a s sd
v) (forall a b. (a -> b) -> [a] -> [b]
map forall {i} {a} {sid} {sd}.
Screen i l a sid sd -> Screen i l' a sid sd
fScreen [Screen i l a s sd]
vs) (forall a b. (a -> b) -> [a] -> [b]
map forall {i} {a}. Workspace i l a -> Workspace i l' a
fWorkspace [Workspace i l a]
hs) Map a RationalRect
m
where
fScreen :: Screen i l a sid sd -> Screen i l' a sid sd
fScreen (Screen Workspace i l a
ws sid
s sd
sd) = forall i l a sid sd.
Workspace i l a -> sid -> sd -> Screen i l a sid sd
Screen (forall {i} {a}. Workspace i l a -> Workspace i l' a
fWorkspace Workspace i l a
ws) sid
s sd
sd
fWorkspace :: Workspace i l a -> Workspace i l' a
fWorkspace (Workspace i
t l
l Maybe (Stack a)
s) = forall i l a. i -> l -> Maybe (Stack a) -> Workspace i l a
Workspace i
t (l -> l'
f l
l) Maybe (Stack a)
s
member :: Eq a => a -> StackSet i l a s sd -> Bool
member :: forall a i l s sd. Eq a => a -> StackSet i l a s sd -> Bool
member a
a StackSet i l a s sd
s = forall a. Maybe a -> Bool
isJust (forall a i l s sd. Eq a => a -> StackSet i l a s sd -> Maybe i
findTag a
a StackSet i l a s sd
s)
findTag :: Eq a => a -> StackSet i l a s sd -> Maybe i
findTag :: forall a i l s sd. Eq a => a -> StackSet i l a s sd -> Maybe i
findTag a
a StackSet i l a s sd
s = forall a. [a] -> Maybe a
listToMaybe
[ forall i l a. Workspace i l a -> i
tag Workspace i l a
w | Workspace i l a
w <- forall i l a sid sd. StackSet i l a sid sd -> [Workspace i l a]
workspaces StackSet i l a s sd
s, forall {a}. Eq a => a -> Maybe (Stack a) -> Bool
has a
a (forall i l a. Workspace i l a -> Maybe (Stack a)
stack Workspace i l a
w) ]
where has :: a -> Maybe (Stack a) -> Bool
has a
_ Maybe (Stack a)
Nothing = Bool
False
has a
x (Just (Stack a
t [a]
l [a]
r)) = a
x forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` (a
t forall a. a -> [a] -> [a]
: [a]
l forall a. [a] -> [a] -> [a]
++ [a]
r)
insertUp :: Eq a => a -> StackSet i l a s sd -> StackSet i l a s sd
insertUp :: forall a i l s sd.
Eq a =>
a -> StackSet i l a s sd -> StackSet i l a s sd
insertUp a
a StackSet i l a s sd
s = if forall a i l s sd. Eq a => a -> StackSet i l a s sd -> Bool
member a
a StackSet i l a s sd
s then StackSet i l a s sd
s else StackSet i l a s sd
insert
where insert :: StackSet i l a s sd
insert = forall a i l s sd.
Maybe (Stack a)
-> (Stack a -> Maybe (Stack a))
-> StackSet i l a s sd
-> StackSet i l a s sd
modify (forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ forall a. a -> [a] -> [a] -> Stack a
Stack a
a [] []) (\(Stack a
t [a]
l [a]
r) -> forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ forall a. a -> [a] -> [a] -> Stack a
Stack a
a [a]
l (a
tforall a. a -> [a] -> [a]
:[a]
r)) StackSet i l a s sd
s
delete :: (Ord a) => a -> StackSet i l a s sd -> StackSet i l a s sd
delete :: forall a i l s sd.
Ord a =>
a -> StackSet i l a s sd -> StackSet i l a s sd
delete a
w = forall a i l s sd.
Ord a =>
a -> StackSet i l a s sd -> StackSet i l a s sd
sink a
w forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a i l s sd.
Eq a =>
a -> StackSet i l a s sd -> StackSet i l a s sd
delete' a
w
delete' :: (Eq a) => a -> StackSet i l a s sd -> StackSet i l a s sd
delete' :: forall a i l s sd.
Eq a =>
a -> StackSet i l a s sd -> StackSet i l a s sd
delete' a
w StackSet i l a s sd
s = StackSet i l a s sd
s { current :: Screen i l a s sd
current = forall {i} {l} {sid} {sd}.
Screen i l a sid sd -> Screen i l a sid sd
removeFromScreen (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
s)
, visible :: [Screen i l a s sd]
visible = forall a b. (a -> b) -> [a] -> [b]
map forall {i} {l} {sid} {sd}.
Screen i l a sid sd -> Screen i l a sid sd
removeFromScreen (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)
, hidden :: [Workspace i l a]
hidden = forall a b. (a -> b) -> [a] -> [b]
map forall {i} {l}. Workspace i l a -> Workspace i l a
removeFromWorkspace (forall i l a sid sd. StackSet i l a sid sd -> [Workspace i l a]
hidden StackSet i l a s sd
s) }
where removeFromWorkspace :: Workspace i l a -> Workspace i l a
removeFromWorkspace Workspace i l a
ws = Workspace i l a
ws { stack :: Maybe (Stack a)
stack = forall i l a. Workspace i l a -> Maybe (Stack a)
stack Workspace i l a
ws forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= forall a. (a -> Bool) -> Stack a -> Maybe (Stack a)
filter (forall a. Eq a => a -> a -> Bool
/=a
w) }
removeFromScreen :: Screen i l a sid sd -> Screen i l a sid sd
removeFromScreen Screen i l a sid sd
scr = Screen i l a sid sd
scr { workspace :: Workspace i l a
workspace = forall {i} {l}. Workspace i l a -> Workspace i l a
removeFromWorkspace (forall i l a sid sd. Screen i l a sid sd -> Workspace i l a
workspace Screen i l a sid sd
scr) }
float :: Ord a => a -> RationalRect -> StackSet i l a s sd -> StackSet i l a s sd
float :: forall a i l s sd.
Ord a =>
a -> RationalRect -> StackSet i l a s sd -> StackSet i l a s sd
float a
w RationalRect
r StackSet i l a s sd
s = StackSet i l a s sd
s { floating :: Map a RationalRect
floating = forall k a. Ord k => k -> a -> Map k a -> Map k a
M.insert a
w RationalRect
r (forall i l a sid sd. StackSet i l a sid sd -> Map a RationalRect
floating StackSet i l a s sd
s) }
sink :: Ord a => a -> StackSet i l a s sd -> StackSet i l a s sd
sink :: forall a i l s sd.
Ord a =>
a -> StackSet i l a s sd -> StackSet i l a s sd
sink a
w StackSet i l a s sd
s = StackSet i l a s sd
s { floating :: Map a RationalRect
floating = forall k a. Ord k => k -> Map k a -> Map k a
M.delete a
w (forall i l a sid sd. StackSet i l a sid sd -> Map a RationalRect
floating StackSet i l a s sd
s) }
swapMaster :: StackSet i l a s sd -> StackSet i l a s sd
swapMaster :: forall i l a s sd. StackSet i l a s sd -> StackSet i l a s sd
swapMaster = forall a i l s sd.
(Stack a -> Stack a) -> StackSet i l a s sd -> StackSet i l a s sd
modify' forall a b. (a -> b) -> a -> b
$ \Stack a
c -> case Stack a
c of
Stack a
_ [] [a]
_ -> Stack a
c
Stack a
t (a
l:[a]
ls) [a]
rs -> forall a. a -> [a] -> [a] -> Stack a
Stack a
t [] ([a]
xs forall a. [a] -> [a] -> [a]
++ a
x forall a. a -> [a] -> [a]
: [a]
rs) where (a
x :| [a]
xs) = forall a. NonEmpty a -> NonEmpty a
NE.reverse (a
l forall a. a -> [a] -> NonEmpty a
:| [a]
ls)
shiftMaster :: StackSet i l a s sd -> StackSet i l a s sd
shiftMaster :: forall i l a s sd. StackSet i l a s sd -> StackSet i l a s sd
shiftMaster = forall a i l s sd.
(Stack a -> Stack a) -> StackSet i l a s sd -> StackSet i l a s sd
modify' forall a b. (a -> b) -> a -> b
$ \Stack a
c -> case Stack a
c of
Stack a
_ [] [a]
_ -> Stack a
c
Stack a
t [a]
ls [a]
rs -> forall a. a -> [a] -> [a] -> Stack a
Stack a
t [] (forall a. [a] -> [a]
reverse [a]
ls forall a. [a] -> [a] -> [a]
++ [a]
rs)
focusMaster :: StackSet i l a s sd -> StackSet i l a s sd
focusMaster :: forall i l a s sd. StackSet i l a s sd -> StackSet i l a s sd
focusMaster = forall a i l s sd.
(Stack a -> Stack a) -> StackSet i l a s sd -> StackSet i l a s sd
modify' forall a b. (a -> b) -> a -> b
$ \Stack a
c -> case Stack a
c of
Stack a
_ [] [a]
_ -> Stack a
c
Stack a
t (a
l:[a]
ls) [a]
rs -> forall a. a -> [a] -> [a] -> Stack a
Stack a
x [] ([a]
xs forall a. [a] -> [a] -> [a]
++ a
t forall a. a -> [a] -> [a]
: [a]
rs) where (a
x :| [a]
xs) = forall a. NonEmpty a -> NonEmpty a
NE.reverse (a
l forall a. a -> [a] -> NonEmpty a
:| [a]
ls)
shift :: (Ord a, Eq s, Eq i) => i -> StackSet i l a s sd -> StackSet i l a s sd
shift :: forall a s i l sd.
(Ord a, Eq s, Eq i) =>
i -> StackSet i l a s sd -> StackSet i l a s sd
shift i
n StackSet i l a s sd
s = forall b a. b -> (a -> b) -> Maybe a -> b
maybe StackSet i l a s sd
s (\a
w -> 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 i
n a
w StackSet i l a s sd
s) (forall i l a s sd. StackSet i l a s sd -> Maybe a
peek StackSet i l a s sd
s)
shiftWin :: (Ord a, Eq s, Eq i) => i -> a -> StackSet i l a s sd -> StackSet i l a s sd
shiftWin :: 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 i
n a
w StackSet i l a s sd
s = case forall a i l s sd. Eq a => a -> StackSet i l a s sd -> Maybe i
findTag a
w StackSet i l a s sd
s of
Just i
from | i
n forall i l a s sd. Eq i => i -> StackSet i l a s sd -> Bool
`tagMember` StackSet i l a s sd
s Bool -> Bool -> Bool
&& i
n forall a. Eq a => a -> a -> Bool
/= i
from -> forall {s} {l} {sd}.
Eq s =>
i -> StackSet i l a s sd -> StackSet i l a s sd
go i
from StackSet i l a s sd
s
Maybe i
_ -> StackSet i l a s sd
s
where go :: i -> StackSet i l a s sd -> StackSet i l a s sd
go i
from = forall i s l a sd.
(Eq i, Eq s) =>
i
-> (StackSet i l a s sd -> StackSet i l a s sd)
-> StackSet i l a s sd
-> StackSet i l a s sd
onWorkspace i
n (forall a i l s sd.
Eq a =>
a -> StackSet i l a s sd -> StackSet i l a s sd
insertUp a
w) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall i s l a sd.
(Eq i, Eq s) =>
i
-> (StackSet i l a s sd -> StackSet i l a s sd)
-> StackSet i l a s sd
-> StackSet i l a s sd
onWorkspace i
from (forall a i l s sd.
Eq a =>
a -> StackSet i l a s sd -> StackSet i l a s sd
delete' a
w)
onWorkspace :: (Eq i, Eq s) => i -> (StackSet i l a s sd -> StackSet i l a s sd)
-> (StackSet i l a s sd -> StackSet i l a s sd)
onWorkspace :: forall i s l a sd.
(Eq i, Eq s) =>
i
-> (StackSet i l a s sd -> StackSet i l a s sd)
-> StackSet i l a s sd
-> StackSet i l a s sd
onWorkspace i
n StackSet i l a s sd -> StackSet i l a s sd
f StackSet i l a s sd
s = forall s i l a sd.
(Eq s, Eq i) =>
i -> StackSet i l a s sd -> StackSet i l a s sd
view (forall i l a s sd. StackSet i l a s sd -> i
currentTag StackSet i l a s sd
s) forall b c a. (b -> c) -> (a -> b) -> a -> c
. StackSet i l a s sd -> StackSet i l a s sd
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s i l a sd.
(Eq s, Eq i) =>
i -> StackSet i l a s sd -> StackSet i l a s sd
view i
n forall a b. (a -> b) -> a -> b
$ StackSet i l a s sd
s