OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GUI::anonymous_namespace{KeyChord.cpp} Namespace Reference

Classes

struct  KeyName

Functions

bool equals_ignoring_case (const std::string &a, const char *b)
bool is_letter (int key)
bool is_digit (int key)
bool is_printable (int key)
bool is_symbol (int key)
bool is_function_key (int key)
bool is_special (int key)
std::string special_key_name (int key)
std::string special_key_label (int key)
int parse_key (const std::string &text)
int parse_modifier (const std::string &text)
int fold_numpad (int key)
const char * canonical_modifier_prefix (int modifier)
template<typename Prefix>
std::string join_modifiers (int modifiers, Prefix prefix)

Variables

constexpr int BINDABLE_MODIFIERS = wxMOD_CONTROL | wxMOD_SHIFT | wxMOD_ALT | wxMOD_RAW_CONTROL
constexpr std::array< KeyName, 15 > special_keys
constexpr std::array< int, 3 > MODIFIER_ORDER { wxMOD_CONTROL, wxMOD_SHIFT, wxMOD_ALT }

Class Documentation

◆ Slic3r::GUI::anonymous_namespace{KeyChord.cpp}::KeyName

struct Slic3r::GUI::anonymous_namespace{KeyChord.cpp}::KeyName
Class Members
const char * alias
int key
const char * label
const char * name

Function Documentation

◆ canonical_modifier_prefix()

const char * Slic3r::GUI::anonymous_namespace{KeyChord.cpp}::canonical_modifier_prefix ( int modifier)
159{
160 if (modifier == wxMOD_CONTROL)
161 return "Ctrl+";
162 if (modifier == wxMOD_SHIFT)
163 return "Shift+";
164 if (modifier == wxMOD_ALT)
165 return "Alt+";
166 return "RawCtrl+";
167}

References canonical_modifier_prefix().

Referenced by canonical_modifier_prefix().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ equals_ignoring_case()

bool Slic3r::GUI::anonymous_namespace{KeyChord.cpp}::equals_ignoring_case ( const std::string & a,
const char * b )
51{
52 if (b == nullptr)
53 return false;
54 size_t i = 0;
55 for (; i < a.size() && b[i] != '\0'; ++i)
56 if (std::tolower(static_cast<unsigned char>(a[i])) != std::tolower(static_cast<unsigned char>(b[i])))
57 return false;
58 return i == a.size() && b[i] == '\0';
59}

References equals_ignoring_case().

Referenced by equals_ignoring_case(), parse_key(), and parse_modifier().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fold_numpad()

int Slic3r::GUI::anonymous_namespace{KeyChord.cpp}::fold_numpad ( int key)
124{
125 if (key >= WXK_NUMPAD0 && key <= WXK_NUMPAD9)
126 return '0' + (key - WXK_NUMPAD0);
127 switch (key) {
128 case WXK_NUMPAD_ENTER: return WXK_RETURN;
129 case WXK_NUMPAD_SPACE: return WXK_SPACE;
130 case WXK_NUMPAD_TAB: return WXK_TAB;
131 case WXK_NUMPAD_HOME: return WXK_HOME;
132 case WXK_NUMPAD_END: return WXK_END;
133 case WXK_NUMPAD_PAGEUP: return WXK_PAGEUP;
134 case WXK_NUMPAD_PAGEDOWN: return WXK_PAGEDOWN;
135 case WXK_NUMPAD_LEFT: return WXK_LEFT;
136 case WXK_NUMPAD_RIGHT: return WXK_RIGHT;
137 case WXK_NUMPAD_UP: return WXK_UP;
138 case WXK_NUMPAD_DOWN: return WXK_DOWN;
139 case WXK_NUMPAD_INSERT: return WXK_INSERT;
140 case WXK_NUMPAD_DELETE: return WXK_DELETE;
141 case WXK_NUMPAD_ADD: return '+';
142 case WXK_NUMPAD_SUBTRACT: return '-';
143 case WXK_NUMPAD_MULTIPLY: return '*';
144 case WXK_NUMPAD_DIVIDE: return '/';
145 case WXK_NUMPAD_DECIMAL: return '.';
146 case WXK_NUMPAD_EQUAL: return '=';
147 default: return key;
148 }
149}

References fold_numpad().

Referenced by fold_numpad().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_digit()

bool Slic3r::GUI::anonymous_namespace{KeyChord.cpp}::is_digit ( int key)
62{ return key >= '0' && key <= '9'; }

References is_digit().

Referenced by is_digit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_function_key()

bool Slic3r::GUI::anonymous_namespace{KeyChord.cpp}::is_function_key ( int key)
65{ return key >= WXK_F1 && key <= WXK_F24; }

References is_function_key().

Referenced by is_function_key(), is_special(), and special_key_name().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_letter()

