mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-08-14 11:45:54 -07:00
make TwoPane work with Layout class
This commit is contained in:
22
TwoPane.hs
22
TwoPane.hs
@@ -17,7 +17,7 @@
|
|||||||
module XMonadContrib.TwoPane (
|
module XMonadContrib.TwoPane (
|
||||||
-- * Usage
|
-- * Usage
|
||||||
-- $usage
|
-- $usage
|
||||||
twoPane
|
TwoPane (..)
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import XMonad
|
import XMonad
|
||||||
@@ -32,13 +32,17 @@ import StackSet ( focus, up, down)
|
|||||||
--
|
--
|
||||||
-- and add, to the list of layouts:
|
-- and add, to the list of layouts:
|
||||||
--
|
--
|
||||||
-- > twoPane delta (1%2)
|
-- > ,("twopane", SomeLayout $ TwoPane 0.03 0.5)
|
||||||
|
|
||||||
-- %import XMonadContrib.TwoPane
|
-- %import XMonadContrib.TwoPane
|
||||||
-- %layout , twoPane delta (1%2)
|
-- %layout , ,("twopane", SomeLayout $ TwoPane 0.03 0.5)
|
||||||
|
|
||||||
twoPane :: Rational -> Rational -> Layout a
|
data TwoPane a =
|
||||||
twoPane delta split = Layout { doLayout = \r s -> return (arrange r s,Nothing), modifyLayout = message }
|
TwoPane Rational Rational
|
||||||
|
deriving ( Show, Read )
|
||||||
|
|
||||||
|
instance Layout TwoPane a where
|
||||||
|
doLayout (TwoPane _ split) r s = return (arrange r s,Nothing)
|
||||||
where
|
where
|
||||||
arrange rect st = case reverse (up st) of
|
arrange rect st = case reverse (up st) of
|
||||||
(master:_) -> [(master,left),(focus st,right)]
|
(master:_) -> [(master,left),(focus st,right)]
|
||||||
@@ -47,7 +51,9 @@ twoPane delta split = Layout { doLayout = \r s -> return (arrange r s,Nothing),
|
|||||||
[] -> [(focus st, rect)]
|
[] -> [(focus st, rect)]
|
||||||
where (left, right) = splitHorizontallyBy split rect
|
where (left, right) = splitHorizontallyBy split rect
|
||||||
|
|
||||||
message x = return $ case fromMessage x of
|
modifyLayout (TwoPane delta split) x =
|
||||||
Just Shrink -> Just (twoPane delta (split - delta))
|
return $ case fromMessage x of
|
||||||
Just Expand -> Just (twoPane delta (split + delta))
|
Just Shrink -> Just (TwoPane delta (split - delta))
|
||||||
|
Just Expand -> Just (TwoPane delta (split + delta))
|
||||||
_ -> Nothing
|
_ -> Nothing
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user