Added SILC Thread Queue API
[crypto.git] / apps / irssi / src / fe-common / core / keyboard.c
index fb1d89fec0f47ac6ee44f4749e3978987978f552..717bed1f6248ab6602559dc4b0dbc0f9d4c84d9e 100644 (file)
@@ -388,6 +388,8 @@ static void key_configure_destroy(KEY_REC *rec)
        rec->info->keys = g_slist_remove(rec->info->keys, rec);
        g_hash_table_remove(keys, rec->key);
 
+       signal_emit("key destroyed", 1, rec);
+
        if (!key_config_frozen)
                 key_states_rescan();
 
@@ -421,6 +423,8 @@ static void key_configure_create(const char *id, const char *key,
        info->keys = g_slist_append(info->keys, rec);
        g_hash_table_insert(keys, rec->key, rec);
 
+       signal_emit("key created", 1, rec);
+
        if (!key_config_frozen)
                 key_states_rescan();
 }
@@ -547,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;
@@ -561,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;
@@ -579,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 ? -1 : 1;
        }
 
        if (g_tree_lookup(key_states, combo) != rec) {
                /* key combo continues.. */
                keyboard->key_state = combo;
-                return TRUE;
+                return 0;
        }
 
         /* finished key combo, execute */
@@ -593,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,