aboutsummaryrefslogtreecommitdiffstats
path: root/RotSlaves.hs
diff options
context:
space:
mode:
authorKarsten Schoelzel <kuser@gmx.de>2007-08-03 20:53:37 +0200
committerKarsten Schoelzel <kuser@gmx.de>2007-08-03 20:53:37 +0200
commitf7ca8f241f88b96b61e7102e4e11171f5264631e (patch)
treefbf1e5a061c3586850faef6998fbbe8b15967940 /RotSlaves.hs
parente466dd697d686184e04aa378ffabdb7b1fcf06dd (diff)
downloadXMonadContrib-f7ca8f241f88b96b61e7102e4e11171f5264631e.tar.gz
XMonadContrib-f7ca8f241f88b96b61e7102e4e11171f5264631e.tar.xz
XMonadContrib-f7ca8f241f88b96b61e7102e4e11171f5264631e.zip
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
Diffstat (limited to 'RotSlaves.hs')
-rw-r--r--RotSlaves.hs28
1 files changed, 14 insertions, 14 deletions
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))