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); }
StyleDialog::StyleDialog ( wxWindow *parent, wxIcon icon, const std::string& bufferParameterUtf8, const wxString& fileNameParameter, const wxString& ruleSetDirectoryParameter, const wxString& filterDirectoryParameter, const wxString& ruleSetPresetParameter, const wxString& filterPresetParameter, #if !defined(USE_ENCHANT) && defined(__WXMSW__) const wxString& aspellDataPathParameter, const wxString& aspellDictPathParameter, #endif int typeParameter, bool readOnlyParameter, wxPoint position, wxSize size ) : wxDialog ( parent, wxID_ANY, wxString ( ( typeParameter == ID_TYPE_STYLE) ? _ ( "Style" ) : _ ( "Spelling" ) ), position, size, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMAXIMIZE_BOX ), indexForContextMenu ( -1 ), bufferUtf8 ( bufferParameterUtf8 ), #if !defined(USE_ENCHANT) && defined(__WXMSW__) aspellDataPath ( aspellDataPathParameter ), aspellDictPath ( aspellDictPathParameter ), #endif fileName ( fileNameParameter ), ruleSetDirectory ( ruleSetDirectoryParameter ), filterDirectory ( filterDirectoryParameter ), ruleSetPreset ( ruleSetPresetParameter ), filterPreset ( filterPresetParameter ), type(typeParameter), readOnly ( readOnlyParameter ) { SetIcon ( icon ); // top box ruleSetCombo = new wxComboBox ( this, ID_STYLE_COMBO_RULESET, _T ( "" ), wxDefaultPosition, wxSize ( 200, -1 ) ); int width, height; ruleSetCombo->GetSize ( &width, &height ); wxSize buttonSize ( 100, height ); filterCombo = new wxComboBox ( this, ID_STYLE_COMBO_FILTER, _T ( "" ), wxDefaultPosition, wxSize ( 200, -1 ) ); //if (type != ID_TYPE_STYLE) // from v. 1.1.0.7: never show filterCombo->Show ( false ); wxButton *createReportButton = new wxButton ( this, ID_STYLE_REPORT, _ ( "&Check" ), wxDefaultPosition, buttonSize, 0 ); wxBoxSizer *comboSizer = new wxBoxSizer ( wxHORIZONTAL ); comboSizer->Add ( ruleSetCombo, 0, wxRIGHT, 10 ); comboSizer->Add ( filterCombo, 0, wxRIGHT, 10 ); comboSizer->Add ( createReportButton, 0, wxRIGHT, 10 ); // middle box wxListCtrl *myTable = new wxListCtrl ( this, ID_STYLE_TABLE, wxPoint ( 0, 0 ), wxSize ( -1, -1 ), wxLC_REPORT ); int widthUnit = 35; myTable->InsertColumn ( 0, _ ( "No." ), wxLIST_FORMAT_LEFT, widthUnit * 1 ); myTable->InsertColumn ( 1, _ ( "Context" ), wxLIST_FORMAT_RIGHT, widthUnit * 3 ); myTable->InsertColumn ( 2, _ ( "Error" ), wxLIST_FORMAT_CENTER, widthUnit * 3 ); myTable->InsertColumn ( 3, _ ( "Context" ), wxLIST_FORMAT_LEFT, widthUnit * 3 ); myTable->InsertColumn ( 4, _ ( "Suggestion" ), wxLIST_FORMAT_LEFT, widthUnit * 3 ); myTable->InsertColumn ( 5, _ ( "Rule" ), wxLIST_FORMAT_LEFT, widthUnit * 3 ); myTable->InsertColumn ( 6, _ ( "Action" ), wxLIST_FORMAT_LEFT, widthUnit * 3 ); table = myTable; // lower box wxButton *editItemsButton = new wxButton ( this, ID_STYLE_EDIT, _ ( "&Apply changes" ), wxDefaultPosition, wxSize ( -1, buttonSize.GetHeight() ), 0 ); wxButton *webReportButton = new wxButton ( this, ID_STYLE_WEB_REPORT, _ ( "&Printable report" ), wxDefaultPosition, wxSize ( -1, buttonSize.GetHeight() ), 0 ); wxButton *webSummaryButton = new wxButton ( this, ID_STYLE_WEB_SUMMARY, _ ( "Pr&intable summary" ), wxDefaultPosition, wxSize ( -1, buttonSize.GetHeight() ), 0 ); wxButton *selectAllButton = new wxButton ( this, ID_STYLE_CHANGE_ALL, _ ( "C&hange all" ), wxDefaultPosition, wxSize ( -1, buttonSize.GetHeight() ), 0 ); wxButton *deselectAllButton = new wxButton ( this, ID_STYLE_IGNORE_ALL, _ ( "I&gnore all" ), wxDefaultPosition, wxSize ( -1, buttonSize.GetHeight() ), 0 ); wxButton *cancelButton = new wxButton ( this, wxID_CANCEL, _ ( "Ca&ncel" ), wxDefaultPosition, wxSize ( -1, buttonSize.GetHeight() ), 0 ); wxBoxSizer *reportButtonSizer = new wxBoxSizer ( wxHORIZONTAL ); reportButtonSizer->Add ( editItemsButton, 0, wxRIGHT, 10 ); reportButtonSizer->Add ( webReportButton, 0, wxLEFT | wxRIGHT, 10 ); reportButtonSizer->Add ( webSummaryButton, 0, wxRIGHT, 10 ); reportButtonSizer->Add ( selectAllButton, 0, wxLEFT | wxRIGHT, 10 ); reportButtonSizer->Add ( deselectAllButton, 0, wxRIGHT, 10 ); reportButtonSizer->Add ( cancelButton, 0, wxLEFT, 10 ); // status bar status = new wxStatusBar ( this, wxID_ANY ); // overall sizer wxBoxSizer *reportTopSizer = new wxBoxSizer ( wxVERTICAL ); reportTopSizer->Add ( comboSizer, 0, wxALL | wxALIGN_CENTER_VERTICAL, 5 ); reportTopSizer->Add ( table, 1, wxEXPAND | wxALL, 5 ); reportTopSizer->Add ( reportButtonSizer, 0, wxALL, 5 ); reportTopSizer->Add ( status, 0, wxEXPAND | wxALL ); this->SetSizer ( reportTopSizer ); createReportButton->SetFocus(); if ( readOnly ) filterCombo->Enable ( false ); // keyboard shortcuts wxAcceleratorEntry entries[7]; entries[0].Set ( wxACCEL_ALT, ( int ) 'C', ID_STYLE_REPORT ); entries[1].Set ( wxACCEL_ALT, ( int ) 'A', ID_STYLE_EDIT ); entries[2].Set ( wxACCEL_ALT, ( int ) 'W', ID_STYLE_WEB_REPORT ); entries[3].Set ( wxACCEL_ALT, ( int ) 'B', ID_STYLE_WEB_SUMMARY ); entries[4].Set ( wxACCEL_ALT, ( int ) 'H', ID_STYLE_CHANGE_ALL ); entries[5].Set ( wxACCEL_ALT, ( int ) 'I', ID_STYLE_IGNORE_ALL ); entries[6].Set ( wxACCEL_ALT, ( int ) 'N', wxID_CANCEL ); wxAcceleratorTable accel ( 7, entries ); this->SetAcceleratorTable ( accel ); // update combo lists // special case spellcheck if (type == ID_TYPE_SPELL) { #ifdef USE_ENCHANT EnchantBroker *broker = enchant_broker_init(); dictdetect adetected(ruleSetCombo); enchant_broker_list_dicts(broker, EnchantDictDescribe, &adetected); bool anyFound = !adetected.empty(); #else AspellConfig *config; AspellDictInfoList *dlist; AspellDictInfoEnumeration *dels; const AspellDictInfo *entry; config = new_aspell_config(); #ifdef __WXMSW__ aspell_config_replace ( config, "data-dir", aspellDataPath.mb_str() ); //ASPELL_DATA_PATH ); aspell_config_replace ( config, "dict-dir", aspellDictPath.mb_str() ); //ASPELL_DICT_PATH ); #endif dlist = get_aspell_dict_info_list( config ); delete_aspell_config ( config ); dels = aspell_dict_info_list_elements ( dlist ); bool anyFound = false; while ( ( entry = aspell_dict_info_enumeration_next ( dels ) ) != 0 ) { anyFound = true; std::string stdEntry = entry->name; wxString entry = wxString ( stdEntry.c_str(), wxConvUTF8, stdEntry.size() ); ruleSetCombo->Append ( entry ); } #endif if ( anyFound ) { if ( ruleSetPreset.empty() ) ruleSetPreset = _ ( "en_US" ); ruleSetCombo->SetValue ( ruleSetPreset ); } else { ruleSetCombo->Append ( _ ( "(No dictionaries found)" ) ); ruleSetCombo->Select ( 0 ); createReportButton->Enable ( false ); } return; } // all other branches if ( wxDirExists ( ruleSetDirectory ) ) { wxString ruleMask, ruleFile; ruleMask = ruleSetDirectory + wxFileName::GetPathSeparator() + _T ( "*.xml" ); ruleFile = wxFindFirstFile ( ruleMask, wxFILE ); if ( !ruleFile.empty() ) { ruleFile.Replace ( _T ( ".xml" ), _T ( "" ) ); ruleFile.Replace ( _T ( "_" ), _T ( " " ) ); ruleSetCombo->Append ( wxFileNameFromPath ( ruleFile ) ); for ( ;; ) { ruleFile = wxFindNextFile(); if ( ruleFile.empty() ) break; ruleFile.Replace ( _T ( ".xml" ), _T ( "" ) ); ruleFile.Replace ( _T ( "_" ), _T ( " " ) ); ruleSetCombo->Append ( wxFileNameFromPath ( ruleFile ) ); } } if ( ruleSetPreset.empty() ) ruleSetPreset = _ ( "Default" ); ruleSetCombo->SetValue ( ruleSetPreset ); } else { ruleSetCombo->Append ( _ ( "(No rule sets found)" ) ); ruleSetCombo->Select ( 0 ); } if ( wxDirExists ( filterDirectory ) ) { filterCombo->Append ( _ ( "(No filter)" ) ); wxString filterMask, filterFile; filterMask = filterDirectory + wxFileName::GetPathSeparator() + _T ( "*.xml" ); filterFile = wxFindFirstFile ( filterMask, wxFILE ); if ( !filterFile.empty() ) { filterFile.Replace ( _T ( ".xml" ), _T ( "" ) ); filterCombo->Append ( wxFileNameFromPath ( filterFile ) ); for ( ;; ) { filterFile = wxFindNextFile(); if ( filterFile.empty() ) break; filterFile.Replace ( _T ( ".xml" ), _T ( "" ) ); filterCombo->Append ( wxFileNameFromPath ( filterFile ) ); } } filterCombo->SetValue ( filterPreset ); } else { filterCombo->Append ( _ ( "(No filters found)" ) ); filterCombo->Select ( 0 ); } }