6#include "imgui_internal.h"
26static constexpr auto allShortcutInfo = std::to_array<AllShortcutInfo>({
27 {HEX_GOTO_ADDR, ImGuiKey_G | ImGuiMod_Ctrl, ALWAYS_LOCAL,
false,
"hex_editor_goto_address",
"Go to address in hex viewer"},
28 {DEBUGGER_STEP_IN, ImGuiKey_F7, LOCAL,
true,
"step-in",
"Debugger: step-in"},
29 {DEBUGGER_STEP_OVER, ImGuiKey_F8, LOCAL,
true,
"step-over",
"Debugger: step-over"},
30 {DEBUGGER_STEP_OUT, ImGuiKey_F7 | ImGuiMod_Shift, LOCAL,
true,
"step-out",
"Debugger: step-out"},
31 {DEBUGGER_STEP_BACK, ImGuiKey_F8 | ImGuiMod_Shift, LOCAL,
true,
"step-back",
"Debugger: step-back"},
32 {DEBUGGER_BREAK_CONTINUE, ImGuiKey_F5, LOCAL,
false,
"break-continue",
"Debugger: toggle break / continue"},
33 {DISASM_GOTO_ADDR, ImGuiMod_Ctrl | ImGuiKey_G, ALWAYS_LOCAL,
false,
"disasm_goto_address",
"Scroll to address in disassembler"},
34 {DISASM_RUN_TO_ADDR, ImGuiMod_Ctrl | ImGuiKey_R, ALWAYS_LOCAL,
false,
"disasm_run_to_address",
"Debugger: run to a specific address"},
35 {DISASM_TOGGLE_BREAKPOINT,ImGuiMod_Ctrl | ImGuiKey_B, ALWAYS_LOCAL,
false,
"disasm_toggle_breakpoint",
"Debugger: toggle breakpoint at current address"},
37static_assert(narrow<int>(allShortcutInfo.size()) == std::to_underlying(
Shortcuts::ID::NUM));
39static constexpr auto defaultShortcuts = []{
42 const auto& all = allShortcutInfo[i];
45 result[
id].keyChord = all.keyChord;
46 result[
id].type = all.type;
51static constexpr auto shortcutRepeats = []{
55 result[
id] = allShortcutInfo[i].repeat;
60static constexpr auto shortcutNames = []{
64 result[
id] = allShortcutInfo[i].name;
69static constexpr auto shortcutDescriptions = []{
73 result[
id] = allShortcutInfo[i].description;
85 shortcuts = defaultShortcuts;
90 return defaultShortcuts[
id];
100 auto oldType = shortcuts[
id].type;
101 shortcuts[
id] = shortcut;
104 shortcuts[
id].type = oldType;
110 return shortcutRepeats[
id];
115 return shortcutNames[
id];
121 if (it == shortcutNames.end())
return {};
122 return static_cast<Shortcuts::ID>(std::distance(shortcutNames.begin(), it));
127 if (name ==
"global")
return GLOBAL;
128 if (name ==
"local")
return LOCAL;
134 return shortcutDescriptions[
id];
139 assert(shortcut.
keyChord != ImGuiKey_None);
141 | (shortcut.
repeat ? ImGuiInputFlags_Repeat : 0);
142 return ImGui::Shortcut(shortcut.
keyChord, flags, 0);
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)