HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
semantic_color.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#pragma once
6
7#include "../enum_metadata.hpp"
8#include <array>
9
10namespace hi::inline v1 {
11
12enum class semantic_color : unsigned char {
13 blue,
14 green,
15 indigo,
16 orange,
17 pink,
18 purple,
19 red,
20 teal,
21 yellow,
22
23 gray,
24 gray2,
25 gray3,
26 gray4,
27 gray5,
28 gray6,
29
30 foreground,
31 border,
32 fill,
33 accent,
34 text_select,
35 primary_cursor,
36 secondary_cursor,
37};
38
39// clang-format off
40constexpr auto semantic_color_metadata = enum_metadata{
41 semantic_color::blue, "blue",
42 semantic_color::green, "green",
43 semantic_color::indigo, "indigo",
44 semantic_color::orange, "orange",
45 semantic_color::pink, "pink",
46 semantic_color::purple, "purple",
47 semantic_color::red, "red",
48 semantic_color::teal, "teal",
49 semantic_color::yellow, "yellow",
50 semantic_color::gray, "gray",
51 semantic_color::gray2, "gray2",
52 semantic_color::gray3, "gray3",
53 semantic_color::gray4, "gray4",
54 semantic_color::gray5, "gray5",
55 semantic_color::gray6, "gray6",
56 semantic_color::foreground, "foreground",
57 semantic_color::border, "border",
58 semantic_color::fill, "fill",
59 semantic_color::accent, "accent",
60 semantic_color::text_select, "text-select",
61 semantic_color::primary_cursor, "primary-cursor",
62 semantic_color::secondary_cursor, "secondary-cursor",
63};
64
65// clang-format on
66
67[[nodiscard]] inline std::string_view to_string(semantic_color rhs) noexcept
68{
69 return semantic_color_metadata[rhs];
70}
71
72
73[[nodiscard]] inline semantic_color semantic_color_from_string(std::string_view str)
74{
75 return semantic_color_metadata[str];
76}
77
78} // namespace hi::inline v1
79
80template<typename CharT>
81struct std::formatter<hi::semantic_color, CharT> : std::formatter<std::string_view, CharT> {
82 auto format(hi::semantic_color const &t, auto &fc)
83 {
84 return std::formatter<std::string_view, CharT>::format(hi::semantic_color_metadata[t], fc);
85 }
86};
87
DOXYGEN BUG.
Definition algorithm.hpp:15
The HikoGUI namespace.
Definition ascii.hpp:19
T fill(T... args)
T to_string(T... args)