aboutsummaryrefslogtreecommitdiffstats
path: root/XMonad/Actions/FocusNth.hs
diff options
context:
space:
mode:
authorSpencer Janssen <sjanssen@cse.unl.edu>2007-11-01 21:10:59 +0100
committerSpencer Janssen <sjanssen@cse.unl.edu>2007-11-01 21:10:59 +0100
commit4866f2e367dfcf22a9591231ba40948826a1b438 (patch)
tree7a245caee3f146826b267d773b7eaa80386a818e /XMonad/Actions/FocusNth.hs
parent47589e1913fb9530481caedb543978a30d4323ea (diff)
downloadXMonadContrib-4866f2e367dfcf22a9591231ba40948826a1b438.tar.gz
XMonadContrib-4866f2e367dfcf22a9591231ba40948826a1b438.tar.xz
XMonadContrib-4866f2e367dfcf22a9591231ba40948826a1b438.zip
Hierarchify
darcs-hash:20071101201059-a5988-fc1f1262bec1b69e13ba18ae7cefeafc8c4471d4.gz
Diffstat (limited to 'XMonad/Actions/FocusNth.hs')
-rw-r--r--XMonad/Actions/FocusNth.hs48
1 files changed, 48 insertions, 0 deletions
diff --git a/XMonad/Actions/FocusNth.hs b/XMonad/Actions/FocusNth.hs
new file mode 100644
index 0000000..42336ef
--- /dev/null
+++ b/XMonad/Actions/FocusNth.hs
@@ -0,0 +1,48 @@
+-----------------------------------------------------------------------------
+-- |
+-- Module : XMonad.Actions.FocusNth
+-- Copyright : (c) Karsten Schoelzel <kuser@gmx.de>
+-- License : BSD
+--
+-- Maintainer : Karsten Schoelzel <kuser@gmx.de>
+-- Stability : unstable
+-- Portability : unportable
+--
+-- Focus the nth window on the screen.
+-----------------------------------------------------------------------------
+
+module XMonad.Actions.FocusNth (
+ -- * Usage
+ -- $usage
+ focusNth) where
+
+import XMonad.StackSet
+import XMonad.Operations
+import XMonad
+
+-- $usage
+-- > import XMonad.Actions.FocusNth
+
+-- > -- mod4-[1..9] @@ Switch to window N
+-- > ++ [((mod4Mask, k), focusNth i)
+-- > | (i, k) <- zip [0 .. 8] [xK_1 ..]]
+
+-- %import XMonad.Actions.FocusNth
+-- %keybdindextra ++
+-- %keybdindextra -- mod4-[1..9] @@ Switch to window N
+-- %keybdindextra [((mod4Mask, k), focusNth i)
+-- %keybdindextra | (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)
+
+