#6760 add UI to configure the minimal length of a word to be added to the list of words for text completion - using richards patch and rework it to match current trunk

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40557 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Stephan Witt 2012-01-02 22:47:04 +00:00
parent bfe67ac65f
commit 97d48fbd6a
5 changed files with 74 additions and 5 deletions

View File

@ -78,6 +78,7 @@ LexerKeyword lyxrcTags[] = {
{ "\\completion_inline_dots", LyXRC::RC_COMPLETION_INLINE_DOTS },
{ "\\completion_inline_math", LyXRC::RC_COMPLETION_INLINE_MATH },
{ "\\completion_inline_text", LyXRC::RC_COMPLETION_INLINE_TEXT },
{ "\\completion_minlength", LyXRC::RC_COMPLETION_MINLENGTH },
{ "\\completion_popup_after_complete", LyXRC::RC_COMPLETION_POPUP_AFTER_COMPLETE },
{ "\\completion_popup_delay", LyXRC::RC_COMPLETION_POPUP_DELAY },
{ "\\completion_popup_math", LyXRC::RC_COMPLETION_POPUP_MATH },
@ -302,6 +303,7 @@ void LyXRC::setDefaults()
#endif
spellchecker_accept_compound = false;
spellcheck_continuously = false;
completion_minlength = 6;
spellcheck_notes = true;
use_kbmap = false;
rtl_support = true;
@ -815,6 +817,10 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format)
lexrc >> completion_popup_after_complete;
break;
case RC_COMPLETION_MINLENGTH:
lexrc >> completion_minlength;
break;
case RC_NUMLASTFILES:
lexrc >> num_lastfiles;
break;
@ -2301,7 +2307,16 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
}
if (tag != RC_LAST)
break;
case RC_NUMLASTFILES:
case RC_COMPLETION_MINLENGTH:
if (ignore_system_lyxrc ||
completion_minlength != system_lyxrc.completion_minlength) {
os << "\\completion_minlength " << convert<string>(completion_minlength)
<< '\n';
}
if (tag != RC_LAST)
break;
case RC_NUMLASTFILES:
if (ignore_system_lyxrc ||
num_lastfiles != system_lyxrc.num_lastfiles) {
os << "\\num_lastfiles " << num_lastfiles << '\n';
@ -2887,6 +2902,7 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new)
case LyXRC::RC_COMPLETION_POPUP_DELAY:
case LyXRC::RC_COMPLETION_POPUP_MATH:
case LyXRC::RC_COMPLETION_POPUP_TEXT:
case LyXRC::RC_COMPLETION_MINLENGTH:
case LyXRC::RC_USELASTFILEPOS:
case LyXRC::RC_LOADSESSION:
case LyXRC::RC_CHKTEX_COMMAND:

View File

@ -58,6 +58,7 @@ public:
RC_COMPLETION_INLINE_MATH,
RC_COMPLETION_INLINE_TEXT,
RC_COMPLETION_INLINE_DOTS,
RC_COMPLETION_MINLENGTH,
RC_COMPLETION_POPUP_DELAY,
RC_COMPLETION_POPUP_MATH,
RC_COMPLETION_POPUP_TEXT,
@ -374,6 +375,8 @@ public:
bool spellcheck_continuously;
/// spellcheck notes and comments?
bool spellcheck_notes;
/// minimum length of words to complete
unsigned int completion_minlength;
///
bool use_kbmap;
///

View File

@ -3489,16 +3489,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) >= (int)lyxrc.completion_minlength) {
docstring word = asString(from, pos, AS_STR_NONE);
FontList::const_iterator cit = d->fontlist_.fontIterator(pos);
if (cit == d->fontlist_.end())

View File

@ -631,6 +631,8 @@ PrefCompletion::PrefCompletion(GuiPreferences * form)
this, SIGNAL(changed()));
connect(cursorTextCB, SIGNAL(clicked()),
this, SIGNAL(changed()));
connect(minlengthSB, SIGNAL(valueChanged(int)),
this, SIGNAL(changed()));
}
@ -666,6 +668,7 @@ void PrefCompletion::apply(LyXRC & rc) const
rc.completion_cursor_text = cursorTextCB->isChecked();
rc.completion_popup_after_complete =
popupAfterCompleteCB->isChecked();
rc.completion_minlength = minlengthSB->value();
}
@ -682,6 +685,7 @@ void PrefCompletion::update(LyXRC const & rc)
cursorTextCB->setChecked(rc.completion_cursor_text);
popupAfterCompleteCB->setChecked(rc.completion_popup_after_complete);
enableCB();
minlengthSB->setValue(rc.completion_minlength);
}

View File

@ -219,6 +219,55 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QSpinBox" name="minlengthSB" >
<property name="toolTip" >
<string>.</string>
</property>
<property name="minimum">
<number>5</number>
</property>
<property name="maximum">
<number>24</number>
</property>
<property name="value">
<number>6</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_5" >
<property name="text" >
<string>Minimum word length for completion</string>
</property>
<property name="buddy" >
<cstring>minlengthSB</cstring>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="popupAfterCompleteCB" >
<property name="toolTip" >