aboutsummaryrefslogtreecommitdiffstats
path: root/RotView.hs
diff options
context:
space:
mode:
authorDavid Roundy <droundy@darcs.net>2007-04-22 01:38:38 +0200
committerDavid Roundy <droundy@darcs.net>2007-04-22 01:38:38 +0200
commitcfdc6283ea7f8a16c790de329fdaf78639ccb474 (patch)
tree32578491d52b86aad344b24dd042350b183194a9 /RotView.hs
parente572762b1d3b6e1ddced0fc8523f53da948a6660 (diff)
downloadXMonadContrib-cfdc6283ea7f8a16c790de329fdaf78639ccb474.tar.gz
XMonadContrib-cfdc6283ea7f8a16c790de329fdaf78639ccb474.tar.xz
XMonadContrib-cfdc6283ea7f8a16c790de329fdaf78639ccb474.zip
add RotView module.
darcs-hash:20070421233838-72aca-f4febdef37080d549ba55fd182b261da493a20ff.gz
Diffstat (limited to 'RotView.hs')
-rw-r--r--RotView.hs30
1 files changed, 30 insertions, 0 deletions
diff --git a/RotView.hs b/RotView.hs
new file mode 100644
index 0000000..8b58fa1
--- /dev/null
+++ b/RotView.hs
@@ -0,0 +1,30 @@
+module XMonad.RotView ( rotView ) where
+
+-- To use:
+-- include XMonad.RotView
+
+-- , ((modMask .|. shiftMask, xK_Right), rotView True)
+-- , ((modMask .|. shiftMask, xK_Left), rotView False)
+
+import qualified Data.Map as M
+import Control.Monad.State
+
+import Operations ( view )
+import XMonad ( X, WorkspaceId, workspace )
+import StackSet ( StackSet, focus )
+import qualified StackSet as W ( current )
+
+rotView :: Bool -> X m ()
+rotView b = do ws <- gets workspace
+ let m = W.current ws
+ allws = if b then allWorkspaces ws else reverse $ allWorkspaces ws
+ n1 = safehead allws m
+ rot (f:fs) | f == m = safehead fs n1
+ | otherwise = rot fs
+ rot [] = n1
+ safehead fs f = case fs of { [] -> f; f':_ -> f'; }
+ view (rot allws)
+
+-- | A list of all the workspaces.
+allWorkspaces :: StackSet WorkspaceId j a -> [WorkspaceId]
+allWorkspaces = M.keys . focus