11#include "../utility/utility.hpp"
12#include "../macros.hpp"
109constexpr auto phrasing_metadata = enum_metadata{
110 phrasing::regular,
"regular",
111 phrasing::emphesis,
"emphesis",
112 phrasing::strong,
"strong",
113 phrasing::code,
"code",
114 phrasing::abbreviation,
"abbreviation",
115 phrasing::quote,
"quote",
116 phrasing::keyboard,
"keyboard",
117 phrasing::highlight,
"highlight",
118 phrasing::math,
"math",
119 phrasing::example,
"example",
120 phrasing::unarticulated,
"unarticulated",
121 phrasing::title,
"title",
122 phrasing::success,
"success",
123 phrasing::warning,
"warning",
124 phrasing::error,
"error",
129[[
nodiscard]]
constexpr std::optional<phrasing> to_phrasing(
char c)
132 case 'r':
return phrasing::regular;
133 case 'e':
return phrasing::emphesis;
134 case 's':
return phrasing::strong;
135 case 'c':
return phrasing::code;
136 case 'a':
return phrasing::abbreviation;
137 case 'q':
return phrasing::quote;
138 case 'k':
return phrasing::keyboard;
139 case 'h':
return phrasing::highlight;
140 case 'm':
return phrasing::math;
141 case 'x':
return phrasing::example;
142 case 'u':
return phrasing::unarticulated;
143 case 't':
return phrasing::title;
144 case 'S':
return phrasing::success;
145 case 'W':
return phrasing::warning;
146 case 'E':
return phrasing::error;
153enum class phrasing_mask : uint16_t {
154 regular = 1 << std::to_underlying(phrasing::regular),
155 emphesis = 1 << std::to_underlying(phrasing::emphesis),
156 strong = 1 << std::to_underlying(phrasing::strong),
157 code = 1 << std::to_underlying(phrasing::code),
158 abbreviation = 1 << std::to_underlying(phrasing::abbreviation),
159 quote = 1 << std::to_underlying(phrasing::quote),
160 keyboard = 1 << std::to_underlying(phrasing::keyboard),
161 highlight = 1 << std::to_underlying(phrasing::highlight),
162 math = 1 << std::to_underlying(phrasing::math),
163 example = 1 << std::to_underlying(phrasing::example),
164 unarticulated = 1 << std::to_underlying(phrasing::unarticulated),
165 title = 1 << std::to_underlying(phrasing::title),
166 success = 1 << std::to_underlying(phrasing::success),
167 warning = 1 << std::to_underlying(phrasing::warning),
168 error = 1 << std::to_underlying(phrasing::error),
171 title | success | warning | error
175 std::bit_width(phrasing_metadata.size() - 1) <=
sizeof(std::underlying_type_t<phrasing_mask>) *
CHAR_BIT,
176 "All phrasings must fit the phrasing_mask.");
178[[
nodiscard]]
constexpr phrasing_mask operator&(phrasing_mask
const& lhs, phrasing_mask
const& rhs)
noexcept
180 return static_cast<phrasing_mask
>(std::to_underlying(lhs) & std::to_underlying(rhs));
183[[
nodiscard]]
constexpr phrasing_mask operator|(phrasing_mask
const& lhs, phrasing_mask
const& rhs)
noexcept
185 return static_cast<phrasing_mask
>(std::to_underlying(lhs) | std::to_underlying(rhs));
188[[
nodiscard]]
constexpr phrasing_mask to_phrasing_mask(phrasing
const& rhs)
noexcept
190 hi_axiom(std::to_underlying(rhs) <
sizeof(phrasing_mask) *
CHAR_BIT);
191 return static_cast<phrasing_mask
>(1 << std::to_underlying(rhs));
196 auto r = phrasing_mask{};
198 for (hilet c : str) {
200 r = phrasing_mask::all;
201 }
else if (hilet p = to_phrasing(c)) {
202 r = r | to_phrasing_mask(*p);
204 throw parse_error(std::format(
"Unknown character '{}' in text-phrasing-mask", c));
211[[
nodiscard]]
constexpr bool all(phrasing_mask
const& rhs)
noexcept
213 return (rhs & phrasing_mask::all) == phrasing_mask::all;
216[[
nodiscard]]
constexpr bool to_bool(phrasing_mask
const& rhs)
noexcept
218 return to_bool(std::to_underlying(rhs));
229 return to_bool(lhs & to_phrasing_mask(rhs));
@ keyboard
The gui_event has keyboard data.
phrasing
Phrasing.
Definition phrasing.hpp:30
@ example
Used in help text to show an example.
@ highlight
The text is marked or highlighted as if being marked by a highlight pen.
@ unarticulated
Unarticulated.
@ strong
Strong text; spoken louder, as if the text is not to be missed.
@ emphesis
Emphesised text; spoken as if the text is special importance, significant or promonent.
@ math
Text formatted as math.
@ code
Text is a piece of programming-code; a variable name, a function name.
@ abbreviation
An abbreviation.
@ title
Format a heading Often in bold, larger font and on a line by itself.
DOXYGEN BUG.
Definition algorithm.hpp:16
@ regular
400: Normal / Regular
constexpr bool matches(phrasing_mask const &lhs, phrasing const &rhs) noexcept
Check if the text-phrasing is included in the text-phrasing-mask.
Definition phrasing.hpp:227
constexpr Out narrow_cast(In const &rhs) noexcept
Cast numeric values without loss of precision.
Definition cast.hpp:377