mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-08-15 20:23:55 -07:00
Improve readability of RotView
This commit is contained in:
20
RotView.hs
20
RotView.hs
@@ -19,8 +19,8 @@ module XMonadContrib.RotView (
|
|||||||
) where
|
) where
|
||||||
|
|
||||||
import Control.Monad.State ( gets )
|
import Control.Monad.State ( gets )
|
||||||
import Data.List ( sortBy )
|
import Data.List ( sortBy, find )
|
||||||
import Data.Maybe ( listToMaybe, isJust )
|
import Data.Maybe ( isJust )
|
||||||
import Data.Ord ( comparing )
|
import Data.Ord ( comparing )
|
||||||
|
|
||||||
import XMonad
|
import XMonad
|
||||||
@@ -29,7 +29,7 @@ import Operations
|
|||||||
|
|
||||||
-- $usage
|
-- $usage
|
||||||
-- You can use this module with the following in your Config.hs file:
|
-- You can use this module with the following in your Config.hs file:
|
||||||
--
|
--
|
||||||
-- > import XMonadContrib.RotView
|
-- > import XMonadContrib.RotView
|
||||||
--
|
--
|
||||||
-- > , ((modMask .|. shiftMask, xK_Right), rotView True)
|
-- > , ((modMask .|. shiftMask, xK_Right), rotView True)
|
||||||
@@ -40,10 +40,14 @@ import Operations
|
|||||||
-- %keybind , ((modMask .|. shiftMask, xK_Left), rotView False)
|
-- %keybind , ((modMask .|. shiftMask, xK_Left), rotView False)
|
||||||
|
|
||||||
rotView :: Bool -> X ()
|
rotView :: Bool -> X ()
|
||||||
rotView b = do
|
rotView forward = do
|
||||||
ws <- gets windowset
|
ws <- gets windowset
|
||||||
let m = tag . workspace . current $ ws
|
let currentTag = tag . workspace . current $ ws
|
||||||
sortWs = sortBy (comparing tag)
|
sortWs = sortBy (comparing tag)
|
||||||
pivoted = uncurry (flip (++)) . span ((< m) . tag) . sortWs . hidden $ ws
|
isNotEmpty = isJust . stack
|
||||||
nextws = listToMaybe . filter (isJust . stack) . (if b then id else reverse) $ pivoted
|
sorted = sortWs (hidden ws)
|
||||||
|
pivoted = let (a,b) = span ((< currentTag) . tag) sorted in b ++ a
|
||||||
|
pivoted' | forward = pivoted
|
||||||
|
| otherwise = reverse pivoted
|
||||||
|
nextws = find isNotEmpty pivoted'
|
||||||
whenJust nextws (windows . view . tag)
|
whenJust nextws (windows . view . tag)
|
||||||
|
Reference in New Issue
Block a user