mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-02 05:27:41 -05:00
fix: pattern editor find/replace. (#2686)
A recent commit broke the pattern editor popups for fin/replace and goto line. The problem was cause by changes to the function that returns the name of the currently focused subwindow using a function that only updates when ImHex main window losses focus. The commit was aimed at fixing evaluation of shortcuts in pattern data view and pattern editor simultaneously but missed to fix some shortcuts like cut and paste. The fix substitutes how the subwindow is first selected by using the result of the subwindow selection used by imhex to insure that menus and other ui components don't steal focus from views. The function that returns the name of the current focused subwindow was changed to use this value. This fixes both the window popups of pattern editor and all the shortcut duplications.
This commit is contained in:
@@ -67,10 +67,6 @@ namespace hex::plugin::builtin {
|
||||
|
||||
constexpr static auto TextEditorView = "/##pattern_editor_";
|
||||
constexpr static auto ConsoleView = "/##console_";
|
||||
constexpr static auto VariablesView = "/##env_vars_";
|
||||
constexpr static auto SettingsView = "/##settings_";
|
||||
constexpr static auto VirtualFilesView = "/##virtual_file_tree_";
|
||||
constexpr static auto DebuggerView = "/##debugger_";
|
||||
|
||||
class ViewPatternEditor::PopupAcceptPattern : public Popup<PopupAcceptPattern> {
|
||||
public:
|
||||
@@ -451,11 +447,9 @@ namespace hex::plugin::builtin {
|
||||
if (g.CurrentWindow->Appearing)
|
||||
return;
|
||||
|
||||
if (g.NavWindow != nullptr) {
|
||||
std::string name = g.NavWindow->Name;
|
||||
if (name.contains(TextEditorView) || name.contains(ConsoleView) || name.contains(VariablesView) || name.contains(SettingsView) || name.contains(VirtualFilesView) || name.contains(DebuggerView))
|
||||
m_focusedSubWindowName = name;
|
||||
}
|
||||
auto *focusedSubWindow = getFocusedSubWindow();
|
||||
if (focusedSubWindow != nullptr)
|
||||
m_focusedSubWindowName = focusedSubWindow->Name;
|
||||
|
||||
auto defaultEditorSize = ImGui::GetContentRegionAvail();
|
||||
defaultEditorSize.y *= 0.66F;
|
||||
@@ -690,10 +684,7 @@ namespace hex::plugin::builtin {
|
||||
findReplaceHandler->setFindWord(textEditor, findWord);
|
||||
requestFocus = true;
|
||||
updateCount = true;
|
||||
if (m_focusedSubWindowName.contains(ConsoleView))
|
||||
canReplace = false;
|
||||
else if (m_focusedSubWindowName.contains(TextEditorView))
|
||||
canReplace = true;
|
||||
canReplace = m_focusedSubWindowName.contains(TextEditorView);
|
||||
}
|
||||
bool enter = ImGui::IsKeyPressed(ImGuiKey_Enter, false) || ImGui::IsKeyPressed(ImGuiKey_KeypadEnter, false);
|
||||
bool upArrow = ImGui::IsKeyPressed(ImGuiKey_UpArrow, false) || ImGui::IsKeyPressed(ImGuiKey_Keypad8, false);
|
||||
@@ -1944,17 +1935,15 @@ namespace hex::plugin::builtin {
|
||||
}
|
||||
|
||||
ui::TextEditor *ViewPatternEditor::getEditorFromFocusedWindow() {
|
||||
if (!this->isFocused())
|
||||
return nullptr;
|
||||
|
||||
auto provider = ImHexApi::Provider::get();
|
||||
if (provider != nullptr) {
|
||||
if (auto provider = ImHexApi::Provider::get(); provider != nullptr) {
|
||||
if (m_focusedSubWindowName.contains(ConsoleView)) {
|
||||
return &m_consoleEditor.get(provider);
|
||||
}
|
||||
if (m_focusedSubWindowName.contains(TextEditorView)) {
|
||||
return &m_textEditor.get(provider);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
|
||||
Reference in New Issue
Block a user