summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/fe-common/core/keyboard.c10
-rw-r--r--src/fe-common/core/keyboard.h5
-rw-r--r--src/fe-text/gui-readline.c20
3 files changed, 22 insertions, 13 deletions
diff --git a/src/fe-common/core/keyboard.c b/src/fe-common/core/keyboard.c
index 9bbb218a..f117c76f 100644
--- a/src/fe-common/core/keyboard.c
+++ b/src/fe-common/core/keyboard.c
@@ -551,8 +551,6 @@ static int key_states_search(const unsigned char *combo,
return 0;
}
-/* Returns TRUE if key press was consumed. Control characters should be sent
- as "^@" .. "^_" instead of #0..#31 chars, #127 should be sent as ^? */
int key_pressed(KEYBOARD_REC *keyboard, const char *key)
{
KEY_REC *rec;
@@ -565,7 +563,7 @@ int key_pressed(KEYBOARD_REC *keyboard, const char *key)
if (keyboard->key_state == NULL && key[1] == '\0' &&
!used_keys[(int) (unsigned char) key[0]]) {
/* fast check - key not used */
- return FALSE;
+ return -1;
}
first_key = keyboard->key_state == NULL;
@@ -583,13 +581,13 @@ int key_pressed(KEYBOARD_REC *keyboard, const char *key)
/* unknown key combo, eat the invalid key
unless it was the first key pressed */
g_free(combo);
- return !first_key;
+ return first_key ? 0 : -1;
}
if (g_tree_lookup(key_states, combo) != rec) {
/* key combo continues.. */
keyboard->key_state = combo;
- return TRUE;
+ return 0;
}
/* finished key combo, execute */
@@ -597,7 +595,7 @@ int key_pressed(KEYBOARD_REC *keyboard, const char *key)
consumed = key_emit_signal(keyboard, rec);
/* never consume non-control characters */
- return consumed;
+ return consumed ? 1 : -1;
}
void keyboard_entry_redirect(SIGNAL_FUNC func, const char *entry,
diff --git a/src/fe-common/core/keyboard.h b/src/fe-common/core/keyboard.h
index eff8966a..970dc7b7 100644
--- a/src/fe-common/core/keyboard.h
+++ b/src/fe-common/core/keyboard.h
@@ -29,8 +29,9 @@ extern GSList *keyinfos;
KEYBOARD_REC *keyboard_create(void *gui_data);
/* Destroys a keyboard */
void keyboard_destroy(KEYBOARD_REC *keyboard);
-/* Returns TRUE if key press was consumed. Control characters should be sent
- as "^@" .. "^_" instead of #0..#31 chars, #127 should be sent as ^? */
+/* Returns 1 if key press was consumed, -1 if not, 0 if it's beginning of a
+ key combo. Control characters should be sent as "^@" .. "^_" instead of
+ #0..#31 chars, #127 should be sent as ^? */
int key_pressed(KEYBOARD_REC *keyboard, const char *key);
void key_bind(const char *id, const char *description,
diff --git a/src/fe-text/gui-readline.c b/src/fe-text/gui-readline.c
index 0bded74f..e94555a5 100644
--- a/src/fe-text/gui-readline.c
+++ b/src/fe-text/gui-readline.c
@@ -343,7 +343,7 @@ static void sig_gui_key_pressed(gpointer keyp)
GTimeVal now;
unichar key;
char str[20];
- int diff;
+ int ret, diff;
key = GPOINTER_TO_INT(keyp);
@@ -355,10 +355,11 @@ static void sig_gui_key_pressed(gpointer keyp)
g_get_current_time(&now);
diff = (now.tv_sec - last_keypress.tv_sec) * 1000 +
(now.tv_usec - last_keypress.tv_usec)/1000;
- last_keypress = now;
- if (check_pasting(key, diff))
+ if (check_pasting(key, diff)) {
+ last_keypress = now;
return;
+ }
if (key < 32) {
/* control key */
@@ -394,11 +395,20 @@ static void sig_gui_key_pressed(gpointer keyp)
prev_entry_pos = gui_entry_get_pos(active_entry);
prev_key = key;
- if (escape_next_key || !key_pressed(keyboard, str)) {
+ ret = key_pressed(keyboard, str);
+ if (escape_next_key || ret < 0) {
/* key wasn't used for anything, print it */
escape_next_key = FALSE;
gui_entry_insert_char(active_entry, key);
}
+
+ if (ret != 0) {
+ /* some key create multiple characters - we're in the middle
+ of one. try to detect the keycombo as a single keypress
+ rather than multiple small onces to avoid incorrect
+ paste detection. */
+ last_keypress = now;
+ }
}
static void key_send_line(void)
@@ -892,7 +902,7 @@ void gui_readline_init(void)
settings_add_time("misc", "paste_detect_time", "10msecs");
/* NOTE: function keys can generate at least 5 characters long
keycodes. this must be larger to allow them to work. */
- settings_add_int("misc", "paste_detect_keycount", 9);
+ settings_add_int("misc", "paste_detect_keycount", 6);
settings_add_int("misc", "paste_verify_line_count", 5);
setup_changed();