[GTK3] Hook up the Break Debugger menu entry

This commit is contained in:
Maximilian Mader 2021-01-02 16:25:43 +01:00
parent 07f6da4c9e
commit cc0827c429
Signed by: Max
GPG Key ID: F71D56A3151C4FB3
3 changed files with 21 additions and 4 deletions

View File

@ -88,7 +88,7 @@ static gboolean on_input_key_press(GtkEntry *input, GdkEventKey *event, ConsoleW
const char *entry = NULL;
gtk_tree_model_get(model, &iter, 0, &entry, -1);
gtk_entry_set_text(self->input, entry);
gtk_entry_set_text(input, entry);
gtk_editable_set_position(GTK_EDITABLE(input), -1);
}
@ -98,7 +98,7 @@ static gboolean on_input_key_press(GtkEntry *input, GdkEventKey *event, ConsoleW
case GDK_KEY_Down:
if (event->type == GDK_KEY_PRESS) {
if (self->command_history_index <= 0) {
gtk_entry_set_text(self->input, "");
gtk_entry_set_text(input, "");
self->command_history_index = -1;
}
@ -117,7 +117,7 @@ static gboolean on_input_key_press(GtkEntry *input, GdkEventKey *event, ConsoleW
const char *entry = NULL;
gtk_tree_model_get(model, &iter, 0, &entry, -1);
gtk_entry_set_text(self->input, entry);
gtk_entry_set_text(input, entry);
gtk_editable_set_position(GTK_EDITABLE(input), -1);
}
@ -237,6 +237,8 @@ static void console_window_init(ConsoleWindow *self) {
g_signal_connect(self->input, "delete-text", G_CALLBACK(on_delete_text), self);
g_signal_connect(self->input, "insert-text", G_CALLBACK(on_insert_text), self);
g_signal_connect(self->input, "move-cursor", G_CALLBACK(on_move_cursor), self);
gtk_widget_grab_focus(GTK_WIDGET(self->input));
}
static void console_window_realize(GtkWidget *widget) {
@ -499,3 +501,9 @@ void console_clear(ConsoleWindow *self) {
// mark as dirty
gtk_widget_queue_draw(GTK_WIDGET(self));
}
void break_debugger(ConsoleWindow *self) {
GB_debugger_break(self->gb);
gtk_window_present_with_time(GTK_WINDOW(self), time(NULL));
gtk_widget_grab_focus(GTK_WIDGET(self->input));
}

View File

@ -12,4 +12,5 @@ char *console_get_async_input(ConsoleWindow *self, GB_gameboy_t *gb);
char *console_get_sync_input(ConsoleWindow *self, GB_gameboy_t *gb);
void console_log(ConsoleWindow *self, const char *message, GB_log_attributes attributes);
void console_clear(ConsoleWindow *self);
void break_debugger(ConsoleWindow *self);
#endif

View File

@ -71,6 +71,7 @@ static void activate_open(GSimpleAction *action, GVariant *parameter, gpointer a
static void activate_close(GSimpleAction *action, GVariant *parameter, gpointer app);
static void activate_reset(GSimpleAction *action, GVariant *parameter, gpointer app);
static void activate_show_console(GSimpleAction *action, GVariant *parameter, gpointer app);
static void activate_break_debugger(GSimpleAction *action, GVariant *parameter, gpointer app);
static void activate_open_gtk_debugger(GSimpleAction *action, GVariant *parameter, gpointer app);
static void activate_open_memory_viewer(GSimpleAction *action, GVariant *parameter, gpointer app);
static void activate_open_vram_viewer(GSimpleAction *action, GVariant *parameter, gpointer app);
@ -99,11 +100,12 @@ static const GActionEntry emulation_entries[] = {
static const GActionEntry developer_entries[] = {
{ "show_console", activate_show_console, NULL, NULL, NULL },
{ "open_gtk_debugger", activate_open_gtk_debugger, NULL, NULL, NULL },
// { "open_memory_viewer", activate_open_memory_viewer, NULL, NULL, NULL },
{ "open_vram_viewer", activate_open_vram_viewer, NULL, NULL, NULL },
{ "break_debugger", activate_break_debugger, NULL, NULL, NULL },
{ "toggle_developer_mode", NULL, NULL, "false", NULL },
{ "clear_console", activate_clear_console, NULL, NULL, NULL },
{ "open_gtk_debugger", activate_open_gtk_debugger, NULL, NULL, NULL },
};
static const GActionEntry app_entries[] = {
@ -1247,6 +1249,12 @@ static void activate_clear_console(GSimpleAction *action, GVariant *parameter, g
console_clear(gui_data.console);
}
// app.break_debugger GAction
// Clears the debugger console
static void activate_break_debugger(GSimpleAction *action, GVariant *parameter, gpointer app) {
break_debugger(gui_data.console);
}
// Closes a ROM
static void close_rom(void) {
stop();