From ab78455a4a98a3e0ad52e741b657d849884b824e Mon Sep 17 00:00:00 2001 From: Mark Oteiza Date: Fri, 18 Sep 2015 19:29:31 -0400 Subject: [PATCH 1/3] make table an argument of modify_other_keys --- termite.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/termite.cc b/termite.cc index 55b79e4..0c201a1 100644 --- a/termite.cc +++ b/termite.cc @@ -205,12 +205,13 @@ static const std::map modify_table = { { GDK_KEY_question, "\033[27;6;63~" }, }; -static gboolean modify_key_feed(GdkEventKey *event, keybind_info *info) { +static gboolean modify_key_feed(GdkEventKey *event, keybind_info *info, + const std::map& table) { if (info->config.modify_other_keys) { unsigned int keyval = gdk_keyval_to_lower(event->keyval); - auto entry = modify_table.find((int)keyval); + auto entry = table.find((int)keyval); - if (entry != modify_table.end()) { + if (entry != table.end()) { vte_terminal_feed_child(info->vte, entry->second, -1); return TRUE; } @@ -902,7 +903,7 @@ gboolean key_press_cb(VteTerminal *vte, GdkEventKey *event, keybind_info *info) reload_config(); return TRUE; default: - if (modify_key_feed(event, info)) + if (modify_key_feed(event, info, modify_table)) return TRUE; } } else if (modifiers == GDK_CONTROL_MASK) { @@ -911,7 +912,7 @@ gboolean key_press_cb(VteTerminal *vte, GdkEventKey *event, keybind_info *info) overlay_show(&info->panel, overlay_mode::completion, vte); return TRUE; default: - if (modify_key_feed(event, info)) + if (modify_key_feed(event, info, modify_table)) return TRUE; } } From 614eca0f030182dcde45e754eb04928549abd178 Mon Sep 17 00:00:00 2001 From: Mark Oteiza Date: Fri, 18 Sep 2015 19:32:43 -0400 Subject: [PATCH 2/3] produce escape sequences for some Ctrl-Meta- modified keys --- termite.cc | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/termite.cc b/termite.cc index 0c201a1..44e9811 100644 --- a/termite.cc +++ b/termite.cc @@ -205,6 +205,34 @@ static const std::map modify_table = { { GDK_KEY_question, "\033[27;6;63~" }, }; +static const std::map modify_meta_table = { + { GDK_KEY_Tab, "\033[27;13;9~" }, + { GDK_KEY_Return, "\033[27;13;13~" }, + { GDK_KEY_apostrophe, "\033[27;13;39~" }, + { GDK_KEY_comma, "\033[27;13;44~" }, + { GDK_KEY_minus, "\033[27;13;45~" }, + { GDK_KEY_period, "\033[27;13;46~" }, + { GDK_KEY_0, "\033[27;13;48~" }, + { GDK_KEY_1, "\033[27;13;49~" }, + { GDK_KEY_9, "\033[27;13;57~" }, + { GDK_KEY_semicolon, "\033[27;13;59~" }, + { GDK_KEY_equal, "\033[27;13;61~" }, + { GDK_KEY_exclam, "\033[27;14;33~" }, + { GDK_KEY_quotedbl, "\033[27;14;34~" }, + { GDK_KEY_numbersign, "\033[27;14;35~" }, + { GDK_KEY_dollar, "\033[27;14;36~" }, + { GDK_KEY_percent, "\033[27;14;37~" }, + { GDK_KEY_ampersand, "\033[27;14;38~" }, + { GDK_KEY_parenleft, "\033[27;14;40~" }, + { GDK_KEY_parenright, "\033[27;14;41~" }, + { GDK_KEY_asterisk, "\033[27;14;42~" }, + { GDK_KEY_plus, "\033[27;14;43~" }, + { GDK_KEY_colon, "\033[27;14;58~" }, + { GDK_KEY_less, "\033[27;14;60~" }, + { GDK_KEY_greater, "\033[27;14;62~" }, + { GDK_KEY_question, "\033[27;14;63~" }, +}; + static gboolean modify_key_feed(GdkEventKey *event, keybind_info *info, const std::map& table) { if (info->config.modify_other_keys) { @@ -906,6 +934,10 @@ gboolean key_press_cb(VteTerminal *vte, GdkEventKey *event, keybind_info *info) if (modify_key_feed(event, info, modify_table)) return TRUE; } + } else if ((modifiers == (GDK_CONTROL_MASK|GDK_MOD1_MASK)) || + (modifiers == (GDK_CONTROL_MASK|GDK_MOD1_MASK|GDK_SHIFT_MASK))) { + if (modify_key_feed(event, info, modify_meta_table)) + return TRUE; } else if (modifiers == GDK_CONTROL_MASK) { switch (gdk_keyval_to_lower(event->keyval)) { case GDK_KEY_Tab: From 7f0d2491bf3f1459f7d84e2e673907c939ac4a2f Mon Sep 17 00:00:00 2001 From: Mark Oteiza Date: Fri, 18 Sep 2015 23:18:50 -0400 Subject: [PATCH 3/3] document modify_other_keys --- config | 2 +- man/termite.config.5 | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/config b/config index 9042259..27db86f 100644 --- a/config +++ b/config @@ -28,7 +28,7 @@ cursor_shape = block # Hide links that are no longer valid in url select overlay mode filter_unmatched_urls = true -# emit escape sequences for other keys modified by Control +# emit escape sequences for extra modified keys #modify_other_keys = false [colors] diff --git a/man/termite.config.5 b/man/termite.config.5 index 898fbdf..1697a2a 100644 --- a/man/termite.config.5 +++ b/man/termite.config.5 @@ -36,6 +36,9 @@ The font description for the terminal's font. The default window geometry for new terminal windows. .IP \fIicon_name\fR The name of the icon to be used for the terminal process. +.IP \fImodify_other_keys\fR +Emit escape sequences for extra keys, like the \fBmodifyOtherKeys\fR +resource for \fBxterm\fR(1). .IP \fImouse_autohide\fR Automatically hide the mouse pointer when you start typing. .IP \fIscrollback_lines\fR