mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-30 05:12:40 +00:00
Convert the spell checking machinery to docstring.
Fix a conversion char -> char_type without encoding conversion in cap::replaceSelectionWithString(). git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16212 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
8193ac607b
commit
26460b39ee
@ -649,7 +649,7 @@ void pasteSelection(LCursor & cur, ErrorList & errorList, size_t sel_index)
|
|||||||
|
|
||||||
|
|
||||||
// simple replacing. The font of the first selected character is used
|
// simple replacing. The font of the first selected character is used
|
||||||
void replaceSelectionWithString(LCursor & cur, string const & str, bool backwards)
|
void replaceSelectionWithString(LCursor & cur, docstring const & str, bool backwards)
|
||||||
{
|
{
|
||||||
recordUndo(cur);
|
recordUndo(cur);
|
||||||
DocIterator selbeg = cur.selectionBegin();
|
DocIterator selbeg = cur.selectionBegin();
|
||||||
@ -661,10 +661,10 @@ void replaceSelectionWithString(LCursor & cur, string const & str, bool backward
|
|||||||
// Insert the new string
|
// Insert the new string
|
||||||
pos_type pos = cur.selEnd().pos();
|
pos_type pos = cur.selEnd().pos();
|
||||||
Paragraph & par = cur.selEnd().paragraph();
|
Paragraph & par = cur.selEnd().paragraph();
|
||||||
string::const_iterator cit = str.begin();
|
docstring::const_iterator cit = str.begin();
|
||||||
string::const_iterator end = str.end();
|
docstring::const_iterator end = str.end();
|
||||||
for (; cit != end; ++cit, ++pos)
|
for (; cit != end; ++cit, ++pos)
|
||||||
par.insertChar(pos, (*cit), font, cur.buffer().params().trackChanges);
|
par.insertChar(pos, *cit, font, cur.buffer().params().trackChanges);
|
||||||
|
|
||||||
// Cut the selection
|
// Cut the selection
|
||||||
cutSelection(cur, true, false);
|
cutSelection(cur, true, false);
|
||||||
|
@ -44,7 +44,7 @@ void cutSelection(LCursor & cur, bool doclear, bool realcut);
|
|||||||
* the new string. When \c backwards == false, set anchor before
|
* the new string. When \c backwards == false, set anchor before
|
||||||
* cursor; otherwise set cursor before anchor.
|
* cursor; otherwise set cursor before anchor.
|
||||||
*/
|
*/
|
||||||
void replaceSelectionWithString(LCursor & cur, std::string const & str,
|
void replaceSelectionWithString(LCursor & cur, docstring const & str,
|
||||||
bool backwards);
|
bool backwards);
|
||||||
/// replace selection helper
|
/// replace selection helper
|
||||||
void replaceSelection(LCursor & cur);
|
void replaceSelection(LCursor & cur);
|
||||||
|
@ -40,9 +40,9 @@ void SpellBase::accept(WordLangTuple const &)
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
string const SpellBase::nextMiss()
|
docstring const SpellBase::nextMiss()
|
||||||
{
|
{
|
||||||
return string();
|
return docstring();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -15,8 +15,6 @@
|
|||||||
|
|
||||||
#include "support/docstring.h"
|
#include "support/docstring.h"
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
|
|
||||||
@ -61,7 +59,7 @@ public:
|
|||||||
virtual void accept(WordLangTuple const &);
|
virtual void accept(WordLangTuple const &);
|
||||||
|
|
||||||
/// return the next near miss after a SUGGESTED_WORDS result
|
/// return the next near miss after a SUGGESTED_WORDS result
|
||||||
virtual std::string const nextMiss();
|
virtual docstring const nextMiss();
|
||||||
|
|
||||||
/// give an error message on messy exit
|
/// give an error message on messy exit
|
||||||
virtual docstring const error();
|
virtual docstring const error();
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
#ifndef WORD_LANG_TUPLE_H
|
#ifndef WORD_LANG_TUPLE_H
|
||||||
#define WORD_LANG_TUPLE_H
|
#define WORD_LANG_TUPLE_H
|
||||||
|
|
||||||
#include <string>
|
#include "support/docstring.h"
|
||||||
|
|
||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
@ -26,12 +26,12 @@ class WordLangTuple {
|
|||||||
public:
|
public:
|
||||||
WordLangTuple() {}
|
WordLangTuple() {}
|
||||||
|
|
||||||
WordLangTuple(std::string const & w, std::string const & c)
|
WordLangTuple(docstring const & w, std::string const & c)
|
||||||
: word_(w), code_(c)
|
: word_(w), code_(c)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/// return the word
|
/// return the word
|
||||||
std::string const & word() const {
|
docstring const & word() const {
|
||||||
return word_;
|
return word_;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
/// the word
|
/// the word
|
||||||
std::string word_;
|
docstring word_;
|
||||||
/// language code of word
|
/// language code of word
|
||||||
std::string code_;
|
std::string code_;
|
||||||
};
|
};
|
||||||
|
18
src/aspell.C
18
src/aspell.C
@ -87,14 +87,16 @@ ASpell::Result ASpell::check(WordLangTuple const & word)
|
|||||||
|
|
||||||
AspellSpeller * m = it->second.speller;
|
AspellSpeller * m = it->second.speller;
|
||||||
|
|
||||||
int const word_ok = aspell_speller_check(m, word.word().c_str(), -1);
|
// FIXME UNICODE: we don't need to convert to UTF8, but probably to the locale encoding
|
||||||
|
int const word_ok = aspell_speller_check(m, to_utf8(word.word()).c_str(), -1);
|
||||||
BOOST_ASSERT(word_ok != -1);
|
BOOST_ASSERT(word_ok != -1);
|
||||||
|
|
||||||
if (word_ok) {
|
if (word_ok) {
|
||||||
res = OK;
|
res = OK;
|
||||||
} else {
|
} else {
|
||||||
|
// FIXME UNICODE: we don't need to convert to UTF8, but probably to the locale encoding
|
||||||
AspellWordList const * sugs =
|
AspellWordList const * sugs =
|
||||||
aspell_speller_suggest(m, word.word().c_str(), -1);
|
aspell_speller_suggest(m, to_utf8(word.word()).c_str(), -1);
|
||||||
BOOST_ASSERT(sugs != 0);
|
BOOST_ASSERT(sugs != 0);
|
||||||
els = aspell_word_list_elements(sugs);
|
els = aspell_word_list_elements(sugs);
|
||||||
if (aspell_word_list_empty(sugs))
|
if (aspell_word_list_empty(sugs))
|
||||||
@ -110,7 +112,8 @@ void ASpell::insert(WordLangTuple const & word)
|
|||||||
{
|
{
|
||||||
Spellers::iterator it = spellers_.find(word.lang_code());
|
Spellers::iterator it = spellers_.find(word.lang_code());
|
||||||
if (it != spellers_.end())
|
if (it != spellers_.end())
|
||||||
aspell_speller_add_to_personal(it->second.speller, word.word().c_str(), -1);
|
// FIXME UNICODE: we don't need to convert to UTF8, but probably to the locale encoding
|
||||||
|
aspell_speller_add_to_personal(it->second.speller, to_utf8(word.word()).c_str(), -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -118,18 +121,20 @@ void ASpell::accept(WordLangTuple const & word)
|
|||||||
{
|
{
|
||||||
Spellers::iterator it = spellers_.find(word.lang_code());
|
Spellers::iterator it = spellers_.find(word.lang_code());
|
||||||
if (it != spellers_.end())
|
if (it != spellers_.end())
|
||||||
aspell_speller_add_to_session(it->second.speller, word.word().c_str(), -1);
|
// FIXME UNICODE: we don't need to convert to UTF8, but probably to the locale encoding
|
||||||
|
aspell_speller_add_to_session(it->second.speller, to_utf8(word.word()).c_str(), -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
string const ASpell::nextMiss()
|
docstring const ASpell::nextMiss()
|
||||||
{
|
{
|
||||||
char const * str = 0;
|
char const * str = 0;
|
||||||
|
|
||||||
if (els)
|
if (els)
|
||||||
str = aspell_string_enumeration_next(els);
|
str = aspell_string_enumeration_next(els);
|
||||||
|
|
||||||
return (str ? str : "");
|
// FIXME UNICODE: str is not in UTF8, but probably the locale encoding
|
||||||
|
return (str ? from_utf8(str) : docstring());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -141,6 +146,7 @@ docstring const ASpell::error()
|
|||||||
err = aspell_error_message(spell_error_object);
|
err = aspell_error_message(spell_error_object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME UNICODE: err is not in UTF8, but probably the locale encoding
|
||||||
return (err ? from_utf8(err) : docstring());
|
return (err ? from_utf8(err) : docstring());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,8 +15,6 @@
|
|||||||
|
|
||||||
#include "SpellBase.h"
|
#include "SpellBase.h"
|
||||||
|
|
||||||
#include "support/docstring.h"
|
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
|
|
||||||
@ -55,7 +53,7 @@ public:
|
|||||||
virtual void accept(WordLangTuple const &);
|
virtual void accept(WordLangTuple const &);
|
||||||
|
|
||||||
/// return the next near miss after a SUGGESTED_WORDS result
|
/// return the next near miss after a SUGGESTED_WORDS result
|
||||||
virtual std::string const nextMiss();
|
virtual docstring const nextMiss();
|
||||||
|
|
||||||
/// give an error message on messy exit
|
/// give an error message on messy exit
|
||||||
virtual docstring const error();
|
virtual docstring const error();
|
||||||
|
@ -173,7 +173,7 @@ WordLangTuple nextWord(LCursor & cur, ptrdiff_t & progress)
|
|||||||
if (inword)
|
if (inword)
|
||||||
if (!word.empty() && !ignoreword) {
|
if (!word.empty() && !ignoreword) {
|
||||||
cur.setSelection();
|
cur.setSelection();
|
||||||
return WordLangTuple(lyx::to_utf8(word), lang_code);
|
return WordLangTuple(word, lang_code);
|
||||||
} else
|
} else
|
||||||
inword = false;
|
inword = false;
|
||||||
}
|
}
|
||||||
@ -182,7 +182,7 @@ WordLangTuple nextWord(LCursor & cur, ptrdiff_t & progress)
|
|||||||
++progress;
|
++progress;
|
||||||
}
|
}
|
||||||
|
|
||||||
return WordLangTuple(string(), string());
|
return WordLangTuple(docstring(), string());
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace anon
|
} // namespace anon
|
||||||
@ -243,7 +243,7 @@ void ControlSpellchecker::check()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
lyxerr[Debug::GUI] << "Found word \"" << getWord() << "\"" << endl;
|
lyxerr[Debug::GUI] << "Found word \"" << to_utf8(getWord()) << "\"" << endl;
|
||||||
|
|
||||||
int const size = cur.selEnd().pos() - cur.selBegin().pos();
|
int const size = cur.selEnd().pos() - cur.selBegin().pos();
|
||||||
cur.pos() -= size;
|
cur.pos() -= size;
|
||||||
@ -297,10 +297,10 @@ void ControlSpellchecker::showSummary()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ControlSpellchecker::replace(string const & replacement)
|
void ControlSpellchecker::replace(docstring const & replacement)
|
||||||
{
|
{
|
||||||
lyxerr[Debug::GUI] << "ControlSpellchecker::replace("
|
lyxerr[Debug::GUI] << "ControlSpellchecker::replace("
|
||||||
<< replacement << ")" << std::endl;
|
<< to_utf8(replacement) << ")" << std::endl;
|
||||||
BufferView & bufferview = *kernel().bufferview();
|
BufferView & bufferview = *kernel().bufferview();
|
||||||
cap::replaceSelectionWithString(bufferview.cursor(), replacement, true);
|
cap::replaceSelectionWithString(bufferview.cursor(), replacement, true);
|
||||||
kernel().buffer().markDirty();
|
kernel().buffer().markDirty();
|
||||||
@ -312,7 +312,7 @@ void ControlSpellchecker::replace(string const & replacement)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ControlSpellchecker::replaceAll(string const & replacement)
|
void ControlSpellchecker::replaceAll(docstring const & replacement)
|
||||||
{
|
{
|
||||||
// TODO: add to list
|
// TODO: add to list
|
||||||
replace(replacement);
|
replace(replacement);
|
||||||
@ -326,13 +326,13 @@ void ControlSpellchecker::insert()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
string const ControlSpellchecker::getSuggestion() const
|
docstring const ControlSpellchecker::getSuggestion() const
|
||||||
{
|
{
|
||||||
return speller_->nextMiss();
|
return speller_->nextMiss();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
string const ControlSpellchecker::getWord() const
|
docstring const ControlSpellchecker::getWord() const
|
||||||
{
|
{
|
||||||
return word_.word();
|
return word_.word();
|
||||||
}
|
}
|
||||||
|
@ -45,10 +45,10 @@ public:
|
|||||||
virtual bool exitEarly() const { return exitEarly_; }
|
virtual bool exitEarly() const { return exitEarly_; }
|
||||||
|
|
||||||
/// replace word with replacement
|
/// replace word with replacement
|
||||||
void replace(std::string const &);
|
void replace(docstring const &);
|
||||||
|
|
||||||
/// replace all occurances of word
|
/// replace all occurances of word
|
||||||
void replaceAll(std::string const &);
|
void replaceAll(docstring const &);
|
||||||
|
|
||||||
/// insert word in personal dictionary
|
/// insert word in personal dictionary
|
||||||
void insert();
|
void insert();
|
||||||
@ -61,10 +61,10 @@ public:
|
|||||||
void check();
|
void check();
|
||||||
|
|
||||||
/// get suggestion
|
/// get suggestion
|
||||||
std::string const getSuggestion() const;
|
docstring const getSuggestion() const;
|
||||||
|
|
||||||
/// get word
|
/// get word
|
||||||
std::string const getWord() const;
|
docstring const getWord() const;
|
||||||
|
|
||||||
/// returns progress value
|
/// returns progress value
|
||||||
int getProgress() const { return oldval_; }
|
int getProgress() const { return oldval_; }
|
||||||
|
@ -72,7 +72,7 @@ void QSpellchecker::ignore()
|
|||||||
|
|
||||||
void QSpellchecker::replace()
|
void QSpellchecker::replace()
|
||||||
{
|
{
|
||||||
controller().replace(fromqstr(dialog_->replaceCO->currentText()));
|
controller().replace(qstring_to_ucs4(dialog_->replaceCO->currentText()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -91,7 +91,7 @@ void QSpellchecker::partialUpdate(int s)
|
|||||||
dialog_->wordED->setText(toqstr(controller().getWord()));
|
dialog_->wordED->setText(toqstr(controller().getWord()));
|
||||||
dialog_->suggestionsLW->clear();
|
dialog_->suggestionsLW->clear();
|
||||||
|
|
||||||
string w;
|
docstring w;
|
||||||
while (!(w = controller().getSuggestion()).empty()) {
|
while (!(w = controller().getSuggestion()).empty()) {
|
||||||
dialog_->suggestionsLW->addItem(toqstr(w));
|
dialog_->suggestionsLW->addItem(toqstr(w));
|
||||||
}
|
}
|
||||||
|
24
src/ispell.C
24
src/ispell.C
@ -252,7 +252,7 @@ ISpell::ISpell(BufferParams const & params, string const & lang)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Parent process: Read ispells identification message */
|
// Parent process: Read ispells identification message
|
||||||
|
|
||||||
bool err_read;
|
bool err_read;
|
||||||
bool error = select(err_read);
|
bool error = select(err_read);
|
||||||
@ -264,7 +264,8 @@ ISpell::ISpell(BufferParams const & params, string const & lang)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* must have read something from stderr */
|
// must have read something from stderr
|
||||||
|
// FIXME UNICODE: buf is not in UTF8, but probably the locale encoding
|
||||||
error_ =from_utf8(buf);
|
error_ =from_utf8(buf);
|
||||||
} else {
|
} else {
|
||||||
// select returned error
|
// select returned error
|
||||||
@ -343,18 +344,19 @@ bool ISpell::select(bool & err_read)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
string const ISpell::nextMiss()
|
docstring const ISpell::nextMiss()
|
||||||
{
|
{
|
||||||
// Well, somebody is a sick fuck.
|
// Well, somebody is a sick fuck.
|
||||||
|
|
||||||
if (str == 0 || *(e+1) == '\0')
|
if (str == 0 || *(e+1) == '\0')
|
||||||
return "";
|
return docstring();
|
||||||
char * b = e + 2;
|
char * b = e + 2;
|
||||||
e = strpbrk(b, ",\n");
|
e = strpbrk(b, ",\n");
|
||||||
*e = '\0';
|
*e = '\0';
|
||||||
if (b)
|
if (b)
|
||||||
return b;
|
// FIXME UNICODE: b is not in UTF8, but probably the locale encoding
|
||||||
return "";
|
return from_utf8(b);
|
||||||
|
return docstring();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -370,7 +372,8 @@ enum ISpell::Result ISpell::check(WordLangTuple const & word)
|
|||||||
|
|
||||||
Result res;
|
Result res;
|
||||||
|
|
||||||
::fputs(word.word().c_str(), out);
|
// FIXME UNICODE: we don't need to convert to UTF8, but probably to the locale encoding
|
||||||
|
::fputs(to_utf8(word.word()).c_str(), out);
|
||||||
::fputc('\n', out);
|
::fputc('\n', out);
|
||||||
|
|
||||||
bool err_read;
|
bool err_read;
|
||||||
@ -382,6 +385,7 @@ enum ISpell::Result ISpell::check(WordLangTuple const & word)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (err_read) {
|
if (err_read) {
|
||||||
|
// FIXME UNICODE: buf is not in UTF8, but probably the locale encoding
|
||||||
error_ = from_utf8(buf);
|
error_ = from_utf8(buf);
|
||||||
return UNKNOWN_WORD;
|
return UNKNOWN_WORD;
|
||||||
}
|
}
|
||||||
@ -434,7 +438,8 @@ enum ISpell::Result ISpell::check(WordLangTuple const & word)
|
|||||||
void ISpell::insert(WordLangTuple const & word)
|
void ISpell::insert(WordLangTuple const & word)
|
||||||
{
|
{
|
||||||
::fputc('*', out); // Insert word in personal dictionary
|
::fputc('*', out); // Insert word in personal dictionary
|
||||||
::fputs(word.word().c_str(), out);
|
// FIXME UNICODE: we don't need to convert to UTF8, but probably to the locale encoding
|
||||||
|
::fputs(to_utf8(word.word()).c_str(), out);
|
||||||
::fputc('\n', out);
|
::fputc('\n', out);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -442,7 +447,8 @@ void ISpell::insert(WordLangTuple const & word)
|
|||||||
void ISpell::accept(WordLangTuple const & word)
|
void ISpell::accept(WordLangTuple const & word)
|
||||||
{
|
{
|
||||||
::fputc('@', out); // Accept in this session
|
::fputc('@', out); // Accept in this session
|
||||||
::fputs(word.word().c_str(), out);
|
// FIXME UNICODE: we don't need to convert to UTF8, but probably to the locale encoding
|
||||||
|
::fputs(to_utf8(word.word()).c_str(), out);
|
||||||
::fputc('\n', out);
|
::fputc('\n', out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ public:
|
|||||||
virtual void accept(WordLangTuple const & word);
|
virtual void accept(WordLangTuple const & word);
|
||||||
|
|
||||||
/// return the next near miss after a SUGGESTED_WORDS result
|
/// return the next near miss after a SUGGESTED_WORDS result
|
||||||
virtual std::string const nextMiss();
|
virtual docstring const nextMiss();
|
||||||
|
|
||||||
/// give an error message on messy exit
|
/// give an error message on messy exit
|
||||||
virtual docstring const error();
|
virtual docstring const error();
|
||||||
|
@ -218,7 +218,7 @@ bool stringSelected(BufferView * bv, string const & searchstr,
|
|||||||
|
|
||||||
|
|
||||||
int replace(BufferView * bv, string const & searchstr,
|
int replace(BufferView * bv, string const & searchstr,
|
||||||
string const & replacestr, bool cs, bool mw, bool fw)
|
std::string const & replacestr, bool cs, bool mw, bool fw)
|
||||||
{
|
{
|
||||||
if (!searchAllowed(bv, searchstr) || bv->buffer()->isReadonly())
|
if (!searchAllowed(bv, searchstr) || bv->buffer()->isReadonly())
|
||||||
return 0;
|
return 0;
|
||||||
@ -227,7 +227,7 @@ int replace(BufferView * bv, string const & searchstr,
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
LCursor & cur = bv->cursor();
|
LCursor & cur = bv->cursor();
|
||||||
cap::replaceSelectionWithString(cur, replacestr, fw);
|
cap::replaceSelectionWithString(cur, from_utf8(replacestr), fw);
|
||||||
bv->buffer()->markDirty();
|
bv->buffer()->markDirty();
|
||||||
find(bv, searchstr, cs, mw, fw);
|
find(bv, searchstr, cs, mw, fw);
|
||||||
bv->update();
|
bv->update();
|
||||||
|
19
src/pspell.C
19
src/pspell.C
@ -97,14 +97,16 @@ enum PSpell::Result PSpell::check(WordLangTuple const & word)
|
|||||||
|
|
||||||
PspellManager * m = it->second.manager;
|
PspellManager * m = it->second.manager;
|
||||||
|
|
||||||
int word_ok = pspell_manager_check(m, word.word().c_str());
|
// FIXME UNICODE: we don't need to convert to UTF8, but probably to the locale encoding
|
||||||
|
int word_ok = pspell_manager_check(m, to_utf8(word.word()).c_str());
|
||||||
BOOST_ASSERT(word_ok != -1);
|
BOOST_ASSERT(word_ok != -1);
|
||||||
|
|
||||||
if (word_ok) {
|
if (word_ok) {
|
||||||
res = OK;
|
res = OK;
|
||||||
} else {
|
} else {
|
||||||
|
// FIXME UNICODE: we don't need to convert to UTF8, but probably to the locale encoding
|
||||||
PspellWordList const * sugs =
|
PspellWordList const * sugs =
|
||||||
pspell_manager_suggest(m, word.word().c_str());
|
pspell_manager_suggest(m, to_utf8(word.word()).c_str());
|
||||||
BOOST_ASSERT(sugs != 0);
|
BOOST_ASSERT(sugs != 0);
|
||||||
els = pspell_word_list_elements(sugs);
|
els = pspell_word_list_elements(sugs);
|
||||||
if (pspell_word_list_empty(sugs))
|
if (pspell_word_list_empty(sugs))
|
||||||
@ -120,7 +122,8 @@ void PSpell::insert(WordLangTuple const & word)
|
|||||||
{
|
{
|
||||||
Managers::iterator it = managers_.find(word.lang_code());
|
Managers::iterator it = managers_.find(word.lang_code());
|
||||||
if (it != managers_.end())
|
if (it != managers_.end())
|
||||||
pspell_manager_add_to_personal(it->second.manager, word.word().c_str());
|
// FIXME UNICODE: we don't need to convert to UTF8, but probably to the locale encoding
|
||||||
|
pspell_manager_add_to_personal(it->second.manager, to_utf8(word.word()).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -128,19 +131,21 @@ void PSpell::accept(WordLangTuple const & word)
|
|||||||
{
|
{
|
||||||
Managers::iterator it = managers_.find(word.lang_code());
|
Managers::iterator it = managers_.find(word.lang_code());
|
||||||
if (it != managers_.end())
|
if (it != managers_.end())
|
||||||
pspell_manager_add_to_session(it->second.manager, word.word().c_str());
|
// FIXME UNICODE: we don't need to convert to UTF8, but probably to the locale encoding
|
||||||
|
pspell_manager_add_to_session(it->second.manager, to_utf8(word.word()).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
string const PSpell::nextMiss()
|
docstring const PSpell::nextMiss()
|
||||||
{
|
{
|
||||||
char const * str = 0;
|
char const * str = 0;
|
||||||
|
|
||||||
if (els)
|
if (els)
|
||||||
str = pspell_string_emulation_next(els);
|
str = pspell_string_emulation_next(els);
|
||||||
if (str)
|
if (str)
|
||||||
return str;
|
// FIXME UNICODE: str is not in UTF8, but probably the locale encoding
|
||||||
return "";
|
return from_utf8(str);
|
||||||
|
return docstring();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ public:
|
|||||||
virtual void accept(WordLangTuple const &);
|
virtual void accept(WordLangTuple const &);
|
||||||
|
|
||||||
/// return the next near miss after a SUGGESTED_WORDS result
|
/// return the next near miss after a SUGGESTED_WORDS result
|
||||||
virtual std::string const nextMiss();
|
virtual docstring const nextMiss();
|
||||||
|
|
||||||
/// give an error message on messy exit
|
/// give an error message on messy exit
|
||||||
virtual docstring const error();
|
virtual docstring const error();
|
||||||
|
Loading…
Reference in New Issue
Block a user