produce escape sequences for extra Ctrl- modified keys
current xterm has the resource modifyOtherKeys which, when enabled, constructs escape sequences for many Ctrl-, Shift-, and Meta- modified keys. This implements support for some Ctrl- modified keys.
This commit is contained in:
parent
9edd015348
commit
4416affc56
55
termite.cc
55
termite.cc
|
@ -22,6 +22,7 @@
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
#include <map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
@ -130,6 +131,45 @@ static long first_row(VteTerminal *vte);
|
||||||
|
|
||||||
static std::function<void ()> reload_config;
|
static std::function<void ()> reload_config;
|
||||||
|
|
||||||
|
static const std::map<int, const char *> modify_table = {
|
||||||
|
{ GDK_KEY_Tab, "\033[27;5;9~" },
|
||||||
|
{ GDK_KEY_Return, "\033[27;5;13~" },
|
||||||
|
{ GDK_KEY_apostrophe, "\033[27;5;39~" },
|
||||||
|
{ GDK_KEY_comma, "\033[27;5;44~" },
|
||||||
|
{ GDK_KEY_minus, "\033[27;5;45~" },
|
||||||
|
{ GDK_KEY_period, "\033[27;5;46~" },
|
||||||
|
{ GDK_KEY_0, "\033[27;5;48~" },
|
||||||
|
{ GDK_KEY_1, "\033[27;5;49~" },
|
||||||
|
{ GDK_KEY_9, "\033[27;5;57~" },
|
||||||
|
{ GDK_KEY_semicolon, "\033[27;5;59~" },
|
||||||
|
{ GDK_KEY_equal, "\033[27;5;61~" },
|
||||||
|
{ GDK_KEY_exclam, "\033[27;6;33~" },
|
||||||
|
{ GDK_KEY_quotedbl, "\033[27;6;34~" },
|
||||||
|
{ GDK_KEY_numbersign, "\033[27;6;35~" },
|
||||||
|
{ GDK_KEY_dollar, "\033[27;6;36~" },
|
||||||
|
{ GDK_KEY_percent, "\033[27;6;37~" },
|
||||||
|
{ GDK_KEY_ampersand, "\033[27;6;38~" },
|
||||||
|
{ GDK_KEY_parenleft, "\033[27;6;40~" },
|
||||||
|
{ GDK_KEY_parenright, "\033[27;6;41~" },
|
||||||
|
{ GDK_KEY_asterisk, "\033[27;6;42~" },
|
||||||
|
{ GDK_KEY_plus, "\033[27;6;43~" },
|
||||||
|
{ GDK_KEY_colon, "\033[27;6;58~" },
|
||||||
|
{ GDK_KEY_less, "\033[27;6;60~" },
|
||||||
|
{ GDK_KEY_greater, "\033[27;6;62~" },
|
||||||
|
{ GDK_KEY_question, "\033[27;6;63~" },
|
||||||
|
};
|
||||||
|
|
||||||
|
static gboolean modify_key_feed(GdkEventKey *event, keybind_info *info) {
|
||||||
|
unsigned int keyval = gdk_keyval_to_lower(event->keyval);
|
||||||
|
auto entry = modify_table.find((int)keyval);
|
||||||
|
|
||||||
|
if (entry != modify_table.end()) {
|
||||||
|
vte_terminal_feed_child(info->vte, entry->second, -1);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
void launch_browser(char *browser, char *url) {
|
void launch_browser(char *browser, char *url) {
|
||||||
char *browser_cmd[3] = {browser, url, nullptr};
|
char *browser_cmd[3] = {browser, url, nullptr};
|
||||||
GError *error = nullptr;
|
GError *error = nullptr;
|
||||||
|
@ -791,10 +831,19 @@ gboolean key_press_cb(VteTerminal *vte, GdkEventKey *event, keybind_info *info)
|
||||||
case GDK_KEY_r:
|
case GDK_KEY_r:
|
||||||
reload_config();
|
reload_config();
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
default:
|
||||||
|
if (modify_key_feed(event, info))
|
||||||
|
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))
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
} else if (modifiers == GDK_CONTROL_MASK && event->keyval == GDK_KEY_Tab) {
|
|
||||||
overlay_show(&info->panel, overlay_mode::completion, vte);
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue