summaryrefslogtreecommitdiffstats
path: root/StackSet.hs
diff options
context:
space:
mode:
authorBrent Yorgey <byorgey@gmail.com>2007-10-22 22:41:05 +0200
committerBrent Yorgey <byorgey@gmail.com>2007-10-22 22:41:05 +0200
commite3ef1c28b8862964f7a211b409edbef6056163dc (patch)
tree4f89506d223396f228815e2b4b0ccc1608046408 /StackSet.hs
parent9134aaf952df72b68c0ea491467ef1a4e8814f5b (diff)
downloadmetatile-e3ef1c28b8862964f7a211b409edbef6056163dc.tar
metatile-e3ef1c28b8862964f7a211b409edbef6056163dc.zip
Replace 'findIndex' with 'findTag', which more accurately describes what the function does.
I realize this is a big change, but the name 'findIndex' was confusing for me, since I expected it to return some sort of integer. What it actually does, of course, is return a workspace tag, which might be more general than an index. Of course, this change breaks several contrib modules; I'll submit a patch to make the change there as well. darcs-hash:20071022204105-bd4d7-9f5d5b8ce00c61b4830fde329f528b2d79af2fa6
Diffstat (limited to 'StackSet.hs')
-rw-r--r--StackSet.hs14
1 files changed, 7 insertions, 7 deletions
diff --git a/StackSet.hs b/StackSet.hs
index 221e123..1abf09a 100644
--- a/StackSet.hs
+++ b/StackSet.hs
@@ -26,7 +26,7 @@ module StackSet (
-- $stackOperations
peek, index, integrate, integrate', differentiate,
focusUp, focusDown, focusMaster, focusWindow,
- tagMember, renameTag, ensureTags, member, findIndex, mapWorkspace, mapLayout,
+ tagMember, renameTag, ensureTags, member, findTag, mapWorkspace, mapLayout,
-- * Modifying the stackset
-- $modifyStackset
insertUp, delete, delete', filter,
@@ -389,7 +389,7 @@ reverseStack (Stack t ls rs) = Stack t rs ls
focusWindow :: (Eq s, Eq a, Eq i) => a -> StackSet i l a s sd -> StackSet i l a s sd
focusWindow w s | Just w == peek s = s
| otherwise = maybe s id $ do
- n <- findIndex w s
+ n <- findTag w s
return $ until ((Just w ==) . peek) focusUp (view n s)
-- | Get a list of all screens in the StackSet.
@@ -439,13 +439,13 @@ mapLayout f (StackSet v vs hs m) = StackSet (fScreen v) (map fScreen vs) (map fW
-- | /O(n)/. Is a window in the StackSet.
member :: Eq a => a -> StackSet i l a s sd -> Bool
-member a s = maybe False (const True) (findIndex a s)
+member a s = maybe False (const True) (findTag a s)
-- | /O(1) on current window, O(n) in general/.
--- Return Just the workspace index of the given window, or Nothing
+-- Return Just the workspace tag of the given window, or Nothing
-- if the window is not in the StackSet.
-findIndex :: Eq a => a -> StackSet i l a s sd -> Maybe i
-findIndex a s = listToMaybe
+findTag :: Eq a => a -> StackSet i l a s sd -> Maybe i
+findTag a s = listToMaybe
[ tag w | w <- workspaces s, has a (stack w) ]
where has _ Nothing = False
has x (Just (Stack t l r)) = x `elem` (t : l ++ r)
@@ -559,7 +559,7 @@ shiftWin :: (Ord a, Eq a, Eq s, Eq i) => i -> a -> StackSet i l a s sd -> StackS
shiftWin n w s | from == Nothing = s -- not found
| n `tagMember` s && (Just n) /= from = go
| otherwise = s
- where from = findIndex w s
+ where from = findTag w s
go = on n (insertUp w) . on (fromJust from) (delete' w) $ s
curtag = tag (workspace (current s))