Skip to main content

slt/
layout.rs

1//! Flexbox layout engine: builds a tree from commands, computes positions,
2//! and renders to a [`Buffer`].
3
4use crate::buffer::Buffer;
5use crate::rect::Rect;
6use crate::style::{
7    Align, Border, BorderSides, Color, Constraints, HeightSpec, Justify, Margin, Padding, Style,
8    WidthSpec,
9};
10use unicode_segmentation::UnicodeSegmentation;
11use unicode_width::UnicodeWidthChar;
12use unicode_width::UnicodeWidthStr;
13
14mod collect;
15mod command;
16mod flexbox;
17mod render;
18mod tree;
19
20pub(crate) use collect::{FrameData, collect_all};
21pub use command::Direction;
22pub(crate) use command::{BeginContainerArgs, BeginScrollableArgs, Command};
23pub(crate) use flexbox::compute;
24pub(crate) use render::{InspectorFocus, render, render_debug_overlay, render_inspector};
25pub(crate) use tree::{LayoutNode, NodeKind, build_tree, wrap_lines, wrap_segments};
26
27/// Test-only entry point exposing `wrap_segments` for allocation-budget tests.
28///
29/// Not part of the stable API. Used by `tests/v020_perf_alloc.rs`.
30#[doc(hidden)]
31pub fn __bench_wrap_segments(
32    segments: &[(String, Style)],
33    max_width: u32,
34) -> Vec<Vec<(String, Style)>> {
35    tree::wrap_segments(segments, max_width)
36}
37
38/// Test-only entry point exposing the modal-aware dim path.
39///
40/// Not part of the stable API. Used by `tests/v020_perf_alloc.rs` and the
41/// `examples/v020_perf_audit` demo.
42#[doc(hidden)]
43pub fn __bench_dim_buffer_around(buf: &mut Buffer, modal_rect: Rect) {
44    render::__bench_dim_buffer_around(buf, modal_rect);
45}
46
47#[cfg(test)]
48mod tests;