diff options
author | Karsten Schoelzel <kuser@gmx.de> | 2007-07-25 22:33:05 +0200 |
---|---|---|
committer | Karsten Schoelzel <kuser@gmx.de> | 2007-07-25 22:33:05 +0200 |
commit | 29a89bf278b310b9364bed850a1f169d0a61df00 (patch) | |
tree | 245778996987f9ccd9641d4860bb9249d7c3f8b8 | |
parent | 6725772600c4dd6f3839becb1a09d8fdc7ef3c26 (diff) | |
download | XMonadContrib-29a89bf278b310b9364bed850a1f169d0a61df00.tar.gz XMonadContrib-29a89bf278b310b9364bed850a1f169d0a61df00.tar.xz XMonadContrib-29a89bf278b310b9364bed850a1f169d0a61df00.zip |
FocusNth initial import
darcs-hash:20070725203305-eb3a1-240d890082c4a8531a139e3cb26073b15f20954c.gz
-rw-r--r-- | FocusNth.hs | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/FocusNth.hs b/FocusNth.hs new file mode 100644 index 0000000..f697c75 --- /dev/null +++ b/FocusNth.hs @@ -0,0 +1,42 @@ +----------------------------------------------------------------------------- +-- | +-- Module : XMonadContrib.FocusNth +-- Copyright : (c) Karsten Schoelzel <kuser@gmx.de> +-- License : BSD +-- +-- Maintainer : Karsten Schoelzel <kuser@gmx.de> +-- Stability : unstable +-- Portability : unportable +-- +-- Focus the n'th window on the screen. +----------------------------------------------------------------------------- + +module XMonadContrib.FocusNth ( + -- * Usage + -- $usage + focusNth) where + +import StackSet +import Operations +import XMonad + +-- $usage +-- > import XMonadContrib.FocusNth + +-- > -- mod4-[1..9] @@ Switch to window N +-- > ++ [((mod4Mask, k), focusNth i) +-- > | (i, k) <- zip [0 .. 8] [xK_1 ..]] + +focusNth :: Int -> X () +focusNth = windows . modify' . focusNth' + +focusNth' :: Int -> Stack a -> Stack a +focusNth' n s@(Stack _ ls rs) | (n < 0) || (n > length(ls) + length(rs)) = s + | otherwise = listToStack n (integrate s) + +listToStack :: Int -> [a] -> Stack a +listToStack n l = Stack t ls rs + where (t:rs) = drop n l + ls = reverse (take n l) + + |