diff --git a/gtk3/console_window.c b/gtk3/console_window.c index 2aed0b3..66f7abe 100644 --- a/gtk3/console_window.c +++ b/gtk3/console_window.c @@ -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)); +} diff --git a/gtk3/console_window.h b/gtk3/console_window.h index 96fbbe4..2fd03d0 100644 --- a/gtk3/console_window.h +++ b/gtk3/console_window.h @@ -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 \ No newline at end of file diff --git a/gtk3/main.c b/gtk3/main.c index 645ee2c..97b7d1d 100644 --- a/gtk3/main.c +++ b/gtk3/main.c @@ -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();