https://github.com/altsem/layzer
A Lightweight Terminal Layout Library
https://github.com/altsem/layzer
Last synced: 9 months ago
JSON representation
A Lightweight Terminal Layout Library
- Host: GitHub
- URL: https://github.com/altsem/layzer
- Owner: altsem
- Created: 2025-06-29T18:58:10.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-06-29T19:41:01.000Z (about 1 year ago)
- Last Synced: 2025-06-29T20:28:19.184Z (about 1 year ago)
- Language: Rust
- Size: 14.6 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# layzer
### A Lightweight Terminal Layout Library
**Work-in-progress, unfinished and broken, be warned**
```txt
Layzer is a zero-heap-allocation layout library for
building nested layouts with discrete positioning
and sizing.
It's designed for terminal UIs, text-based interfaces,
and any scenario where you need to compute positions and
sizes of rectangular elements.
- Zero heap allocations - - Hierarchical layouts -
All layout computation is done Support for nesting layouts
without dynamic memory allocation. and arranging children within them.
- Flexible sizing - - Axis-oriented layouts -
Auto-sizing based on content or Arrange children horizontally
fixed dimensions. children
vertically
```
### Quick Start
```rust
use layzer::{Layout, LayoutMeta, Axis};
// Create a text element
let text_layout = Layout::text("Hello, World!");
// Create a container with children
let mut container = Layout {
meta: LayoutMeta::default().vertical().gap(1),
children: &mut [
Layout::text("First line"),
Layout::text("Second line"),
],
};
// Compute layout within 80x24 bounds
container.compute([80, 24]);
// Iterate over computed positions and data with a stack-size of 8
for (position, text) in container.iter::<8>() {
println!("Text '{}' at position {:?}", text, position);
}
```
### Layout Structure
Layouts form a tree structure where each node can contain data and/or children.
The layout engine computes positions recursively, respecting the orientation
and sizing constraints of each node.