diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2017-06-10 08:15:44 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2017-06-10 08:15:44 +0200 |
commit | 46b27bff4e9e604b4c882f8043f8638e30078760 (patch) | |
tree | 23fe7e4d6e192c67e7db4c803f46559130868588 /src | |
parent | 964481aaebe10e06fb282daa9a749812260bc21e (diff) | |
download | weechat-46b27bff4e9e604b4c882f8043f8638e30078760.zip |
core: fix bind of keys with space key, like alt+space (bug #32133)
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/gui-key.c | 119 |
1 files changed, 67 insertions, 52 deletions
diff --git a/src/gui/gui-key.c b/src/gui/gui-key.c index f2e7c0ab9..4fbd2db21 100644 --- a/src/gui/gui-key.c +++ b/src/gui/gui-key.c @@ -273,42 +273,49 @@ gui_key_grab_end_timer_cb (const void *pointer, void *data, char * gui_key_get_internal_code (const char *key) { - char *result; + char *result, *result2; if ((key[0] == '@') && strchr (key, ':')) return strdup (key); - if ((result = malloc (strlen (key) + 1))) + result = malloc (strlen (key) + 1); + if (!result) + return NULL; + + result[0] = '\0'; + while (key[0]) { - result[0] = '\0'; - while (key[0]) + if (strncmp (key, "meta2-", 6) == 0) { - if (strncmp (key, "meta2-", 6) == 0) - { - strcat (result, "\x01[["); - key += 6; - } - if (strncmp (key, "meta-", 5) == 0) - { - strcat (result, "\x01["); - key += 5; - } - else if (strncmp (key, "ctrl-", 5) == 0) - { - strcat (result, "\x01"); - key += 5; - } - else - { - strncat (result, key, 1); - key++; - } + strcat (result, "\x01[["); + key += 6; + } + if (strncmp (key, "meta-", 5) == 0) + { + strcat (result, "\x01["); + key += 5; + } + else if (strncmp (key, "ctrl-", 5) == 0) + { + strcat (result, "\x01"); + key += 5; + } + else if (strncmp (key, "space", 5) == 0) + { + strcat (result, " "); + key += 5; + } + else + { + strncat (result, key, 1); + key++; } } - else - return NULL; - return result; + result2 = strdup (result); + free (result); + + return result2; } /* @@ -322,41 +329,49 @@ gui_key_get_internal_code (const char *key) char * gui_key_get_expanded_name (const char *key) { - char *result; + char *result, *result2; if (!key) return NULL; result = malloc ((strlen (key) * 5) + 1); - if (result) + if (!result) + return NULL; + + result[0] = '\0'; + while (key[0]) { - result[0] = '\0'; - while (key[0]) + if (strncmp (key, "\x01[[", 3) == 0) { - if (strncmp (key, "\x01[[", 3) == 0) - { - strcat (result, "meta2-"); - key += 3; - } - if (strncmp (key, "\x01[", 2) == 0) - { - strcat (result, "meta-"); - key += 2; - } - else if ((key[0] == '\x01') && (key[1])) - { - strcat (result, "ctrl-"); - key++; - } - else - { - strncat (result, key, 1); - key++; - } + strcat (result, "meta2-"); + key += 3; + } + if (strncmp (key, "\x01[", 2) == 0) + { + strcat (result, "meta-"); + key += 2; + } + else if ((key[0] == '\x01') && (key[1])) + { + strcat (result, "ctrl-"); + key++; + } + else if (key[0] == ' ') + { + strcat (result, "space"); + key++; + } + else + { + strncat (result, key, 1); + key++; } } - return result; + result2 = strdup (result); + free (result); + + return result2; } /* |