From f7ca8f241f88b96b61e7102e4e11171f5264631e Mon Sep 17 00:00:00 2001 From: Karsten Schoelzel Date: Fri, 3 Aug 2007 20:53:37 +0200 Subject: RotSlaves rework Rework the logic of RotSlaves and rename it RotSlavesDown, add RotSlavesUp. These rotate the slaves in different directions. Also changed the usage, eliminating the need for "windows" in the keybinding. darcs-hash:20070803185337-eb3a1-8ece91cb3a0d5a87c4007ef843aaebc262936bcc.gz --- RotSlaves.hs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'RotSlaves.hs') diff --git a/RotSlaves.hs b/RotSlaves.hs index 6bda6e7..8f06117 100644 --- a/RotSlaves.hs +++ b/RotSlaves.hs @@ -13,10 +13,12 @@ ----------------------------------------------------------------------------- module XMonadContrib.RotSlaves ( -- $usage - rotSlaves', rotSlaves + rotSlaves', rotSlavesUp, rotSlavesDown ) where -import qualified StackSet as SS +import StackSet +import Operations +import XMonad -- $usage -- @@ -26,22 +28,20 @@ import qualified StackSet as SS -- -- and add a keybinding: -- --- , ((modMask .|. shiftMask, xK_Tab ), windows rotSlaves) +-- , ((modMask .|. shiftMask, xK_Tab ), rotSlavesUp) -- -- -- This operation will rotate all windows except the master window, while the focus -- stays where it is. It is usefull together with the TwoPane-Layout (see XMonadContrib.TwoPane). -- -rotSlaves :: SS.StackSet i a s sd -> SS.StackSet i a s sd -rotSlaves = SS.modify' rotSlaves' - -rotSlaves' :: SS.Stack a -> SS.Stack a -rotSlaves' (SS.Stack t ls rs) | (null ls) = SS.Stack t [] ((rearRs)++(frontRs)) --Master has focus - | otherwise = SS.Stack t' (reverse ((master)++revls')) rs' --otherwise - where (frontRs, rearRs) = splitAt (max 0 ((length rs) - 1)) rs - (ils, master) = splitAt (max 0 ((length ls) - 1)) ls - toBeRotated = (reverse ils)++(t:rs) - (revls',t':rs') = splitAt (length ils) ((last toBeRotated):(init toBeRotated)) - +rotSlavesUp,rotSlavesDown :: X () +rotSlavesUp = windows $ modify' (rotSlaves' (\l -> (tail l)++[head l])) +rotSlavesDown = windows $ modify' (rotSlaves' (\l -> [last l]++(init l))) +rotSlaves' :: ([a] -> [a]) -> Stack a -> Stack a +rotSlaves' _ s@(Stack _ [] []) = s +rotSlaves' f (Stack t [] rs) = Stack t [] (f rs) -- Master has focus +rotSlaves' f s@(Stack _ ls _ ) = Stack t' (reverse revls') rs' -- otherwise + where (master:ws) = integrate s + (revls',t':rs') = splitAt (length ls) (master:(f ws)) -- cgit v1.2.3