Example #1
0
void
gui_mouse_grab_end (const char *mouse_key)
{
    char mouse_key_input[256];

    /* insert mouse key in input */
    if (gui_current_window->buffer->input)
    {
        if (gui_mouse_grab == 2)
        {
            /* mouse key with area */
            snprintf (mouse_key_input, sizeof (mouse_key_input),
                      "%s:%s",
                      gui_mouse_grab_event2input (),
                      mouse_key);
        }
        else
        {
            /* mouse key without area */
            snprintf (mouse_key_input, sizeof (mouse_key_input),
                      "%s", mouse_key);
        }
        gui_input_insert_string (gui_current_window->buffer,
                                 mouse_key_input, -1);
        if (gui_current_window->buffer->completion)
            gui_completion_stop (gui_current_window->buffer->completion, 1);
        gui_input_text_changed_modifier_and_signal (gui_current_window->buffer, 1);
    }

    gui_mouse_grab = 0;
}
Example #2
0
void
gui_cursor_display_debug_info ()
{
    struct t_gui_focus_info *focus_info;
    char str_info[1024];

    if (!gui_cursor_debug)
        return;

    focus_info = gui_focus_get_info (gui_cursor_x, gui_cursor_y);
    if (focus_info)
    {
        snprintf (str_info, sizeof (str_info),
                  "%s(%d,%d) window:0x%lx, buffer:0x%lx (%s), "
                  "bar_window:0x%lx (bar: %s, item: %s, line: %d, col: %d), "
                  "chat: %d, word: \"%s\"",
                  gui_color_get_custom ("yellow,red"),
                  focus_info->x, focus_info->y,
                  (long unsigned int)focus_info->window,
                  (long unsigned int)focus_info->buffer,
                  (focus_info->buffer) ? (focus_info->buffer)->full_name : "-",
                  (long unsigned int)focus_info->bar_window,
                  (focus_info->bar_window) ? ((focus_info->bar_window)->bar)->name : "-",
                  (focus_info->bar_item) ? focus_info->bar_item : "-",
                  focus_info->bar_item_line,
                  focus_info->bar_item_col,
                  focus_info->chat,
                  focus_info->chat_word);
        gui_input_delete_line (gui_current_window->buffer);
        gui_input_insert_string (gui_current_window->buffer, str_info, -1);
        gui_focus_free_info (focus_info);
    }
}
Example #3
0
void
gui_input_clipboard_paste ()
{
    if ((gui_current_window->buffer->input)
        && gui_input_clipboard) 
    {
        gui_input_insert_string (gui_current_window->buffer,
                                 gui_input_clipboard, -1);
        gui_completion_stop (gui_current_window->buffer->completion, 1);
        
        gui_input_text_changed_modifier_and_signal (gui_current_window->buffer);
    }
}
Example #4
0
int
gui_chat_hsignal_quote_line_cb (void *data, const char *signal,
                                struct t_hashtable *hashtable)
{
    const char *time, *prefix, *message;
    int length_time, length_prefix, length_message, length;
    char *str;

    /* make C compiler happy */
    (void) data;

    if (!gui_current_window->buffer->input)
        return WEECHAT_RC_OK;

    time = (strstr (signal, "time")) ?
        hashtable_get (hashtable, "_chat_line_time") : NULL;
    prefix = (strstr (signal, "prefix")) ?
        hashtable_get (hashtable, "_chat_line_prefix") : NULL;
    message = hashtable_get (hashtable, "_chat_line_message");

    if (!message)
        return WEECHAT_RC_OK;

    length_time = (time) ? strlen (time) : 0;
    length_prefix = (prefix) ? strlen (prefix) : 0;
    length_message = strlen (message);

