Example #1
0
char *
irc_bar_item_buffer_title (void *data, struct t_gui_bar_item *item,
                           struct t_gui_window *window,
                           struct t_gui_buffer *buffer,
                           struct t_hashtable *extra_info)
{
    const char *title;
    char *title_color;

    /* make C compiler happy */
    (void) data;
    (void) item;
    (void) window;
    (void) extra_info;

    if (!buffer)
        return NULL;

    title = weechat_buffer_get_string (buffer, "title");
    if (!title)
        return NULL;

    title_color = irc_color_decode (title,
                                    (weechat_config_boolean (irc_config_look_topic_strip_colors)) ?
                                    0 : 1);

    return (title_color) ? title_color : strdup (title);
}
Example #2
0
void
irc_input_user_message_display (struct t_gui_buffer *buffer, const char *text)
{
    struct t_irc_nick *ptr_nick;
    char *text_decoded;

    text_decoded = irc_color_decode (text,
                                     weechat_config_boolean (irc_config_network_colors_send));

    IRC_BUFFER_GET_SERVER_CHANNEL(buffer);

    if (ptr_channel)
    {
        ptr_nick = NULL;
        if (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL)
        {
            ptr_nick = irc_nick_search (ptr_server, ptr_channel,
                                        ptr_server->nick);
        }

        weechat_printf_tags (buffer,
                             irc_protocol_tags ("privmsg",
                                                "notify_none,no_highlight",
                                                (ptr_nick) ? ptr_nick->name : ptr_server->nick),
                             "%s%s",
                             irc_nick_as_prefix (ptr_server,
                                                 (ptr_nick) ? ptr_nick : NULL,
                                                 (ptr_nick) ? NULL : ptr_server->nick,
                                                 IRC_COLOR_CHAT_NICK_SELF),
                             (text_decoded) ? text_decoded : text);
    }

    if (text_decoded)
        free (text_decoded);
}
Example #3
0
char *
irc_color_modifier_cb (void *data, const char *modifier,
                       const char *modifier_data, const char *string)
{
    int keep_colors;

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

    keep_colors = (modifier_data && (strcmp (modifier_data, "1") == 0)) ? 1 : 0;

    if (strcmp (modifier, "irc_color_decode") == 0)
        return irc_color_decode (string, keep_colors);

    if (strcmp (modifier, "irc_color_encode") == 0)
        return irc_color_encode (string, keep_colors);

    if (strcmp (modifier, "irc_color_decode_ansi") == 0)
        return irc_color_decode_ansi (string, keep_colors);

    /* unknown modifier */
    return NULL;
}
Example #4
0
void
irc_input_user_message_display (struct t_gui_buffer *buffer, int action,
                                const char *text)
{
    struct t_irc_nick *ptr_nick;
    char *pos, *text2, *text_decoded, str_tags[256], *str_color;
    const char *ptr_text;

    /* if message is an action, force "action" to 1 and extract message */
    if (strncmp (text, "\01ACTION ", 8) == 0)
    {
        action = 1;
        pos = strrchr (text + 8, '\01');
        if (pos)
            text2 = weechat_strndup (text + 8, pos - text - 8);
        else
            text2 = strdup (text + 8);
    }
    else
        text2 = strdup (text);

    text_decoded = irc_color_decode (
        (text2) ? text2 : text,
        weechat_config_boolean (irc_config_network_colors_send));

    IRC_BUFFER_GET_SERVER_CHANNEL(buffer);

    if (ptr_channel)
    {
        ptr_nick = NULL;
        if (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL)
        {
            ptr_nick = irc_nick_search (ptr_server, ptr_channel,
                                        ptr_server->nick);
        }

        if (action)
        {
            snprintf (str_tags, sizeof (str_tags),
                      "irc_action,self_msg,notify_none,no_highlight");
        }
        else
        {
            str_color = irc_color_for_tags (
                weechat_config_color (
                    weechat_config_get ("weechat.color.chat_nick_self")));
            snprintf (str_tags, sizeof (str_tags),
                      "notify_none,self_msg,no_highlight,prefix_nick_%s",
                      (str_color) ? str_color : "default");
            if (str_color)
                free (str_color);
        }
        ptr_text = (text_decoded) ? text_decoded : ((text2) ? text2 : text);
        if (action)
        {
            weechat_printf_date_tags (
                buffer,
                0,
                irc_protocol_tags (
                    "privmsg", str_tags,
                    (ptr_nick) ? ptr_nick->name : ptr_server->nick,
                    NULL),
                "%s%s%s%s%s %s",
                weechat_prefix ("action"),
                irc_nick_mode_for_display (ptr_server, ptr_nick, 0),
                IRC_COLOR_CHAT_NICK_SELF,
                ptr_server->nick,
                IRC_COLOR_RESET,
                ptr_text);
        }
        else
        {
            weechat_printf_date_tags (
                buffer,
                0,
                irc_protocol_tags (
                    "privmsg", str_tags,
                    (ptr_nick) ? ptr_nick->name : ptr_server->nick,
                    NULL),
                "%s%s",
                irc_nick_as_prefix (
                    ptr_server,
                    (ptr_nick) ? ptr_nick : NULL,
                    (ptr_nick) ? NULL : ptr_server->nick,
                    IRC_COLOR_CHAT_NICK_SELF),
                ptr_text);
        }
    }

    if (text2)
        free (text2);
    if (text_decoded)
        free (text_decoded);
}