From cfdc6283ea7f8a16c790de329fdaf78639ccb474 Mon Sep 17 00:00:00 2001 From: David Roundy Date: Sun, 22 Apr 2007 01:38:38 +0200 Subject: add RotView module. darcs-hash:20070421233838-72aca-f4febdef37080d549ba55fd182b261da493a20ff.gz --- RotView.hs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 RotView.hs (limited to 'RotView.hs') 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 -- cgit v1.2.3