Portals0.7.0 · dev (544a5c68c72e · 2026-11-28 UTC)
Loading...
Searching...
No Matches
text_metadata.hpp
1// Copyright (c) 2026 ttldtor.
2// SPDX-License-Identifier: BSL-1.0
3#pragma once
4
5#include <portals/text.hpp>
6
7namespace portals::detail {
10 std::vector<Grapheme> graphemes;
11 std::vector<std::size_t> wordStarts;
12 std::int32_t cells{};
14};
15
25std::expected<std::int32_t, TextError> scanTextMetadataInto(std::string_view bytes, WidthPolicy policy,
26 TextLimits limits, std::vector<Grapheme> &graphemes,
27 std::vector<std::size_t> *wordStarts = nullptr,
28 bool *lineSeparator = nullptr);
29
37std::expected<TextMetadata, TextError> scanTextMetadata(std::string_view bytes, WidthPolicy policy, TextLimits limits,
38 bool collectWordStarts = false);
39} // namespace portals::detail
std::expected< TextSegments, TreeError > graphemes(const GraphemeText &input, TextSplitOptions options={})
Return one token for every existing extended grapheme, including whitespace.
Owning limits checked without silently truncating input or clusters.
Definition text.hpp:57
Owning deterministic width policy; no font or terminal matching promise.
Definition text.hpp:42
Numeric Unicode metadata; never retains source bytes or decoded scalar strings.
Definition text_metadata.hpp:9
std::vector< std::size_t > wordStarts
Whole-cluster starts of alphanumeric/mark runs.
Definition text_metadata.hpp:11
std::vector< Grapheme > graphemes
Whole-cluster byte boundaries and terminal widths.
Definition text_metadata.hpp:10
std::int32_t cells
Checked total terminal cells.
Definition text_metadata.hpp:12
bool lineSeparator
Input contained a separator excluded by one-line editors.
Definition text_metadata.hpp:13