- changed : don't provide feedback on the current word while it's still being typed/edited

--HG--
branch : Misc-Spellcheck
master
Kitty Barnett 2010-12-24 03:00:58 +01:00
parent bd4eb79446
commit a0eb817c02
2 changed files with 28 additions and 1 deletions

View File

@ -68,6 +68,9 @@ const S32 SCROLL_INCREMENT_ADD = 0; // make space for typing
const S32 SCROLL_INCREMENT_DEL = 4; // make space for baskspacing
const F32 AUTO_SCROLL_TIME = 0.05f;
const F32 TRIPLE_CLICK_INTERVAL = 0.3f; // delay between double and triple click. *TODO: make this equal to the double click interval?
// [SL:KB] - Patch: Misc-Spellcheck | Checked: 2010-12-24 (Catznip-2.5.0a) | Added: Catznip-2.5.0a
const F32 SPELLCHECK_DELAY = 0.5f; // delay between the last keypress and showing spell checking feedback for the word the cursor is on
// [/SL:KB]
const std::string PASSWORD_ASTERISK( "\xE2\x80\xA2" ); // U+2022 BULLET
@ -163,6 +166,9 @@ LLLineEditor::LLLineEditor(const LLLineEditor::Params& p)
mScrollTimer.reset();
mTripleClickTimer.reset();
// [SL:KB] - Patch: Misc-Spellcheck | Checked: 2010-12-25 (Catznip-2.5.0a) | Added: Catznip-2.5.0a
mSpellCheckTimer.reset();
// [/SL:KB]
setText(p.default_text());
// Initialize current history line iterator
@ -1513,6 +1519,13 @@ BOOL LLLineEditor::handleKeyHere(KEY key, MASK mask )
{
mKeystrokeCallback(this);
}
// [SL:KB] - Patch: Misc-Spellcheck | Checked: 2010-12-24 (Catznip-2.5.0a) | Added: Catznip-2.5.0a
// We're only interested in the backspace key
if ( (!selection_modified) && (KEY_BACKSPACE == key) )
{
mSpellCheckTimer.setTimerExpirySec(SPELLCHECK_DELAY);
}
// [/SL:KB]
}
}
}
@ -1563,6 +1576,9 @@ BOOL LLLineEditor::handleUnicodeCharHere(llwchar uni_char)
// We'll have to do something about this if something ever changes! - Doug
mKeystrokeCallback( this );
}
// [SL:KB] - Patch: Misc-Spellcheck | Checked: 2010-12-24 (Catznip-2.5.0a) | Added: Catznip-2.5.0a
mSpellCheckTimer.setTimerExpirySec(SPELLCHECK_DELAY);
// [/SL:KB]
}
}
return handled;
@ -1604,6 +1620,9 @@ void LLLineEditor::doDelete()
{
mKeystrokeCallback( this );
}
// [SL:KB] - Patch: Misc-Spellcheck | Checked: 2010-12-24 (Catznip-2.5.0a) | Added: Catznip-2.5.0a
mSpellCheckTimer.setTimerExpirySec(SPELLCHECK_DELAY);
// [/SL:KB]
}
}
}
@ -1836,7 +1855,7 @@ void LLLineEditor::draw()
#endif
// [SL:KB] - Patch: Misc-Spellcheck | Checked: 2010-12-19 (Catznip-2.5.0a) | Added: Catznip-2.5.0a
if ( (mSpellCheck) && (!mReadOnly) && (mText.length() > 2) )
if ( (useSpellCheck()) && (mText.length() > 2) )
{
// Calculate start and end (character) indices for the first and last visible word
U32 idxStart = prevWordPos(mScrollHPos); static U32 idxPrevStart = -1;
@ -1891,6 +1910,10 @@ void LLLineEditor::draw()
if ( ((itMisspell->first < idxStart) && (itMisspell->second < idxStart)) || (itMisspell->first > idxEnd) )
continue;
// Skip the current word if the user is still busy editing it
if ( (!mSpellCheckTimer.hasExpired()) && (itMisspell->first <= (U32)mCursorPos) && (itMisspell->second >= (U32)mCursorPos) )
continue;
S32 pxWidth = getRect().getWidth();
S32 pxStart = findPixelNearestPos(itMisspell->first - getCursor());
if (pxStart > pxWidth)
@ -2304,6 +2327,9 @@ void LLLineEditor::updatePreedit(const LLWString &preedit_string,
{
mKeystrokeCallback( this );
}
// [SL:KB] - Patch: Misc-Spellcheck | Checked: 2010-12-24 (Catznip-2.5.0a) | Added: Catznip-2.5.0a
mSpellCheckTimer.setTimerExpirySec(SPELLCHECK_DELAY);
// [/SL:KB]
}
BOOL LLLineEditor::getPreeditLocation(S32 query_offset, LLCoordGL *coord, LLRect *bounds, LLRect *control) const

View File

@ -341,6 +341,7 @@ protected:
// [SL:KB] - Patch: Misc-Spellcheck | Checked: 2010-12-19 (Catznip-2.5.0a) | Added: Catznip-2.5.0a
BOOL mSpellCheck;
BOOL mNeedsSpellCheck;
LLTimer mSpellCheckTimer;
std::list<std::pair<U32, U32> > mMisspellRanges;
std::vector<std::string> mSuggestionList;
// [/SL:KB]