diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2014-07-21 21:29:44 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2014-07-21 21:29:44 +0200 |
commit | 3aadfc6765b3560dce639b22abb05503aba47bc9 (patch) | |
tree | 212104f12b2ac37d8efe5cc7d16e5075d8be5c96 /src | |
parent | 29385e39be4fcf47bedbdefc85d619ceee3cc6ac (diff) | |
download | weechat-3aadfc6765b3560dce639b22abb05503aba47bc9.zip |
core: fix insert of mouse code in input line after a partial key combo (closes #130)
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/gui-key.c | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/src/gui/gui-key.c b/src/gui/gui-key.c index 618c48854..4cbaaea52 100644 --- a/src/gui/gui-key.c +++ b/src/gui/gui-key.c @@ -1240,6 +1240,34 @@ end: } /* + * Checks if the given combo of keys is complete or not. + * It's not complete if the end of string is in the middle of a key + * (for example meta- without the following char/key). + * + * Returns: + * 0: key is incomplete (truncated) + * 1: key is complete + */ + +int +gui_key_is_complete (const char *key) +{ + int length; + + if (!key || !key[0]) + return 1; + + length = strlen (key); + + if (((length >= 1) && (strcmp (key + length - 1, "\x01") == 0)) + || ((length >= 2) && (strcmp (key + length - 2, "\x01[") == 0)) + || ((length >= 3) && (strcmp (key + length - 3, "\x01[[") == 0))) + return 0; + + return 1; +} + +/* * Processes a new key pressed. * * Returns: @@ -1289,7 +1317,7 @@ gui_key_pressed (const char *key_str) return 0; } - if (strcmp (gui_key_combo_buffer, "\x01[[M") == 0) + if (strstr (gui_key_combo_buffer, "\x01[[M")) { gui_key_combo_buffer[0] = '\0'; gui_mouse_event_init (); @@ -1389,7 +1417,8 @@ gui_key_pressed (const char *key_str) } } - gui_key_combo_buffer[0] = '\0'; + if (gui_key_is_complete (gui_key_combo_buffer)) + gui_key_combo_buffer[0] = '\0'; /* * if this is first key and not found (even partial) => return 1 |