feat: Added basic Pattern Language debugger

This commit is contained in:
WerWolv
2023-06-11 21:41:11 +02:00
parent 9a9b211ebb
commit 03673b5846
10 changed files with 184 additions and 82 deletions

View File

@@ -823,14 +823,8 @@ void TextEditor::Render() {
drawList->AddRectFilled(vstart, vend, mPalette[(int)PaletteIndex::Selection]);
}
// Draw breakpoints
auto start = ImVec2(lineStartScreenPos.x + scrollX, lineStartScreenPos.y);
if (mBreakpoints.count(lineNo + 1) != 0) {
auto end = ImVec2(lineStartScreenPos.x + contentSize.x + 2.0f * scrollX, lineStartScreenPos.y + mCharAdvance.y);
drawList->AddRectFilled(start, end, mPalette[(int)PaletteIndex::Breakpoint]);
}
// Draw error markers
auto errorIt = mErrorMarkers.find(lineNo + 1);
if (errorIt != mErrorMarkers.end()) {
@@ -856,6 +850,15 @@ void TextEditor::Render() {
auto lineNoWidth = ImGui::GetFont()->CalcTextSizeA(ImGui::GetFontSize(), FLT_MAX, -1.0f, buf, nullptr, nullptr).x;
drawList->AddText(ImVec2(lineStartScreenPos.x + mTextStart - lineNoWidth, lineStartScreenPos.y), mPalette[(int)PaletteIndex::LineNumber], buf);
// Draw breakpoints
if (mBreakpoints.count(lineNo + 1) != 0) {
auto end = ImVec2(lineStartScreenPos.x + contentSize.x + 2.0f * scrollX, lineStartScreenPos.y + mCharAdvance.y);
drawList->AddRectFilled(start + ImVec2(mTextStart, 0), end, mPalette[(int)PaletteIndex::Breakpoint]);
drawList->AddCircleFilled(start + ImVec2(0, mCharAdvance.y) / 2, mCharAdvance.y / 3, mPalette[(int)PaletteIndex::Breakpoint]);
drawList->AddCircle(start + ImVec2(0, mCharAdvance.y) / 2, mCharAdvance.y / 3, mPalette[(int)PaletteIndex::Default]);
}
if (mState.mCursorPosition.mLine == lineNo) {
auto focused = ImGui::IsWindowFocused();

View File

@@ -15,8 +15,7 @@ namespace hex {
class View;
enum class Keys
{
enum class Keys {
Space = GLFW_KEY_SPACE,
Apostrophe = GLFW_KEY_APOSTROPHE,
Comma = GLFW_KEY_COMMA,
@@ -144,11 +143,12 @@ namespace hex {
};
constexpr static auto CTRL = Key(static_cast<Keys>(0x0100'0000));
constexpr static auto ALT = Key(static_cast<Keys>(0x0200'0000));
constexpr static auto SHIFT = Key(static_cast<Keys>(0x0400'0000));
constexpr static auto SUPER = Key(static_cast<Keys>(0x0800'0000));
constexpr static auto CurrentView = Key(static_cast<Keys>(0x1000'0000));
constexpr static auto CTRL = Key(static_cast<Keys>(0x0100'0000));
constexpr static auto ALT = Key(static_cast<Keys>(0x0200'0000));
constexpr static auto SHIFT = Key(static_cast<Keys>(0x0400'0000));
constexpr static auto SUPER = Key(static_cast<Keys>(0x0800'0000));
constexpr static auto CurrentView = Key(static_cast<Keys>(0x1000'0000));
constexpr static auto AllowWhileTyping = Key(static_cast<Keys>(0x2000'0000));
#if defined (OS_MACOS)
constexpr static auto CTRLCMD = SUPER;

View File

@@ -37,18 +37,23 @@ namespace hex {
void ShortcutManager::process(const std::unique_ptr<View> &currentView, bool ctrl, bool alt, bool shift, bool super, bool focused, u32 keyCode) {
Shortcut pressedShortcut = getShortcut(ctrl, alt, shift, super, focused, keyCode);
if (ImGui::GetIO().WantTextInput)
return;
if (currentView->m_shortcuts.contains(pressedShortcut))
currentView->m_shortcuts[pressedShortcut]();
if (currentView->m_shortcuts.contains(pressedShortcut + AllowWhileTyping)) {
currentView->m_shortcuts[pressedShortcut + AllowWhileTyping]();
} else if (currentView->m_shortcuts.contains(pressedShortcut)) {
if (!ImGui::GetIO().WantTextInput)
currentView->m_shortcuts[pressedShortcut]();
}
}
void ShortcutManager::processGlobals(bool ctrl, bool alt, bool shift, bool super, u32 keyCode) {
Shortcut pressedShortcut = getShortcut(ctrl, alt, shift, super, false, keyCode);
if (ShortcutManager::s_globalShortcuts.contains(pressedShortcut))
ShortcutManager::s_globalShortcuts[pressedShortcut]();
if (ShortcutManager::s_globalShortcuts.contains(pressedShortcut + AllowWhileTyping)) {
ShortcutManager::s_globalShortcuts[pressedShortcut + AllowWhileTyping]();
} else if (ShortcutManager::s_globalShortcuts.contains(pressedShortcut)) {
if (!ImGui::GetIO().WantTextInput)
ShortcutManager::s_globalShortcuts[pressedShortcut]();
}
}
void ShortcutManager::clearShortcuts() {