PHOE-2170: port of FIRE-2250; In autocorrection process all strings as unicode so we get proper ind

Sat, 10 Mar 2012 19:13:22 -0800

author
Kadah_Coba <kadah.coba@gmail.com>
date
Sat, 10 Mar 2012 19:13:22 -0800
changeset 1673
045c423f7390
parent 1672
79154d17a197
child 1674
b0890f7568f2

PHOE-2170: port of FIRE-2250; In autocorrection process all strings as unicode so we get proper ind

indra/llui/lllineeditor.cpp file | annotate | diff | revisions
     1.1 --- a/indra/llui/lllineeditor.cpp	Fri Mar 09 18:21:13 2012 -0800
     1.2 +++ b/indra/llui/lllineeditor.cpp	Sat Mar 10 19:13:22 2012 -0800
     1.3 @@ -1847,35 +1847,48 @@
     1.4  		S32 wordStart = 0;
     1.5  		S32 wordEnd = mCursorPos-1;
     1.6  		//llinfos <<"Checking Word, Cursor is at "<<mCursorPos<<" and text is "<<mText.getString().c_str()<<llendl;
     1.7 -		if(wordEnd<1)return;
     1.8 -		const LLWString& text = mText.getWString();
     1.9 -		if(text.size()<1)return;
    1.10 -		if( LLTextEditor::isPartOfWord( text[wordEnd] )) return;//we only check on word breaks
    1.11 +
    1.12 +		if(wordEnd < 1)
    1.13 +			return;
    1.14 +
    1.15 +		LLWString text = mText.getWString();
    1.16 +
    1.17 +		if(text.size()<1)
    1.18 +			return;
    1.19 +
    1.20 +		if( LLTextEditor::isPartOfWord( text[wordEnd] ))
    1.21 +			return;//we only check on word breaks
    1.22 +
    1.23  		wordEnd--;
    1.24 +
    1.25  		if( LLTextEditor::isPartOfWord( text[wordEnd] ) )
    1.26  		{
    1.27  			while ((wordEnd > 0) && (' '!=text[wordEnd-1]))
    1.28  			{
    1.29  				wordEnd--;
    1.30  			}
    1.31 +
    1.32  			wordStart=wordEnd;		
    1.33 +
    1.34  			while ((wordEnd < (S32)text.length()) && (' '!=text[wordEnd] ) )
    1.35  			{
    1.36  				wordEnd++;
    1.37  			}
    1.38 -			std::string lastTypedWord(std::string(text.begin(), 
    1.39 -			text.end()).substr(wordStart,wordEnd-wordStart));
    1.40 -			//llinfos << " The last typed word has been chosen, it is "<<lastTypedWord.c_str()<<llendl;
    1.41 -		
    1.42 -			std::string correctedWord(LGGAutoCorrect::getInstance()->replaceWord(lastTypedWord));
    1.43 +
    1.44 +			std::string strLastWord = std::string(text.begin(), text.end());
    1.45 +			std::string lastTypedWord = strLastWord.substr( wordStart, wordEnd-wordStart);
    1.46 +			std::string correctedWord( LGGAutoCorrect::getInstance()->replaceWord(lastTypedWord));
    1.47 +
    1.48  			if(correctedWord!=lastTypedWord)
    1.49  			{
    1.50 -				int dif = correctedWord.length()-lastTypedWord.length();
    1.51 -				std::string regText(mText);
    1.52 +				LLWString strNew = utf8str_to_wstring( correctedWord );
    1.53 +				LLWString strOld = utf8str_to_wstring( lastTypedWord );
    1.54 +				int nDiff = strNew.size() - strOld.size();
    1.55 +
    1.56  				//int wordStart = regText.find(lastTypedWord);
    1.57 -				regText.replace(wordStart,lastTypedWord.length(),correctedWord);
    1.58 -				mText=regText;
    1.59 -				mCursorPos+=dif;
    1.60 +				text.replace(wordStart,lastTypedWord.length(),strNew);
    1.61 +				mText = wstring_to_utf8str(text);
    1.62 +				mCursorPos+=nDiff;
    1.63  			}
    1.64  		}
    1.65  	}

mercurial