summaryrefslogtreecommitdiffstats
path: root/Operations.hs
diff options
context:
space:
mode:
authorDavid Roundy <droundy@darcs.net>2007-09-24 20:57:53 +0200
committerDavid Roundy <droundy@darcs.net>2007-09-24 20:57:53 +0200
commit8874b8675a000b63fe435abdc013af03199e6c31 (patch)
treea4d6d620b193174a6b5dbc3572f559dfb06c1f3c /Operations.hs
parente252cc1479451e1cb277ba82364125314d886092 (diff)
downloadmetatile-8874b8675a000b63fe435abdc013af03199e6c31.tar
metatile-8874b8675a000b63fe435abdc013af03199e6c31.zip
Make a String description part of each Layout.
darcs-hash:20070924185753-72aca-95002aa27cfef74bf8caf1e6f243a4626f20659c
Diffstat (limited to 'Operations.hs')
-rw-r--r--Operations.hs22
1 files changed, 13 insertions, 9 deletions
diff --git a/Operations.hs b/Operations.hs
index d1bcad2..e03a4ae 100644
--- a/Operations.hs
+++ b/Operations.hs
@@ -338,34 +338,36 @@ data ChangeLayout = NextLayout | PrevLayout | JumpToLayout String
instance Message ChangeLayout
instance ReadableSomeLayout Window where
- defaults = map snd defaultLayouts
+ defaults = SomeLayout (LayoutSelection defaultLayouts) :
+ SomeLayout Full : SomeLayout (Tall 1 0.1 0.5) :
+ SomeLayout (Mirror $ Tall 1 0.1 0.5) : defaultLayouts
-data LayoutSelection a = LayoutSelection [(String, SomeLayout a)]
+data LayoutSelection a = LayoutSelection [SomeLayout a]
deriving ( Show, Read )
instance ReadableSomeLayout a => Layout LayoutSelection a where
- doLayout (LayoutSelection ((n,l):ls)) r s =
+ doLayout (LayoutSelection (l:ls)) r s =
do (x,ml') <- doLayout l r s
- return (x, (\l' -> LayoutSelection ((n,l'):ls)) `fmap` ml')
+ return (x, (\l' -> LayoutSelection (l':ls)) `fmap` ml')
doLayout (LayoutSelection []) r s = do (x,_) <- doLayout Full r s
return (x,Nothing)
-- respond to messages only when there's an actual choice:
- modifyLayout (LayoutSelection ((n,l):ls@(_:_))) m
+ modifyLayout (LayoutSelection (l:ls@(_:_))) m
| Just NextLayout <- fromMessage m = switchl rls
| Just PrevLayout <- fromMessage m = switchl rls'
| Just (JumpToLayout x) <- fromMessage m = switchl (j x)
where rls (x:xs) = xs ++ [x]
rls [] = []
rls' = reverse . rls . reverse
- j s zs = case partition (\z -> s == fst z) zs of
+ j s zs = case partition (\z -> s == description z) zs of
(xs,ys) -> xs++ys
switchl f = do ml' <- modifyLayout l (SomeMessage Hide)
- return $ Just (LayoutSelection $ f $ (n,fromMaybe l ml'):ls)
+ return $ Just (LayoutSelection $ f $ fromMaybe l ml':ls)
-- otherwise, or if we don't understand the message, pass it along to the real
-- layout:
- modifyLayout (LayoutSelection ((n,l):ls)) m
+ modifyLayout (LayoutSelection (l:ls)) m
= do ml' <- modifyLayout l m
- return $ (\l' -> LayoutSelection ((n,l'):ls)) `fmap` ml'
+ return $ (\l' -> LayoutSelection (l':ls)) `fmap` ml'
-- Unless there is no layout...
modifyLayout (LayoutSelection []) _ = return Nothing
--
@@ -404,6 +406,7 @@ instance Layout Tall a where
where resize Shrink = Tall nmaster delta (max 0 $ frac-delta)
resize Expand = Tall nmaster delta (min 1 $ frac+delta)
incmastern (IncMasterN d) = Tall (max 0 (nmaster+d)) delta frac
+ description _ = "Tall"
-- | Mirror a rectangle
mirrorRect :: Rectangle -> Rectangle
@@ -416,6 +419,7 @@ instance Layout l a => Layout (Mirror l) a where
doLayout (Mirror l) r s = (map (second mirrorRect) *** fmap Mirror)
`fmap` doLayout l (mirrorRect r) s
modifyLayout (Mirror l) = fmap (fmap Mirror) . modifyLayout l
+ description (Mirror l) = "Mirror "++ description l
-- | tile. Compute the positions for windows using the default 2 pane tiling algorithm.
--