- added : replace the current (misspelled) word with the selected suggestion from the context menu
--HG-- branch : Misc-Spellcheckmaster
parent
5934f0b646
commit
131ef53fe5
|
|
@ -536,6 +536,31 @@ U32 LLLineEditor::getSuggestionCount() const
|
|||
return mSuggestionList.size();
|
||||
}
|
||||
|
||||
void LLLineEditor::replaceWithSuggestion(U32 idxSuggestion)
|
||||
{
|
||||
for (std::list<std::pair<U32, U32> >::const_iterator itMisspell = mMisspellRanges.begin();
|
||||
itMisspell != mMisspellRanges.end(); ++itMisspell)
|
||||
{
|
||||
if ( (itMisspell->first <= (U32)mCursorPos) && (itMisspell->second >= (U32)mCursorPos) )
|
||||
{
|
||||
deselect();
|
||||
|
||||
// Delete the misspelled word
|
||||
mText.erase(itMisspell->first, itMisspell->second - itMisspell->first);
|
||||
setCursor(itMisspell->first);
|
||||
|
||||
// Insert the suggestion in its place
|
||||
LLWString wstrSuggestion = utf8str_to_wstring(mSuggestionList[idxSuggestion]);
|
||||
mText.insert(getCursor(), wstrSuggestion);
|
||||
|
||||
setCursor(mCursorPos + (S32)wstrSuggestion.length());
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
mNeedsSpellCheck = TRUE;
|
||||
}
|
||||
|
||||
void LLLineEditor::addToDictionary()
|
||||
{
|
||||
// TODO: implement this
|
||||
|
|
|
|||
|
|
@ -158,6 +158,7 @@ public:
|
|||
|
||||
/*virtual*/ std::string getSuggestion(U32 idxSuggestion) const;
|
||||
/*virtual*/ U32 getSuggestionCount() const;
|
||||
/*virtual*/ void replaceWithSuggestion(U32 idxSuggestion);
|
||||
|
||||
/*virtual*/ void addToDictionary();
|
||||
/*virtual*/ bool canAddToDictionary() const;
|
||||
|
|
|
|||
|
|
@ -3937,7 +3937,8 @@ void LLContextMenu::hide()
|
|||
}
|
||||
mHoverItem = NULL;
|
||||
// [SL:KB] - Patch: Misc-Spellcheck | Checked: 2010-12-19 (Catznip-2.5.0a) | Added: Catznip-2.5.0a
|
||||
mSpawningViewHandle.markDead();
|
||||
// NOTE: this should be done *somewhere* but a menu item's onCommit() calls "hideMenus" before it fires the "onCommit" signal
|
||||
// mSpawningViewHandle.markDead();
|
||||
// [/SL:KB]
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ public:
|
|||
|
||||
virtual std::string getSuggestion(U32 idxSuggestion) const { return ""; }
|
||||
virtual U32 getSuggestionCount() const { return 0; }
|
||||
virtual void replaceWithSuggestion(U32 idxSuggestion) {}
|
||||
|
||||
virtual void addToDictionary() {}
|
||||
virtual bool canAddToDictionary() const { return false; }
|
||||
|
|
|
|||
|
|
@ -5064,6 +5064,16 @@ class LLViewEnableLastChatter : public view_listener_t
|
|||
// [SL:KB] - Patch: Misc-Spellcheck | Checked: 2010-12-19 (Catznip-2.5.0a) | Added: Catznip-2.5.0a
|
||||
void spellCheck_ReplaceWithSuggestion(LLUICtrl* pMenuItemCtrl, const LLSD& sdParam)
|
||||
{
|
||||
LLContextMenu* pMenu = dynamic_cast<LLContextMenu*>(pMenuItemCtrl->getParent());
|
||||
LLSpellCheckMenuHandler* pSpellCheckHandler = (pMenu) ? dynamic_cast<LLSpellCheckMenuHandler*>(pMenu->getSpawningView()) : NULL;
|
||||
if ( (!pSpellCheckHandler) || (!pSpellCheckHandler->useSpellCheck()) )
|
||||
return;
|
||||
|
||||
U32 idxSuggestion = 0;
|
||||
if ( (!LLStringUtil::convertToU32(sdParam.asString(), idxSuggestion)) || (idxSuggestion >= pSpellCheckHandler->getSuggestionCount()) )
|
||||
return;
|
||||
|
||||
pSpellCheckHandler->replaceWithSuggestion(idxSuggestion);
|
||||
}
|
||||
|
||||
bool spellCheck_VisibleSuggestion(LLUICtrl* pMenuItemCtrl, const LLSD& sdParam)
|
||||
|
|
|
|||
Loading…
Reference in New Issue