From 9c7815314b5d8e1d120a333e625c1ea12a951a6f Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Thu, 31 May 2012 09:31:54 -0400 Subject: [PATCH] make keybindings easy to configure --- config.h | 12 ++++++++++++ termite.c | 16 ++++++++-------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/config.h b/config.h index 48af579..c540baf 100644 --- a/config.h +++ b/config.h @@ -1,5 +1,7 @@ #include +#include + #define URGENT_ON_BEEP #define DYNAMIC_TITLE #define CLICKABLE_URL @@ -47,3 +49,13 @@ static const bool visible_bell = false; static const bool mouse_autohide = false; static const char *term = "vte-256color"; + +// keybindings +#define KEY_COPY GDK_KEY_c +#define KEY_PASTE GDK_KEY_v +#define KEY_PREV GDK_KEY_p +#define KEY_NEXT GDK_KEY_n +#define KEY_SEARCH GDK_KEY_f +#define KEY_RSEARCH GDK_KEY_r +#define KEY_URL GDK_KEY_j +#define KEY_RURL GDK_KEY_k diff --git a/termite.c b/termite.c index be32002..e66b794 100644 --- a/termite.c +++ b/termite.c @@ -77,30 +77,30 @@ static gboolean key_press_cb(GtkWidget *vte, GdkEventKey *event, search_dialog_i const GdkModifierType modifiers = event->state & gtk_accelerator_get_default_mod_mask(); if (modifiers == (GDK_CONTROL_MASK|GDK_SHIFT_MASK)) { switch (gdk_keyval_to_lower(event->keyval)) { - case GDK_KEY_c: + case KEY_COPY: vte_terminal_copy_clipboard(VTE_TERMINAL(vte)); return TRUE; - case GDK_KEY_v: + case KEY_PASTE: vte_terminal_paste_clipboard(VTE_TERMINAL(vte)); return TRUE; - case GDK_KEY_p: + case KEY_PREV: vte_terminal_search_find_previous(VTE_TERMINAL(vte)); vte_terminal_copy_primary(VTE_TERMINAL(vte)); return TRUE; - case GDK_KEY_n: + case KEY_NEXT: vte_terminal_search_find_next(VTE_TERMINAL(vte)); vte_terminal_copy_primary(VTE_TERMINAL(vte)); return TRUE; - case GDK_KEY_f: + case KEY_SEARCH: open_search_dialog(vte, false, info); return TRUE; - case GDK_KEY_b: + case KEY_RSEARCH: open_search_dialog(vte, true, info); return TRUE; - case GDK_KEY_j: + case KEY_URL: search(VTE_TERMINAL(vte), url_regex, false); return TRUE; - case GDK_KEY_k: + case KEY_RURL: search(VTE_TERMINAL(vte), url_regex, true); return TRUE; }