From 35f278e1f3a149fd3ff8ba63870b29efc509e1aa Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Fri, 14 Feb 2014 12:59:25 +0100 Subject: [PATCH] Add shortcuts for ^C and Esc in all modes This should fix #392 and hopefully doesn't break anything else. Signed-off-by: Sebastian Ramacher --- config.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/config.c b/config.c index 0e9b0b0..7216647 100644 --- a/config.c +++ b/config.c @@ -129,6 +129,14 @@ config_load_default(zathura_t* zathura) #define FULLSCREEN zathura->modes.fullscreen #define PRESENTATION zathura->modes.presentation + const girara_mode_t all_modes[] = { + NORMAL, + INSERT, + INDEX, + FULLSCREEN, + PRESENTATION + }; + /* Set default mode */ girara_mode_set(gsession, zathura->modes.normal); @@ -318,9 +326,13 @@ config_load_default(zathura_t* zathura) girara_mouse_event_add(gsession, GDK_BUTTON2_MASK, GIRARA_MOUSE_BUTTON2, sc_mouse_scroll, (mode), GIRARA_EVENT_BUTTON_RELEASE, 0, NULL); \ girara_mouse_event_add(gsession, GDK_BUTTON2_MASK, 0, sc_mouse_scroll, (mode), GIRARA_EVENT_MOTION_NOTIFY, 0, NULL); \ - /* Define mode-less shortcuts */ - girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_KEY_c, NULL, sc_abort, 0, 0, NULL); - girara_shortcut_add(gsession, 0, GDK_KEY_Escape, NULL, sc_abort, 0, 0, NULL); + /* Define mode-less shortcuts + * girara adds them only for normal mode, so passing 0 as mode is currently + * not enough. We need to add/override for every mode. */ + for (size_t idx = 0; idx != LENGTH(all_modes); ++idx) { + girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_KEY_c, NULL, sc_abort, all_modes[idx], 0, NULL); + girara_shortcut_add(gsession, 0, GDK_KEY_Escape, NULL, sc_abort, all_modes[idx], 0, NULL); + } /* Normal mode */ girara_shortcut_add(gsession, 0, GDK_KEY_F5, NULL, sc_toggle_presentation, NORMAL, 0, NULL);