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 diff --git a/termite.cc b/termite.cc index 5e0cc97..b32b366 100644 --- a/termite.cc +++ b/termite.cc @@ -205,12 +205,41 @@ static const std::map modify_table = { { GDK_KEY_question, "\033[27;6;63~" }, }; -static gboolean modify_key_feed(GdkEventKey *event, keybind_info *info) { +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) { 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,16 +931,20 @@ 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|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: 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; } }