XMonad.Layout.BinarySpacePartition

xmonad-contrib-0.18.1: Community-maintained extensions for xmonad

Copyright | (c) 2013 Ben Weitzman <benweitzman@gmail.com> 2015 Anton Pirogov <anton.pirogov@gmail.com> 2019 Mateusz Karbowy <obszczymucha@gmail.com
License | BSD3-style (see LICENSE)
Maintainer | Ben Weitzman <benweitzman@gmail.com>
Stability | unstable
Portability | unportable
Safe Haskell | None
Language | Haskell2010

XMonad.Layout.BinarySpacePartition

Contents

- Usage

Description

Layout where new windows will split the focused window in half, based off of BSPWM

Synopsis

- emptyBSP :: BinarySpacePartition a
- data BinarySpacePartition a
- data Rotate = Rotate
- data Swap = Swap
- data ResizeDirectional where
  - ExpandTowardsBy Direction2D Rational
  - ShrinkFromBy Direction2D Rational
  - MoveSplitBy Direction2D Rational
  - pattern ExpandTowards :: Direction2D -> ResizeDirectional
  - pattern ShrinkFrom :: Direction2D -> ResizeDirectional
  - pattern MoveSplit :: Direction2D -> ResizeDirectional
- data TreeRotate
  - = RotateL
  - | RotateR
- data TreeBalance
  - = Balance
  - | Equalize
- data FocusParent = FocusParent
- data SelectMoveNode
  - = SelectNode
  - | MoveNode
- data Direction2D
  - = U
  - | D
  - | R
  - | L
- newtype SplitShiftDirectional = SplitShift Direction1D

# Usage

You can use this module with the following in your `xmonad.hs`:

    import XMonad.Layout.BinarySpacePartition

Then add the layout, using the default BSP (BinarySpacePartition)

    myLayout = emptyBSP ||| etc ..

It may be a good idea to use XMonad.Actions.Navigation2D to move between the windows.

This layout responds to SetGeometry and is compatible with e.g. XMonad.Actions.MouseResize or XMonad.Layout.BorderResize. You should probably try both to decide which is better for you, if you want to be able to resize the splits with the mouse.

If you don't want to use the mouse, add the following key bindings to resize the splits with the keyboard:

    , ((modm .|. altMask,                 xK_l     ), sendMessage $ ExpandTowards R)
    , ((modm .|. altMask,                 xK_h     ), sendMessage $ ExpandTowards L)
    , ((modm .|. altMask,                 xK_j     ), sendMessage $ ExpandTowards D)
    , ((modm .|. altMask,                 xK_k     ), sendMessage $ ExpandTowards U)
    , ((modm .|. altMask .|. ctrlMask ,   xK_l     ), sendMessage $ ShrinkFrom R)
    , ((modm .|. altMask .|. ctrlMask ,   xK_h     ), sendMessage $ ShrinkFrom L)
    , ((modm .|. altMask .|. ctrlMask ,   xK_j     ), sendMessage $ ShrinkFrom D)
    , ((modm .|. altMask .|. ctrlMask ,   xK_k     ), sendMessage $ ShrinkFrom U)
    , ((modm,                             xK_r     ), sendMessage Rotate)
    , ((modm,                             xK_s     ), sendMessage Swap)
    , ((modm,                             xK_n     ), sendMessage FocusParent)
    , ((modm .|. ctrlMask,                xK_n     ), sendMessage SelectNode)
    , ((modm .|. shiftMask,               xK_n     ), sendMessage MoveNode)
    , ((modm .|. shiftMask .|. ctrlMask , xK_j     ), sendMessage $ SplitShift Prev)
    , ((modm .|. shiftMask .|. ctrlMask , xK_k     ), sendMessage $ SplitShift Next)

