diff --git a/XMonad/Actions/CycleWindows.hs b/XMonad/Actions/CycleWindows.hs index 1d647f21..c26bb965 100644 --- a/XMonad/Actions/CycleWindows.hs +++ b/XMonad/Actions/CycleWindows.hs @@ -50,7 +50,6 @@ module XMonad.Actions.CycleWindows ( -- $pointer -- * Generic list rotations - -- $generic rotUp, rotDown ) where @@ -223,12 +222,3 @@ rotUnfocused' f s@(W.Stack _ [] _ ) = rotSlaves' f s -- Master h rotUnfocused' f (W.Stack t ls rs) = W.Stack t (reverse revls') rs' -- otherwise where (master :| revls) = NE.reverse (let l:ll = ls in l :| ll) (revls',rs') = splitAt (length ls) (f $ master:revls ++ rs) - --- $generic --- Generic list rotations such that @rotUp [1..4]@ is equivalent to --- @[2,3,4,1]@ and @rotDown [1..4]@ to @[4,1,2,3]@. They both are --- @id@ for null or singleton lists. -rotUp :: [a] -> [a] -rotUp l = drop 1 l ++ take 1 l -rotDown :: [a] -> [a] -rotDown = reverse . rotUp . reverse diff --git a/XMonad/Actions/RotSlaves.hs b/XMonad/Actions/RotSlaves.hs index 3fc45803..cceda016 100644 --- a/XMonad/Actions/RotSlaves.hs +++ b/XMonad/Actions/RotSlaves.hs @@ -17,7 +17,11 @@ module XMonad.Actions.RotSlaves ( -- $usage rotSlaves', rotSlavesUp, rotSlavesDown, - rotAll', rotAllUp, rotAllDown + rotAll', rotAllUp, rotAllDown, + + -- * Generic list rotations + -- $generic + rotUp, rotDown ) where import XMonad @@ -44,8 +48,8 @@ import XMonad.Prelude -- | Rotate the windows in the current stack, excluding the first one -- (master). rotSlavesUp,rotSlavesDown :: X () -rotSlavesUp = windows $ modify' (rotSlaves' (\l -> tail l++[head l])) -rotSlavesDown = windows $ modify' (rotSlaves' (\l -> last l : init l)) +rotSlavesUp = windows $ modify' (rotSlaves' rotUp) +rotSlavesDown = windows $ modify' (rotSlaves' rotDown) -- | The actual rotation, as a pure function on the window stack. rotSlaves' :: ([a] -> [a]) -> Stack a -> Stack a @@ -57,10 +61,19 @@ rotSlaves' f s@(Stack _ ls _ ) = Stack t' (reverse revls') rs' -- otherwise -- | Rotate all the windows in the current stack. rotAllUp,rotAllDown :: X () -rotAllUp = windows $ modify' (rotAll' (\l -> tail l++[head l])) -rotAllDown = windows $ modify' (rotAll' (\l -> last l : init l)) +rotAllUp = windows $ modify' (rotAll' rotUp) +rotAllDown = windows $ modify' (rotAll' rotDown) -- | The actual rotation, as a pure function on the window stack. rotAll' :: ([a] -> [a]) -> Stack a -> Stack a rotAll' f s = Stack r (reverse revls) rs where (revls, notEmpty -> r :| rs) = splitAt (length (up s)) (f (integrate s)) + +-- $generic +-- Generic list rotations such that @rotUp [1..4]@ is equivalent to +-- @[2,3,4,1]@ and @rotDown [1..4]@ to @[4,1,2,3]@. They both are +-- @id@ for null or singleton lists. +rotUp :: [a] -> [a] +rotUp l = drop 1 l ++ take 1 l +rotDown :: [a] -> [a] +rotDown = reverse . rotUp . reverse