bool Slic3r::GUI::anonymous_namespace{KeyChord.cpp}::is_letter ( int key)
61{ return key >= 'A' && key <= 'Z'; }

References is_letter().

Referenced by is_letter().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_printable()

bool Slic3r::GUI::anonymous_namespace{KeyChord.cpp}::is_printable ( int key)
63{ return key > ' ' && key < 127; }

References is_printable().

Referenced by is_printable(), is_symbol(), and parse_key().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_special()

bool Slic3r::GUI::anonymous_namespace{KeyChord.cpp}::is_special ( int key)
68{
69 if (is_function_key(key))
70 return true;
71 return std::any_of(special_keys.begin(), special_keys.end(), [key](const KeyName& k) { return k.key == key; });
72}
constexpr std::array< KeyName, 15 > special_keys
Definition KeyChord.cpp:31
bool is_function_key(int key)
Definition KeyChord.cpp:65

References is_function_key(), is_special(), and special_keys.

Referenced by is_special().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_symbol()

bool Slic3r::GUI::anonymous_namespace{KeyChord.cpp}::is_symbol ( int key)
64{ return is_printable(key) && !std::isalnum(key); }
bool is_printable(int key)
Definition KeyChord.cpp:63

References is_printable(), and is_symbol().

Referenced by is_symbol().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ join_modifiers()

template<typename Prefix>
std::string Slic3r::GUI::anonymous_namespace{KeyChord.cpp}::join_modifiers ( int modifiers,
Prefix prefix )
171{
172 std::string out;
173 for (int modifier : MODIFIER_ORDER)
174 if (modifiers & modifier)
175 out += prefix(modifier);
176 return out;
177}
constexpr std::array< int, 3 > MODIFIER_ORDER
Definition KeyChord.cpp:155

References join_modifiers(), and MODIFIER_ORDER.

Referenced by join_modifiers().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_key()

int Slic3r::GUI::anonymous_namespace{KeyChord.cpp}::parse_key ( const std::string & text)
93{
94 if (text.size() == 1) {
95 const int key = static_cast<unsigned char>(text[0]);
96 return is_printable(key) ? std::toupper(key) : WXK_NONE;
97 }
98 for (const KeyName& k : special_keys)
99 if (equals_ignoring_case(text, k.name) || equals_ignoring_case(text, k.alias))
100 return k.key;
101 if ((text[0] == 'F' || text[0] == 'f') && text.size() <= 3 && std::all_of(text.begin() + 1, text.end(), [](char c) { return std::isdigit(static_cast<unsigned char>(c)); })) {
102 const int n = std::stoi(text.substr(1));
103 if (n >= 1 && n <= 24)
104 return WXK_F1 + n - 1;
105 }
106 return WXK_NONE;
107}
bool equals_ignoring_case(const std::string &a, const char *b)
Definition KeyChord.cpp:50

References equals_ignoring_case(), is_printable(), parse_key(), and special_keys.

Referenced by parse_key().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_modifier()

int Slic3r::GUI::anonymous_namespace{KeyChord.cpp}::parse_modifier ( const std::string & text)
110{
111 if (equals_ignoring_case(text, "Ctrl") || equals_ignoring_case(text, "Control") || equals_ignoring_case(text, "Cmd") || equals_ignoring_case(text, "Command"))
112 return wxMOD_CONTROL;
113 if (equals_ignoring_case(text, "Shift"))
114 return wxMOD_SHIFT;
115 if (equals_ignoring_case(text, "Alt") || equals_ignoring_case(text, "Option"))
116 return wxMOD_ALT;
117 if (equals_ignoring_case(text, "RawCtrl"))
118 return wxMOD_RAW_CONTROL;
119 return wxMOD_NONE;
120}

References equals_ignoring_case(), and parse_modifier().

Referenced by parse_modifier().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ special_key_label()

std::string Slic3r::GUI::anonymous_namespace{KeyChord.cpp}::special_key_label ( int key)
85{
86 for (const KeyName& k : special_keys)
87 if (k.key == key)
88 return _u8L_CONTEXT(k.label != nullptr ? k.label : k.name, "Keyboard Shortcut");
89 return special_key_name(key);
90}
std::string special_key_name(int key)
Definition KeyChord.cpp:74
#define _u8L_CONTEXT(s, ctx)
Definition I18N.hpp:16

References _u8L_CONTEXT, special_key_label(), special_key_name(), and special_keys.

Referenced by special_key_label().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ special_key_name()

std::string Slic3r::GUI::anonymous_namespace{KeyChord.cpp}::special_key_name ( int key)
75{
76 if (is_function_key(key))
77 return "F" + std::to_string(key - WXK_F1 + 1);
78 for (const KeyName& k : special_keys)
79 if (k.key == key)
80 return k.name;
81 return {};
82}

References is_function_key(), special_key_name(), and special_keys.

