@@ -59,37 +59,54 @@ namespace hex::plugin::builtin {
59
59
ImGui::SetKeyboardFocusHere ();
60
60
m_requestFocus = false ;
61
61
}
62
- if (ImGuiExt::InputTextIcon (" ##input" , ICON_VS_SYMBOL_OPERATOR, m_input, ImGuiInputTextFlags_EnterReturnsTrue | ImGuiInputTextFlags_AutoSelectAll )) {
62
+ if (ImGuiExt::InputTextIcon (" ##input" , ICON_VS_SYMBOL_OPERATOR, m_input)) {
63
63
if (auto result = m_evaluator.evaluate (m_input); result.has_value ()) {
64
64
const auto inputResult = result.value ();
65
- u64 newAddress = 0x00 ;
66
-
67
65
auto provider = ImHexApi::Provider::get ();
68
66
69
67
switch (m_mode) {
70
68
case Mode::Absolute: {
71
- newAddress = inputResult;
69
+ m_newAddress = inputResult;
72
70
}
73
71
break ;
74
72
case Mode::Relative: {
75
73
const auto selection = editor->getSelection ();
76
- newAddress = selection.getStartAddress () + inputResult;
74
+ m_newAddress = selection.getStartAddress () + inputResult;
77
75
}
78
76
break ;
79
77
case Mode::Begin: {
80
- newAddress = provider->getBaseAddress () + provider->getCurrentPageAddress () + inputResult;
78
+ m_newAddress = provider->getBaseAddress () + provider->getCurrentPageAddress () + inputResult;
81
79
}
82
80
break ;
83
81
case Mode::End: {
84
- newAddress = provider->getActualSize () - inputResult;
82
+ m_newAddress = provider->getActualSize () - inputResult;
85
83
}
86
84
break ;
87
85
}
86
+ } else {
87
+ m_newAddress.reset ();
88
+ }
89
+ }
90
+
91
+ bool executeGoto = false ;
92
+ if (ImGui::IsItemFocused () && ImGui::IsKeyPressed (ImGuiKey_Enter)) {
93
+ executeGoto = true ;
94
+ }
88
95
89
- editor->setSelection (newAddress, newAddress);
90
- editor->jumpToSelection ();
96
+ ImGui::BeginDisabled (!m_newAddress.has_value ());
97
+ {
98
+ const auto label = hex::format (" {} {}" , " hex.builtin.view.hex_editor.menu.file.goto" _lang, m_newAddress.has_value () ? hex::format (" 0x{:08X}" , *m_newAddress) : " ???" );
99
+ const auto buttonWidth = ImGui::GetWindowWidth () - ImGui::GetStyle ().WindowPadding .x * 2 ;
100
+ if (ImGuiExt::DimmedButton (label.c_str (), ImVec2 (buttonWidth, 0 ))) {
101
+ executeGoto = true ;
91
102
}
92
103
}
104
+ ImGui::EndDisabled ();
105
+
106
+ if (executeGoto && m_newAddress.has_value ()) {
107
+ editor->setSelection (*m_newAddress, *m_newAddress);
108
+ editor->jumpToSelection ();
109
+ }
93
110
94
111
ImGui::EndTabBar ();
95
112
}
@@ -104,9 +121,10 @@ namespace hex::plugin::builtin {
104
121
};
105
122
106
123
Mode m_mode = Mode::Absolute;
124
+ std::optional<u64> m_newAddress;
107
125
108
126
bool m_requestFocus = true ;
109
- std::string m_input;
127
+ std::string m_input = " 0x " ;
110
128
wolv::math_eval::MathEvaluator<i128> m_evaluator;
111
129
};
112
130
@@ -1101,7 +1119,7 @@ namespace hex::plugin::builtin {
1101
1119
ContentRegistry::Interface::addMenuItem ({ " hex.builtin.menu.edit" , " hex.builtin.view.hex_editor.menu.edit.resize" }, ICON_VS_ARROW_BOTH, 1700 , Shortcut::None,
1102
1120
[this ] {
1103
1121
auto provider = ImHexApi::Provider::get ();
1104
- this ->openPopup <PopupResize>(provider->getBaseAddress ());
1122
+ this ->openPopup <PopupResize>(provider->getActualSize ());
1105
1123
},
1106
1124
[] { return ImHexApi::Provider::isValid () && ImHexApi::Provider::get ()->isResizable (); });
1107
1125
0 commit comments