// 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);
DocIterator selbeg = cur.selectionBegin();
// Insert the new string
pos_type pos = cur.selEnd().pos();
Paragraph & par = cur.selEnd().paragraph();
- string::const_iterator cit = str.begin();
- string::const_iterator end = str.end();
+ docstring::const_iterator cit = str.begin();
+ docstring::const_iterator end = str.end();
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
cutSelection(cur, true, false);
* the new string. When \c backwards == false, set anchor before
* cursor; otherwise set cursor before anchor.
*/
-void replaceSelectionWithString(LCursor & cur, std::string const & str,
+void replaceSelectionWithString(LCursor & cur, docstring const & str,
bool backwards);
/// replace selection helper
void replaceSelection(LCursor & cur);
{}
-string const SpellBase::nextMiss()
+docstring const SpellBase::nextMiss()
{
- return string();
+ return docstring();
}
#include "support/docstring.h"
-#include <string>
-
namespace lyx {
virtual void accept(WordLangTuple const &);
/// 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
virtual docstring const error();
#ifndef WORD_LANG_TUPLE_H
#define WORD_LANG_TUPLE_H
-#include <string>
+#include "support/docstring.h"
namespace lyx {
public:
WordLangTuple() {}
- WordLangTuple(std::string const & w, std::string const & c)
+ WordLangTuple(docstring const & w, std::string const & c)
: word_(w), code_(c)
{}
/// return the word
- std::string const & word() const {
+ docstring const & word() const {
return word_;
}
private:
/// the word
- std::string word_;
+ docstring word_;
/// language code of word
std::string code_;
};
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);
if (word_ok) {
res = OK;
} else {
+ // FIXME UNICODE: we don't need to convert to UTF8, but probably to the locale encoding
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);
els = aspell_word_list_elements(sugs);
if (aspell_word_list_empty(sugs))
{
Spellers::iterator it = spellers_.find(word.lang_code());
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);
}
{
Spellers::iterator it = spellers_.find(word.lang_code());
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;
if (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());
}
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());
}
#include "SpellBase.h"
-#include "support/docstring.h"
-
#include <map>
virtual void accept(WordLangTuple const &);
/// 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
virtual docstring const error();
if (inword)
if (!word.empty() && !ignoreword) {
cur.setSelection();
- return WordLangTuple(lyx::to_utf8(word), lang_code);
+ return WordLangTuple(word, lang_code);
} else
inword = false;
}
++progress;
}
- return WordLangTuple(string(), string());
+ return WordLangTuple(docstring(), string());
}
} // namespace anon
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();
cur.pos() -= size;
}
-void ControlSpellchecker::replace(string const & replacement)
+void ControlSpellchecker::replace(docstring const & replacement)
{
lyxerr[Debug::GUI] << "ControlSpellchecker::replace("
- << replacement << ")" << std::endl;
+ << to_utf8(replacement) << ")" << std::endl;
BufferView & bufferview = *kernel().bufferview();
cap::replaceSelectionWithString(bufferview.cursor(), replacement, true);
kernel().buffer().markDirty();
}
-void ControlSpellchecker::replaceAll(string const & replacement)
+void ControlSpellchecker::replaceAll(docstring const & replacement)
{
// TODO: add to list
replace(replacement);
}
-string const ControlSpellchecker::getSuggestion() const
+docstring const ControlSpellchecker::getSuggestion() const
{
return speller_->nextMiss();
}
-string const ControlSpellchecker::getWord() const
+docstring const ControlSpellchecker::getWord() const
{
return word_.word();
}
virtual bool exitEarly() const { return exitEarly_; }
/// replace word with replacement
- void replace(std::string const &);
+ void replace(docstring const &);
/// replace all occurances of word
- void replaceAll(std::string const &);
+ void replaceAll(docstring const &);
/// insert word in personal dictionary
void insert();
void check();
/// get suggestion
- std::string const getSuggestion() const;
+ docstring const getSuggestion() const;
/// get word
- std::string const getWord() const;
+ docstring const getWord() const;
/// returns progress value
int getProgress() const { return oldval_; }
void QSpellchecker::replace()
{
- controller().replace(fromqstr(dialog_->replaceCO->currentText()));
+ controller().replace(qstring_to_ucs4(dialog_->replaceCO->currentText()));
}
dialog_->wordED->setText(toqstr(controller().getWord()));
dialog_->suggestionsLW->clear();
- string w;
+ docstring w;
while (!(w = controller().getSuggestion()).empty()) {
dialog_->suggestionsLW->addItem(toqstr(w));
}
return;
}
- /* Parent process: Read ispells identification message */
+ // Parent process: Read ispells identification message
bool err_read;
bool error = select(err_read);
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);
} else {
// select returned error
}
-string const ISpell::nextMiss()
+docstring const ISpell::nextMiss()
{
// Well, somebody is a sick fuck.
if (str == 0 || *(e+1) == '\0')
- return "";
+ return docstring();
char * b = e + 2;
e = strpbrk(b, ",\n");
*e = '\0';
if (b)
- return b;
- return "";
+ // FIXME UNICODE: b is not in UTF8, but probably the locale encoding
+ return from_utf8(b);
+ return docstring();
}
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);
bool err_read;
}
if (err_read) {
+ // FIXME UNICODE: buf is not in UTF8, but probably the locale encoding
error_ = from_utf8(buf);
return UNKNOWN_WORD;
}
void ISpell::insert(WordLangTuple const & word)
{
::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);
}
void ISpell::accept(WordLangTuple const & word)
{
::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);
}
virtual void accept(WordLangTuple const & word);
/// 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
virtual docstring const error();
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())
return 0;
return 0;
LCursor & cur = bv->cursor();
- cap::replaceSelectionWithString(cur, replacestr, fw);
+ cap::replaceSelectionWithString(cur, from_utf8(replacestr), fw);
bv->buffer()->markDirty();
find(bv, searchstr, cs, mw, fw);
bv->update();
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);
if (word_ok) {
res = OK;
} else {
+ // FIXME UNICODE: we don't need to convert to UTF8, but probably to the locale encoding
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);
els = pspell_word_list_elements(sugs);
if (pspell_word_list_empty(sugs))
{
Managers::iterator it = managers_.find(word.lang_code());
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());
}
{
Managers::iterator it = managers_.find(word.lang_code());
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;
if (els)
str = pspell_string_emulation_next(els);
if (str)
- return str;
- return "";
+ // FIXME UNICODE: str is not in UTF8, but probably the locale encoding
+ return from_utf8(str);
+ return docstring();
}
virtual void accept(WordLangTuple const &);
/// 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
virtual docstring const error();