TUIOSTUIOS

BSP Tiling

Advanced window tiling with Binary Space Partitioning

Binary Space Partitioning Tiling

TUIOS implements automatic window tiling using Binary Space Partitioning (BSP), an algorithm that recursively divides screen space to fit windows efficiently. Unlike rigid grid-based tiling, BSP adapts to any number of windows and allows fine-grained control over splits.

Key Advantage: BSP works with any number of windows (not limited to 2, 4, 6, etc.), and each window can have a different size.

Enable Tiling

In Window Management Mode, press t to toggle tiling on/off.

Or using prefix commands:

  • Ctrl+B Space - Alternative
  • Ctrl+B t t - Via tiling prefix menu

The status bar shows "TILING" when enabled.

Auto-Tiling Behavior

When tiling is enabled, TUIOS automatically positions new windows:

First Window

Takes full screen

Second Window

Splits vertically (side-by-side)

Third Window

Splits horizontally (top/bottom on right side)

Fourth+ Windows

Spiral pattern (alternating V/H splits)

This spiral layout balances screen space naturally as you add windows.

BSP Concepts

The Split Tree

Internally, TUIOS maintains a binary tree for each workspace:

Root Split (Vertical) ├── Window 1 (left half) └── Split (Horizontal) ├── Window 2 (top-right quarter) └── Window 3 (bottom-right quarter)

Each split has a direction (vertical or horizontal) and a ratio determining how space is divided.

Split Direction Indicators

The dock shows the next split direction when tiling is active:

  • V - Next window splits vertically (left/right)
  • H - Next window splits horizontally (top/bottom)

This helps you predict where the next window will appear.

Manual Split Control

Rather than relying on automatic placement, you can manually split the focused window.

Create Splits

In Window Management Mode with a window focused:

KeyAction
Ctrl+B -Split horizontally (top/bottom)
Ctrl+B | or \Split vertically (left/right)

This divides the focused window's space in half, placing the focused window in one half and preparing space for a new window in the other half.

Workflow: Create a split, then create a new window with n. The new window appears in the prepared space.

Rotate Split Direction

To change an existing split's direction:

Press Ctrl+B R to rotate the split at the focused window.

This toggles the split containing the focused window between vertical and horizontal.

Example: Side-by-side windows become stacked, and vice versa.

Preselection

Preselection lets you control where the next window spawns relative to the focused window.

Preselection Commands

KeyAction
Alt+hNext window appears left
Alt+lNext window appears right
Alt+kNext window appears above
Alt+jNext window appears below

After preselecting, create a window normally with n. The preselection is consumed and resets.

Preselection only works when tiling mode is enabled. Press t to enable tiling first.

Use Case: Creating sidebar layouts, asymmetric designs, or inserting windows into specific locations in complex layouts.

Preselection Example

Start with one window

Press n to create it

Preselect left

Press Alt+h

Create sidebar

Press n - New window appears on the left

Resize sidebar

Press < multiple times to make it narrower

Result: Narrow sidebar on left, main area on right.

Window Swapping

Rearrange tiled windows without changing the split structure.

Swap Commands

KeyAction
Shift+H or Ctrl+Swap with window to the left
Shift+L or Ctrl+Swap with window to the right
Shift+K or Ctrl+Swap with window above
Shift+J or Ctrl+Swap with window below

Difference: h/j/k/l move focus. Shift + those keys swap windows.

Drag to Swap

Mouse users can drag windows in tiling mode. Dragging a window onto another swaps them.

Resizing in BSP Mode

Master Ratio Adjustment

Control the size of the main window area:

KeyAction
> or Shift+.Grow master area (from right edge)
< or Shift+,Shrink master area (from right edge)
. (period)Grow master area (from left edge)
, (comma)Shrink master area (from left edge)

Adjustment increment: 5% per keypress.

Height Adjustment

Control the vertical split ratio:

