X.L.Mosaic: prevent users from causing non-termination with negative elements

This commit is contained in:
Adam Vogt
2009-02-10 02:27:27 +00:00
parent aa7dce7085
commit 92aa7079ea

View File

@@ -71,10 +71,11 @@ data Aspect
instance Message Aspect instance Message Aspect
data Mosaic a data Mosaic a
{- | The relative magnitudes of the positive rational numbers provided {- | The relative magnitudes (the sign is ignored) of the rational numbers
determine the relative areas that the windows receive. The first - provided determine the relative areas that the windows receive. The
number represents the size of the master window, the second is for the - first number represents the size of the master window, the second is for
next window in the stack, and so on. - the next window in the stack, and so on. Windows without a list element
- are hidden.
-} -}
= Mosaic [Rational] = Mosaic [Rational]
-- override the aspect? current index, maximum index -- override the aspect? current index, maximum index
@@ -141,7 +142,8 @@ shrinkMaster [] = []
shrinkMaster (x:xs) = x/2:xs shrinkMaster (x:xs) = x/2:xs
splits :: Int -> Rectangle -> [Rational] -> [[Rectangle]] splits :: Int -> Rectangle -> [Rational] -> [[Rectangle]]
splits num rect sz = splitsL rect $ makeTree $ normalize $ reverse $ take num sz splits num rect sz = splitsL rect $ makeTree $ normalize
$ map abs $ reverse $ take num sz
-- recursively enumerate splits -- recursively enumerate splits
splitsL :: Rectangle -> Tree Rational -> [[Rectangle]] splitsL :: Rectangle -> Tree Rational -> [[Rectangle]]