This commit is contained in:
f1u77y
2015-12-11 16:42:14 +03:00
parent b9b4f4af07
commit d81c48d022

View File

@@ -14,7 +14,8 @@
module XMonad.Actions.FocusNth (
-- * Usage
-- $usage
focusNth,focusNth') where
focusNth,focusNth',
swapNth,swapNth') where
import XMonad.StackSet
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
| 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 n l = Stack t ls rs
where