ratatui-spatial-splits
Pure geometry engine for spatial split management in ratatui applications.
ratatui-spatial-splits provides a SplitManager that manages a binary tree of horizontal and vertical splits, computing accurate areas for each leaf. It handles spatial navigation (beam/raycasting), tree mutations (split, close, resize), and area caching with automatic invalidation.
Check out the docs for more info.
Usage
Add ratatui-spatial-splits to your Cargo.toml:
[]
= "0.1.0"
Split Management
SplitManager handles a binary tree of splits — adding, removing, resizing, and navigating between areas:
use ;
use Rect;
let mut mgr = new;
// Set the viewport.
mgr.set_viewport;
// Split the initial leaf vertically (left/right).
let result = mgr.split_vertical.unwrap;
assert_eq!;
// Split the right leaf horizontally (top/bottom).
mgr.split_horizontal.unwrap;
// Retrieve computed areas for all leaves.
let areas = mgr.areas;
assert_eq!;
// Navigate between areas using spatial raycasting.
let neighbor = mgr.navigate;
assert_eq!;
// Resize a split.
mgr.resize;
// Close an area (sibling replaces parent).
let result = mgr.close.unwrap;
assert_eq!;