16struct EditStorageAccess;
188 [[nodiscard]] std::string_view
bytes() const noexcept;
196 [[nodiscard]] std::int32_t
measure() const noexcept;
224 friend struct detail::EditStorageAccess;
227 std::
string bytes_ = std::
string(0,
'\0');
230 std::int32_t cells_{};
TextClip clipPrefix(std::int32_t max_cells) const noexcept
Return the maximal prefix fitting a cell budget, stopping before a wide cluster that cannot fit.
bool operator==(const GraphemeText &other) const noexcept
Compare logical UTF-8 bytes and the complete captured width policy without allocating.
GraphemeText & operator=(const GraphemeText &other)
Replace storage with an independent copy; invalidates borrowed views.
std::span< const Grapheme > graphemes() const noexcept
Borrow metadata until this object's assignment/move/destruction.
std::expected< std::size_t, TextError > previousCursor(std::size_t byte_offset) const noexcept
Retreat a byte-boundary cursor by one cluster; zero stays at zero.
GraphemeText(GraphemeText &&other)
Transfer storage and empty the source; may allocate debug bookkeeping before changing the source.
GraphemeText & operator=(GraphemeText &&other) noexcept
Transfer storage; invalidates both objects' views and empties a distinct source. Self-move is a no-op...
std::expected< std::size_t, TextError > nextCursor(std::size_t byte_offset) const noexcept
Advance a byte-boundary cursor by one cluster; end stays at end.
WidthPolicy policy() const noexcept
Return the owning captured cache-key policy; no errors.
std::int32_t measure() const noexcept
Return cached int32_t-compatible total cells; no allocation or errors.
std::string_view bytes() const noexcept
Borrow original bytes until this object's assignment/move/destruction.
static std::expected< GraphemeText, TextError > from(std::string_view bytes, WidthPolicy policy={}, TextLimits limits={})
Validate, segment and measure a single logical UTF-8 buffer.
GraphemeText(const GraphemeText &other)=default
Copy bytes and metadata into independent storage; may allocate.
Public Portals API.
Definition action.hpp:8
@ PRINTABLE
ASCII graphic character.
Definition document_hex.hpp:20
@ UNSUPPORTED
The application explicitly excludes this annotated phase.
Definition key_binding.hpp:44
EmojiWidth
Terminal policy for recognized emoji clusters, including single emoji.
Definition text.hpp:28
@ TWO
Use two cells.
Definition text.hpp:32
@ ONE
Use one cell.
Definition text.hpp:30
AmbiguousWidth
Terminal policy for printable East Asian Ambiguous scalars.
Definition text.hpp:20
@ NARROW
Use one cell.
Definition text.hpp:22
@ WIDE
Use two cells.
Definition text.hpp:24
TextDisplay
How a cell renderer must display a complete logical cluster.
Definition text.hpp:103
TextErrorKind
Observable text construction/cursor failure.
Definition text.hpp:69
@ CLUSTER_LIMIT
One whole cluster exceeds its byte limit.
Definition text.hpp:75
@ NOT_BOUNDARY
A cursor offset is outside the text or inside a cluster.
Definition text.hpp:83
@ GRAPHEME_LIMIT
The number of clusters exceeds its limit.
Definition text.hpp:77
@ INPUT_LIMIT
Input bytes exceed the selected budget.
Definition pss_data.hpp:155
@ INVALID_UTF8
Invalid UTF-8 sequence anywhere in strict input.
Definition pss_data.hpp:162
@ CELL_LIMIT
Checked cell product exceeds the cap or representation.
Definition cell_buffer.hpp:144
@ INVALID_POLICY
An unrecognized width policy value.
Definition cell_buffer.hpp:138
Owning metadata for a half-open UTF-8 byte range.
Definition text.hpp:111
std::size_t byte_begin
Inclusive byte offset in GraphemeText::bytes().
Definition text.hpp:113
std::uint8_t cells
One or two cells, including a one-cell unsupported placeholder.
Definition text.hpp:117
std::size_t byte_end
Exclusive byte offset in GraphemeText::bytes().
Definition text.hpp:115
TextDisplay display
Renderer disposition; preserves the original logical bytes.
Definition text.hpp:119
Owning metadata for the maximal whole-cluster prefix in a cell budget.
Definition text.hpp:123
std::size_t graphemes
Number of included clusters.
Definition text.hpp:127
std::size_t byte_end
Exclusive byte end at an extended grapheme boundary.
Definition text.hpp:125
std::int32_t cells
Measured cells in the prefix.
Definition text.hpp:129
Owning error value, independent of the failed input's lifetime.
Definition text.hpp:87
bool operator==(const TextError &other) const noexcept=default
Compare category and byte offset.
std::size_t byte_offset
Byte offset of an invalid sequence, rejected cluster or cursor. Input-limit and invalid-policy errors...
Definition text.hpp:94
TextErrorKind kind
Failure category.
Definition text.hpp:89
Owning limits checked without silently truncating input or clusters.
Definition text.hpp:57
std::size_t max_cells
Maximum measured cells; additionally bounded by INT32_MAX.
Definition text.hpp:65
std::size_t max_cluster_bytes
Maximum bytes in one extended grapheme cluster.
Definition text.hpp:61
std::size_t max_input_bytes
Maximum input bytes; also bounded by PTRDIFF_MAX.
Definition text.hpp:59
std::size_t max_graphemes
Maximum cluster records.
Definition text.hpp:63
Owning deterministic width policy; no font or terminal matching promise.
Definition text.hpp:42
EmojiWidth emoji
Width of recognized emoji clusters.
Definition text.hpp:46
std::uint64_t revision
Caller-owned terminal capability revision, included in equality.
Definition text.hpp:48
bool operator==(const WidthPolicy &other) const noexcept=default
Compare the full cache-key policy.
AmbiguousWidth ambiguous
Width of printable Ambiguous scalars.
Definition text.hpp:44