diff --git a/src/LyXRC.cpp b/src/LyXRC.cpp index 4de11cc08f..488bdf699e 100644 --- a/src/LyXRC.cpp +++ b/src/LyXRC.cpp @@ -180,6 +180,7 @@ LexerKeyword lyxrcTags[] = { { "\\sort_layouts", LyXRC::RC_SORT_LAYOUTS }, { "\\spell_command", LyXRC::RC_SPELL_COMMAND }, { "\\spellcheck_continuously", LyXRC::RC_SPELLCHECK_CONTINUOUSLY }, + { "\\spellcheck_minlength", LyXRC::RC_SPELL_MINLENGTH }, { "\\spellcheck_notes", LyXRC::RC_SPELLCHECK_NOTES }, { "\\spellchecker", LyXRC::RC_SPELLCHECKER }, { "\\splitindex_command", LyXRC::RC_SPLITINDEX_COMMAND }, @@ -297,6 +298,7 @@ void LyXRC::setDefaults() #endif spellchecker_accept_compound = false; spellcheck_continuously = false; + spellcheck_minlength = 6; spellcheck_notes = true; use_kbmap = false; rtl_support = true; @@ -921,6 +923,19 @@ int LyXRC::read(Lexer & lexrc) case RC_SPELLCHECKER: lexrc >> spellchecker; break; + case RC_SPELL_MINLENGTH: { + int len; + lexrc >> len; + // make sure we have a sensible value + // these should be kept in sync with the min and max + // values for the spinbox in PrefSpellcheckerUi.ui + if (len < 5) + len = 5; + else if (len > 15) + len = 15; + spellcheck_minlength = len; + break; + } case RC_ALT_LANG: lexrc >> spellchecker_alt_lang; break; @@ -2421,6 +2436,15 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c if (tag != RC_LAST) break; + case RC_SPELL_MINLENGTH: + if (ignore_system_lyxrc || + spellcheck_minlength != system_lyxrc.spellcheck_minlength) { + os << "\\spellcheck_minlength " << convert(spellcheck_minlength) + << '\n'; + } + if (tag != RC_LAST) + break; + case RC_SPELLCHECK_NOTES: if (ignore_system_lyxrc || spellcheck_notes != system_lyxrc.spellcheck_notes) { @@ -2872,6 +2896,7 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new) case LyXRC::RC_SPELLCHECKER: case LyXRC::RC_SPELLCHECK_CONTINUOUSLY: case LyXRC::RC_SPELLCHECK_NOTES: + case LyXRC::RC_SPELL_MINLENGTH: case LyXRC::RC_SPLITINDEX_COMMAND: case LyXRC::RC_TEMPDIRPATH: case LyXRC::RC_TEMPLATEPATH: diff --git a/src/LyXRC.h b/src/LyXRC.h index 823dc15f74..cb7d3f6aaf 100644 --- a/src/LyXRC.h +++ b/src/LyXRC.h @@ -165,6 +165,7 @@ public: RC_SPELLCHECK_CONTINUOUSLY, RC_SPELLCHECK_NOTES, RC_SPELLCHECKER, + RC_SPELL_MINLENGTH, RC_SPLITINDEX_COMMAND, RC_TEMPDIRPATH, RC_TEMPLATEPATH, @@ -362,6 +363,8 @@ public: bool spellcheck_continuously; /// spellcheck notes and comments? bool spellcheck_notes; + /// minimum length of words to complete + unsigned int spellcheck_minlength; /// bool use_kbmap; /// diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index 150c28d6a9..9ae11bb1f2 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -3126,16 +3126,13 @@ void Paragraph::locateWord(pos_type & from, pos_type & to, void Paragraph::collectWords() { - // This is the value that needs to be exposed in the preferences - // to resolve bug #6760. - static int minlength = 6; pos_type n = size(); for (pos_type pos = 0; pos < n; ++pos) { if (isWordSeparator(pos)) continue; pos_type from = pos; locateWord(from, pos, WHOLE_WORD); - if (pos - from >= minlength) { + if (pos - from >= lyxrc.spellcheck_minlength) { docstring word = asString(from, pos, AS_STR_NONE); FontList::const_iterator cit = d->fontlist_.fontIterator(pos); if (cit == d->fontlist_.end()) diff --git a/src/frontends/qt4/GuiPrefs.cpp b/src/frontends/qt4/GuiPrefs.cpp index 0b37b037b4..759562facf 100644 --- a/src/frontends/qt4/GuiPrefs.cpp +++ b/src/frontends/qt4/GuiPrefs.cpp @@ -1365,6 +1365,7 @@ PrefSpellchecker::PrefSpellchecker(GuiPreferences * form) this, SIGNAL(changed())); connect(spellcheckNotesCB, SIGNAL(clicked()), this, SIGNAL(changed())); + connect(minlengthSB, SIGNAL(changed()), this, SIGNAL(changed())); #else spellcheckerCB->setEnabled(false); altLanguageED->setEnabled(false); @@ -1372,6 +1373,7 @@ PrefSpellchecker::PrefSpellchecker(GuiPreferences * form) compoundWordCB->setEnabled(false); spellcheckContinuouslyCB->setEnabled(false); spellcheckNotesCB->setEnabled(false); + minlengthSB->setEnabled(false); #endif } @@ -1384,6 +1386,7 @@ void PrefSpellchecker::apply(LyXRC & rc) const rc.spellchecker_esc_chars = fromqstr(escapeCharactersED->text()); rc.spellchecker_accept_compound = compoundWordCB->isChecked(); rc.spellcheck_continuously = spellcheckContinuouslyCB->isChecked(); + rc.spellcheck_minlength = minlengthSB->value(); rc.spellcheck_notes = spellcheckNotesCB->isChecked(); } @@ -1395,7 +1398,10 @@ void PrefSpellchecker::update(LyXRC const & rc) altLanguageED->setText(toqstr(rc.spellchecker_alt_lang)); escapeCharactersED->setText(toqstr(rc.spellchecker_esc_chars)); compoundWordCB->setChecked(rc.spellchecker_accept_compound); - spellcheckContinuouslyCB->setChecked(rc.spellcheck_continuously); + bool const continuous = rc.spellcheck_continuously; + spellcheckContinuouslyCB->setChecked(continuous); + minlengthSB->setValue(rc.spellcheck_minlength); + minlengthSB->setEnabled(continuous); spellcheckNotesCB->setChecked(rc.spellcheck_notes); } diff --git a/src/frontends/qt4/ui/PrefSpellcheckerUi.ui b/src/frontends/qt4/ui/PrefSpellcheckerUi.ui index 9a8f1dfb09..b584a200c1 100644 --- a/src/frontends/qt4/ui/PrefSpellcheckerUi.ui +++ b/src/frontends/qt4/ui/PrefSpellcheckerUi.ui @@ -1,33 +1,33 @@ - + PrefSpellcheckerUi - - + + 0 0 519 - 224 + 241 - + - - + + 9 - + 6 - + - + Qt::Vertical - + QSizePolicy::Expanding - + 501 21 @@ -35,58 +35,48 @@ - - - - If unchecked, notes and comments will be excluded from spell checking - - - Spellcheck &notes and comments - - - - - - + + + &Spellchecker engine: - + altLanguageED - - + + - - - - Accept words such as "diskdrive" + + + + Accept words such as "diskdrive" - + Accept compound &words - - - + + + Mark misspelled words with a wavy underline. - + S&pellcheck continuously - + - + Qt::Horizontal - + QSizePolicy::Expanding - + 41 22 @@ -94,40 +84,73 @@ - - - + + + The characters inserted here are ignored by the spellchecker. - - - + + + &Escape characters: - + escapeCharactersED - - - + + + Override the language used for the spellchecker - - - + + + Al&ternative language: - + altLanguageED + + + + Minimum word length for completion + + + + + + + + + + 5 + + + 15 + + + 6 + + + + + + + If unchecked, notes and comments will be excluded from spell checking + + + Spellcheck &notes and comments + + + @@ -136,7 +159,7 @@ compoundWordCB - qt_i18n.h + qt_i18n.h