aboutsummaryrefslogtreecommitdiffstats
path: root/TwoPane.hs
diff options
context:
space:
mode:
authorAndrea Rossato <andrea.rossato@unibz.it>2007-09-22 14:42:10 +0200
committerAndrea Rossato <andrea.rossato@unibz.it>2007-09-22 14:42:10 +0200
commit344fa9ae6d73dda205256f9c280b4b9f84d98495 (patch)
tree0287b53c7b0e2b2f31ef8cb2ae2bfe5faf6d8099 /TwoPane.hs
parent51ad1a684f6e106227c0651f113eaa1058a9a36e (diff)
downloadXMonadContrib-344fa9ae6d73dda205256f9c280b4b9f84d98495.tar.gz
XMonadContrib-344fa9ae6d73dda205256f9c280b4b9f84d98495.tar.xz
XMonadContrib-344fa9ae6d73dda205256f9c280b4b9f84d98495.zip
make TwoPane work with Layout class
darcs-hash:20070922124210-32816-73cddcf8a80fe7fc229d39bd72bdb666b041dbb3.gz
Diffstat (limited to 'TwoPane.hs')
-rw-r--r--TwoPane.hs42
1 files 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
+