aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDon Stewart <dons@cse.unsw.edu.au>2007-04-11 08:09:47 +0200
committerDon Stewart <dons@cse.unsw.edu.au>2007-04-11 08:09:47 +0200
commit64c8cdae0c0d44ed4b4cc54797c9e79a1e76548c (patch)
tree5f9fae1ea28cf307bf5823e16da06cde5656b68b
parentf24008745e645cf03a1e78fdbf751924f75fb9eb (diff)
downloadxmonad-64c8cdae0c0d44ed4b4cc54797c9e79a1e76548c.tar.gz
xmonad-64c8cdae0c0d44ed4b4cc54797c9e79a1e76548c.tar.xz
xmonad-64c8cdae0c0d44ed4b4cc54797c9e79a1e76548c.zip
merge with toList/fromList patch
darcs-hash:20070411060947-9c5c1-88a2c630ec0bb669c5d34410fb546cc1ff538ded.gz
-rw-r--r--StackSet.hs22
1 files changed, 12 insertions, 10 deletions
diff --git a/StackSet.hs b/StackSet.hs
index 58cbac6..83f64e4 100644
--- a/StackSet.hs
+++ b/StackSet.hs
@@ -88,24 +88,26 @@ size = M.size . stacks
------------------------------------------------------------------------
--- | fromList. Build a new StackSet from a list of list of elements
--- If there are duplicates in the list, the last occurence wins.
--- FIXME: This always makes a StackSet with 1 screen.
-fromList :: Ord a => (Int,[[a]]) -> StackSet a
-fromList (_,[]) = error "Cannot build a StackSet from an empty list"
-
-fromList (n,xs) | n < 0 || n >= length xs
+-- | fromList. Build a new StackSet from a list of list of elements,
+-- keeping track of the currently focused workspace, and the total
+-- number of workspaces. If there are duplicates in the list, the last
+-- occurence wins.
+fromList :: Ord a => (WorkspaceId, Int,[[a]]) -> StackSet a
+fromList (_,_,[]) = error "Cannot build a StackSet from an empty list"
+
+fromList (n,m,xs) | n < 0 || n >= L.genericLength xs
= error $ "Cursor index is out of range: " ++ show (n, length xs)
- | m < 1 || m > length xs
+ | m < 1 || m > L.genericLength xs
= error $ "Can't have more screens than workspaces: " ++ show (m, length xs)
fromList (o,m,xs) = view o $ foldr (\(i,ys) s ->
foldr (\a t -> insert a i t) s ys)
(empty (length xs) m) (zip [0..] xs)
+
-- | toList. Flatten a stackset to a list of lists
-toList :: StackSet a -> (Int,[[a]])
-toList x = (current x, map snd $ M.toList (stacks x))
+toList :: StackSet a -> (WorkspaceId,Int,[[a]])
+toList x = (current x, M.size $ screen2ws x, map snd $ M.toList (stacks x))
-- | Push. Insert an element onto the top of the current stack.
-- If the element is already in the current stack, it is moved to the top.