mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-23 02:14:50 +00:00
Initial support for continuous spell-checking. This is far from working perfectly. I reused the word completion framework to achieve this. This doesn't seem to have sensible effect over edition speed.
You'll need to check the continuous spellcheck option in order to test this. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@29465 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
1d2077e51e
commit
ea54380e13
@ -37,11 +37,13 @@
|
|||||||
#include "output_latex.h"
|
#include "output_latex.h"
|
||||||
#include "paragraph_funcs.h"
|
#include "paragraph_funcs.h"
|
||||||
#include "ParagraphParameters.h"
|
#include "ParagraphParameters.h"
|
||||||
|
#include "SpellChecker.h"
|
||||||
#include "sgml.h"
|
#include "sgml.h"
|
||||||
#include "TextClass.h"
|
#include "TextClass.h"
|
||||||
#include "TexRow.h"
|
#include "TexRow.h"
|
||||||
#include "Text.h"
|
#include "Text.h"
|
||||||
#include "VSpace.h"
|
#include "VSpace.h"
|
||||||
|
#include "WordLangTuple.h"
|
||||||
#include "WordList.h"
|
#include "WordList.h"
|
||||||
|
|
||||||
#include "frontends/alert.h"
|
#include "frontends/alert.h"
|
||||||
@ -2905,28 +2907,39 @@ void Paragraph::locateWord(pos_type & from, pos_type & to,
|
|||||||
|
|
||||||
void Paragraph::collectWords(CursorSlice const & sl)
|
void Paragraph::collectWords(CursorSlice const & sl)
|
||||||
{
|
{
|
||||||
// find new words
|
SpellChecker * speller = theSpellChecker();
|
||||||
bool inword = false;
|
|
||||||
|
|
||||||
//lyxerr << "Words: ";
|
//lyxerr << "Words: ";
|
||||||
pos_type n = size();
|
pos_type n = size();
|
||||||
for (pos_type pos = 0; pos < n; ++pos) {
|
for (pos_type pos = 0; pos < n; ++pos) {
|
||||||
if (isDeleted(pos))
|
if (isDeleted(pos))
|
||||||
continue;
|
continue;
|
||||||
if (!isLetter(pos)) {
|
if (!isLetter(pos))
|
||||||
inword = false;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
if (inword)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
inword = true;
|
|
||||||
pos_type from = pos;
|
pos_type from = pos;
|
||||||
locateWord(from, pos, WHOLE_WORD);
|
locateWord(from, pos, WHOLE_WORD);
|
||||||
if (pos - from < 6)
|
if (!lyxrc.spellcheck_continuously && pos - from < 6)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
docstring word = asString(from, pos, false);
|
docstring word = asString(from, pos, false);
|
||||||
d->words_.insert(word);
|
if (pos - from >= 6)
|
||||||
|
d->words_.insert(word);
|
||||||
|
|
||||||
|
if (!lyxrc.spellcheck_continuously || !speller)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
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())
|
||||||
|
continue;
|
||||||
|
bool const misspelled = res != SpellChecker::OK
|
||||||
|
&& res != SpellChecker::IGNORED_WORD;
|
||||||
|
d->fontlist_.setMisspelled(from, pos, misspelled);
|
||||||
|
|
||||||
//lyxerr << word << " ";
|
//lyxerr << word << " ";
|
||||||
}
|
}
|
||||||
//lyxerr << std::endl;
|
//lyxerr << std::endl;
|
||||||
|
Loading…
Reference in New Issue
Block a user