Here's an alternative key mapping, this time using additionalKeysP, arrow keys, and slightly different behavior when resizing windows

    , ("M-M1-<Left>",    sendMessage $ ExpandTowards L)
    , ("M-M1-<Right>",   sendMessage $ ShrinkFrom L)
    , ("M-M1-<Up>",      sendMessage $ ExpandTowards U)
    , ("M-M1-<Down>",    sendMessage $ ShrinkFrom U)
    , ("M-M1-C-<Left>",  sendMessage $ ShrinkFrom R)
    , ("M-M1-C-<Right>", sendMessage $ ExpandTowards R)
    , ("M-M1-C-<Up>",    sendMessage $ ShrinkFrom D)
    , ("M-M1-C-<Down>",  sendMessage $ ExpandTowards D)
    , ("M-s",            sendMessage $ Swap)
    , ("M-M1-s",         sendMessage $ Rotate)
    , ("M-S-C-j",        sendMessage $ SplitShift Prev)
    , ("M-S-C-k",        sendMessage $ SplitShift Next)

Note that `ExpandTowards x`, `ShrinkFrom x`, and `MoveSplit x` are the same as respectively `ExpandTowardsBy x 0.05`, `ShrinkFromBy x 0.05` and `MoveSplitBy x 0.05`.

If you have many windows open and the layout begins to look too hard to manage, you can `Balance` the layout, so that the current splittings are discarded and windows are tiled freshly in a way that the split depth is minimized. You can combine this with `Equalize`, which does not change your tree, but tunes the split ratios in a way that each window gets the same amount of space:

    , ((myModMask,               xK_a),     sendMessage Balance)
    , ((myModMask .|. shiftMask, xK_a),     sendMessage Equalize)

emptyBSP :: BinarySpacePartition a #

an empty BinarySpacePartition to use as a default for adding windows to.

data BinarySpacePartition a #

#### Instances

Instances details

LayoutClass BinarySpacePartition Window # |
Instance details Defined in XMonad.Layout.BinarySpacePartition Methods runLayout :: Workspace WorkspaceId (BinarySpacePartition Window) Window -> Rectangle -> X ([(Window, Rectangle)], Maybe (BinarySpacePartition Window)) # doLayout :: BinarySpacePartition Window -> Rectangle -> Stack Window -> X ([(Window, Rectangle)], Maybe (BinarySpacePartition Window)) # pureLayout :: BinarySpacePartition Window -> Rectangle -> Stack Window -> [(Window, Rectangle)] # emptyLayout :: BinarySpacePartition Window -> Rectangle -> X ([(Window, Rectangle)], Maybe (BinarySpacePartition Window)) # handleMessage :: BinarySpacePartition Window -> SomeMessage -> X (Maybe (BinarySpacePartition Window)) # pureMessage :: BinarySpacePartition Window -> SomeMessage -> Maybe (BinarySpacePartition Window) # description :: BinarySpacePartition Window -> String #
Read (BinarySpacePartition a) # |
Instance details Defined in XMonad.Layout.BinarySpacePartition Methods readsPrec :: Int -> ReadS (BinarySpacePartition a) # readList :: ReadS [BinarySpacePartition a] # readPrec :: ReadPrec (BinarySpacePartition a) # readListPrec :: ReadPrec [BinarySpacePartition a] #
Show (BinarySpacePartition a) # |
Instance details Defined in XMonad.Layout.BinarySpacePartition Methods showsPrec :: Int -> BinarySpacePartition a -> ShowS # show :: BinarySpacePartition a -> String # showList :: [BinarySpacePartition a] -> ShowS #
Eq (BinarySpacePartition a) # |
Instance details Defined in XMonad.Layout.BinarySpacePartition Methods (==) :: BinarySpacePartition a -> BinarySpacePartition a -> Bool # (/=) :: BinarySpacePartition a -> BinarySpacePartition a -> Bool #

data Rotate #

Message for rotating a split (horizontal/vertical) in the BSP

Constructors

Rotate |

#### Instances

Instances details

Message Rotate # |
Instance details Defined in XMonad.Layout.BinarySpacePartition

data Swap #

Message for swapping the left child of a split with the right child of split

Constructors

Swap |

#### Instances

Instances details

Message Swap # |
Instance details Defined in XMonad.Layout.BinarySpacePartition

data ResizeDirectional #

Message for resizing one of the cells in the BSP