    length = length_time + 1 + length_prefix + 1 +
        strlen (CONFIG_STRING(config_look_prefix_suffix)) + 1 +
        length_message + 1 + 1;
    str = malloc (length);
    if (str)
    {
        snprintf (str, length, "%s%s%s%s%s%s%s ",
                  (time) ? time : "",
                  (time) ? " " : "",
                  (prefix) ? prefix : "",
                  (prefix) ? " " : "",
                  (time || prefix) ? CONFIG_STRING(config_look_prefix_suffix) : "",
                  ((time || prefix) && CONFIG_STRING(config_look_prefix_suffix)
                   && CONFIG_STRING(config_look_prefix_suffix)[0]) ? " " : "",
                  message);
        gui_input_insert_string (gui_current_window->buffer, str, -1);
        gui_input_text_changed_modifier_and_signal (gui_current_window->buffer,
                                                    1, /* save undo */
                                                    1); /* stop completion */
        free (str);
    }

    return WEECHAT_RC_OK;
}
Example #5
0
void
gui_input_insert (const char *args)
{
    char *args2;
    
    if (args)
    {
        args2 = string_convert_hex_chars (args);
        gui_input_insert_string (gui_current_window->buffer, (args2) ? args2 : args, -1);
        gui_input_text_changed_modifier_and_signal (gui_current_window->buffer);
        if (args2)
            free (args2);
    }
}
Example #6
0
int
gui_chat_hsignal_quote_line_cb (const void *pointer, void *data,
                                const char *signal,
                                struct t_hashtable *hashtable)
{
    const char *date, *line, *prefix, *ptr_prefix, *message;
    long unsigned int value;
    long number;
    struct tm *local_time;
    struct t_gui_line *ptr_line;
    int is_nick, length_time, length_nick_prefix, length_prefix;
    int length_nick_suffix, length_message, length, rc;
    time_t line_date;
    char str_time[128], *str, *error;

    /* make C compiler happy */
    (void) pointer;
    (void) data;

    if (!gui_current_window->buffer->input)
        return WEECHAT_RC_OK;

    /* get time */
    str_time[0] = '\0';
    date = (strstr (signal, "time")) ?
        hashtable_get (hashtable, "_chat_line_date") : NULL;
    if (date)
    {
        number = strtol (date, &error, 10);
        if (error && !error[0])
        {
            line_date = (time_t)number;
            local_time = localtime (&line_date);
            if (local_time)
            {
                strftime (str_time, sizeof (str_time),
                          CONFIG_STRING(config_look_quote_time_format),
                          local_time);
            }
        }
    }

    /* check if the prefix is a nick */
    is_nick = 0;
    line = hashtable_get (hashtable, "_chat_line");
    if (line && line[0])
    {
        rc = sscanf (line, "%lx", &value);
        if ((rc != EOF) && (rc != 0))
        {
            ptr_line = (struct t_gui_line *)value;
            if (gui_line_search_tag_starting_with (ptr_line, "prefix_nick"))
                is_nick = 1;
        }
    }

    /* get prefix + message */
    prefix = (strstr (signal, "prefix")) ?
        hashtable_get (hashtable, "_chat_line_prefix") : NULL;
    ptr_prefix = prefix;
    if (ptr_prefix)
    {
        while (ptr_prefix[0] == ' ')
        {
            ptr_prefix++;
        }
    }
    message = hashtable_get (hashtable, "_chat_line_message");

    if (!message)
        return WEECHAT_RC_OK;

    length_time = strlen (str_time);
    length_nick_prefix = strlen (CONFIG_STRING(config_look_quote_nick_prefix));
    length_prefix = (ptr_prefix) ? strlen (ptr_prefix) : 0;
    length_nick_suffix = strlen (CONFIG_STRING(config_look_quote_nick_suffix));
    length_message = strlen (message);

    length = length_time + 1 +
        length_nick_prefix + length_prefix + length_nick_suffix + 1 +
        length_message + 1 + 1;
    str = malloc (length);
    if (str)
    {
        snprintf (str, length, "%s%s%s%s%s%s%s ",
                  str_time,
                  (str_time[0]) ? " " : "",
                  (ptr_prefix && ptr_prefix[0] && is_nick) ? CONFIG_STRING(config_look_quote_nick_prefix) : "",
                  (ptr_prefix) ? ptr_prefix : "",
                  (ptr_prefix && ptr_prefix[0] && is_nick) ? CONFIG_STRING(config_look_quote_nick_suffix) : "",
                  (ptr_prefix && ptr_prefix[0]) ? " " : "",
                  message);
        gui_input_insert_string (gui_current_window->buffer, str, -1);
        gui_input_text_changed_modifier_and_signal (gui_current_window->buffer,
                                                    1, /* save undo */
                                                    1); /* stop completion */
        free (str);
    }

    return WEECHAT_RC_OK;
}
Example #7
0
void
gui_input_complete (struct t_gui_buffer *buffer)
{
    int i;
    
    if (!buffer->completion)
        return;
    
    if (buffer->completion->word_found)
    {
        /* replace word with new completed word into input buffer */
        if (buffer->completion->diff_size > 0)
        {
            buffer->input_buffer_size +=
                buffer->completion->diff_size;
            buffer->input_buffer_length +=
                buffer->completion->diff_length;
            gui_input_optimize_size (buffer);
            buffer->input_buffer[buffer->input_buffer_size] = '\0';
            for (i = buffer->input_buffer_size - 1;
                 i >=  buffer->completion->position_replace +
                     (int)strlen (buffer->completion->word_found); i--)
            {
                buffer->input_buffer[i] =
                    buffer->input_buffer[i - buffer->completion->diff_size];
            }
        }
        else
        {
            for (i = buffer->completion->position_replace +
                     strlen (buffer->completion->word_found);
                 i < buffer->input_buffer_size; i++)
            {
                buffer->input_buffer[i] =
                    buffer->input_buffer[i - buffer->completion->diff_size];
            }
            buffer->input_buffer_size += buffer->completion->diff_size;
            buffer->input_buffer_length += buffer->completion->diff_length;
            gui_input_optimize_size (buffer);
            buffer->input_buffer[buffer->input_buffer_size] = '\0';
        }
            
        strncpy (buffer->input_buffer + buffer->completion->position_replace,
                 buffer->completion->word_found,
                 strlen (buffer->completion->word_found));
        buffer->input_buffer_pos =
            utf8_pos (buffer->input_buffer,
                      buffer->completion->position_replace) +
            utf8_strlen (buffer->completion->word_found);
        
        /* position is < 0 this means only one word was found to complete,
           so reinit to stop completion */
        if (buffer->completion->position >= 0)
            buffer->completion->position = utf8_real_pos (buffer->input_buffer,
                                                      buffer->input_buffer_pos);
        
        /* add space if needed after completion */
        if (buffer->completion->add_space)
        {
            if (buffer->input_buffer[utf8_real_pos (buffer->input_buffer,
                                                    buffer->input_buffer_pos)] != ' ')
                gui_input_insert_string (buffer, " ",
                                         buffer->input_buffer_pos);
            else
                buffer->input_buffer_pos++;
            if (buffer->completion->position >= 0)
                buffer->completion->position++;
        }
        gui_input_text_changed_modifier_and_signal (buffer);
    }
}
Example #8
0
void
gui_key_flush (int paste)
{
    int i, key, last_key_used, insert_ok, undo_done;
    static char key_str[64] = { '\0' };
    static int length_key_str = 0;
    char key_temp[2], *key_utf, *input_old, *ptr_char, *next_char, *ptr_error;
    char utf_partial_char[16];
    struct t_gui_buffer *old_buffer;

    /* if paste pending or bracketed paste detected, just return */
    if (gui_key_paste_pending || gui_key_paste_bracketed)
        return;

    /* if buffer is empty, just return */
    if (gui_key_buffer_size == 0)
        return;

    /*
     * if there's no paste pending, then we use buffer and do actions
     * according to keys
     */
    gui_key_last_activity_time = time (NULL);
    last_key_used = -1;
    undo_done = 0;
    old_buffer = NULL;
    for (i = 0; i < gui_key_buffer_size; i++)
    {
        key = gui_key_buffer[i];
        insert_ok = 1;
        utf_partial_char[0] = '\0';

        if (gui_mouse_event_pending || (key < 32) || (key == 127))
        {
            if (gui_mouse_event_pending)
            {
                insert_ok = 0;
                key_str[0] = (char)key;
                key_str[1] = '\0';
                length_key_str = 1;
            }
            else if (key < 32)
            {
                insert_ok = 0;
                key_str[0] = '\x01';
                key_str[1] = (char)key + '@';
                key_str[2] = '\0';
                length_key_str = 2;
            }
            else if (key == 127)
            {
                key_str[0] = '\x01';
                key_str[1] = '?';
                key_str[2] = '\0';
                length_key_str = 2;
            }
        }
        else
        {
            if (local_utf8)
            {
                key_str[length_key_str] = (char)key;
                key_str[length_key_str + 1] = '\0';
                length_key_str++;

                /*
                 * replace invalid chars by "?", but NOT last char of
                 * string, if it is incomplete UTF-8 char (another char
                 * will be added to the string on next iteration)
                 */
                ptr_char = key_str;
                while (ptr_char && ptr_char[0])
                {
                    (void) utf8_is_valid (ptr_char, -1, &ptr_error);
                    if (!ptr_error)
                        break;
                    next_char = (char *)utf8_next_char (ptr_error);
                    if (next_char && next_char[0])
                    {
                        ptr_char = ptr_error;
                        while (ptr_char < next_char)
                        {
                            ptr_char[0] = '?';
                            ptr_char++;
                        }
                    }
                    else
                    {
                        strcpy (utf_partial_char, ptr_char);
                        ptr_char[0] = '\0';
                        break;
                    }
                    ptr_char = next_char;
                }
            }
            else
            {
                /* convert input to UTF-8 */
                key_temp[0] = (char)key;
                key_temp[1] = '\0';
                key_utf = string_iconv_to_internal (NULL, key_temp);
                strcat (key_str, key_utf);
            }
        }

        if (key_str[0])
        {
            (void) hook_signal_send ("key_pressed",
                                     WEECHAT_HOOK_SIGNAL_STRING, key_str);

            if (gui_current_window->buffer->text_search != GUI_TEXT_SEARCH_DISABLED)
                input_old = (gui_current_window->buffer->input_buffer) ?
                    strdup (gui_current_window->buffer->input_buffer) : strdup ("");
            else
                input_old = NULL;
            old_buffer = gui_current_window->buffer;

            if ((gui_key_pressed (key_str) != 0) && (insert_ok)
                && (!gui_cursor_mode))
            {
                if (!paste || !undo_done)
                    gui_buffer_undo_snap (gui_current_window->buffer);
                gui_input_insert_string (gui_current_window->buffer,
                                         key_str, -1);
                gui_input_text_changed_modifier_and_signal (gui_current_window->buffer,
                                                            (!paste || !undo_done) ? 1 : 0,
                                                            1); /* stop completion */
                undo_done = 1;
            }

            /* incremental text search in buffer */
            if ((old_buffer == gui_current_window->buffer)
                && (gui_current_window->buffer->text_search != GUI_TEXT_SEARCH_DISABLED)
                && ((input_old == NULL)
                    || (gui_current_window->buffer->input_buffer == NULL)
                    || (strcmp (input_old, gui_current_window->buffer->input_buffer) != 0)))
            {
                /*
                 * if following conditions are all true, then do not search
                 * again (search will not find any result and can take some time
                 * on a buffer with many lines):
                 * - old search was not successful
                 * - searching a string (not a regex)
                 * - current input is longer than old input
                 * - beginning of current input is exactly equal to old input.
                 */
                if (!gui_current_window->buffer->text_search_found
                    && !gui_current_window->buffer->text_search_regex
                    && (input_old != NULL)
                    && (input_old[0])
                    && (gui_current_window->buffer->input_buffer != NULL)
                    && (gui_current_window->buffer->input_buffer[0])
                    && (strlen (gui_current_window->buffer->input_buffer) > strlen (input_old))
                    && (strncmp (gui_current_window->buffer->input_buffer, input_old,
                                 strlen (input_old)) == 0))
                {
                    /*
                     * do not search text in buffer, just alert about text not
                     * found
                     */
                    if (CONFIG_BOOLEAN(config_look_search_text_not_found_alert))
                    {
                        fprintf (stderr, "\a");
                        fflush (stderr);
                    }
                }
                else
                {
                    gui_window_search_restart (gui_current_window);
                }
            }

            if (input_old)
                free (input_old);
        }

        /* prepare incomplete UTF-8 char for next iteration */
        if (utf_partial_char[0])
            strcpy (key_str, utf_partial_char);
        else
            key_str[0] = '\0';
        length_key_str = strlen (key_str);

        /* set last key used in buffer if combo buffer is empty */
        if (gui_key_grab || gui_mouse_event_pending || !gui_key_combo_buffer[0])
            last_key_used = i;
    }

    if (last_key_used == gui_key_buffer_size - 1)
        gui_key_buffer_reset ();
    else if (last_key_used >= 0)
        gui_key_buffer_remove (0, last_key_used + 1);

    if (!gui_key_grab && !gui_mouse_event_pending)
        gui_key_combo_buffer[0] = '\0';
}
Example #9
0
int
gui_chat_hsignal_quote_line_cb (void *data, const char *signal,
                                struct t_hashtable *hashtable)
{
    const char *time, *prefix, *message, *date, *nick, *tags;
    unsigned int length_time, length_prefix, length_message, length;
    char *str, *ptr_str_time, *custom_nick_prefix;
    static char str_time[128];
    struct tm local_time;
    int tags_count, i, custom_nick_ok = 0;
    char **tags_array;

