diff options
author | Jason Creighton <jcreigh@gmail.com> | 2007-04-11 06:42:15 +0200 |
---|---|---|
committer | Jason Creighton <jcreigh@gmail.com> | 2007-04-11 06:42:15 +0200 |
commit | 7e88f8a48c3daecff0b5d62219ee2b0a937d8b82 (patch) | |
tree | 13fa85ae236834e80dbd8beb428c33312f38a731 /StackSet.hs | |
parent | 399cca198965e1bd1810b72bdf487567688c3861 (diff) | |
download | xmonad-7e88f8a48c3daecff0b5d62219ee2b0a937d8b82.tar.gz xmonad-7e88f8a48c3daecff0b5d62219ee2b0a937d8b82.tar.xz xmonad-7e88f8a48c3daecff0b5d62219ee2b0a937d8b82.zip |
fromList/toList have # of screens + another QC property
darcs-hash:20070411044215-b9aa7-e66ef93fac9102201bfd145ebb26c38bbecd25de.gz
Diffstat (limited to '')
-rw-r--r-- | StackSet.hs | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/StackSet.hs b/StackSet.hs index cf1f343..6bc2e99 100644 --- a/StackSet.hs +++ b/StackSet.hs @@ -80,20 +80,21 @@ 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 :: Ord a => (Int,Int,[[a]]) -> StackSet a +fromList (_,_,[]) = error "Cannot build a StackSet from an empty list" -fromList (n,xs) | n < 0 || n >= length xs +fromList (n,m,xs) | n < 0 || n >= length xs = error $ "Cursor index is out of range: " ++ show (n, length xs) + | m < 1 || m > length xs + = error $ "Can't have more screens than workspaces: " ++ show (m, length xs) -fromList (o,xs) = view o $ foldr (\(i,ys) s -> - foldr (\a t -> insert a i t) s ys) - (empty (length xs) 1) (zip [0..] 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 -> (Int,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. |