#include "insets/InsetLabel.h"
#include "support/lassert.h"
-#include "support/convert.h"
#include "support/debug.h"
#include "support/ExceptionMessage.h"
#include "support/gettext.h"
}
+bool Paragraph::isFullyDeleted(pos_type start, pos_type end) const
+{
+ LASSERT(start >= 0 && start <= size(), /**/);
+ LASSERT(end > start && end <= size() + 1, /**/);
+
+ return d->changes_.isFullyDeleted(start, end);
+}
+
+
bool Paragraph::isChanged(pos_type start, pos_type end) const
{
LASSERT(start >= 0 && start <= size(), /**/);
// the next two functions are for the manual labels
docstring const Paragraph::getLabelWidthString() const
{
- if (d->layout_->margintype == MARGIN_MANUAL)
+ if (d->layout_->margintype == MARGIN_MANUAL
+ || d->layout_->latextype == LATEX_BIB_ENVIRONMENT)
return d->params_.labelWidthString();
else
return _("Senseless with this layout!");
if (Inset const * inset = getInset(pos))
return inset->isLetter();
char_type const c = d->text_[pos];
- return isLetterChar(c) || isDigit(c);
+ // We want to pass the ' and escape chars to the spellchecker
+ static docstring const quote = from_utf8(lyxrc.spellchecker_esc_chars + '\'');
+ return (isLetterChar(c) || isDigit(c) || contains(quote, c))
+ && (!d->inset_owner_ || d->inset_owner_->allowSpellCheck())
+ && pos != size()
+ && !isDeleted(pos);
}
//lyxerr << "Words: ";
pos_type n = size();
for (pos_type pos = 0; pos < n; ++pos) {
- if (isDeleted(pos))
- continue;
if (!isLetter(pos))
continue;
pos_type from = pos;
registerWords();
}
+
+bool Paragraph::isMisspelled(pos_type pos) const
+{
+ SpellChecker * speller = theSpellChecker();
+ pos_type from = pos;
+ pos_type to = pos;
+ locateWord(from, to, WHOLE_WORD);
+ docstring word = asString(from, to, false);
+ if (!speller)
+ return false;
+
+ string lang_code = lyxrc.spellchecker_use_alt_lang
+ ? lyxrc.spellchecker_alt_lang
+ : getFontSettings(d->inset_owner_->buffer().params(), from).language()->code();
+ WordLangTuple wl(word, lang_code);
+ SpellChecker::Result res = speller->check(wl);
+ // ... just ignore any error that the spellchecker reports.
+ if (!speller->error().empty())
+ return false;
+
+ bool const misspelled = res != SpellChecker::OK
+ && res != SpellChecker::IGNORED_WORD;
+ if (lyxrc.spellcheck_continuously)
+ d->fontlist_.setMisspelled(from, pos, misspelled);
+ return misspelled;
+}
+
+
} // namespace lyx