diff options
author | Eric Mertens <emertens@galois.com> | 2007-10-11 19:52:00 +0200 |
---|---|---|
committer | Eric Mertens <emertens@galois.com> | 2007-10-11 19:52:00 +0200 |
commit | aec488f1be7879e178efe150b881a225737c8959 (patch) | |
tree | 74a7346d42c4fd6fcc085741b8a2b88e92a9ec0d | |
parent | b86fbb245fd7ff0af9fda7958cd2b80fffb09150 (diff) | |
download | XMonadContrib-aec488f1be7879e178efe150b881a225737c8959.tar.gz XMonadContrib-aec488f1be7879e178efe150b881a225737c8959.tar.xz XMonadContrib-aec488f1be7879e178efe150b881a225737c8959.zip |
Improve readability of RotView
darcs-hash:20071011175200-b49f3-732d731fed3f8b1af4bfaacfcc426b2292d61475.gz
-rw-r--r-- | RotView.hs | 20 |
1 files changed, 12 insertions, 8 deletions
@@ -19,8 +19,8 @@ module XMonadContrib.RotView ( ) where import Control.Monad.State ( gets ) -import Data.List ( sortBy ) -import Data.Maybe ( listToMaybe, isJust ) +import Data.List ( sortBy, find ) +import Data.Maybe ( isJust ) import Data.Ord ( comparing ) import XMonad @@ -29,7 +29,7 @@ import Operations -- $usage -- You can use this module with the following in your Config.hs file: --- +-- -- > import XMonadContrib.RotView -- -- > , ((modMask .|. shiftMask, xK_Right), rotView True) @@ -40,10 +40,14 @@ import Operations -- %keybind , ((modMask .|. shiftMask, xK_Left), rotView False) rotView :: Bool -> X () -rotView b = do +rotView forward = do ws <- gets windowset - let m = tag . workspace . current $ ws - sortWs = sortBy (comparing tag) - pivoted = uncurry (flip (++)) . span ((< m) . tag) . sortWs . hidden $ ws - nextws = listToMaybe . filter (isJust . stack) . (if b then id else reverse) $ pivoted + let currentTag = tag . workspace . current $ ws + sortWs = sortBy (comparing tag) + isNotEmpty = isJust . stack + sorted = sortWs (hidden ws) + pivoted = let (a,b) = span ((< currentTag) . tag) sorted in b ++ a + pivoted' | forward = pivoted + | otherwise = reverse pivoted + nextws = find isNotEmpty pivoted' whenJust nextws (windows . view . tag) |