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.hpp"
9#include "../cast.hpp"
10#include "../enum_metadata.hpp"
11#include <cstdint>
12
13namespace hi::inline v1 {
14
15enum class text_phrasing {
16 regular,
17 emphesis,
18 strong,
19 code,
20 abbreviation,
21 bold,
22 italic,
23 citation,
24 keyboard,
25 mark,
26 math,
27 example,
29};
30
31// clang-format off
32constexpr auto text_phrasing_metadata = enum_metadata{
33 text_phrasing::regular, "regular",
34 text_phrasing::emphesis, "emphesis",
35 text_phrasing::strong, "strong",
36 text_phrasing::code, "code",
37 text_phrasing::abbreviation, "abbreviation",
38 text_phrasing::bold, "bold",
39 text_phrasing::italic, "italic",
40 text_phrasing::citation, "citation",
41 text_phrasing::keyboard, "keyboard",
42 text_phrasing::mark, "mark",
43 text_phrasing::math, "math",
44 text_phrasing::example, "example",
45 text_phrasing::unarticulated, "unarticulated",
46};
47// clang-format on
48
49enum class text_phrasing_mask : uint16_t {
50 regular = 1 << to_underlying(text_phrasing::regular),
51 emphesis = 1 << to_underlying(text_phrasing::emphesis),
52 strong = 1 << to_underlying(text_phrasing::strong),
53 code = 1 << to_underlying(text_phrasing::code),
54 abbreviation = 1 << to_underlying(text_phrasing::abbreviation),
55 bold = 1 << to_underlying(text_phrasing::bold),
56 italic = 1 << to_underlying(text_phrasing::italic),
57 citation = 1 << to_underlying(text_phrasing::citation),
58 keyboard = 1 << to_underlying(text_phrasing::keyboard),
59 mark = 1 << to_underlying(text_phrasing::mark),
60 math = 1 << to_underlying(text_phrasing::math),
61 example = 1 << to_underlying(text_phrasing::example),
62 unarticulated = 1 << to_underlying(text_phrasing::unarticulated),
63
64 all = regular | emphesis | strong | code | abbreviation | bold | italic | citation | keyboard | mark | math | example |
66};
67
68[[nodiscard]] constexpr text_phrasing_mask to_text_phrasing_mask(text_phrasing const& rhs) noexcept
69{
70 hi_axiom(to_underlying(rhs) < sizeof(text_phrasing_mask) * CHAR_BIT);
71 return static_cast<text_phrasing_mask>(1 << to_underlying(rhs));
72}
73
74[[nodiscard]] constexpr text_phrasing_mask operator&(text_phrasing_mask const& lhs, text_phrasing_mask const& rhs) noexcept
75{
76 return static_cast<text_phrasing_mask>(to_underlying(lhs) & to_underlying(rhs));
77}
78
79[[nodiscard]] constexpr text_phrasing_mask operator|(text_phrasing_mask const& lhs, text_phrasing_mask const& rhs) noexcept
80{
81 return static_cast<text_phrasing_mask>(to_underlying(lhs) | to_underlying(rhs));
82}
83
84[[nodiscard]] constexpr bool all(text_phrasing_mask const& rhs) noexcept
85{
86 return (rhs & text_phrasing_mask::all) == text_phrasing_mask::all;
87}
88
89[[nodiscard]] constexpr bool to_bool(text_phrasing_mask const& rhs) noexcept
90{
91 return to_bool(to_underlying(rhs));
92}
93
94} // namespace hi::inline v1
Utilities used by the HikoGUI library itself.
@ keyboard
The gui_event has keyboard data.
DOXYGEN BUG.
Definition algorithm.hpp:15
constexpr alignment operator|(horizontal_alignment lhs, vertical_alignment rhs) noexcept
Combine vertical and horizontal alignment.
Definition alignment.hpp:200
text_phrasing
Definition text_phrasing.hpp:15
@ example
Used for displaying console output.
@ unarticulated
underlined
@ mark
Yellow highlight.