1
0
mirror of https://github.com/irssi/irssi.git synced 2024-12-04 14:46:39 -05:00

Modify escape of ^ key so it can be used as well as Ctrl+^

Fixes FS#721

This makes Ctrl+^ and ^ bindable again as different keys. We do this
by escaping single `^` as `^-`, which is not a valid control character
(unlike `^^`)

The original approach suggested in FS#721 is insufficient, it will
break bindings such as `meta-^` because Irssi is convinced that `^`
introduces a Control-key ("key combo") so it is waiting for what may
follow.
This commit is contained in:
Ailin Nemui 2014-07-28 13:58:13 +02:00
parent cb6266f212
commit 09f23d06b5
2 changed files with 13 additions and 7 deletions

View File

@ -292,12 +292,18 @@ static int expand_key(const char *key, GSList **out)
} }
last_hyphen = !last_hyphen; last_hyphen = !last_hyphen;
} else if (*key == '^') { } else if (*key == '^') {
/* ctrl-code */
if (key[1] != '\0')
key++;
expand_out_char(*out, '^'); expand_out_char(*out, '^');
/* ctrl-code */
if (key[1] != '\0' && key[1] != '-') {
key++;
expand_out_char(*out, *key); expand_out_char(*out, *key);
}
else {
/* escaped syntax for ^, see gui-readline.c */
expand_out_char(*out, '-');
}
expand_out_char(*out, '-'); expand_out_char(*out, '-');
last_hyphen = FALSE; /* optional */ last_hyphen = FALSE; /* optional */
} else if (last_hyphen && i_isalpha(*key)) { } else if (last_hyphen && i_isalpha(*key)) {

View File

@ -393,8 +393,8 @@ static void sig_gui_key_pressed(gpointer keyp)
} }
if (strcmp(str, "^") == 0) { if (strcmp(str, "^") == 0) {
/* change it as ^^ */ /* change it as ^-, that is an invalid control char */
str[1] = '^'; str[1] = '-';
str[2] = '\0'; str[2] = '\0';
} }