From ee9be16599f20aef6d1d3fd15666c00452f85aba Mon Sep 17 00:00:00 2001 From: Josh Rahm Date: Mon, 21 Nov 2022 12:05:03 -0700 Subject: Format with ormolu. --- src/Rahm/Desktop/Workspaces.hs | 76 +++++++++++++++++++++--------------------- 1 file changed, 38 insertions(+), 38 deletions(-) (limited to 'src/Rahm/Desktop/Workspaces.hs') diff --git a/src/Rahm/Desktop/Workspaces.hs b/src/Rahm/Desktop/Workspaces.hs index 6c52f01..9ddafa5 100644 --- a/src/Rahm/Desktop/Workspaces.hs +++ b/src/Rahm/Desktop/Workspaces.hs @@ -1,21 +1,17 @@ - -- Common ways to select workspaces module Rahm.Desktop.Workspaces where -import Prelude hiding ((!!)) - -import Control.Monad.Trans.Maybe import Control.Arrow (second, (&&&)) -import qualified Rahm.Desktop.StackSet as W -import XMonad - +import Control.Monad.Trans.Maybe +import Data.Char (isAlphaNum, isUpper, toLower, toUpper) +import Data.List (find, sort, sortBy, sortOn) import Data.List.Safe ((!!)) - +import Data.Maybe (fromMaybe, mapMaybe) import Rahm.Desktop.Common import Rahm.Desktop.History -import Data.List (sortOn, sort, sortBy, find) -import Data.Maybe (mapMaybe, fromMaybe) -import Data.Char (isUpper, toUpper, toLower, isAlphaNum) +import qualified Rahm.Desktop.StackSet as W +import XMonad +import Prelude hiding ((!!)) newtype Selector = Selector (forall a. (a -> Bool) -> [a] -> Maybe a) @@ -32,18 +28,19 @@ data WorkspaceState = Current | Hidden | Visible getPopulatedWorkspaces :: W.StackSet String l a sid sd -> [(WorkspaceState, W.Workspace String l a)] getPopulatedWorkspaces (W.StackSet (W.Screen cur _ _) vis hi _) = - filter ((/="*") . W.tag . snd) $ + filter ((/= "*") . W.tag . snd) $ sortOn (W.tag . snd) $ - mapMaybe (\w@(W.Workspace _ _ s) -> fmap (const (Hidden, w)) s) hi ++ - map (\(W.Screen w _ _) -> (Visible, w)) vis ++ - [(Current, cur)] + mapMaybe (\w@(W.Workspace _ _ s) -> fmap (const (Hidden, w)) s) hi + ++ map (\(W.Screen w _ _) -> (Visible, w)) vis + ++ [(Current, cur)] next :: Selector next = Selector $ \f l -> select f l l - where select f (x:y:xs) _ | f x = Just y - select f [x] (y:_) | f x = Just y - select f (x:xs) orig = select f xs orig - select f _ _ = Nothing + where + select f (x : y : xs) _ | f x = Just y + select f [x] (y : _) | f x = Just y + select f (x : xs) orig = select f xs orig + select f _ _ = Nothing prev :: Selector prev = Selector $ \f l -> @@ -64,18 +61,19 @@ windowsInCurrentWorkspace = withWindowSet $ getHorizontallyOrderedScreens :: W.StackSet wid l a ScreenId ScreenDetail -> - [(Bool, W.Screen wid l a ScreenId ScreenDetail)] + [(Bool, W.Screen wid l a ScreenId ScreenDetail)] -- ^ Returns a list of screens ordered from leftmost to rightmost. getHorizontallyOrderedScreens windowSet = - flip sortBy screens $ \sc1 sc2 -> - let (SD (Rectangle x1 _ _ _)) = W.screenDetail (snd sc1) - (SD (Rectangle x2 _ _ _)) = W.screenDetail (snd sc2) - in x1 `compare` x2 - where - screens = (True, W.current windowSet) : map (False,) (W.visible windowSet) + flip sortBy screens $ \sc1 sc2 -> + let (SD (Rectangle x1 _ _ _)) = W.screenDetail (snd sc1) + (SD (Rectangle x2 _ _ _)) = W.screenDetail (snd sc2) + in x1 `compare` x2 + where + screens = (True, W.current windowSet) : map (False,) (W.visible windowSet) accompaningWorkspace :: WorkspaceId -> WorkspaceId -accompaningWorkspace [s] = return $ +accompaningWorkspace [s] = + return $ if isUpper s then toLower s else toUpper s @@ -84,18 +82,20 @@ accompaningWorkspace s = s adjacentWorkspaceNotVisible :: Selector -> WorkspaceId -> X WorkspaceId adjacentWorkspaceNotVisible (Selector selector) from = withWindowSet $ \ss -> - let tags = sort $ - W.tag . snd <$> filter (\x -> fst x /= Visible) ( - getPopulatedWorkspaces ss) - in - return $ fromMaybe from $ selector (==from) tags + let tags = + sort $ + W.tag . snd + <$> filter + (\x -> fst x /= Visible) + ( getPopulatedWorkspaces ss + ) + in return $ fromMaybe from $ selector (== from) tags adjacentWorkspace :: Selector -> WorkspaceId -> X WorkspaceId adjacentWorkspace (Selector selector) from = withWindowSet $ \ss -> - let tags = sort $ W.tag . snd <$> getPopulatedWorkspaces ss - in - return $ fromMaybe from $ selector (==from) tags + let tags = sort $ W.tag . snd <$> getPopulatedWorkspaces ss + in return $ fromMaybe from $ selector (== from) tags viewAdjacent :: Selector -> X () viewAdjacent sel = @@ -115,10 +115,10 @@ withScreen fn n = do Nothing -> windowSet Just screen -> fn (W.tag $ W.workspace screen) windowSet - workspaceWithWindow :: Window -> X (Maybe WorkspaceId) workspaceWithWindow wid = withWindowSet $ \(W.StackSet c v h _) -> return $ - W.tag <$> - find (\(W.Workspace _ _ stack) -> wid `elem` W.integrate' stack) + W.tag + <$> find + (\(W.Workspace _ _ stack) -> wid `elem` W.integrate' stack) (map W.workspace (c : v) ++ h) -- cgit