aboutsummaryrefslogtreecommitdiffstats
path: root/DynamicLog.hs
diff options
context:
space:
mode:
authorSpencer Janssen <sjanssen@cse.unl.edu>2007-09-28 16:49:00 +0200
committerSpencer Janssen <sjanssen@cse.unl.edu>2007-09-28 16:49:00 +0200
commit7f0c492f12e298a69df4af87d45d75dd6683ca6e (patch)
treec6372a8899c9518dc073ccb682e3e888e845a20b /DynamicLog.hs
parentf60f9341e62101a9f99374979edda5bcf6a39116 (diff)
downloadXMonadContrib-7f0c492f12e298a69df4af87d45d75dd6683ca6e.tar.gz
XMonadContrib-7f0c492f12e298a69df4af87d45d75dd6683ca6e.tar.xz
XMonadContrib-7f0c492f12e298a69df4af87d45d75dd6683ca6e.zip
DynamicLog: sort first by index in the workspaces list, then by tag name
darcs-hash:20070928144900-a5988-70e97865519ee4249ca82b815490edb04d40c2ee.gz
Diffstat (limited to 'DynamicLog.hs')
-rw-r--r--DynamicLog.hs15
1 files changed, 13 insertions, 2 deletions
diff --git a/DynamicLog.hs b/DynamicLog.hs
index 26327ae..468a335 100644
--- a/DynamicLog.hs
+++ b/DynamicLog.hs
@@ -28,11 +28,13 @@ module XMonadContrib.DynamicLog (
-- Useful imports
--
import XMonad
+import {-# SOURCE #-} Config (workspaces)
import Operations () -- for ReadableSomeLayout instance
import Data.Maybe ( isJust )
import Data.List
import Data.Ord ( comparing )
import qualified StackSet as S
+import Data.Monoid
-- $usage
--
@@ -63,9 +65,18 @@ dynamicLog = withWindowSet $ \ws -> do
io . putStrLn $ "(" ++ desc ++ ") " ++ pprWindowSet ws
pprWindowSet :: WindowSet -> String
-pprWindowSet s = concatMap fmt $ sortBy (comparing S.tag)
+pprWindowSet s = concatMap fmt $ sortBy cmp
(map S.workspace (S.current s : S.visible s) ++ S.hidden s)
- where this = S.tag (S.workspace (S.current s))
+ where f Nothing Nothing = EQ
+ f (Just _) Nothing = LT
+ f Nothing (Just _) = GT
+ f (Just x) (Just y) = compare x y
+
+ wsIndex = flip elemIndex workspaces . S.tag
+
+ cmp a b = f (wsIndex a) (wsIndex b) `mappend` compare (S.tag a) (S.tag b)
+
+ this = S.tag (S.workspace (S.current s))
visibles = map (S.tag . S.workspace) (S.visible s)
fmt w | S.tag w == this = "[" ++ S.tag w ++ "]"