    /* make C compiler happy */
    (void) data;

    if (!gui_current_window->buffer->input)
        return WEECHAT_RC_OK;

    if (strstr(signal, "time"))
    {
        if (!CONFIG_STRING(config_look_quote_time_format) ||
            !CONFIG_STRING(config_look_quote_time_format)[0])
            time = hashtable_get (hashtable, "_chat_line_time");
        else
        {
            date = hashtable_get (hashtable, "_chat_line_date");
            if (date && date[0] && strptime (date, "%s", &local_time) && mktime(&local_time) != 0)
            {
                str_time[0] = '\0';
                strftime (str_time, sizeof (str_time),
                    CONFIG_STRING(config_look_quote_time_format),
                    &local_time);
                length_time = strlen(str_time);
                ptr_str_time = malloc (length_time);
                strncpy (ptr_str_time, str_time, length_time);
                time = ptr_str_time;
            }
            else
                time = NULL;
        }
    }
    else
        time = NULL;
    prefix = (strstr (signal, "prefix")) ?
        hashtable_get (hashtable, "_chat_line_prefix") : NULL;
    message = hashtable_get (hashtable, "_chat_line_message");

    if (!message)
        return WEECHAT_RC_OK;

    length_time = (time) ? strlen (time) : 0;
    length_prefix = (prefix) ? strlen (prefix) : 0;
    length_message = strlen (message);