Constructors

ExpandTowardsBy Direction2D Rational |
ShrinkFromBy Direction2D Rational |
MoveSplitBy Direction2D Rational |

Bundled Patterns

pattern ExpandTowards :: Direction2D -> ResizeDirectional | `ExpandTowards x` is now the equivalent of `ExpandTowardsBy x 0.05`
pattern ShrinkFrom :: Direction2D -> ResizeDirectional | `ShrinkFrom x` is now the equivalent of `ShrinkFromBy x 0.05`
pattern MoveSplit :: Direction2D -> ResizeDirectional | `MoveSplit x` is now the equivalent of `MoveSplitBy x 0.05`

#### Instances

Instances details

Message ResizeDirectional # |
Instance details Defined in XMonad.Layout.BinarySpacePartition

data TreeRotate #

Message for rotating the binary tree around the parent node of the window to the left or right

Constructors

RotateL |
RotateR |

#### Instances

Instances details

Message TreeRotate # |
Instance details Defined in XMonad.Layout.BinarySpacePartition

data TreeBalance #

Message to balance the tree in some way (Balance retiles the windows, Equalize changes ratios)

Constructors

Balance |
Equalize |

#### Instances

Instances details

Message TreeBalance # |
Instance details Defined in XMonad.Layout.BinarySpacePartition

data FocusParent #

Message to cyclically select the parent node instead of the leaf

Constructors

FocusParent |

#### Instances

Instances details

Message FocusParent # |
Instance details Defined in XMonad.Layout.BinarySpacePartition

data SelectMoveNode #

Message to move nodes inside the tree

Constructors

SelectNode |
MoveNode |

#### Instances

Instances details

Message SelectMoveNode # |
Instance details Defined in XMonad.Layout.BinarySpacePartition

data Direction2D #

Two-dimensional directions:

Constructors

U | Up
D | Down
R | Right
L | Left

#### Instances

Instances details

Bounded Direction2D # |
Instance details Defined in XMonad.Util.Types Methods minBound :: Direction2D # maxBound :: Direction2D #
Enum Direction2D # |
Instance details Defined in XMonad.Util.Types Methods succ :: Direction2D -> Direction2D # pred :: Direction2D -> Direction2D # toEnum :: Int -> Direction2D # fromEnum :: Direction2D -> Int # enumFrom :: Direction2D -> [Direction2D] # enumFromThen :: Direction2D -> Direction2D -> [Direction2D] # enumFromTo :: Direction2D -> Direction2D -> [Direction2D] # enumFromThenTo :: Direction2D -> Direction2D -> Direction2D -> [Direction2D] #
Read Direction2D # |
Instance details Defined in XMonad.Util.Types Methods readsPrec :: Int -> ReadS Direction2D # readList :: ReadS [Direction2D] # readPrec :: ReadPrec Direction2D # readListPrec :: ReadPrec [Direction2D] #
Show Direction2D # |
Instance details Defined in XMonad.Util.Types Methods showsPrec :: Int -> Direction2D -> ShowS # show :: Direction2D -> String # showList :: [Direction2D] -> ShowS #
Eq Direction2D # |
Instance details Defined in XMonad.Util.Types Methods (==) :: Direction2D -> Direction2D -> Bool # (/=) :: Direction2D -> Direction2D -> Bool #
Ord Direction2D # |
Instance details Defined in XMonad.Util.Types Methods compare :: Direction2D -> Direction2D -> Ordering # (<) :: Direction2D -> Direction2D -> Bool # (<=) :: Direction2D -> Direction2D -> Bool # (>) :: Direction2D -> Direction2D -> Bool # (>=) :: Direction2D -> Direction2D -> Bool # max :: Direction2D -> Direction2D -> Direction2D # min :: Direction2D -> Direction2D -> Direction2D #

newtype SplitShiftDirectional #

Message for shifting window by splitting its neighbour

Constructors

SplitShift Direction1D |

#### Instances

Instances details

Message SplitShiftDirectional # |
Instance details Defined in XMonad.Layout.BinarySpacePartition