EN
RU
Portals
0.7.0 · dev
0.7.0 · dev (544a5c68c72e · 2026-11-28 UTC)
Toggle main menu visibility
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
7
namespace
portals::detail {
9
struct
TextMetadata
{
10
std::vector<Grapheme>
graphemes
;
11
std::vector<std::size_t>
wordStarts
;
12
std::int32_t
cells
{};
13
bool
lineSeparator
{};
14
};
15
25
std::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
37
std::expected<TextMetadata, TextError> scanTextMetadata(std::string_view bytes,
WidthPolicy
policy,
TextLimits
limits,
38
bool
collectWordStarts =
false
);
39
}
// namespace portals::detail
portals::graphemes
std::expected< TextSegments, TreeError > graphemes(const GraphemeText &input, TextSplitOptions options={})
Return one token for every existing extended grapheme, including whitespace.
portals::TextLimits
Owning limits checked without silently truncating input or clusters.
Definition
text.hpp:57
portals::WidthPolicy
Owning deterministic width policy; no font or terminal matching promise.
Definition
text.hpp:42
portals::detail::TextMetadata
Numeric Unicode metadata; never retains source bytes or decoded scalar strings.
Definition
text_metadata.hpp:9
portals::detail::TextMetadata::wordStarts
std::vector< std::size_t > wordStarts
Whole-cluster starts of alphanumeric/mark runs.
Definition
text_metadata.hpp:11
portals::detail::TextMetadata::graphemes
std::vector< Grapheme > graphemes
Whole-cluster byte boundaries and terminal widths.
Definition
text_metadata.hpp:10
portals::detail::TextMetadata::cells
std::int32_t cells
Checked total terminal cells.
Definition
text_metadata.hpp:12
portals::detail::TextMetadata::lineSeparator
bool lineSeparator
Input contained a separator excluded by one-line editors.
Definition
text_metadata.hpp:13
include
portals
detail
text_metadata.hpp