    nick = hashtable_get (hashtable, "_chat_line_nick");
    tags = hashtable_get (hashtable, "_chat_line_tags");

    if (prefix && nick && nick[0] &&
        CONFIG_STRING(config_look_quote_nick_format) &&
        CONFIG_STRING(config_look_quote_nick_format)[0])
    {
        tags_array = string_split (tags, ",", 0, 0, &tags_count);
        if (tags_array)
        {
            for (i = 0; i < tags_count; i++)
            {
                if (!strcmp (tags_array[i], "irc_privmsg"))
                    custom_nick_ok = 1;
                else if (!strcmp (tags_array[i], "irc_action"))
                {
                    custom_nick_ok = 0;
                    break;
                }
            }
            string_free_split(tags_array);
            if (custom_nick_ok)
            {
                custom_nick_prefix = malloc (255);
                length_prefix = snprintf (custom_nick_prefix, sizeof (custom_nick_prefix), CONFIG_STRING(config_look_quote_nick_format), nick);
                if (length_prefix >= sizeof (custom_nick_prefix))
                {
                    custom_nick_prefix = realloc (custom_nick_prefix, length_prefix + 1);
                    snprintf (custom_nick_prefix, length_prefix, CONFIG_STRING(config_look_quote_nick_format), nick);
                }
            }
        }
    }
    length = length_time + 1 + length_prefix + 1 +
        strlen (CONFIG_STRING(config_look_prefix_suffix)) + 1 +
        length_message + 1 + 1;
    str = malloc (length);
    if (str)
    {
        if (custom_nick_ok)
        {
            snprintf (str, length, "%s%s%s%s%s ",
                      (time) ? time : "",
                      (time) ? " " : "",
                      (prefix) ? custom_nick_prefix : "",
                      (prefix) ? " " : "",
                      message);
        }
        else
        {
            snprintf (str, length, "%s%s%s%s%s%s%s ",
                      (time) ? time : "",
                      (time && !(prefix && prefix[0] == ' ')) ? " " : "",
                      (prefix) ? prefix : "",
                      (prefix && prefix[0]) ? " " : "",
                      ((time || prefix) && CONFIG_BOOLEAN(config_look_quote_show_prefix_suffix)) ? CONFIG_STRING(config_look_prefix_suffix) : "",
                      ((time || prefix) && CONFIG_BOOLEAN(config_look_quote_show_prefix_suffix) && CONFIG_STRING(config_look_prefix_suffix)
                       && CONFIG_STRING(config_look_prefix_suffix)[0]) ? " " : "",
                      message);
        }
        gui_input_insert_string (gui_current_window->buffer, str, -1);
        gui_input_text_changed_modifier_and_signal (gui_current_window->buffer,
                                                    1, /* save undo */
                                                    1); /* stop completion */
        free (str);
    }

