コード例 #1
0
ファイル: weechat-aspell.c プロジェクト: sardemff7/weechat
int
weechat_aspell_check_word (struct t_aspell_speller_buffer *speller_buffer,
                           const char *word)
{
    int i;

    /* word too small? then do not check word */
    if ((weechat_config_integer (weechat_aspell_config_check_word_min_length) > 0)
        && ((int)strlen (word) < weechat_config_integer (weechat_aspell_config_check_word_min_length)))
        return 1;

    /* word is a number? then do not check word */
    if (weechat_aspell_string_is_simili_number (word))
        return 1;

    /* check word with all spellers (order is important) */
    if (speller_buffer->spellers)
    {
        for (i = 0; speller_buffer->spellers[i]; i++)
        {
#ifdef USE_ENCHANT
            if (enchant_dict_check (speller_buffer->spellers[i], word, strlen (word)) == 0)
#else
            if (aspell_speller_check (speller_buffer->spellers[i], word, -1) == 1)
#endif /* USE_ENCHANT */
                return 1;
        }
    }

    /* misspelled word! */
    return 0;
}
コード例 #2
0
ファイル: weechat-aspell.c プロジェクト: FauxFaux/weechat_old
int
weechat_aspell_check_word (struct t_gui_buffer *buffer,
                           struct t_aspell_speller_buffer *speller_buffer,
                           const char *word)
{
    const char *buffer_type, *buffer_nick, *buffer_channel;
    int i;

    /* word too small? then do not check word */
    if ((weechat_config_integer (weechat_aspell_config_check_word_min_length) > 0)
        && ((int)strlen (word) < weechat_config_integer (weechat_aspell_config_check_word_min_length)))
        return 1;

    /* word is a number? then do not check word */
    if (weechat_aspell_string_is_simili_number (word))
        return 1;

    /* word is a nick of nicklist on this buffer? then do not check word */
    if (weechat_nicklist_search_nick (buffer, NULL, word))
        return 1;

    /* for "private" buffers, ignore self and remote nicks */
    buffer_type = weechat_buffer_get_string (buffer, "localvar_type");
    if (buffer_type && (strcmp (buffer_type, "private") == 0))
    {
        /* check self nick */
        buffer_nick = weechat_buffer_get_string (buffer, "localvar_nick");
        if (buffer_nick && (weechat_strcasecmp (buffer_nick, word) == 0))
            return 1;
        /* check remote nick */
        buffer_channel = weechat_buffer_get_string (buffer, "localvar_channel");
        if (buffer_channel && (weechat_strcasecmp (buffer_channel, word) == 0))
            return 1;
    }

    /* check word with all spellers for this buffer (order is important) */
    if (speller_buffer->spellers)
    {
        for (i = 0; speller_buffer->spellers[i]; i++)
        {
#ifdef USE_ENCHANT
            if (enchant_dict_check (speller_buffer->spellers[i], word, strlen (word)) == 0)
#else
            if (aspell_speller_check (speller_buffer->spellers[i], word, -1) == 1)
#endif
                return 1;
        }
    }

    /* misspelled word! */
    return 0;
}
コード例 #3
0
ファイル: weechat-aspell.c プロジェクト: matsuu/weechat
int
weechat_aspell_check_word (struct t_gui_buffer *buffer, const char *word)
{
    struct t_aspell_speller *ptr_speller;
    int rc;
    
    rc = 0;
    
    /* word too small? then do not check word */
    if ((weechat_config_integer (weechat_aspell_config_check_word_min_length) > 0)
        && ((int)strlen (word) < weechat_config_integer (weechat_aspell_config_check_word_min_length)))
        rc = 1;
    else
    {
        /* word is URL? then do not check word */
        if (weechat_aspell_string_is_url (word))
            rc = 1;
        else
        {
            /* word is a number? then do not check word */
            if (weechat_aspell_string_is_simili_number (word))
                rc = 1;
            else
            {
                /* word is a nick of nicklist on this buffer? then do not check word */
                if (weechat_nicklist_search_nick (buffer, NULL, word))
                    rc = 1;
                else
                {
                    /* check word with all spellers for this buffer (order is important) */
                    for (ptr_speller = weechat_aspell_spellers; ptr_speller;
                         ptr_speller = ptr_speller->next_speller)
                    {
                        if (aspell_speller_check (ptr_speller->speller, word, -1) == 1)
                        {
                            rc = 1;
                            break;
                        }
                    }
                }
            }
        }
    }
    
    return rc;
}