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"},
32 {DISASM_RUN_TO_ADDR, ImGuiMod_Ctrl | ImGuiKey_R, ALWAYS_LOCAL,
false,
"disasm_run_to_address",
"Debugger: run to a specific address"},
33 {DISASM_TOGGLE_BREAKPOINT,ImGuiMod_Ctrl | ImGuiKey_B, ALWAYS_LOCAL,
false,
"disasm_toggle_breakpoint",
"Debugger: toggle breakpoint at current address"},
37static constexpr auto defaultShortcuts = []{
40 const auto& all = allShortcutInfo[i];
43 result[
id].keyChord = all.keyChord;
44 result[
id].type = all.type;
49static constexpr auto shortcutRepeats = []{
53 result[
id] = allShortcutInfo[i].repeat;
58static constexpr auto shortcutNames = []{
62 result[
id] = allShortcutInfo[i].name;
67static constexpr auto shortcutDescriptions = []{
71 result[
id] = allShortcutInfo[i].description;
83 shortcuts = defaultShortcuts;
88 return defaultShortcuts[
id];
98 auto oldType = shortcuts[
id].type;
99 shortcuts[
id] = shortcut;
102 shortcuts[
id].type = oldType;
108 return shortcutRepeats[
id];
113 return shortcutNames[
id];
119 if (it == shortcutNames.end())
return {};
120 return static_cast<Shortcuts::ID>(std::distance(shortcutNames.begin(), it));
125 if (name ==
"global")
return GLOBAL;
126 if (name ==
"local")
return LOCAL;
132 return shortcutDescriptions[
id];
137 assert(shortcut.
keyChord != ImGuiKey_None);
139 | (shortcut.
repeat ? ImGuiInputFlags_Repeat : 0);
140 return ImGui::Shortcut(shortcut.
keyChord, flags, 0);
145 const auto& shortcut = shortcuts[
id];
146 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)
constexpr auto to_underlying(E e) noexcept