This repository was archived by the owner on Aug 24, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
This repository was archived by the owner on Aug 24, 2025. It is now read-only.
Improve text wrapping #2
Copy link
Copy link
Open
0 / 10 of 1 issue completedDescription
Currently word-wrapping can be achieved by first splitting a text into multiple "rectangles of words" via Layout::text:
let mut layout = Layout {
meta: LayoutMeta::default(),
children: &mut "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."
.split_word_bounds()
.map(Layout::text)
.collect::<Vec<_>>(),
};
layout.compute([20, 20]);
layout.iter()...An idea is to instead compute the size and position (perform text wrapping) only when looking at
the text.
let mut layout = Layout {
meta: LayoutMeta::default()
.data("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."),
children: &mut [],
};
layout.compute([20, 20]); // Need to materialize the text wrapping, in order to measure the size/position
layout.iter() // And again herecompute and iter should probably be merged into a single function...
Will likely want to support
- Word wrap
- Plain per-character (grapheme) wrap
- Some kind of hybrid?
Reactions are currently unavailable
Sub-issues
Metadata
Metadata
Assignees
Labels
No labels