void weechat_aspell_speller_check_dictionaries (const char *dict_list) { char **argv; int argc, i; if (dict_list) { argv = weechat_string_split (dict_list, ",", 0, 0, &argc); if (argv) { for (i = 0; i < argc; i++) { if (!weechat_aspell_speller_dict_supported (argv[i])) { weechat_printf (NULL, _("%s: warning: dictionary \"%s\" is not " "available on your system"), ASPELL_PLUGIN_NAME, argv[i]); } } weechat_string_free_split (argv); } } }
void weechat_aspell_command_add_word (struct t_gui_buffer *buffer, const char *dict, const char *word) { struct t_aspell_speller_buffer *ptr_speller_buffer; #ifdef USE_ENCHANT EnchantDict *new_speller, *ptr_speller; #else AspellSpeller *new_speller, *ptr_speller; #endif new_speller = NULL; if (dict) { ptr_speller = weechat_hashtable_get (weechat_aspell_spellers, dict); if (!ptr_speller) { if (!weechat_aspell_speller_dict_supported (dict)) { weechat_printf (NULL, _("%s: error: dictionary \"%s\" is not " "available on your system"), ASPELL_PLUGIN_NAME, dict); return; } new_speller = weechat_aspell_speller_new (dict); if (!new_speller) return; ptr_speller = new_speller; } } else { ptr_speller_buffer = weechat_hashtable_get (weechat_aspell_speller_buffer, buffer); if (!ptr_speller_buffer) ptr_speller_buffer = weechat_aspell_speller_buffer_new (buffer); if (!ptr_speller_buffer) goto error; if (!ptr_speller_buffer->spellers || !ptr_speller_buffer->spellers[0]) { weechat_printf (NULL, _("%s%s: no dictionary on this buffer for " "adding word"), weechat_prefix ("error"), ASPELL_PLUGIN_NAME); return; } else if (ptr_speller_buffer->spellers[1]) { weechat_printf (NULL, _("%s%s: many dictionaries are defined for " "this buffer, please specify dictionary"), weechat_prefix ("error"), ASPELL_PLUGIN_NAME); return; } ptr_speller = ptr_speller_buffer->spellers[0]; } #ifdef USE_ENCHANT enchant_dict_add (ptr_speller, word, strlen (word)); #else if (aspell_speller_add_to_personal (ptr_speller, word, strlen (word)) == 1) { weechat_printf (NULL, _("%s: word \"%s\" added to personal dictionary"), ASPELL_PLUGIN_NAME, word); } else goto error; #endif goto end; error: weechat_printf (NULL, _("%s%s: failed to add word to personal " "dictionary"), weechat_prefix ("error"), ASPELL_PLUGIN_NAME); end: if (new_speller) weechat_hashtable_remove (weechat_aspell_spellers, dict); }