7#include "ucd_grapheme_cluster_breaks.hpp"
8#include "unicode_break_opportunity.hpp"
9#include "../macros.hpp"
13hi_export_module(hikogui.unicode.unicode_grapheme_cluster_break);
15hi_export
namespace hi {
inline namespace v1 {
19 unicode_grapheme_cluster_break previous = unicode_grapheme_cluster_break::Other;
21 bool first_character =
true;
22 bool in_extended_pictograph =
false;
24 constexpr void reset()
noexcept
26 previous = unicode_grapheme_cluster_break::Other;
28 first_character =
true;
29 in_extended_pictograph =
false;
43 using enum unicode_grapheme_cluster_break;
45 auto const lhs = state.previous;
57 bool GB1 = state.first_character;
62 state.first_character =
false;
65 auto const GB3 = (lhs == CR) && (rhs == LF);
66 auto const GB4 = (lhs == Control) || (lhs == CR) || (lhs == LF);
67 auto const GB5 = (rhs == Control) || (rhs == CR) || (rhs == LF);
77 auto const GB6 = (lhs == L) && ((rhs == L) || (rhs == V) || (rhs == LV) | (rhs == LVT));
78 auto const GB7 = ((lhs == LV) || (lhs == V)) && ((rhs == V) || (rhs == T));
79 auto const GB8 = ((lhs == LVT) || (lhs == T)) && (rhs == T);
85 auto const GB9 = ((rhs == Extend) || (rhs == ZWJ));
89 auto const GB9a = (rhs == SpacingMark);
90 auto const GB9b = (lhs == Prepend);
96 auto const GB11 = state.in_extended_pictograph && (lhs == ZWJ) && (rhs == Extended_Pictographic);
101 if (rhs == Extended_Pictographic) {
102 state.in_extended_pictograph =
true;
103 }
else if (!((rhs == Extend) || (rhs == ZWJ))) {
104 state.in_extended_pictograph =
false;
110 auto const GB12_13 = (lhs == Regional_Indicator) && (rhs == Regional_Indicator) && ((state.RI_count % 2) == 1);
115 if (rhs == Regional_Indicator) {
126 state.previous = rhs;
137[[
nodiscard]]
constexpr bool breaks_grapheme(
char32_t code_point, grapheme_break_state& state)
noexcept
139 return breaks_grapheme(ucd_get_grapheme_cluster_break(code_point), state);
144template<
typename It,
typename ItEnd>
148 auto state = detail::grapheme_break_state{};
150 for (
auto it = first;
it != last; ++
it) {
151 auto const opportunity = detail::breaks_grapheme(*
it, state) ? unicode_break_opportunity::yes : unicode_break_opportunity::no;
155 r.push_back(unicode_break_opportunity::yes);
DOXYGEN BUG.
Definition algorithm_misc.hpp:20
The HikoGUI namespace.
Definition recursive_iterator.hpp:15
constexpr Out narrow_cast(In const &rhs) noexcept
Cast numeric values without loss of precision.
Definition cast.hpp:378
Definition unicode_grapheme_cluster_break.hpp:18