5#include "imgui_internal.h"
24static constexpr auto allShortcutInfo = std::to_array<AllShortcutInfo>({
25 {HEX_GOTO_ADDR, ImGuiKey_G | ImGuiMod_Ctrl, ALWAYS_LOCAL,
false,
"hex_editor_goto_address",
"Go to address in hex viewer"},
26 {DEBUGGER_STEP_IN, ImGuiKey_F7, LOCAL,
true,
"step-in",
"Debugger: step-in"},
27 {DEBUGGER_STEP_OVER, ImGuiKey_F8, LOCAL,
true,
"step-over",
"Debugger: step-over"},
28 {DEBUGGER_STEP_OUT, ImGuiKey_F7 | ImGuiMod_Shift, LOCAL,
true,
"step-out",
"Debugger: step-out"},
29 {DEBUGGER_STEP_BACK, ImGuiKey_F8 | ImGuiMod_Shift, LOCAL,
true,
"step-back",
"Debugger: step-back"},
30 {DEBUGGER_BREAK_CONTINUE, ImGuiKey_F5, LOCAL,
false,
"break-continue",
"Debugger: toggle break / continue"},
31 {DISASM_GOTO_ADDR, ImGuiMod_Ctrl | ImGuiKey_G, ALWAYS_LOCAL,
false,
"disasm_goto_address",
"Scroll to address in disassembler"},
35static constexpr auto defaultShortcuts = []{
36 std::array<Shortcuts::Shortcut, Shortcuts::ID::NUM_SHORTCUTS> result = {};
38 const auto& all = allShortcutInfo[i];
40 result[i].keyChord = all.keyChord;
41 result[i].type = all.type;
46static constexpr auto shortcutRepeats = []{
47 std::array<bool, Shortcuts::ID::NUM_SHORTCUTS> result = {};
49 result[i] = allShortcutInfo[i].repeat;
54static constexpr auto shortcutNames = []{
55 std::array<zstring_view, Shortcuts::ID::NUM_SHORTCUTS> result = {};
57 result[i] = allShortcutInfo[i].name;
62static constexpr auto shortcutDescriptions = []{
63 std::array<zstring_view, Shortcuts::ID::NUM_SHORTCUTS> result = {};
65 result[i] = allShortcutInfo[i].description;
77 shortcuts = defaultShortcuts;
83 return defaultShortcuts[
id];
95 auto oldType = shortcuts[
id].type;
96 shortcuts[
id] = shortcut;
99 shortcuts[
id].type = oldType;
106 return shortcutRepeats[
id];
112 return shortcutNames[
id];
118 if (it == shortcutNames.end())
return {};
119 return static_cast<Shortcuts::ID>(std::distance(shortcutNames.begin(), it));
124 if (name ==
"global")
return GLOBAL;
125 if (name ==
"local")
return LOCAL;
132 return shortcutDescriptions[
id];
137 assert(shortcut.
keyChord != ImGuiKey_None);
139 | ImGuiInputFlags_RouteUnlessBgFocused
140 | (shortcut.
repeat ? ImGuiInputFlags_Repeat : 0);
141 return ImGui::Shortcut(shortcut.
keyChord, 0, flags);
147 const auto& shortcut = shortcuts[
id];
148 if (shortcut.keyChord == ImGuiKey_None)
return false;
static zstring_view getShortcutName(ID id)
void setDefaultShortcuts()
static const Shortcut & getDefaultShortcut(ID id)
static zstring_view getShortcutDescription(ID id)
bool checkShortcut(const ShortcutWithRepeat &shortcut) const
static std::optional< ID > parseShortcutName(std::string_view name)
static std::optional< Type > parseType(std::string_view name)
void setShortcut(ID id, const Shortcut &shortcut)
const Shortcut & getShortcut(ID id) const
static bool getShortcutRepeat(ID id)
Like std::string_view, but with the extra guarantee that it refers to a zero-terminated string.
This file implemented 3 utility functions:
auto find(InputRange &&range, const T &value)