QList<QString> ASpellChecker::getAllLanguages() const { QList<QString> langs; AspellDictInfoList* dict_info_list = get_aspell_dict_info_list(config_); if (!aspell_dict_info_list_empty(dict_info_list)) { AspellDictInfoEnumeration* dict_info_enum = aspell_dict_info_list_elements(dict_info_list); while (!aspell_dict_info_enumeration_at_end(dict_info_enum)) { const AspellDictInfo* dict_info = aspell_dict_info_enumeration_next(dict_info_enum); QString lang(dict_info -> code); if (lang.contains('_')) lang.truncate(lang.indexOf('_')); if (!langs.contains(lang)) { langs.append(lang); } } delete_aspell_dict_info_enumeration(dict_info_enum); } return langs; }
int weechat_aspell_speller_dict_supported (const char *lang) { #ifdef USE_ENCHANT return enchant_broker_dict_exists (broker, lang); #else struct AspellConfig *config; AspellDictInfoList *list; AspellDictInfoEnumeration *elements; const AspellDictInfo *dict; int rc; rc = 0; config = new_aspell_config (); list = get_aspell_dict_info_list (config); elements = aspell_dict_info_list_elements (list); while ((dict = aspell_dict_info_enumeration_next (elements)) != NULL) { if (strcmp (dict->name, lang) == 0) { rc = 1; break; } } delete_aspell_dict_info_enumeration (elements); delete_aspell_config (config); return rc; #endif /* USE_ENCHANT */ }
//__________________________________________________________________________ void Speller::Aspell::Suggest::listDicts(std::vector<AspellDictInfo>& vals) { AspellDictInfoList* dlist = get_aspell_dict_info_list( fconfig ); AspellDictInfoEnumeration* dinfo_enum = aspell_dict_info_list_elements( dlist ); const AspellDictInfo* entry; while( (entry = aspell_dict_info_enumeration_next( dinfo_enum )) ) { vals.push_back( *entry ); } delete_aspell_dict_info_enumeration( dinfo_enum ); }
string SpellerConfig::getLangs() { string res; if (cfg == NULL) return res; AspellDictInfoList *dlist = get_aspell_dict_info_list(cfg); AspellDictInfoEnumeration *dels = aspell_dict_info_list_elements(dlist); const AspellDictInfo *entry; while ((entry = aspell_dict_info_enumeration_next(dels)) != NULL){ if (!res.empty()) res += ";"; res += entry->name; } delete_aspell_dict_info_enumeration(dels); return res; }
/** * List all available dictionaries. * @param class object * @return array of AspellDictInfo objects. */ static VALUE aspell_s_list_dicts(VALUE klass) { AspellConfig * config; AspellDictInfoList * dlist; AspellDictInfoEnumeration * dels; const AspellDictInfo * entry; VALUE result = rb_ary_new(); //get a list of dictionaries config = new_aspell_config(); dlist = get_aspell_dict_info_list(config); delete_aspell_config(config); //iterate over list - fill ruby array dels = aspell_dict_info_list_elements(dlist); while ( (entry = aspell_dict_info_enumeration_next(dels)) != 0) { rb_ary_push(result, Data_Wrap_Struct(cDictInfo, 0, 0, (AspellDictInfo *)entry)); } delete_aspell_dict_info_enumeration(dels); return result; }
QStringList SpellChecker::notCheckedLanguages() { QStringList result; AspellDictInfoList* dlist; AspellDictInfoEnumeration* dels; const AspellDictInfo* entry; /* the returned pointer should _not_ need to be deleted */ dlist = get_aspell_dict_info_list(spellConfig); dels = aspell_dict_info_list_elements(dlist); while ((entry = aspell_dict_info_enumeration_next(dels)) != 0) { if (checkers.find(entry->name) == checkers.end()) result.push_back(entry->name); } delete_aspell_dict_info_enumeration(dels); return result; }
int weechat_aspell_completion_dicts_cb (const void *pointer, void *data, const char *completion_item, struct t_gui_buffer *buffer, struct t_gui_completion *completion) { #ifndef USE_ENCHANT struct AspellConfig *config; AspellDictInfoList *list; AspellDictInfoEnumeration *elements; const AspellDictInfo *dict; #endif /* USE_ENCHANT */ /* make C compiler happy */ (void) pointer; (void) data; (void) completion_item; (void) buffer; #ifdef USE_ENCHANT enchant_broker_list_dicts (broker, weechat_aspell_completion_enchant_add_dict_cb, completion); #else config = new_aspell_config (); list = get_aspell_dict_info_list (config); elements = aspell_dict_info_list_elements (list); while ((dict = aspell_dict_info_enumeration_next (elements)) != NULL) { weechat_hook_completion_list_add (completion, dict->name, 0, WEECHAT_LIST_POS_SORT); } delete_aspell_dict_info_enumeration (elements); delete_aspell_config (config); #endif /* USE_ENCHANT */ return WEECHAT_RC_OK; }
QSet<LanguageManager::LangId> ASpellChecker::getAllLanguages() const { QSet<LanguageManager::LangId> langs; AspellDictInfoList* dict_info_list = get_aspell_dict_info_list(config_); if (!aspell_dict_info_list_empty(dict_info_list)) { AspellDictInfoEnumeration* dict_info_enum = aspell_dict_info_list_elements(dict_info_list); while (!aspell_dict_info_enumeration_at_end(dict_info_enum)) { const AspellDictInfo* dict_info = aspell_dict_info_enumeration_next(dict_info_enum); auto id = LanguageManager::fromString(QString::fromLatin1(dict_info -> code)); if (id.language) { langs.insert(id); } } delete_aspell_dict_info_enumeration(dict_info_enum); } return langs; }
void SpellChecker::enumerateDicts() { AspellConfig *config; AspellDictInfoList *dlist; AspellDictInfoEnumeration *dels; const AspellDictInfo *entry; config = new_aspell_config(); /* the returned pointer should _not_ need to be deleted */ dlist = get_aspell_dict_info_list(config); /* config is no longer needed */ delete_aspell_config(config); dels = aspell_dict_info_list_elements(dlist); while ((entry = aspell_dict_info_enumeration_next(dels)) != 0) { dictList->append(entry->code); } delete_aspell_dict_info_enumeration(dels); }
/* * Return an array of strings, each being the dict's code:name * Class: calliope_AeseSpeller * Method: listDicts * Signature: ()[Ljava/lang/String; */ JNIEXPORT jobjectArray JNICALL Java_calliope_AeseSpeller_listDicts (JNIEnv *env, jobject obj) { AspellConfig *config; AspellDictInfoList *dlist; AspellDictInfoEnumeration *dels; const AspellDictInfo *entry; config = new_aspell_config(); /* the returned pointer should _not_ need to be deleted */ dlist = get_aspell_dict_info_list(config); /* config is no longer needed */ delete_aspell_config(config); jobjectArray ret=NULL; int i=0; dels = aspell_dict_info_list_elements(dlist); if ( dels != NULL ) { dict_info *head = NULL; dict_info *di,*tail = NULL; int size = 0; while ( (entry = aspell_dict_info_enumeration_next(dels)) != 0) { size++; di = calloc( 1, sizeof(dict_info) ); if ( di != NULL ) { di->name = entry->name; di->code = entry->code; if ( head == NULL ) tail = head = di; else { tail->next = di; tail = di; } } } ret = (jobjectArray)(*env)->NewObjectArray(env,size, (*env)->FindClass(env,"java/lang/String"), (*env)->NewStringUTF(env,"")); di = head; i = 0; while ( di != NULL ) { dict_info *next = di->next; int slen = strlen(di->code)+strlen(di->name)+2; char *str = calloc(slen,1); if ( str != NULL ) { snprintf(str,slen,"%s\t%s",di->code,di->name); (*env)->SetObjectArrayElement(env,ret,i++, (*env)->NewStringUTF(env,str)); free( str ); } free( di ); di = next; } delete_aspell_dict_info_enumeration(dels); } return ret; }
void weechat_aspell_command_speller_list_dicts () { #ifndef USE_ENCHANT char *country, *lang, *pos, *iso; char str_dict[256], str_country[128]; struct AspellConfig *config; AspellDictInfoList *list; AspellDictInfoEnumeration *elements; const AspellDictInfo *dict; #endif weechat_printf (NULL, ""); weechat_printf (NULL, /* TRANSLATORS: "%s" is "aspell" */ _( "%s dictionaries list:"), ASPELL_PLUGIN_NAME); #ifdef USE_ENCHANT enchant_broker_list_dicts (broker, weechat_aspell_enchant_dict_describe_cb, NULL); #else config = new_aspell_config(); list = get_aspell_dict_info_list (config); elements = aspell_dict_info_list_elements (list); while ((dict = aspell_dict_info_enumeration_next (elements)) != NULL) { lang = NULL; country = NULL; pos = strchr (dict->code, '_'); if (pos) { iso = weechat_strndup (dict->code, pos - dict->code); if (iso) { lang = weechat_aspell_command_iso_to_lang (iso); country = weechat_aspell_command_iso_to_country (pos + 1); free (iso); } } else lang = weechat_aspell_command_iso_to_lang ((char*)dict->code); str_country[0] = '\0'; if (country || dict->jargon[0]) { snprintf (str_country, sizeof (str_country), " (%s%s%s)", (country) ? country : dict->jargon, (country && dict->jargon[0]) ? " - " : "", (country && dict->jargon[0]) ? ((dict->jargon[0]) ? dict->jargon : country) : ""); } snprintf (str_dict, sizeof (str_dict), "%-22s %s%s", dict->name, lang, str_country); weechat_printf (NULL, " %s", str_dict); if (lang) free (lang); if (country) free (country); } delete_aspell_dict_info_enumeration (elements); delete_aspell_config (config); #endif }
void weechat_aspell_speller_list_dicts () { char *country, *lang, *pos; char buffer[192]; struct AspellConfig *config; AspellDictInfoList *list; AspellDictInfoEnumeration *el; const AspellDictInfo *dict; config = new_aspell_config(); list = get_aspell_dict_info_list (config); el = aspell_dict_info_list_elements (list); weechat_printf (NULL, ""); weechat_printf (NULL, /* TRANSLATORS: "%s" is "aspell" */ _( "%s dictionaries list:"), ASPELL_PLUGIN_NAME); while ((dict = aspell_dict_info_enumeration_next (el))) { country = NULL; pos = strchr (dict->code, '_'); if (pos) { pos[0] = '\0'; lang = weechat_aspell_iso_to_lang ((char*)dict->code); pos[0] = '_'; country = weechat_aspell_iso_to_country (pos + 1); } else lang = weechat_aspell_iso_to_lang ((char*)dict->code); if (strlen (dict->jargon) == 0) { if (pos) { snprintf (buffer, sizeof (buffer), "%-22s %s (%s)", dict->name, lang, country); } else { snprintf (buffer, sizeof (buffer), "%-22s %s", dict->name, lang); } } else { if (pos) { snprintf (buffer, sizeof (buffer), "%-22s %s (%s - %s)", dict->name, lang, country, dict->jargon); } else { snprintf (buffer, sizeof (buffer), "%-22s %s (%s)", dict->name, lang, dict->jargon); } } weechat_printf (NULL, " %s", buffer); if (lang) free (lang); if (country) free (country); } delete_aspell_dict_info_enumeration (el); delete_aspell_config (config); }