From 8edfff7669858451516d8cd401e4ece04859bafa Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Thu, 8 Sep 2011 21:15:19 +0200 Subject: [PATCH] - changed : don't provide feedback on the current word while it's still being typed/edited (for text editors) --HG-- branch : Misc-Spellcheck --- indra/llui/lltextbase.cpp | 9 +++++++++ indra/llui/lltextbase.h | 4 ++++ indra/llui/lltexteditor.cpp | 4 ++++ 3 files changed, 17 insertions(+) diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp index b8981c43c9..18b6abea07 100644 --- a/indra/llui/lltextbase.cpp +++ b/indra/llui/lltextbase.cpp @@ -50,6 +50,10 @@ const F32 CURSOR_FLASH_DELAY = 1.0f; // in seconds const S32 CURSOR_THICKNESS = 2; +// [SL:KB] - Patch: Misc-Spellcheck | Checked: 2011-09-08 (Catznip-2.8.0a) | Added: Catznip-2.8.0a +const F32 LLTextBase::SPELLCHECK_DELAY = 0.5f; // Delay between the last keypress and showing spell checking feedback for the word the cursor is on +// [/SL:KB] + LLTextBase::line_info::line_info(S32 index_start, S32 index_end, LLRect rect, S32 line_num) : mDocIndexStart(index_start), mDocIndexEnd(index_end), @@ -250,6 +254,7 @@ LLTextBase::LLTextBase(const LLTextBase::Params &p) // [SL:KB] - Patch: Misc-Spellcheck | Checked: 2011-09-07 (Catznip-2.8.0a) | Added: Catznip-2.8.0a if (mSpellCheck) LLHunspellWrapper::setSettingsChangeCallback(boost::bind(&LLTextBase::onSpellCheckSettingsChange, this)); + mSpellCheckTimer.reset(); // [/SL:KB] mDocumentView = LLUICtrlFactory::create(view_params); @@ -654,6 +659,10 @@ void LLTextBase::drawText() // Draw squiggly lines under any (visible) misspelled words for (; (itMisspell != mMisspellRanges.end()) && ((itMisspell->first < line_end) && (itMisspell->second > line_start)); ++itMisspell) { + // 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 pxStart, pxEnd, pxTemp; cur_segment->getDimensions(seg_start - cur_segment->getStart(), itMisspell->first - seg_start + 1, pxStart, pxTemp); cur_segment->getDimensions(itMisspell->first - seg_start + 1, itMisspell->second - itMisspell->first, pxEnd, pxTemp); diff --git a/indra/llui/lltextbase.h b/indra/llui/lltextbase.h index 5afb978c3d..9c5120de8d 100644 --- a/indra/llui/lltextbase.h +++ b/indra/llui/lltextbase.h @@ -565,7 +565,11 @@ protected: // [SL:KB] - Patch: Misc-Spellcheck | Checked: 2011-09-07 (Catznip-2.8.0a) | Added: Catznip-2.8.0a BOOL mSpellCheck; BOOL mNeedsSpellCheck; + LLTimer mSpellCheckTimer; std::list > mMisspellRanges; + + // Constant + static const F32 SPELLCHECK_DELAY; // [/SL:KB] // configuration diff --git a/indra/llui/lltexteditor.cpp b/indra/llui/lltexteditor.cpp index 9bd445988d..ceaa40906b 100644 --- a/indra/llui/lltexteditor.cpp +++ b/indra/llui/lltexteditor.cpp @@ -2830,6 +2830,10 @@ void LLTextEditor::setKeystrokeCallback(const keystroke_signal_t::slot_type& cal void LLTextEditor::onKeyStroke() { mKeystrokeSignal(this); +// [SL:KB] - Patch: Misc-Spellcheck | Checked: 2011-09-08 (Catznip-2.8.0a) | Added: Catznip-2.8.0a + mNeedsSpellCheck = TRUE; + mSpellCheckTimer.setTimerExpirySec(SPELLCHECK_DELAY); +// [/SL:KB] } //virtual