[Xmonad] Rotate window Stack

Karsten Schoelzel kuser at gmx.de
Thu Aug 2 13:59:22 EDT 2007


On Thu, Aug 02, 2007 at 12:55:13AM +0200, Hans Philipp Annen wrote:
> Hello List, 
> ...
Hi,
> 
> I was not sure whether I should put this in XMonadContrib, since I think
> it's a candidate for Operations.hs.
> 
> Anyway, here is the function:
> 
> 
> 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))
> 
I think I have a version which is easier to understand (at least for me):

rotSlaves' s@(SS.Stack _ [] [])   = s
rotSlaves' (SS.Stack t [] (r:rs)) = SS.Stack t [] (rs ++ [r])                  --Master has focus
rotSlaves' (SS.Stack t ls rs)     = SS.Stack t' (reverse (master:revls')) rs'  --otherwise
    where  (master:q:revls') = reverse (t:ls)
           (t':rs')          = (rs ++ [q])

Actually it rotates the slaves into the other direction (which made it
simpler), but that shouldn't matter much when using the TwoPane layout.
> 
> I hope someone else will find that usefull...
> 
> Hans Philipp Annen
> 

Karsten Schölzel
-- 
Karsten Schölzel        | Email:  kuser at gmx.de
Friedrichstraße 7       | Jabber: topox at jabber.ccc.de
18057 Rostock           | VoIP:   sip:5857712 at sipgate.de
Germany                 |         sip:708529 at fwd.pulver.com
                        | Tel:    +4918015855857712
			| Mobile: +491627144185


More information about the Xmonad mailing list