KeyAction
} or Shift+]Grow height (from bottom edge)
{ or Shift+[Shrink height (from bottom edge)
]Grow height (from top edge)
[Shrink height (from top edge)

Edge Control: The distinction between left/right and top/bottom edge resizing gives you precise control in complex layouts.

Advanced Operations

Equalize Splits

Reset all splits to equal proportions:

Press Ctrl+B = to equalize all splits.

This sets all split ratios to 50/50 throughout the entire tree, giving all windows equal space based on their position.

Useful when you've made many resize adjustments and want to start fresh with balanced spacing.

Practical Workflows

Workflow 1: Development Environment

Classic three-pane layout (editor + terminal + docs).

Enable tiling:

Press t

Create editor window:

Press n to create window, then i to enter terminal mode

vim main.go

Preselect right for terminal:

Press Ctrl+B d to return to window mode

Press Alt+l to preselect right

Press n to create terminal window, then i to enter it

go run .

Preselect below for logs:

Press Ctrl+B d then Tab to focus terminal

Press Alt+j to preselect below

Press n then i to create logs window

tail -f logs/app.log

Result:

┌──────────┬──────────┐ │ │ Terminal │ │ Editor ├──────────┤ │ │ Logs │ └──────────┴──────────┘

Workflow 2: Dashboard Grid

Four equal quadrants for monitoring.

Enable tiling and create first window:

Press t to enable tiling

Press n to create first window (full screen)

Split vertically for left/right:

Press Ctrl+B | to split vertically

Press n to create second window (right side)

Focus left and split horizontally:

Press Tab to focus left window

Press Ctrl+B - to split horizontally

Press n to create third window (bottom-left)

Focus top-right and split horizontally:

Press Tab twice to focus right side

Press Ctrl+B - to split horizontally

Press n to create fourth window (bottom-right)

Equalize all splits for perfect quadrants:

Press Ctrl+B =

Result:

┌─────┬─────┐ │ 1 │ 2 │ ├─────┼─────┤ │ 3 │ 4 │ └─────┴─────┘

Workflow 3: Ultrawide Layout

Three-column layout for ultrawide monitors.

Enable tiling and split vertically:

Press t to enable tiling

Press n to create first window (full screen)

Press Ctrl+B | to split vertically

Press n to create second window (right)

Split left side for third column:

Press Tab to focus first (left) window

Press Ctrl+B | to split left side vertically

Press n to create third window (middle)

Adjust widths for 1:2:1 ratio:

Press Tab twice to focus rightmost

Press < twice to shrink right column

Press Tab twice to focus leftmost

Press . twice to shrink left column

Result: Left sidebar, main area, right sidebar.

Workflow 4: Presenter Layout

Main presentation area with hidden notes.

Create main presentation window:

Press t to enable tiling

Press n to create main window

Press Alt+j to preselect below

Press n to create notes window

Shrink notes to minimal height:

Press { five times to shrink notes area

Result: Full screen presentation with a thin strip of notes at bottom.

Technical Details

BSP Tree Structure

Each workspace maintains a BSPTree with nodes of two types:

  • Leaf nodes: Contain a window ID
  • Internal nodes: Contain split direction (H/V), ratio (0.0-1.0), and two child nodes

Split Ratio Storage

Each internal node stores a ratio (default 0.5) representing the fraction of space given to the left/top child. Ratio range: 0.3 to 0.7 (enforced to prevent unusable layouts).

Layout Application

After tree modifications, TUIOS walks the tree recursively, calculating rectangles:

  1. Start with workspace dimensions
  2. At each split node, divide rectangle by ratio and direction
  3. At each leaf node, assign rectangle to corresponding window
  4. Apply all window geometry in a single batch

This prevents flicker and ensures atomic layout updates.

Troubleshooting

Windows Not Tiling

Check tiling is enabled - status bar should show "TILING". Press t to toggle.

Each workspace has independent tiling state. Switching workspaces may land you on a workspace with tiling disabled.

Unexpected Layout After Resize

Reset to balanced layout by pressing Ctrl+B = to equalize all splits.

Verify the correct window is focused. Resize operations affect the split containing the focused window.

Swap Not Working

Swap commands are directional. If there's no window in the specified direction, nothing happens.

Try mouse drag: Dragging one window onto another always swaps.

Preselection Not Applied

Preselection is one-time. After creating a window, preselection resets. You need to preselect again for the next window.

Press Esc in Window Management Mode to cancel a preselection without creating a window.

Comparison with Grid Tiling

BSP Advantages

  • Works with any number of windows (not limited to grid cells)
  • No wasted space with odd numbers of windows
  • Full control over layout
  • Each window can have different size

Grid Tiling

  • Fixed positions (1, 2, 3, 4 windows fit in grid cells)
  • Wasted space with odd numbers
  • Predictable but inflexible

TUIOS chose BSP for flexibility and space efficiency.

On this page