HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
command.hpp
1// Copyright Take Vos 2020-2021.
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 "required.hpp"
8#include "enum_metadata.hpp"
9#include <string>
10#include <string_view>
11#include <ostream>
12
13namespace hi::inline v1 {
14
15enum class command {
16 unknown,
17 text_cursor_left_char,
18 text_cursor_right_char,
19 text_cursor_down_char,
20 text_cursor_up_char,
21 text_cursor_left_word,
22 text_cursor_right_word,
23 text_cursor_begin_line,
24 text_cursor_end_line,
25 text_cursor_begin_sentence,
26 text_cursor_end_sentence,
27 text_cursor_begin_document,
28 text_cursor_end_document,
29 text_select_left_char,
30 text_select_right_char,
31 text_select_down_char,
32 text_select_up_char,
33 text_select_word,
34 text_select_left_word,
35 text_select_right_word,
36 text_select_begin_line,
37 text_select_end_line,
38 text_select_begin_sentence,
39 text_select_end_sentence,
40 text_select_document,
41 text_select_begin_document,
42 text_select_end_document,
43 text_delete_char_prev,
44 text_delete_char_next,
45 text_delete_word_prev,
46 text_delete_word_next,
47 text_swap_chars,
48 text_edit_paste,
49 text_edit_copy,
50 text_edit_cut,
51 text_undo,
52 text_redo,
53 text_insert_line,
54 text_insert_line_up,
55 text_insert_line_down,
56 text_mode_insert,
57 gui_keyboard_enter,
58 gui_keyboard_exit,
59 gui_mouse_enter,
60 gui_mouse_exit,
61 gui_widget_next,
62 gui_widget_prev,
63 gui_menu_next,
64 gui_menu_prev,
65 gui_sysmenu_open,
66 gui_toolbar_open,
67 gui_toolbar_next,
68 gui_toolbar_prev,
69 gui_activate,
70 gui_enter,
71 gui_cancel,
72};
73
74// clang-format off
75constexpr auto command_metadata = enum_metadata{
76 command::unknown, "unknown",
77 command::text_cursor_left_char, "text_cursor_left_char",
78 command::text_cursor_right_char, "text_cursor_right_char",
79 command::text_cursor_down_char, "text_cursor_down_char",
80 command::text_cursor_up_char, "text_cursor_up_char",
81 command::text_cursor_left_word, "text_cursor_left_word",
82 command::text_cursor_right_word, "text_cursor_right_word",
83 command::text_cursor_begin_line, "text_cursor_begin_line",
84 command::text_cursor_end_line, "text_cursor_end_line",
85 command::text_cursor_begin_sentence, "text_cursor_begin_sentence",
86 command::text_cursor_end_sentence, "text_cursor_end_sentence",
87 command::text_cursor_begin_document, "text_cursor_begin_document",
88 command::text_cursor_end_document, "text_cursor_end_document",
89 command::text_select_left_char, "text_select_left_char",
90 command::text_select_right_char, "text_select_right_char",
91 command::text_select_down_char, "text_select_down_char",
92 command::text_select_up_char, "text_select_up_char",
93 command::text_select_word, "text_select_word",
94 command::text_select_left_word, "text_select_left_word",
95 command::text_select_right_word, "text_select_right_word",
96 command::text_select_begin_line, "text_select_begin_line",
97 command::text_select_end_line, "text_select_end_line",
98 command::text_select_begin_sentence, "text_select_begin_sentence",
99 command::text_select_end_sentence, "text_select_end_sentence",
100 command::text_select_begin_document, "text_select_begin_document",
101 command::text_select_end_document, "text_select_end_document",
102 command::text_select_document, "text_select_document",
103 command::text_delete_char_prev, "text_delete_char_prev",
104 command::text_delete_char_next, "text_delete_char_next",
105 command::text_delete_word_prev, "text_delete_word_prev",
106 command::text_delete_word_next, "text_delete_word_next",
107 command::text_insert_line, "text_insert_line",
108 command::text_insert_line_up, "text_insert_line_up",
109 command::text_insert_line_down, "text_insert_line_down",
110 command::text_swap_chars, "text_swap_chars",
111 command::text_edit_paste, "text_edit_paste",
112 command::text_edit_copy, "text_edit_copy",
113 command::text_edit_cut, "text_edit_cut",
114 command::text_undo, "text_undo",
115 command::text_redo, "text_redo",
116 command::text_mode_insert, "text_mode_insert",
117 command::gui_keyboard_enter, "gui_keyboard_enter",
118 command::gui_keyboard_exit, "gui_keyboard_exit",
119 command::gui_mouse_enter, "gui_mouse_enter",
120 command::gui_mouse_exit, "gui_mouse_exit",
121 command::gui_widget_next, "gui_widget_next",
122 command::gui_widget_prev, "gui_widget_prev",
123 command::gui_menu_next, "gui_menu_next",
124 command::gui_menu_prev, "gui_menu_prev",
125 command::gui_sysmenu_open, "gui_sysmenu_open",
126 command::gui_toolbar_open, "gui_toolbar_open",
127 command::gui_toolbar_next, "gui_toolbar_next",
128 command::gui_toolbar_prev, "gui_toolbar_prev",
129 command::gui_activate, "gui_activate",
130 command::gui_enter, "gui_enter",
131 command::gui_cancel, "gui_cancel"
132};
133// clang-format on
134
135inline std::string_view to_string(command rhs) noexcept
136{
137 return command_metadata[rhs];
138}
139
140inline std::ostream &operator<<(std::ostream &lhs, command const &rhs)
141{
142 return lhs << command_metadata[rhs];
143}
144
145constexpr command to_command(std::string_view name) noexcept
146{
147 return command_metadata.at(name, command::unknown);
148}
149
150} // namespace hi::inline v1
This file includes required definitions.
T to_string(T... args)