mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 03:20:21 -07:00
add XMonad.Actions.Sift (siftUp, siftDown)
Provide swap-like functions that handle the wrapping case by exchanging the windows at either end of the stack rather than rotating the stack. https://github.com/xmonad/xmonad/issues/234
This commit is contained in:
parent
58feba91d9
commit
e2fa1ce8a1
57
XMonad/Actions/Sift.hs
Normal file
57
XMonad/Actions/Sift.hs
Normal file
@ -0,0 +1,57 @@
|
||||
-----------------------------------------------------------------------------
|
||||
-- |
|
||||
-- Module : XMonad.Actions.Sift
|
||||
-- Copyright : (c) 2020 Ivan Brennan <ivanbrennan@gmail.com>
|
||||
-- License : BSD3-style (see LICENSE)
|
||||
--
|
||||
-- Maintainer : Ivan Brennan <ivanbrennan@gmail.com>
|
||||
-- Stability : stable
|
||||
-- Portability : unportable
|
||||
--
|
||||
-- Functions for sifting windows up and down. Sifts behave identically to
|
||||
-- swaps (i.e. 'swapUp' and 'swapDown' from "XMonad.StackSet"), except in
|
||||
-- the wrapping case: rather than rotating the entire stack by one position
|
||||
-- like a swap would, a sift causes the windows at either end of the stack
|
||||
-- to trade positions.
|
||||
--
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
module XMonad.Actions.Sift (
|
||||
-- * Usage
|
||||
-- $usage
|
||||
siftUp,
|
||||
siftDown,
|
||||
) where
|
||||
|
||||
import XMonad.StackSet (Stack (Stack), StackSet, modify')
|
||||
|
||||
-- $usage
|
||||
-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@:
|
||||
--
|
||||
-- > import XMonad.Actions.Sift
|
||||
--
|
||||
-- and add keybindings such as the following:
|
||||
--
|
||||
-- > , ((modMask .|. shiftMask, xK_j ), windows siftDown)
|
||||
-- > , ((modMask .|. shiftMask, xK_k ), windows siftUp )
|
||||
--
|
||||
|
||||
-- |
|
||||
-- siftUp, siftDown. Exchange the focused window with its neighbour in
|
||||
-- the stack ordering, wrapping if we reach the end. Unlike 'swapUp' and
|
||||
-- 'swapDown', wrapping is handled by trading positions with the window
|
||||
-- at the other end of the stack.
|
||||
--
|
||||
siftUp, siftDown :: StackSet i l a s sd -> StackSet i l a s sd
|
||||
siftUp = modify' siftUp'
|
||||
siftDown = modify' (reverseStack . siftUp' . reverseStack)
|
||||
|
||||
siftUp' :: Stack a -> Stack a
|
||||
siftUp' (Stack t (l:ls) rs) = Stack t ls (l:rs)
|
||||
siftUp' (Stack t [] rs) =
|
||||
case reverse rs of
|
||||
(x:xs) -> Stack t (xs ++ [x]) []
|
||||
[] -> Stack t [] []
|
||||
|
||||
reverseStack :: Stack a -> Stack a
|
||||
reverseStack (Stack t ls rs) = Stack t rs ls
|
@ -127,6 +127,7 @@ library
|
||||
XMonad.Actions.RotSlaves
|
||||
XMonad.Actions.Search
|
||||
XMonad.Actions.ShowText
|
||||
XMonad.Actions.Sift
|
||||
XMonad.Actions.SimpleDate
|
||||
XMonad.Actions.SinkAll
|
||||
XMonad.Actions.SpawnOn
|
||||
|
Loading…
x
Reference in New Issue
Block a user