11#include "../utility/module.hpp"
15namespace hi::inline
v1 {
101constexpr auto text_phrasing_metadata = enum_metadata{
102 text_phrasing::regular,
"regular",
103 text_phrasing::emphesis,
"emphesis",
104 text_phrasing::strong,
"strong",
105 text_phrasing::code,
"code",
106 text_phrasing::abbreviation,
"abbreviation",
107 text_phrasing::quote,
"quote",
108 text_phrasing::keyboard,
"keyboard",
109 text_phrasing::highlight,
"highlight",
110 text_phrasing::math,
"math",
111 text_phrasing::example,
"example",
112 text_phrasing::unarticulated,
"unarticulated",
113 text_phrasing::title,
"title",
114 text_phrasing::success,
"success",
115 text_phrasing::warning,
"warning",
116 text_phrasing::error,
"error",
119static_assert(text_phrasing_metadata.size() <= 15,
"The mask of a text_phrasing is 16-bit");
122[[nodiscard]]
constexpr std::optional<text_phrasing> to_text_phrasing(
char c)
125 case 'r':
return text_phrasing::regular;
126 case 'e':
return text_phrasing::emphesis;
127 case 's':
return text_phrasing::strong;
128 case 'c':
return text_phrasing::code;
129 case 'a':
return text_phrasing::abbreviation;
130 case 'q':
return text_phrasing::quote;
131 case 'k':
return text_phrasing::keyboard;
132 case 'h':
return text_phrasing::highlight;
133 case 'm':
return text_phrasing::math;
134 case 'x':
return text_phrasing::example;
135 case 'u':
return text_phrasing::unarticulated;
136 case 't':
return text_phrasing::title;
137 case 'S':
return text_phrasing::success;
138 case 'W':
return text_phrasing::warning;
139 case 'E':
return text_phrasing::error;
146enum class text_phrasing_mask : uint16_t {
147 regular = 1 << to_underlying(text_phrasing::regular),
148 emphesis = 1 << to_underlying(text_phrasing::emphesis),
149 strong = 1 << to_underlying(text_phrasing::strong),
150 code = 1 << to_underlying(text_phrasing::code),
151 abbreviation = 1 << to_underlying(text_phrasing::abbreviation),
152 quote = 1 << to_underlying(text_phrasing::quote),
153 keyboard = 1 << to_underlying(text_phrasing::keyboard),
154 highlight = 1 << to_underlying(text_phrasing::highlight),
155 math = 1 << to_underlying(text_phrasing::math),
156 example = 1 << to_underlying(text_phrasing::example),
157 unarticulated = 1 << to_underlying(text_phrasing::unarticulated),
158 title = 1 << to_underlying(text_phrasing::title),
159 success = 1 << to_underlying(text_phrasing::success),
160 warning = 1 << to_underlying(text_phrasing::warning),
161 error = 1 << to_underlying(text_phrasing::error),
167[[nodiscard]]
constexpr text_phrasing_mask operator&(text_phrasing_mask
const& lhs, text_phrasing_mask
const& rhs)
noexcept
169 return static_cast<text_phrasing_mask
>(to_underlying(lhs) & to_underlying(rhs));
172[[nodiscard]]
constexpr text_phrasing_mask operator|(text_phrasing_mask
const& lhs, text_phrasing_mask
const& rhs)
noexcept
174 return static_cast<text_phrasing_mask
>(to_underlying(lhs) | to_underlying(rhs));
177[[nodiscard]]
constexpr text_phrasing_mask to_text_phrasing_mask(text_phrasing
const& rhs)
noexcept
179 hi_axiom(to_underlying(rhs) <
sizeof(text_phrasing_mask) * CHAR_BIT);
180 return static_cast<text_phrasing_mask
>(1 << to_underlying(rhs));
183[[nodiscard]]
constexpr text_phrasing_mask to_text_phrasing_mask(
std::string const& str)
185 auto r = text_phrasing_mask{};
187 for (
hilet c : str) {
189 r = text_phrasing_mask::all;
190 }
else if (
hilet p = to_text_phrasing(c)) {
191 r = r | to_text_phrasing_mask(*p);
193 throw parse_error(std::format(
"Unknown character '{}' in text-phrasing-mask", c));
200[[nodiscard]]
constexpr bool all(text_phrasing_mask
const& rhs)
noexcept
202 return (rhs & text_phrasing_mask::all) == text_phrasing_mask::all;
205[[nodiscard]]
constexpr bool to_bool(text_phrasing_mask
const& rhs)
noexcept
207 return to_bool(to_underlying(rhs));
218 return to_bool(lhs & to_text_phrasing_mask(rhs));
#define hi_axiom(expression,...)
Specify an axiom; an expression that is true.
Definition assert.hpp:253
#define hilet
Invariant should be the default for variables.
Definition utility.hpp:23
@ keyboard
The gui_event has keyboard data.
text_phrasing
Text phrasing.
Definition text_phrasing.hpp:22
@ 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.
@ warning
Format a warning message Often in bright yellow.
@ math
Text formatted as math.
@ code
Text is a piece of programming-code; a variable name, a function name.
@ abbreviation
An abbreviation.
@ error
Format a "bad" message Often in bright red.
@ title
Format a heading Often in bold, larger font and on a line by itself.
DOXYGEN BUG.
Definition algorithm.hpp:13
@ regular
400: Normal / Regular
constexpr bool matches(text_phrasing_mask const &lhs, text_phrasing const &rhs) noexcept
Check if the text-phrasing is included in the text-phrasing-mask.
Definition text_phrasing.hpp:216