From d81c48d022899c145ad8473c6c1d5c131d688b9d Mon Sep 17 00:00:00 2001 From: f1u77y Date: Fri, 11 Dec 2015 16:42:14 +0300 Subject: [PATCH] fix #14 --- XMonad/Actions/FocusNth.hs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/XMonad/Actions/FocusNth.hs b/XMonad/Actions/FocusNth.hs index b02df9b3..d124e084 100644 --- a/XMonad/Actions/FocusNth.hs +++ b/XMonad/Actions/FocusNth.hs @@ -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