1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//! Atom segmentation (width-aware layout units).
//!
//! This module defines [`atoms()`], a runefix-specific alternative to graphemes.
//! It segments a string into visual display units for terminal and TUI rendering.
//!
//! This helps solve alignment bugs in monospaced environments caused by emoji and CJK widths.
use crateRuneDisplayWidth;
/// Splits the input string into **layout atoms** — visual units used for width-aware layout.
///
/// This is a **runefix-specific segmentation**, based on actual display width, not linguistic boundaries.
/// It differs from [`graphemes()`] (which follows Unicode UAX #29) by focusing purely on units that affect layout:
///
/// - Characters with width = 0 (e.g., combining marks, control codes) are grouped with their leading base
/// - Emoji sequences (e.g. ZWJ, variation selectors) are preserved as atomic units
/// - Output is suitable for TUI rendering, Markdown table layout, and CLI alignment
///
/// # Example
/// ```
/// use runefix_core::atoms;
/// assert_eq!(atoms("👩❤️💋👨"), vec!["👩", "\u{200d}", "❤", "\u{fe0f}", "\u{200d}", "💋", "\u{200d}", "👨"]);
/// ```
///
/// # Note
/// This function is **not** Unicode-compliant segmentation. For that, see [`graphemes()`].