void AspellChecker::suggest(WordLangTuple const & wl, docstring_list & suggestions) { suggestions.clear(); AspellSpeller * m = d->speller(wl.lang()); if (!m) return; string const word = d->toAspellWord(wl.word()); AspellWordList const * sugs = aspell_speller_suggest(m, word.c_str(), -1); LASSERT(sugs != 0, return); AspellStringEnumeration * els = aspell_word_list_elements(sugs); if (!els || aspell_word_list_empty(sugs)) return; for (;;) { char const * str = aspell_string_enumeration_next(els); if (!str) break; suggestions.push_back(from_utf8(str)); } delete_aspell_string_enumeration(els); }
void AppleSpellChecker::suggest(WordLangTuple const & wl, docstring_list & suggestions) { suggestions.clear(); string const word_str = to_utf8(wl.word()); size_t num = AppleSpeller_makeSuggestion(d->speller, word_str.c_str(), wl.lang()->code().c_str()); for (size_t i = 0; i < num; i++) { char const * next = AppleSpeller_getSuggestion(d->speller, i); if (!next) break; suggestions.push_back(from_utf8(next)); } }
void EnchantChecker::suggest(WordLangTuple const & wl, docstring_list & suggestions) { suggestions.clear(); enchant::Dict * m = d->speller(wl.lang()->code()); if (!m) return; string utf8word = to_utf8(wl.word()); vector<string> suggs = m->suggest(utf8word); vector<string>::const_iterator it = suggs.begin(); for (; it != suggs.end(); ++it) suggestions.push_back(from_utf8(*it)); }
void GuiSpellchecker::updateSuggestions(docstring_list & words) { QString const suggestion = toqstr(d->word_.word()); d->ui.wordED->setText(suggestion); QListWidget * lw = d->ui.suggestionsLW; lw->clear(); if (words.empty()) { on_suggestionsLW_itemClicked(new QListWidgetItem(suggestion)); return; } for (size_t i = 0; i != words.size(); ++i) lw->addItem(toqstr(words[i])); on_suggestionsLW_itemClicked(lw->item(0)); lw->setCurrentRow(0); }