1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-03 01:02:06 +00:00

HackStudio: Disable debug specific context entries

Context menu entries like evaluate expression and
move execution to line action should only be enabled
when a debug session is running. Otherwise they should
be disabled.
This commit is contained in:
Maurice Hieronymus 2021-07-11 17:38:38 +02:00 committed by Gunnar Beutner
parent 488d0722bd
commit dfc33cd412
5 changed files with 28 additions and 8 deletions

View file

@ -43,18 +43,12 @@ Editor::Editor()
initialize_documentation_tooltip();
initialize_parameters_hint_tooltip();
m_evaluate_expression_action = GUI::Action::create("Evaluate expression", { Mod_Ctrl, Key_E }, [this](auto&) {
if (!execution_position().has_value()) {
GUI::MessageBox::show(window(), "Program is not running", "Error", GUI::MessageBox::Type::Error);
return;
}
VERIFY(is_program_running());
auto dialog = EvaluateExpressionDialog::construct(window());
dialog->exec();
});
m_move_execution_to_line_action = GUI::Action::create("Set execution point to line", [this](auto&) {
if (!execution_position().has_value()) {
GUI::MessageBox::show(window(), "Program must be paused", "Error", GUI::MessageBox::Type::Error);
return;
}
VERIFY(is_program_running());
auto success = Debugger::the().set_execution_position(currently_open_file(), cursor().line());
if (success) {
set_execution_position(cursor().line());
@ -62,6 +56,9 @@ Editor::Editor()
GUI::MessageBox::show(window(), "Failed to set execution position", "Error", GUI::MessageBox::Type::Error);
}
});
set_debug_mode(false);
add_custom_context_menu_action(*m_evaluate_expression_action);
add_custom_context_menu_action(*m_move_execution_to_line_action);
@ -672,4 +669,10 @@ void Editor::handle_function_parameters_hint_request()
cursor().column());
}
void Editor::set_debug_mode(bool enabled)
{
m_evaluate_expression_action->set_enabled(enabled);
m_move_execution_to_line_action->set_enabled(enabled);
}
}