    return WEECHAT_RC_OK;
}
Example #10
0
void
gui_keyboard_flush ()
{
    int i, key, insert_ok;
    char key_str[32], *key_utf, *input_old;
    
    /* if there's no paste pending, then we use buffer and do actions
       according to keys */
    if (!gui_keyboard_paste_pending)
    {
        if (gui_keyboard_buffer_size > 0)
            gui_keyboard_last_activity_time = time (NULL);
        
        for (i = 0; i < gui_keyboard_buffer_size; i++)
        {
            key = gui_keyboard_buffer[i];
            
            insert_ok = 1;
            
            if (key < 32)
            {
                insert_ok = 0;
                key_str[0] = '^';
                key_str[1] = (char) key + '@';
                key_str[2] = '\0';
            }
            else if (key == 127)
            {
                key_str[0] = '^';
                key_str[1] = '?';
                key_str[2] = '\0';
            }
            else
            {
                if (local_utf8)
                {
                    /* 1 char: 0vvvvvvv */
                    if (key < 0x80)
                    {
                        key_str[0] = (char) key;
                        key_str[1] = '\0';
                    }
                    /* 2 chars: 110vvvvv 10vvvvvv */
                    else if ((key & 0xE0) == 0xC0)
                    {
                        key_str[0] = (char) key;
                        if (i < gui_keyboard_buffer_size - 1)
                        {
                            key_str[1] = (char) (gui_keyboard_buffer[++i]);
                            key_str[2] = '\0';
                        }
                        else
                            key_str[1] = '\0';
                    }
                    /* 3 chars: 1110vvvv 10vvvvvv 10vvvvvv */
                    else if ((key & 0xF0) == 0xE0)
                    {
                        key_str[0] = (char) key;
                        if (i < gui_keyboard_buffer_size - 1)
                        {
                            key_str[1] = (char) (gui_keyboard_buffer[++i]);
                            if (i < gui_keyboard_buffer_size - 1)
                            {
                                key_str[2] = (char) (gui_keyboard_buffer[++i]);
                                key_str[3] = '\0';
                            }
                            else
                                key_str[2] = '\0';
                        }
                        else
                            key_str[1] = '\0';
                    }
                    /* 4 chars: 11110vvv 10vvvvvv 10vvvvvv 10vvvvvv */
                    else if ((key & 0xF8) == 0xF0)
                    {
                        key_str[0] = (char) key;
                        if (i < gui_keyboard_buffer_size - 1)
                        {
                            key_str[1] = (char) (gui_keyboard_buffer[++i]);
                            if (i < gui_keyboard_buffer_size - 1)
                            {
                                key_str[2] = (char) (gui_keyboard_buffer[++i]);
                                if (i < gui_keyboard_buffer_size - 1)
                                {
                                    key_str[3] = (char) (gui_keyboard_buffer[++i]);
                                    key_str[4] = '\0';
                                }
                                else
                                    key_str[3] = '\0';
                            }
                            else
                                key_str[2] = '\0';
                        }
                        else
                            key_str[1] = '\0';
                    }
                }
                else
                {
                    key_str[0] = (char) key;
                    key_str[1] = '\0';
                    
                    /* convert input to UTF-8 is user is not using UTF-8 as locale */
                    if (!local_utf8)
                    {
                        key_utf = string_iconv_to_internal (NULL, key_str);
                        strncpy (key_str, key_utf, sizeof (key_str));
                        key_str[sizeof (key_str) - 1] = '\0';
                    }
                }
            }
            
            if (strcmp (key_str, "^") == 0)
            {
                key_str[1] = '^';
                key_str[2] = '\0';
            }
            
            /*gui_printf (gui_current_window->buffer,
                          "gui_input_read: key = %s (%d)\n", key_str, key);*/
            
            hook_signal_send ("key_pressed",
                              WEECHAT_HOOK_SIGNAL_STRING, key_str);
            
            if (gui_current_window->buffer->text_search != GUI_TEXT_SEARCH_DISABLED)
                input_old = (gui_current_window->buffer->input_buffer) ?
                    strdup (gui_current_window->buffer->input_buffer) : strdup ("");
            else
                input_old = NULL;
            
            if ((gui_keyboard_pressed (key_str) != 0) && (insert_ok))
            {
                if (strcmp (key_str, "^^") == 0)
                    key_str[1] = '\0';
                
                gui_input_insert_string (gui_current_window->buffer,
                                         key_str, -1);
                if (gui_current_window->buffer->completion)
                    gui_completion_stop (gui_current_window->buffer->completion, 0);
                gui_input_text_changed_modifier_and_signal (gui_current_window->buffer);
            }
            
            /* incremental text search in buffer */
            if ((gui_current_window->buffer->text_search != GUI_TEXT_SEARCH_DISABLED)
                && ((input_old == NULL) || (gui_current_window->buffer->input_buffer == NULL)
                    || (strcmp (input_old, gui_current_window->buffer->input_buffer) != 0)))
            {
                gui_window_search_restart (gui_current_window);
            }
            
            if (input_old)
                free (input_old);
        }
        
        if (gui_key_grab && (gui_key_grab_count > 0))
            gui_keyboard_grab_end ();
        
        gui_keyboard_buffer_reset ();
    }
}