Referenced by special_key_label(), and special_key_name().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ BINDABLE_MODIFIERS

int Slic3r::GUI::anonymous_namespace{KeyChord.cpp}::BINDABLE_MODIFIERS = wxMOD_CONTROL | wxMOD_SHIFT | wxMOD_ALT | wxMOD_RAW_CONTROL
constexpr

◆ MODIFIER_ORDER

std::array<int, 3> Slic3r::GUI::anonymous_namespace{KeyChord.cpp}::MODIFIER_ORDER { wxMOD_CONTROL, wxMOD_SHIFT, wxMOD_ALT }
constexpr
155{ wxMOD_CONTROL, wxMOD_SHIFT, wxMOD_ALT };

Referenced by join_modifiers().

◆ special_keys

std::array<KeyName, 15> Slic3r::GUI::anonymous_namespace{KeyChord.cpp}::special_keys
constexpr
Initial value:
{{
{ WXK_BACK, L_CONTEXT("Backspace", "Keyboard Shortcut"), "Back", nullptr },
{ WXK_TAB, L_CONTEXT("Tab", "Keyboard Shortcut"), nullptr, nullptr },
{ WXK_RETURN, L_CONTEXT("Enter", "Keyboard Shortcut"), "Return", nullptr },
{ WXK_ESCAPE, L_CONTEXT("Esc", "Keyboard Shortcut"), "Escape", nullptr },
{ WXK_SPACE, L_CONTEXT("Space", "Keyboard Shortcut"), nullptr, nullptr },
{ WXK_DELETE, L_CONTEXT("Del", "Keyboard Shortcut"), "Delete", nullptr },
{ WXK_INSERT, L_CONTEXT("Ins", "Keyboard Shortcut"), "Insert", nullptr },
{ WXK_HOME, L_CONTEXT("Home", "Keyboard Shortcut"), nullptr, nullptr },
{ WXK_END, L_CONTEXT("End", "Keyboard Shortcut"), nullptr, nullptr },
{ WXK_PAGEUP, L_CONTEXT("PgUp", "Keyboard Shortcut"), "PageUp", nullptr },
{ WXK_PAGEDOWN, L_CONTEXT("PgDn", "Keyboard Shortcut"), "PageDown", nullptr },
{ WXK_LEFT, "Left", nullptr, L_CONTEXT("Arrow Left", "Keyboard Shortcut") },
{ WXK_RIGHT, "Right", nullptr, L_CONTEXT("Arrow Right", "Keyboard Shortcut") },
{ WXK_UP, "Up", nullptr, L_CONTEXT("Arrow Up", "Keyboard Shortcut") },
{ WXK_DOWN, "Down", nullptr, L_CONTEXT("Arrow Down", "Keyboard Shortcut") },
}}
#define L_CONTEXT(s, context)
Definition DesignOffer.hpp:17
31 {{
32 { WXK_BACK, L_CONTEXT("Backspace", "Keyboard Shortcut"), "Back", nullptr },
33 { WXK_TAB, L_CONTEXT("Tab", "Keyboard Shortcut"), nullptr, nullptr },
34 { WXK_RETURN, L_CONTEXT("Enter", "Keyboard Shortcut"), "Return", nullptr },
35 { WXK_ESCAPE, L_CONTEXT("Esc", "Keyboard Shortcut"), "Escape", nullptr },
36 { WXK_SPACE, L_CONTEXT("Space", "Keyboard Shortcut"), nullptr, nullptr },
37 { WXK_DELETE, L_CONTEXT("Del", "Keyboard Shortcut"), "Delete", nullptr },
38 { WXK_INSERT, L_CONTEXT("Ins", "Keyboard Shortcut"), "Insert", nullptr },
39 { WXK_HOME, L_CONTEXT("Home", "Keyboard Shortcut"), nullptr, nullptr },
40 { WXK_END, L_CONTEXT("End", "Keyboard Shortcut"), nullptr, nullptr },
41 { WXK_PAGEUP, L_CONTEXT("PgUp", "Keyboard Shortcut"), "PageUp", nullptr },
42 { WXK_PAGEDOWN, L_CONTEXT("PgDn", "Keyboard Shortcut"), "PageDown", nullptr },
43 // Displayed as "Arrow Left" and so on, which is what the catalogs translate.
44 { WXK_LEFT, "Left", nullptr, L_CONTEXT("Arrow Left", "Keyboard Shortcut") },
45 { WXK_RIGHT, "Right", nullptr, L_CONTEXT("Arrow Right", "Keyboard Shortcut") },
46 { WXK_UP, "Up", nullptr, L_CONTEXT("Arrow Up", "Keyboard Shortcut") },
47 { WXK_DOWN, "Down", nullptr, L_CONTEXT("Arrow Down", "Keyboard Shortcut") },
48}};

Referenced by is_special(), parse_key(), special_key_label(), and special_key_name().