From 344fa9ae6d73dda205256f9c280b4b9f84d98495 Mon Sep 17 00:00:00 2001 From: Andrea Rossato Date: Sat, 22 Sep 2007 14:42:10 +0200 Subject: make TwoPane work with Layout class darcs-hash:20070922124210-32816-73cddcf8a80fe7fc229d39bd72bdb666b041dbb3.gz --- TwoPane.hs | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/TwoPane.hs b/TwoPane.hs index 65d52de..0a3f0d5 100644 --- a/TwoPane.hs +++ b/TwoPane.hs @@ -17,7 +17,7 @@ module XMonadContrib.TwoPane ( -- * Usage -- $usage - twoPane + TwoPane (..) ) where import XMonad @@ -32,22 +32,28 @@ import StackSet ( focus, up, down) -- -- and add, to the list of layouts: -- --- > twoPane delta (1%2) +-- > ,("twopane", SomeLayout $ TwoPane 0.03 0.5) -- %import XMonadContrib.TwoPane --- %layout , twoPane delta (1%2) - -twoPane :: Rational -> Rational -> Layout a -twoPane delta split = Layout { doLayout = \r s -> return (arrange r s,Nothing), modifyLayout = message } - where - arrange rect st = case reverse (up st) of - (master:_) -> [(master,left),(focus st,right)] - [] -> case down st of - (next:_) -> [(focus st,left),(next,right)] - [] -> [(focus st, rect)] - where (left, right) = splitHorizontallyBy split rect - - message x = return $ case fromMessage x of - Just Shrink -> Just (twoPane delta (split - delta)) - Just Expand -> Just (twoPane delta (split + delta)) - _ -> Nothing +-- %layout , ,("twopane", SomeLayout $ TwoPane 0.03 0.5) + +data TwoPane a = + TwoPane Rational Rational + deriving ( Show, Read ) + +instance Layout TwoPane a where + doLayout (TwoPane _ split) r s = return (arrange r s,Nothing) + where + arrange rect st = case reverse (up st) of + (master:_) -> [(master,left),(focus st,right)] + [] -> case down st of + (next:_) -> [(focus st,left),(next,right)] + [] -> [(focus st, rect)] + where (left, right) = splitHorizontallyBy split rect + + modifyLayout (TwoPane delta split) x = + return $ case fromMessage x of + Just Shrink -> Just (TwoPane delta (split - delta)) + Just Expand -> Just (TwoPane delta (split + delta)) + _ -> Nothing + -- cgit v1.2.3