mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-07-31 12:11:52 -07:00
fix #14
This commit is contained in:
@@ -14,7 +14,8 @@
|
|||||||
module XMonad.Actions.FocusNth (
|
module XMonad.Actions.FocusNth (
|
||||||
-- * Usage
|
-- * Usage
|
||||||
-- $usage
|
-- $usage
|
||||||
focusNth,focusNth') where
|
focusNth,focusNth',
|
||||||
|
swapNth,swapNth') where
|
||||||
|
|
||||||
import XMonad.StackSet
|
import XMonad.StackSet
|
||||||
import XMonad
|
import XMonad
|
||||||
@@ -41,6 +42,16 @@ focusNth' :: Int -> Stack a -> Stack a
|
|||||||
focusNth' n s@(Stack _ ls rs) | (n < 0) || (n > length(ls) + length(rs)) = s
|
focusNth' n s@(Stack _ ls rs) | (n < 0) || (n > length(ls) + length(rs)) = s
|
||||||
| otherwise = listToStack n (integrate s)
|
| otherwise = listToStack n (integrate s)
|
||||||
|
|
||||||
|
swapNth :: Int -> X ()
|
||||||
|
swapNth = windows . modify' . swapNth'
|
||||||
|
|
||||||
|
swapNth' :: Int -> Stack a -> Stack a
|
||||||
|
swapNth' n s(Stack c l r)
|
||||||
|
| (n < 0) || (n > length ls + length rs) || (n == length ls) = s
|
||||||
|
| n < length ls = let (nl, (nc : nr)) = splitAt (n + 1) l in Stack nc (nl ++ c : nr) r
|
||||||
|
| otherwise = let (nl, (nc : nr)) = splitAt (n - length l) r in Stack nc l (nl ++ c : nr)
|
||||||
|
|
||||||
|
|
||||||
listToStack :: Int -> [a] -> Stack a
|
listToStack :: Int -> [a] -> Stack a
|
||||||
listToStack n l = Stack t ls rs
|
listToStack n l = Stack t ls rs
|
||||||
where
|
where
|
||||||
|
Reference in New Issue
Block a user