diff options
author | Devin Mullins <me@twifkak.com> | 2007-10-06 07:41:04 +0200 |
---|---|---|
committer | Devin Mullins <me@twifkak.com> | 2007-10-06 07:41:04 +0200 |
commit | 69c51b662a5a98769d302c2cca35e5942ec184a3 (patch) | |
tree | 3b8df920368898ae748bbe491a7c82f61235be58 | |
parent | 447bef34cd6635eed6eb4fb9831c812650d89522 (diff) | |
download | metatile-69c51b662a5a98769d302c2cca35e5942ec184a3.tar metatile-69c51b662a5a98769d302c2cca35e5942ec184a3.zip |
(cleanup) extract mapWorkspace out of renameTag
darcs-hash:20071006054104-78224-364be3b89447beadba7438f7ebe3f867f4677a61
-rw-r--r-- | StackSet.hs | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/StackSet.hs b/StackSet.hs index 8b8d123..e5eef97 100644 --- a/StackSet.hs +++ b/StackSet.hs @@ -410,11 +410,8 @@ tagMember t = elem t . map tag . workspaces -- | Rename a given tag if present in the StackSet. renameTag :: Eq i => i -> i -> StackSet i l a s sd -> StackSet i l a s sd -renameTag o n s = s { current = rs $ current s - , visible = map rs $ visible s - , hidden = map rw $ hidden s } - where rs scr = scr { workspace = rw $ workspace scr } - rw w = if tag w == o then w { tag = n } else w +renameTag o n = mapWorkspace rename + where rename w = if tag w == o then w { tag = n } else w -- | Ensure that a given set of tags is present. ensureTags :: Eq i => l -> [i] -> StackSet i l a s sd -> StackSet i l a s sd @@ -424,6 +421,14 @@ ensureTags l allt st = et allt (map tag (workspaces st) \\ allt) st et (i:is) [] s = et is [] (s { hidden = Workspace i l Nothing : hidden s }) et (i:is) (r:rs) s = et is rs $ renameTag r i s +-- | Map a function on all the workspaces in the StackSet. +mapWorkspace :: (Workspace i l a -> Workspace i l a) -> StackSet i l a s sd -> StackSet i l a s sd +mapWorkspace f s = s { current = updScr $ current s + , visible = map updScr $ visible s + , hidden = map f $ hidden s } + where updScr scr = scr { workspace = f $ workspace scr } + +-- | Map a function on all the layouts in the StackSet. mapLayout :: (l -> l') -> StackSet i l a s sd -> StackSet i l' a s sd mapLayout f (StackSet v vs hs m) = StackSet (fScreen v) (map fScreen vs) (map fWorkspace hs) m where |