mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 11:30:22 -07:00
FocusNth initial import
This commit is contained in:
parent
3861c22e8b
commit
628244f06d
42
FocusNth.hs
Normal file
42
FocusNth.hs
Normal file
@ -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)
|
||||||
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user