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_width::UnicodeWidthChar;
11use unicode_width::UnicodeWidthStr;
12
13mod collect;
14mod command;
15mod flexbox;
16mod render;
17mod tree;
18
19pub(crate) use collect::{collect_all, FrameData};
20pub use command::Direction;
21pub(crate) use command::{BeginContainerArgs, BeginScrollableArgs, Command};
22pub(crate) use flexbox::compute;
23pub(crate) use render::{render, render_debug_overlay};
24pub(crate) use tree::{build_tree, wrap_lines, wrap_segments, LayoutNode, NodeKind};
25
26/// Test-only entry point exposing `wrap_segments` for allocation-budget tests.
27///
28/// Not part of the stable API. Used by `tests/v020_perf_alloc.rs`.
29#[doc(hidden)]
30pub fn __bench_wrap_segments(
31    segments: &[(String, Style)],
32    max_width: u32,
33) -> Vec<Vec<(String, Style)>> {
34    tree::wrap_segments(segments, max_width)
35}
36
37/// Test-only entry point exposing the modal-aware dim path.
38///
39/// Not part of the stable API. Used by `tests/v020_perf_alloc.rs` and the
40/// `examples/v020_perf_audit` demo.
41#[doc(hidden)]
42pub fn __bench_dim_buffer_around(buf: &mut Buffer, modal_rect: Rect) {
43    render::__bench_dim_buffer_around(buf, modal_rect);
44}
45
46#[cfg(test)]
47mod tests;