#include "output_xhtml.h"
#include "output_docbook.h"
#include "ParagraphParameters.h"
+#include "Session.h"
#include "SpellChecker.h"
#include "texstream.h"
#include "TexRow.h"
/// \return the number of characters written.
int latexSurrogatePair(BufferParams const &, otexstream & os,
char_type c, char_type next,
- OutputParams const &);
+ OutputParams const &) const;
/// Output a space in appropriate formatting (or a surrogate pair
/// if the next character is a combining character).
pos_type i,
unsigned int & column,
Font const & font,
- Layout const & style);
+ Layout const & style) const;
/// This could go to ParagraphParameters if we want to.
int startTeXParParams(BufferParams const &, otexstream &,
unsigned int & column,
bool const fontswitch_inset,
bool const closeLanguage,
- bool const lang_switched_at_inset);
+ bool const lang_switched_at_inset) const;
///
void latexSpecialChar(
Layout const & style,
pos_type & i,
pos_type end_pos,
- unsigned int & column);
+ unsigned int & column) const;
///
bool latexSpecialT1(
return speller_change_number > speller_state_.currentChangeNumber();
}
- bool ignoreWord(docstring const & word) const ;
+ bool ignoreWord(docstring const & word) const;
void setMisspelled(pos_type from, pos_type to, SpellChecker::Result state)
{
return numskips;
}
- void markMisspelledWords(pos_type const & first, pos_type const & last,
- SpellChecker::Result result,
- docstring const & word,
- SkipPositions const & skips);
+ void markMisspelledWords(Language const * lang,
+ pos_type const & first, pos_type const & last,
+ SpellChecker::Result result,
+ docstring const & word,
+ SkipPositions const & skips);
InsetCode ownerCode() const
{
// Update list of misspelled positions
speller_state_.increasePosAfterPos(pos);
+
+ // Update bookmarks
+ if (inset_owner_ && inset_owner_->isBufferValid())
+ theSession().bookmarks().adjustPosAfterPos(inset_owner_->buffer().fileName(),
+ id_, pos, 1);
}
d->speller_state_.decreasePosAfterPos(pos);
d->speller_state_.refreshLast(size());
+ // Update bookmarks
+ if (d->inset_owner_ && d->inset_owner_->isBufferValid())
+ theSession().bookmarks().adjustPosAfterPos(d->inset_owner_->buffer().fileName(),
+ d->id_, pos, -1);
+
return true;
}
// Handle combining characters
int Paragraph::Private::latexSurrogatePair(BufferParams const & bparams,
otexstream & os, char_type c, char_type next,
- OutputParams const & runparams)
+ OutputParams const & runparams) const
{
// Writing next here may circumvent a possible font change between
// c and next. Since next is only output if it forms a surrogate pair
pos_type i,
unsigned int & column,
Font const & font,
- Layout const & style)
+ Layout const & style) const
{
if (style.pass_thru || runparams.pass_thru)
return false;
unsigned int & column,
bool const fontswitch_inset,
bool const closeLanguage,
- bool const lang_switched_at_inset)
+ bool const lang_switched_at_inset) const
{
Inset * inset = owner_->getInset(i);
LBUFERR(inset);
Layout const & style,
pos_type & i,
pos_type end_pos,
- unsigned int & column)
+ unsigned int & column) const
{
char_type const c = owner_->getUChar(bparams, runparams, i);
docstring word = asString(from, to, AS_STR_INSETS | AS_STR_SKIPDELETE);
Language * lang = d->getSpellLanguage(from);
- if (getFontSettings(d->inset_owner_->buffer().params(), from).fontInfo().nospellcheck() == FONT_ON)
+ BufferParams const & bparams = d->inset_owner_->buffer().params();
+
+ if (getFontSettings(bparams, from).fontInfo().nospellcheck() == FONT_ON)
return result;
wl = WordLangTuple(word, lang);
pos_type end = to;
if (!d->ignoreWord(word)) {
bool const trailing_dot = to < size() && d->text_[to] == '.';
- result = speller->check(wl);
+ result = speller->check(wl, bparams.spellignore());
if (SpellChecker::misspelled(result) && trailing_dot) {
wl = WordLangTuple(word.append(from_ascii(".")), lang);
- result = speller->check(wl);
+ result = speller->check(wl, bparams.spellignore());
if (!SpellChecker::misspelled(result)) {
LYXERR(Debug::GUI, "misspelled word is correct with dot: \"" <<
word << "\" [" <<
void Paragraph::Private::markMisspelledWords(
+ Language const * lang,
pos_type const & first, pos_type const & last,
SpellChecker::Result result,
docstring const & word,
int wlen = 0;
speller->misspelledWord(index, wstart, wlen);
/// should not happen if speller supports range checks
- if (!wlen) continue;
- docstring const misspelled = word.substr(wstart, wlen);
+ if (!wlen)
+ continue;
+ WordLangTuple const candidate(word.substr(wstart, wlen), lang);
wstart += first + numskipped;
if (snext < wstart) {
/// mark the range of correct spelling
wstart - 1, SpellChecker::WORD_OK);
}
snext = wstart + wlen;
+ // Check whether the candidate is in the document's local dict
+ SpellChecker::Result actresult = result;
+ if (inset_owner_->buffer().params().spellignored(candidate))
+ actresult = SpellChecker::DOCUMENT_LEARNED_WORD;
numskipped += countSkips(it, et, snext);
/// mark the range of misspelling
- setMisspelled(wstart, snext, result);
- LYXERR(Debug::GUI, "misspelled word: \"" <<
- misspelled << "\" [" <<
- wstart << ".." << (snext-1) << "]");
+ setMisspelled(wstart, snext, actresult);
+ if (actresult == SpellChecker::DOCUMENT_LEARNED_WORD)
+ LYXERR(Debug::GUI, "local dictionary word: \"" <<
+ candidate.word() << "\" [" <<
+ wstart << ".." << (snext-1) << "]");
+ else
+ LYXERR(Debug::GUI, "misspelled word: \"" <<
+ candidate.word() << "\" [" <<
+ wstart << ".." << (snext-1) << "]");
++snext;
}
if (snext <= last) {
// start the spell checker on the unit of meaning
docstring word = asString(first, last, AS_STR_INSETS + AS_STR_SKIPDELETE);
WordLangTuple wl = WordLangTuple(word, lang);
+ BufferParams const & bparams = d->inset_owner_->buffer().params();
SpellChecker::Result result = !word.empty() ?
- speller->check(wl) : SpellChecker::WORD_OK;
- d->markMisspelledWords(first, last, result, word, skips);
+ speller->check(wl, bparams.spellignore()) : SpellChecker::WORD_OK;
+ d->markMisspelledWords(lang, first, last, result, word, skips);
first = ++last;
}
} else {