Merged with Irssi 0.8.6.
[silc.git] / apps / irssi / src / fe-text / gui-readline.c
index 1cabfac72b634e77e804139e1619e97cc7b97600..66867ffb7de0924074087efaf629eacbe806e4ab 100644 (file)
@@ -81,10 +81,10 @@ static void handle_key_redirect(int key)
        data = redir->data;
        g_free_and_null(redir);
 
+       gui_entry_set_prompt(active_entry, "");
+
        if (func != NULL)
                func(key, data, active_win->active_server, active_win->active);
-
-       gui_entry_set_prompt(active_entry, "");
 }
 
 static void handle_entry_redirect(const char *line)
@@ -98,12 +98,12 @@ static void handle_entry_redirect(const char *line)
        data = redir->data;
        g_free_and_null(redir);
 
+       gui_entry_set_prompt(active_entry, "");
+
        if (func != NULL) {
                func(line, data, active_win->active_server,
                     active_win->active);
        }
-
-       gui_entry_set_prompt(active_entry, "");
 }
 
 static int get_scroll_count(void)
@@ -134,17 +134,20 @@ static void window_next_page(void)
        gui_window_scroll(active_win, get_scroll_count());
 }
 
-void handle_key(unichar key)
+static void sig_gui_key_pressed(gpointer keyp)
 {
+        unichar key;
        char str[20];
 
-       idle_time = time(NULL);
+       key = GPOINTER_TO_INT(keyp);
 
        if (redir != NULL && redir->flags & ENTRY_REDIRECT_FLAG_HOTKEY) {
                handle_key_redirect(key);
                return;
        }
 
+       idle_time = time(NULL);
+
        if (key < 32) {
                /* control key */
                 str[0] = '^';
@@ -367,8 +370,10 @@ static void sig_input(void)
                if (!term_detached)
                        signal_emit("command quit", 1, "Lost terminal");
        } else {
-               for (i = 0; i < ret; i++)
-                       handle_key(buffer[i]);
+               for (i = 0; i < ret; i++) {
+                       signal_emit("gui key pressed", 1,
+                                   GINT_TO_POINTER(buffer[i]));
+               }
        }
 }
 
@@ -762,6 +767,7 @@ void gui_readline_init(void)
 
        signal_add("window changed automatic", (SIGNAL_FUNC) sig_window_auto_changed);
        signal_add("gui entry redirect", (SIGNAL_FUNC) sig_gui_entry_redirect);
+       signal_add("gui key pressed", (SIGNAL_FUNC) sig_gui_key_pressed);
 }
 
 void gui_readline_deinit(void)
@@ -825,4 +831,5 @@ void gui_readline_deinit(void)
 
        signal_remove("window changed automatic", (SIGNAL_FUNC) sig_window_auto_changed);
        signal_remove("gui entry redirect", (SIGNAL_FUNC) sig_gui_entry_redirect);
+       signal_remove("gui key pressed", (SIGNAL_FUNC) sig_gui_key_pressed);
 }