HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
text_phrasing.hpp
1// Copyright Take Vos 2022.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
5
6#pragma once
7
8#include "../utility/module.hpp"
9#include <cstdint>
10
11namespace hi::inline v1 {
12
13enum class text_phrasing {
14 regular,
15 emphesis,
16 strong,
17 code,
18 abbreviation,
19 bold,
20 italic,
21 citation,
22 keyboard,
23 mark,
24 math,
25 example,
27};
28
29// clang-format off
30constexpr auto text_phrasing_metadata = enum_metadata{
31 text_phrasing::regular, "regular",
32 text_phrasing::emphesis, "emphesis",
33 text_phrasing::strong, "strong",
34 text_phrasing::code, "code",
35 text_phrasing::abbreviation, "abbreviation",
36 text_phrasing::bold, "bold",
37 text_phrasing::italic, "italic",
38 text_phrasing::citation, "citation",
39 text_phrasing::keyboard, "keyboard",
40 text_phrasing::mark, "mark",
41 text_phrasing::math, "math",
42 text_phrasing::example, "example",
43 text_phrasing::unarticulated, "unarticulated",
44};
45// clang-format on
46
47enum class text_phrasing_mask : uint16_t {
48 regular = 1 << to_underlying(text_phrasing::regular),
49 emphesis = 1 << to_underlying(text_phrasing::emphesis),
50 strong = 1 << to_underlying(text_phrasing::strong),
51 code = 1 << to_underlying(text_phrasing::code),
52 abbreviation = 1 << to_underlying(text_phrasing::abbreviation),
53 bold = 1 << to_underlying(text_phrasing::bold),
54 italic = 1 << to_underlying(text_phrasing::italic),
55 citation = 1 << to_underlying(text_phrasing::citation),
56 keyboard = 1 << to_underlying(text_phrasing::keyboard),
57 mark = 1 << to_underlying(text_phrasing::mark),
58 math = 1 << to_underlying(text_phrasing::math),
59 example = 1 << to_underlying(text_phrasing::example),
60 unarticulated = 1 << to_underlying(text_phrasing::unarticulated),
61
62 all = regular | emphesis | strong | code | abbreviation | bold | italic | citation | keyboard | mark | math | example |
64};
65
66[[nodiscard]] constexpr text_phrasing_mask to_text_phrasing_mask(text_phrasing const& rhs) noexcept
67{
68 hi_axiom(to_underlying(rhs) < sizeof(text_phrasing_mask) * CHAR_BIT);
69 return static_cast<text_phrasing_mask>(1 << to_underlying(rhs));
70}
71
72[[nodiscard]] constexpr text_phrasing_mask operator&(text_phrasing_mask const& lhs, text_phrasing_mask const& rhs) noexcept
73{
74 return static_cast<text_phrasing_mask>(to_underlying(lhs) & to_underlying(rhs));
75}
76
77[[nodiscard]] constexpr text_phrasing_mask operator|(text_phrasing_mask const& lhs, text_phrasing_mask const& rhs) noexcept
78{
79 return static_cast<text_phrasing_mask>(to_underlying(lhs) | to_underlying(rhs));
80}
81
82[[nodiscard]] constexpr bool all(text_phrasing_mask const& rhs) noexcept
83{
84 return (rhs & text_phrasing_mask::all) == text_phrasing_mask::all;
85}
86
87[[nodiscard]] constexpr bool to_bool(text_phrasing_mask const& rhs) noexcept
88{
89 return to_bool(to_underlying(rhs));
90}
91
92} // namespace hi::inline v1
#define hi_axiom(expression,...)
Specify an axiom; an expression that is true.
Definition assert.hpp:238
@ keyboard
The gui_event has keyboard data.
DOXYGEN BUG.
Definition algorithm.hpp:13
text_phrasing
Definition text_phrasing.hpp:13
@ example
Used for displaying console output.
@ unarticulated
underlined
@ mark
Yellow highlight.