aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra')
-rw-r--r--linden/indra/llui/lllineeditor.cpp207
-rw-r--r--linden/indra/llui/lllineeditor.h4
-rw-r--r--linden/indra/llui/lltexteditor.cpp267
-rw-r--r--linden/indra/llui/lltexteditor.h4
-rw-r--r--linden/indra/newview/lgghunspell_wrapper.cpp327
-rw-r--r--linden/indra/newview/lgghunspell_wrapper.h6
6 files changed, 470 insertions, 345 deletions
diff --git a/linden/indra/llui/lllineeditor.cpp b/linden/indra/llui/lllineeditor.cpp
index c1d8efa..e95af79 100644
--- a/linden/indra/llui/lllineeditor.cpp
+++ b/linden/indra/llui/lllineeditor.cpp
@@ -171,7 +171,7 @@ LLLineEditor::LLLineEditor(const std::string& name, const LLRect& rect,
171 mHaveHistory(FALSE), 171 mHaveHistory(FALSE),
172 mImage( sImage ), 172 mImage( sImage ),
173 mReplaceNewlinesWithSpaces( TRUE ), 173 mReplaceNewlinesWithSpaces( TRUE ),
174 mOverRideAndShowMisspellings( FALSE ) 174 mShowMisspellings( FALSE )
175{ 175{
176 llassert( max_length_bytes > 0 ); 176 llassert( max_length_bytes > 0 );
177 177
@@ -546,19 +546,19 @@ void LLLineEditor::spell_show(void * data)
546 SpellMenuBind* tempBind = (SpellMenuBind*)data; 546 SpellMenuBind* tempBind = (SpellMenuBind*)data;
547 LLLineEditor* line = tempBind->origin; 547 LLLineEditor* line = tempBind->origin;
548 548
549 if(tempBind && line) 549 if( tempBind && line)
550 { 550 {
551 if(tempBind->word=="Show Misspellings") 551 if (tempBind->word=="Show Misspellings")
552 { 552 {
553 line->setOverRideAndShowMisspellings(TRUE); 553 line->setShowMisspellings(TRUE);
554 }else 554 }
555 else
555 { 556 {
556 line->setOverRideAndShowMisspellings(FALSE); 557 line->setShowMisspellings(FALSE);
557 } 558 }
558 } 559 }
559
560
561} 560}
561
562std::vector<S32> LLLineEditor::getMisspelledWordsPositions() 562std::vector<S32> LLLineEditor::getMisspelledWordsPositions()
563{ 563{
564 std::vector<S32> thePosesOfBadWords; 564 std::vector<S32> thePosesOfBadWords;
@@ -604,25 +604,29 @@ std::vector<S32> LLLineEditor::getMisspelledWordsPositions()
604 } 604 }
605 return thePosesOfBadWords; 605 return thePosesOfBadWords;
606} 606}
607
607void LLLineEditor::spell_add(void* data) 608void LLLineEditor::spell_add(void* data)
608{ 609{
609 SpellMenuBind* tempBind = (SpellMenuBind*)data; 610 SpellMenuBind* tempBind = (SpellMenuBind*)data;
610 if(tempBind) 611 if (tempBind)
611 { 612 {
612 glggHunSpell->addWordToCustomDictionary(tempBind->word); 613 glggHunSpell->addWordToCustomDictionary(tempBind->word);
613 tempBind->origin->mPrevSpelledText="";//make it update 614 tempBind->origin->mPrevSpelledText="";//make it update
614 } 615 }
615} 616}
617
616void LLLineEditor::context_paste(void* data) 618void LLLineEditor::context_paste(void* data)
617{ 619{
618 LLLineEditor* line = (LLLineEditor*)data; 620 LLLineEditor* line = (LLLineEditor*)data;
619 if(line)line->paste(); 621 if(line)line->paste();
620} 622}
623
621void LLLineEditor::context_delete(void* data) 624void LLLineEditor::context_delete(void* data)
622{ 625{
623 LLLineEditor* line = (LLLineEditor*)data; 626 LLLineEditor* line = (LLLineEditor*)data;
624 if(line)line->doDelete(); 627 if(line)line->doDelete();
625} 628}
629
626void LLLineEditor::context_selectall(void* data) 630void LLLineEditor::context_selectall(void* data)
627{ 631{
628 LLLineEditor* line = (LLLineEditor*)data; 632 LLLineEditor* line = (LLLineEditor*)data;
@@ -728,16 +732,17 @@ BOOL LLLineEditor::handleRightMouseDown( S32 x, S32 y, MASK mask )
728 S32 wordStart = 0; 732 S32 wordStart = 0;
729 S32 wordEnd = calculateCursorFromMouse(x); 733 S32 wordEnd = calculateCursorFromMouse(x);
730 734
731
732 LLMenuGL* menu = (LLMenuGL*)mPopupMenuHandle.get(); 735 LLMenuGL* menu = (LLMenuGL*)mPopupMenuHandle.get();
733 if (menu) 736 if (menu)
734 { 737 {
735 if(menu->isOpen()) 738 if(menu->isOpen())
739 {
736 menu->setVisible(FALSE); 740 menu->setVisible(FALSE);
737 for(int i = 0;i<(int)suggestionMenuItems.size();i++) 741 }
742 for (int i = 0;i<(int)suggestionMenuItems.size();i++)
738 { 743 {
739 SpellMenuBind * tempBind = suggestionMenuItems[i]; 744 SpellMenuBind * tempBind = suggestionMenuItems[i];
740 if(tempBind) 745 if (tempBind)
741 { 746 {
742 menu->remove((LLMenuItemCallGL *)tempBind->menuItem); 747 menu->remove((LLMenuItemCallGL *)tempBind->menuItem);
743 ((LLMenuItemCallGL *)tempBind->menuItem)->die(); 748 ((LLMenuItemCallGL *)tempBind->menuItem)->die();
@@ -748,69 +753,74 @@ BOOL LLLineEditor::handleRightMouseDown( S32 x, S32 y, MASK mask )
748 } 753 }
749 suggestionMenuItems.clear(); 754 suggestionMenuItems.clear();
750 755
751 menu->setItemVisible("Translate To",!mReadOnly); 756 menu->setItemVisible("Translate To", !mReadOnly);
752 menu->setItemVisible("Transep",!mReadOnly); 757 menu->setItemVisible("Transep", !mReadOnly);
753 758
754 const LLWString& text = mText.getWString(); 759 // spell_check="true" in xui
755 if(( LLTextEditor::isPartOfWord( text[wordEnd] ) ) 760 if (!mReadOnly && mShowMisspellings)
756 &&(!mReadOnly))
757 { 761 {
758 // Select word the cursor is over 762 const LLWString& text = mText.getWString();
759 while ((wordEnd > 0) && LLTextEditor::isPartOfWord(text[wordEnd-1]))
760 {
761 wordEnd--;
762 }
763 wordStart=wordEnd;
764 //startSelection();
765 763
766 while ((wordEnd < (S32)text.length()) && LLTextEditor::isPartOfWord( text[wordEnd] ) ) 764 // search for word matches
765 if (LLTextEditor::isPartOfWord(text[wordEnd]))
767 { 766 {
768 wordEnd++; 767 // Select word the cursor is over
769 } 768 while ((wordEnd > 0) && LLTextEditor::isPartOfWord(text[wordEnd-1]))
770 std::string selectedWord(std::string(text.begin(), 769 {
771 text.end()).substr(wordStart,wordEnd-wordStart)); 770 wordEnd--;
772 if(!glggHunSpell->isSpelledRight(selectedWord)) 771 }
773 { 772 wordStart = wordEnd;
774 //misspelled word here, and you have just right clicked on it! 773 //startSelection();
775 std::vector<std::string> suggs = glggHunSpell->getSuggestionList(selectedWord);
776 //menu->setItemVisible("Transep",(suggs.size()>0));
777 774
778 for(int i = 0;i<(int)suggs.size();i++) 775 while ((wordEnd < (S32)text.length()) && LLTextEditor::isPartOfWord( text[wordEnd] ) )
779 { 776 {
777 wordEnd++;
778 }
779 std::string selectedWord(std::string(text.begin(), text.end()).substr(wordStart,wordEnd-wordStart));
780
781 if (!glggHunSpell->isSpelledRight(selectedWord))
782 {
783 //misspelled word here, and you have just right clicked on it!
784 std::vector<std::string> suggs = glggHunSpell->getSuggestionList(selectedWord);
785 //menu->setItemVisible("Transep",(suggs.size()>0));
786
787 for (int i = 0; i<(int)suggs.size() ;i++)
788 {
789 SpellMenuBind * tempStruct = new SpellMenuBind;
790 tempStruct->origin = this;
791 tempStruct->word = suggs[i];
792 tempStruct->wordPositionEnd = wordEnd;
793 tempStruct->wordPositionStart=wordStart;
794 LLMenuItemCallGL * suggMenuItem = new LLMenuItemCallGL(
795 tempStruct->word, spell_correct, NULL, tempStruct);
796 //new LLMenuItemCallGL("Select All", context_selectall, NULL, this));
797 tempStruct->menuItem = suggMenuItem;
798 suggestionMenuItems.push_back(tempStruct);
799 menu->append(suggMenuItem);
800 }
780 SpellMenuBind * tempStruct = new SpellMenuBind; 801 SpellMenuBind * tempStruct = new SpellMenuBind;
781 tempStruct->origin = this; 802 tempStruct->origin = this;
782 tempStruct->word = suggs[i]; 803 tempStruct->word = selectedWord;
783 tempStruct->wordPositionEnd = wordEnd; 804 tempStruct->wordPositionEnd = wordEnd;
784 tempStruct->wordPositionStart=wordStart; 805 tempStruct->wordPositionStart=wordStart;
785 LLMenuItemCallGL * suggMenuItem = new LLMenuItemCallGL( 806 LLMenuItemCallGL * suggMenuItem = new LLMenuItemCallGL(
786 tempStruct->word, spell_correct, NULL, tempStruct); 807 "Add Word", spell_add, NULL, tempStruct);
787 //new LLMenuItemCallGL("Select All", context_selectall, NULL, this));
788 tempStruct->menuItem = suggMenuItem; 808 tempStruct->menuItem = suggMenuItem;
789 suggestionMenuItems.push_back(tempStruct); 809 suggestionMenuItems.push_back(tempStruct);
790 menu->append(suggMenuItem); 810 menu->append(suggMenuItem);
791 } 811 }
792 SpellMenuBind * tempStruct = new SpellMenuBind;
793 tempStruct->origin = this;
794 tempStruct->word = selectedWord;
795 tempStruct->wordPositionEnd = wordEnd;
796 tempStruct->wordPositionStart=wordStart;
797 LLMenuItemCallGL * suggMenuItem = new LLMenuItemCallGL(
798 "Add Word", spell_add, NULL, tempStruct);
799 tempStruct->menuItem = suggMenuItem;
800 suggestionMenuItems.push_back(tempStruct);
801 menu->append(suggMenuItem);
802 } 812 }
803 813
804 }
805 if((!mReadOnly)&&((!glggHunSpell->highlightInRed)
806 ||(mOverRideAndShowMisspellings)))
807 {
808 SpellMenuBind * tempStruct = new SpellMenuBind; 814 SpellMenuBind * tempStruct = new SpellMenuBind;
809 tempStruct->origin = this; 815 tempStruct->origin = this;
810 if(mOverRideAndShowMisspellings) 816 if (glggHunSpell->mSpellCheckHighlight)
817 {
811 tempStruct->word = "Hide Misspellings"; 818 tempStruct->word = "Hide Misspellings";
819 }
812 else 820 else
821 {
813 tempStruct->word = "Show Misspellings"; 822 tempStruct->word = "Show Misspellings";
823 }
814 LLMenuItemCallGL * suggMenuItem = new LLMenuItemCallGL( 824 LLMenuItemCallGL * suggMenuItem = new LLMenuItemCallGL(
815 tempStruct->word, spell_show, NULL, tempStruct); 825 tempStruct->word, spell_show, NULL, tempStruct);
816 tempStruct->menuItem = suggMenuItem; 826 tempStruct->menuItem = suggMenuItem;
@@ -1838,36 +1848,43 @@ void LLLineEditor::doDelete()
1838 } 1848 }
1839 } 1849 }
1840} 1850}
1851
1841void LLLineEditor::autoCorrectText() 1852void LLLineEditor::autoCorrectText()
1842{ 1853{
1843 static BOOL *doAnything = rebind_llcontrol<BOOL>("EmeraldEnableAutoCorrect", &gSavedSettings, true); 1854 static BOOL *doAnything = rebind_llcontrol<BOOL>("EmeraldEnableAutoCorrect", &gSavedSettings, true);
1844 if( (!mReadOnly) && (*doAnything) && (isSpellDirty())) 1855 if (!mReadOnly && *doAnything && isSpellDirty())
1845 { 1856 {
1846 S32 wordStart = 0; 1857 S32 wordStart = 0;
1847 S32 wordEnd = mCursorPos-1; 1858 S32 wordEnd = mCursorPos-1;
1848 //llinfos <<"Checking Word, Cursor is at "<<mCursorPos<<" and text is "<<mText.getString().c_str()<<llendl; 1859 //llinfos <<"Checking Word, Cursor is at "<<mCursorPos<<" and text is "<<mText.getString().c_str()<<llendl;
1849 if(wordEnd<1)return; 1860 if (wordEnd < 1)
1861 {
1862 return;
1863 }
1850 const LLWString& text = mText.getWString(); 1864 const LLWString& text = mText.getWString();
1851 if(text.size()<1)return; 1865 if (text.size() < 1 || LLTextEditor::isPartOfWord(text[wordEnd]))
1852 if( LLTextEditor::isPartOfWord( text[wordEnd] )) return;//we only check on word breaks 1866 {
1867 return;//we only check on word breaks
1868 }
1869
1853 wordEnd--; 1870 wordEnd--;
1854 if( LLTextEditor::isPartOfWord( text[wordEnd] ) ) 1871 if (LLTextEditor::isPartOfWord(text[wordEnd]))
1855 { 1872 {
1856 while ((wordEnd > 0) && (' '!=text[wordEnd-1])) 1873 while ((wordEnd > 0) && (' '!=text[wordEnd-1]))
1857 { 1874 {
1858 wordEnd--; 1875 wordEnd--;
1859 } 1876 }
1860 wordStart=wordEnd; 1877 wordStart = wordEnd;
1861 while ((wordEnd < (S32)text.length()) && (' '!=text[wordEnd] ) ) 1878 while ((wordEnd < (S32)text.length()) && (' '!=text[wordEnd] ) )
1862 { 1879 {
1863 wordEnd++; 1880 wordEnd++;
1864 } 1881 }
1865 std::string lastTypedWord(std::string(text.begin(), 1882 std::string lastTypedWord(std::string(text.begin(),
1866 text.end()).substr(wordStart,wordEnd-wordStart)); 1883 text.end()).substr(wordStart, wordEnd-wordStart));
1867 //llinfos << " The last typed word has been chosen, it is "<<lastTypedWord.c_str()<<llendl; 1884 //llinfos << " The last typed word has been chosen, it is "<<lastTypedWord.c_str()<<llendl;
1868 1885
1869 std::string correctedWord(LGGAutoCorrect::getInstance()->replaceWord(lastTypedWord)); 1886 std::string correctedWord(LGGAutoCorrect::getInstance()->replaceWord(lastTypedWord));
1870 if(correctedWord!=lastTypedWord) 1887 if(correctedWord != lastTypedWord)
1871 { 1888 {
1872 int dif = correctedWord.length()-lastTypedWord.length(); 1889 int dif = correctedWord.length()-lastTypedWord.length();
1873 std::string regText(mText); 1890 std::string regText(mText);
@@ -1879,53 +1896,56 @@ void LLLineEditor::autoCorrectText()
1879 } 1896 }
1880 } 1897 }
1881} 1898}
1899
1882void LLLineEditor::drawMisspelled(LLRect background) 1900void LLLineEditor::drawMisspelled(LLRect background)
1883{ 1901{
1884 if((glggHunSpell->highlightInRed || mOverRideAndShowMisspellings) 1902 if (!mReadOnly && mShowMisspellings)
1885 &&(!mReadOnly))
1886 { 1903 {
1887 S32 newStartSpellHere =mScrollHPos; 1904 S32 newStartSpellHere = mScrollHPos;
1888 S32 cursorloc =calculateCursorFromMouse(mMaxHPixels); 1905 S32 cursorloc = calculateCursorFromMouse(mMaxHPixels);
1889 S32 newStopSpellHere = ( ((S32)mText.length())>cursorloc)?cursorloc:(S32)mText.length(); 1906 S32 newStopSpellHere = (((S32)mText.length())>cursorloc) ? cursorloc : (S32)mText.length();
1890 1907
1891 F32 elapsed = mSpellTimer.getElapsedTimeF32(); 1908 F32 elapsed = mSpellTimer.getElapsedTimeF32();
1892 if(S32(elapsed / 1) & 1) 1909 if (S32(elapsed / 1) & 1)
1893 { 1910 {
1894 if(isSpellDirty()||(newStartSpellHere!=mStartSpellHere)||(newStopSpellHere!=mEndSpellHere)) 1911 if (isSpellDirty() || (newStartSpellHere != mStartSpellHere) || ( newStopSpellHere != mEndSpellHere))
1895 { 1912 {
1896 mStartSpellHere=newStartSpellHere; 1913 mStartSpellHere = newStartSpellHere;
1897 mEndSpellHere= newStopSpellHere; 1914 mEndSpellHere = newStopSpellHere;
1898 resetSpellDirty(); 1915 resetSpellDirty();
1899 misspellLocations=getMisspelledWordsPositions(); 1916 misspellLocations=getMisspelledWordsPositions();
1900 } 1917 }
1901 } 1918 }
1902 for(int i =0;i<(int)misspellLocations.size();i++)
1903 {
1904 S32 wstart =findPixelNearestPos( misspellLocations[i]-getCursor());
1905 S32 wend = findPixelNearestPos(misspellLocations[++i]-getCursor());
1906 S32 maxw = getRect().getWidth();
1907 1919
1908 if(wend > maxw) 1920 if (glggHunSpell->mSpellCheckHighlight)
1909 { 1921 {
1910 wend=maxw; 1922 for (int i =0; i<(int)misspellLocations.size(); i++)
1911 }
1912 if(wstart > maxw)
1913 {
1914 wstart=maxw;
1915 }
1916 gGL.color4ub(255,0,0,200);
1917 //3 line zig zags..
1918 while(wstart<wend)
1919 { 1923 {
1920 gl_line_2d(wstart,background.mBottom-1,wstart+3,background.mBottom+2); 1924 S32 wstart =findPixelNearestPos( misspellLocations[i]-getCursor());
1921 gl_line_2d(wstart+3,background.mBottom+2,wstart+6,background.mBottom-1); 1925 S32 wend = findPixelNearestPos(misspellLocations[++i]-getCursor());
1922 wstart+=6; 1926 S32 maxw = getRect().getWidth();
1923 }
1924 1927
1928 if (wend > maxw)
1929 {
1930 wend = maxw;
1931 }
1932 if (wstart > maxw)
1933 {
1934 wstart = maxw;
1935 }
1936 gGL.color4ub(255,0,0,200);
1937 //3 line zig zags..
1938 while (wstart < wend)
1939 {
1940 gl_line_2d(wstart, background.mBottom-1, wstart+3, background.mBottom+2);
1941 gl_line_2d(wstart+3, background.mBottom+2, wstart+6, background.mBottom-1);
1942 wstart+=6;
1943 }
1944 }
1925 } 1945 }
1926 } 1946 }
1927
1928} 1947}
1948
1929void LLLineEditor::draw() 1949void LLLineEditor::draw()
1930{ 1950{
1931 autoCorrectText(); 1951 autoCorrectText();
@@ -2797,6 +2817,11 @@ LLView* LLLineEditor::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory
2797 { 2817 {
2798 line_editor->setCommitOnFocusLost(commit_on_focus_lost); 2818 line_editor->setCommitOnFocusLost(commit_on_focus_lost);
2799 } 2819 }
2820 BOOL show_misspellings = FALSE;
2821 if (node->getAttributeBOOL("spell_check", show_misspellings))
2822 {
2823 line_editor->setShowMisspellings(show_misspellings);
2824 }
2800 2825
2801 line_editor->setColorParameters(node); 2826 line_editor->setColorParameters(node);
2802 2827
diff --git a/linden/indra/llui/lllineeditor.h b/linden/indra/llui/lllineeditor.h
index 6de57ec..1d24803 100644
--- a/linden/indra/llui/lllineeditor.h
+++ b/linden/indra/llui/lllineeditor.h
@@ -198,7 +198,7 @@ public:
198 void setWriteableBgColor( const LLColor4& c ) { mWriteableBgColor = c; } 198 void setWriteableBgColor( const LLColor4& c ) { mWriteableBgColor = c; }
199 void setReadOnlyBgColor( const LLColor4& c ) { mReadOnlyBgColor = c; } 199 void setReadOnlyBgColor( const LLColor4& c ) { mReadOnlyBgColor = c; }
200 void setFocusBgColor(const LLColor4& c) { mFocusBgColor = c; } 200 void setFocusBgColor(const LLColor4& c) { mFocusBgColor = c; }
201 void setOverRideAndShowMisspellings(BOOL b) { mOverRideAndShowMisspellings =b;} 201 void setShowMisspellings(BOOL b) { mShowMisspellings = b;}
202 202
203 const LLColor4& getFgColor() const { return mFgColor; } 203 const LLColor4& getFgColor() const { return mFgColor; }
204 const LLColor4& getReadOnlyFgColor() const { return mReadOnlyFgColor; } 204 const LLColor4& getReadOnlyFgColor() const { return mReadOnlyFgColor; }
@@ -293,7 +293,7 @@ protected:
293 std::vector<S32> misspellLocations; // where all the mispelled words are 293 std::vector<S32> misspellLocations; // where all the mispelled words are
294 S32 mStartSpellHere; // the position of the first char on the screen, stored so we know when to update 294 S32 mStartSpellHere; // the position of the first char on the screen, stored so we know when to update
295 S32 mEndSpellHere; // the location of the last char on the screen 295 S32 mEndSpellHere; // the location of the last char on the screen
296 BOOL mOverRideAndShowMisspellings; 296 BOOL mShowMisspellings;
297 LLFrameTimer mSpellTimer; 297 LLFrameTimer mSpellTimer;
298 //to keep track of what we have to remove before showing menu 298 //to keep track of what we have to remove before showing menu
299 std::vector<SpellMenuBind* > suggestionMenuItems; 299 std::vector<SpellMenuBind* > suggestionMenuItems;
diff --git a/linden/indra/llui/lltexteditor.cpp b/linden/indra/llui/lltexteditor.cpp
index 6e5cdc4..d2469c3 100644
--- a/linden/indra/llui/lltexteditor.cpp
+++ b/linden/indra/llui/lltexteditor.cpp
@@ -323,7 +323,7 @@ LLTextEditor::LLTextEditor(
323 mLastSelectionY(-1), 323 mLastSelectionY(-1),
324 mReflowNeeded(FALSE), 324 mReflowNeeded(FALSE),
325 mScrollNeeded(FALSE), 325 mScrollNeeded(FALSE),
326 mOverRideAndShowMisspellings(FALSE) 326 mShowMisspellings(FALSE)
327{ 327{
328 mSourceID.generate(); 328 mSourceID.generate();
329 329
@@ -490,10 +490,10 @@ void LLTextEditor::spell_show(void * data)
490 { 490 {
491 if(tempBind->word=="Show Misspellings") 491 if(tempBind->word=="Show Misspellings")
492 { 492 {
493 line->setOverRideAndShowMisspellings(TRUE); 493 line->setShowMisspellings(TRUE);
494 }else 494 }else
495 { 495 {
496 line->setOverRideAndShowMisspellings(FALSE); 496 line->setShowMisspellings(FALSE);
497 } 497 }
498 } 498 }
499} 499}
@@ -1426,7 +1426,6 @@ BOOL LLTextEditor::handleMouseDown(S32 x, S32 y, MASK mask)
1426} 1426}
1427BOOL LLTextEditor::handleRightMouseDown( S32 x, S32 y, MASK mask ) 1427BOOL LLTextEditor::handleRightMouseDown( S32 x, S32 y, MASK mask )
1428{ 1428{
1429
1430 setFocus(TRUE); 1429 setFocus(TRUE);
1431 1430
1432 //setCursorAtLocalPos( x, y, TRUE ); 1431 //setCursorAtLocalPos( x, y, TRUE );
@@ -1450,69 +1449,73 @@ BOOL LLTextEditor::handleRightMouseDown( S32 x, S32 y, MASK mask )
1450 } 1449 }
1451 suggestionMenuItems.clear(); 1450 suggestionMenuItems.clear();
1452 1451
1453 menu->setItemVisible("Translate To",!mReadOnly); 1452 menu->setItemVisible("Translate To", !mReadOnly);
1454 menu->setItemVisible("Transep",!mReadOnly); 1453 menu->setItemVisible("Transep", !mReadOnly);
1455
1456 const LLWString &text = mWText;
1457 1454
1458 if(( isPartOfWord( text[wordEnd] ) )&&(!mReadOnly)) 1455 // spell_check="true" in xui
1456 if (!mReadOnly && mShowMisspellings)
1459 { 1457 {
1460 // Select word the cursor is over 1458 const LLWString &text = mWText;
1461 while ((wordEnd > 0) && isPartOfWord(text[wordEnd-1])) 1459
1462 { 1460 if (isPartOfWord(text[wordEnd]) && !mReadOnly)
1463 wordEnd--;
1464 }
1465 wordStart=wordEnd;
1466 //startSelection();
1467
1468 while ((wordEnd < (S32)text.length()) && isPartOfWord( text[wordEnd] ) )
1469 {
1470 wordEnd++;
1471 }
1472 std::string selectedWord(std::string(text.begin(), text.end()).substr(wordStart,wordEnd-wordStart));
1473 if(!glggHunSpell->isSpelledRight(selectedWord))
1474 { 1461 {
1475 //misspelled word here, and you have just right clicked on it! 1462 // Select word the cursor is over
1476 std::vector<std::string> suggs = glggHunSpell->getSuggestionList(selectedWord); 1463 while ((wordEnd > 0) && isPartOfWord(text[wordEnd-1]))
1464 {
1465 wordEnd--;
1466 }
1467 wordStart = wordEnd;
1468 //startSelection();
1477 1469
1478 //menu->setItemVisible("Transep",(suggs.size()>0)); 1470 while ((wordEnd < (S32)text.length()) && isPartOfWord( text[wordEnd] ) )
1479 for(int i = 0;i<(int)suggs.size();i++) 1471 {
1472 wordEnd++;
1473 }
1474 std::string selectedWord(std::string(text.begin(), text.end()).substr(wordStart,wordEnd-wordStart));
1475 if (!glggHunSpell->isSpelledRight(selectedWord))
1480 { 1476 {
1477 //misspelled word here, and you have just right clicked on it!
1478 std::vector<std::string> suggs = glggHunSpell->getSuggestionList(selectedWord);
1479
1480 //menu->setItemVisible("Transep",(suggs.size()>0));
1481 for (int i = 0; i<(int)suggs.size(); i++)
1482 {
1483 SpellMenuBind * tempStruct = new SpellMenuBind;
1484 tempStruct->origin = this;
1485 tempStruct->word = suggs[i];
1486 tempStruct->wordPositionEnd = wordEnd;
1487 tempStruct->wordPositionStart=wordStart;
1488 tempStruct->wordY=y;
1489 LLMenuItemCallGL * suggMenuItem = new LLMenuItemCallGL(
1490 tempStruct->word, spell_correct, NULL, tempStruct);
1491 tempStruct->menuItem = suggMenuItem;
1492 suggestionMenuItems.push_back(tempStruct);
1493 menu->append(suggMenuItem);
1494 }
1481 SpellMenuBind * tempStruct = new SpellMenuBind; 1495 SpellMenuBind * tempStruct = new SpellMenuBind;
1482 tempStruct->origin = this; 1496 tempStruct->origin = this;
1483 tempStruct->word = suggs[i]; 1497 tempStruct->word = selectedWord;
1484 tempStruct->wordPositionEnd = wordEnd; 1498 tempStruct->wordPositionEnd = wordEnd;
1485 tempStruct->wordPositionStart=wordStart; 1499 tempStruct->wordPositionStart=wordStart;
1486 tempStruct->wordY=y; 1500 tempStruct->wordY=y;
1487 LLMenuItemCallGL * suggMenuItem = new LLMenuItemCallGL( 1501 LLMenuItemCallGL * suggMenuItem = new LLMenuItemCallGL(
1488 tempStruct->word, spell_correct, NULL, tempStruct); 1502 "Add Word", spell_add, NULL, tempStruct);
1489 tempStruct->menuItem = suggMenuItem; 1503 tempStruct->menuItem = suggMenuItem;
1490 suggestionMenuItems.push_back(tempStruct); 1504 suggestionMenuItems.push_back(tempStruct);
1491 menu->append(suggMenuItem); 1505 menu->append(suggMenuItem);
1492 } 1506 }
1493 SpellMenuBind * tempStruct = new SpellMenuBind;
1494 tempStruct->origin = this;
1495 tempStruct->word = selectedWord;
1496 tempStruct->wordPositionEnd = wordEnd;
1497 tempStruct->wordPositionStart=wordStart;
1498 tempStruct->wordY=y;
1499 LLMenuItemCallGL * suggMenuItem = new LLMenuItemCallGL(
1500 "Add Word", spell_add, NULL, tempStruct);
1501 tempStruct->menuItem = suggMenuItem;
1502 suggestionMenuItems.push_back(tempStruct);
1503 menu->append(suggMenuItem);
1504 } 1507 }
1505 1508
1506 }
1507 if((!mReadOnly)&&((!glggHunSpell->highlightInRed)
1508 ||(mOverRideAndShowMisspellings)||(mShowLineNumbers)))
1509 {
1510 SpellMenuBind * tempStruct = new SpellMenuBind; 1509 SpellMenuBind * tempStruct = new SpellMenuBind;
1511 tempStruct->origin = this; 1510 tempStruct->origin = this;
1512 if(mOverRideAndShowMisspellings) 1511 if (glggHunSpell->mSpellCheckHighlight)
1512 {
1513 tempStruct->word = "Hide Misspellings"; 1513 tempStruct->word = "Hide Misspellings";
1514 }
1514 else 1515 else
1516 {
1515 tempStruct->word = "Show Misspellings"; 1517 tempStruct->word = "Show Misspellings";
1518 }
1516 LLMenuItemCallGL * suggMenuItem = new LLMenuItemCallGL( 1519 LLMenuItemCallGL * suggMenuItem = new LLMenuItemCallGL(
1517 tempStruct->word, spell_show, NULL, tempStruct); 1520 tempStruct->word, spell_show, NULL, tempStruct);
1518 tempStruct->menuItem = suggMenuItem; 1521 tempStruct->menuItem = suggMenuItem;
@@ -3077,51 +3080,57 @@ void LLTextEditor::drawSelectionBackground()
3077 } 3080 }
3078 } 3081 }
3079} 3082}
3083
3080void LLTextEditor::autoCorrectText() 3084void LLTextEditor::autoCorrectText()
3081{ 3085{
3082
3083 static BOOL *doAnything = rebind_llcontrol<BOOL>("EmeraldEnableAutoCorrect", &gSavedSettings, true); 3086 static BOOL *doAnything = rebind_llcontrol<BOOL>("EmeraldEnableAutoCorrect", &gSavedSettings, true);
3084 if( (!mReadOnly) && (*doAnything) && (isSpellDirty()) ) 3087 if (!mReadOnly && *doAnything && isSpellDirty())
3085 { 3088 {
3086 S32 wordStart = 0; 3089 S32 wordStart = 0;
3087 S32 wordEnd = mCursorPos-1; 3090 S32 wordEnd = mCursorPos-1;
3088 if(wordEnd<1)return; 3091 if (wordEnd < 1)
3092 {
3093 return;
3094 }
3089 LLWString& text = mWText; 3095 LLWString& text = mWText;
3090 if(text.size()<1)return; 3096 if (text.size() < 1 || LLTextEditor::isPartOfWord(text[wordEnd]))
3091 if( LLTextEditor::isPartOfWord( text[wordEnd] )) return;//we only check on word breaks 3097 {
3098 return;//we only check on word breaks
3099 }
3100
3092 wordEnd--; 3101 wordEnd--;
3093 if( LLTextEditor::isPartOfWord( text[wordEnd] ) ) 3102 if (LLTextEditor::isPartOfWord(text[wordEnd]))
3094 { 3103 {
3095 while ((wordEnd > 0) && (text[wordEnd-1]!=' ')) 3104 while ((wordEnd > 0) && (text[wordEnd-1]!=' '))
3096 { 3105 {
3097 wordEnd--; 3106 wordEnd--;
3098 } 3107 }
3099 wordStart=wordEnd; 3108 wordStart = wordEnd;
3100 while ((wordEnd < (S32)text.length()) && (' '!= text[wordEnd] ) ) 3109 while ((wordEnd < (S32)text.length()) && (' '!= text[wordEnd] ) )
3101 { 3110 {
3102 wordEnd++; 3111 wordEnd++;
3103 } 3112 }
3104 std::string lastTypedWord(std::string(text.begin(), 3113 std::string lastTypedWord(std::string(text.begin(),
3105 text.end()).substr(wordStart,wordEnd-wordStart)); 3114 text.end()).substr(wordStart, wordEnd-wordStart));
3106 3115
3107 std::string regText(text.begin(),text.end()); 3116 std::string regText(text.begin(), text.end());
3108 3117
3109 std::string correctedWord(LGGAutoCorrect::getInstance()->replaceWord(lastTypedWord)); 3118 std::string correctedWord(LGGAutoCorrect::getInstance()->replaceWord(lastTypedWord));
3110 if(correctedWord!=lastTypedWord) 3119 if (correctedWord != lastTypedWord)
3111 { 3120 {
3112 int dif = correctedWord.length()-lastTypedWord.length(); 3121 int dif = correctedWord.length() - lastTypedWord.length();
3113 regText.replace(wordStart,lastTypedWord.length(),correctedWord); 3122 regText.replace(wordStart, lastTypedWord.length(), correctedWord);
3114 mWText=utf8str_to_wstring(regText); 3123 mWText = utf8str_to_wstring(regText);
3115 mCursorPos+=dif; 3124 mCursorPos += dif;
3116 needsReflow(); 3125 needsReflow();
3117 } 3126 }
3118 } 3127 }
3119 } 3128 }
3120} 3129}
3130
3121void LLTextEditor::drawMisspelled() 3131void LLTextEditor::drawMisspelled()
3122{ 3132{
3123 if(mReadOnly)return; 3133 if (!mReadOnly && mShowMisspellings)
3124 if(glggHunSpell->highlightInRed || mOverRideAndShowMisspellings)
3125 { 3134 {
3126 if( 3135 if(
3127 ( ((getLength()<400)||(false)) &&( (S32(mSpellTimer.getElapsedTimeF32() / 1) & 1) )) 3136 ( ((getLength()<400)||(false)) &&( (S32(mSpellTimer.getElapsedTimeF32() / 1) & 1) ))
@@ -3132,80 +3141,86 @@ void LLTextEditor::drawMisspelled()
3132 S32 newSpellStart = getLineStart(mScrollbar->getDocPos());//start at the scroll start 3141 S32 newSpellStart = getLineStart(mScrollbar->getDocPos());//start at the scroll start
3133 S32 newSpellEnd = getLineStart(mScrollbar->getDocPos() + 1 + mScrollbar->getDocSize()-mScrollbar->getDocPosMax());//end at the end o.o 3142 S32 newSpellEnd = getLineStart(mScrollbar->getDocPos() + 1 + mScrollbar->getDocSize()-mScrollbar->getDocPosMax());//end at the end o.o
3134 3143
3135 if(mScrollbar->getDocPos() == mScrollbar->getDocPosMax()) 3144 if (mScrollbar->getDocPos() == mScrollbar->getDocPosMax())
3136 { 3145 {
3137 newSpellEnd=(S32)mWText.length(); 3146 newSpellEnd = (S32)mWText.length();
3138 } 3147 }
3139 if((isSpellDirty())||(newSpellEnd!=spellEnd || newSpellStart!=spellStart)) 3148 if (isSpellDirty() || (newSpellEnd!=spellEnd || newSpellStart!=spellStart))
3140 { 3149 {
3141 spellEnd = newSpellEnd; 3150 spellEnd = newSpellEnd;
3142 spellStart = newSpellStart; 3151 spellStart = newSpellStart;
3143 misspellLocations=getMisspelledWordsPositions(); 3152 misspellLocations = getMisspelledWordsPositions();
3144 } 3153 }
3145 } 3154 }
3146 //draw 3155 //draw
3147 for(int i =0;i<(int)misspellLocations.size();i++) 3156 if (glggHunSpell->mSpellCheckHighlight)
3148 { 3157 {
3149 S32 wstart = misspellLocations[i]; 3158 for (int i = 0; i<(int)misspellLocations.size() ;i++)
3150 S32 wend = misspellLocations[++i];
3151 //start curor code mod
3152 const LLWString &text = mWText;
3153 const S32 text_len = getLength();
3154 // Skip through the lines we aren't drawing.
3155 S32 search_pos = mScrollbar->getDocPos();
3156 S32 num_lines = getLineCount();
3157 if (search_pos >= num_lines)return;
3158 S32 line_start = getLineStart(search_pos);
3159 F32 line_height = mGLFont->getLineHeight();
3160 F32 text_y = (F32)(mTextRect.mTop) - line_height;
3161
3162 F32 word_left = 0.f;
3163 F32 word_right = 0.f;
3164 F32 word_bottom = 0.f;
3165 BOOL word_visible = FALSE;
3166
3167 S32 line_end = 0;
3168 // Determine if the cursor is visible and if so what its coordinates are.
3169 while( (mTextRect.mBottom <= llround(text_y)) && (search_pos < num_lines))
3170 { 3159 {
3171 line_end = text_len + 1; 3160 S32 wstart = misspellLocations[i];
3172 S32 next_line = -1; 3161 S32 wend = misspellLocations[++i];
3173 3162 //start curor code mod
3174 if ((search_pos + 1) < num_lines) 3163 const LLWString &text = mWText;
3164 const S32 text_len = getLength();
3165 // Skip through the lines we aren't drawing.
3166 S32 search_pos = mScrollbar->getDocPos();
3167 S32 num_lines = getLineCount();
3168 if (search_pos >= num_lines)
3175 { 3169 {
3176 next_line = getLineStart(search_pos + 1); 3170 return;
3177 line_end = next_line - 1;
3178 } 3171 }
3179 const llwchar* line = text.c_str() + line_start; 3172 S32 line_start = getLineStart(search_pos);
3180 // Find the cursor and selection bounds 3173 F32 line_height = mGLFont->getLineHeight();
3181 if( line_start <= wstart && wend <= line_end ) 3174 F32 text_y = (F32)(mTextRect.mTop) - line_height;
3175
3176 F32 word_left = 0.f;
3177 F32 word_right = 0.f;
3178 F32 word_bottom = 0.f;
3179 BOOL word_visible = FALSE;
3180
3181 S32 line_end = 0;
3182 // Determine if the cursor is visible and if so what its coordinates are.
3183 while( (mTextRect.mBottom <= llround(text_y)) && (search_pos < num_lines))
3182 { 3184 {
3183 word_visible = TRUE; 3185 line_end = text_len + 1;
3184 word_left = (F32)mTextRect.mLeft + mGLFont->getWidthF32(line, 0, wstart - line_start, mAllowEmbeddedItems )-1.f; 3186 S32 next_line = -1;
3185 word_right = (F32)mTextRect.mLeft + mGLFont->getWidthF32(line, 0, wend - line_start, mAllowEmbeddedItems )+1.f; 3187
3186 word_bottom = text_y; 3188 if ((search_pos + 1) < num_lines)
3187 break; 3189 {
3190 next_line = getLineStart(search_pos + 1);
3191 line_end = next_line - 1;
3192 }
3193 const llwchar* line = text.c_str() + line_start;
3194 // Find the cursor and selection bounds
3195 if( line_start <= wstart && wend <= line_end )
3196 {
3197 word_visible = TRUE;
3198 word_left = (F32)mTextRect.mLeft + mGLFont->getWidthF32(line, 0, wstart - line_start, mAllowEmbeddedItems )-1.f;
3199 word_right = (F32)mTextRect.mLeft + mGLFont->getWidthF32(line, 0, wend - line_start, mAllowEmbeddedItems )+1.f;
3200 word_bottom = text_y;
3201 break;
3202 }
3203 // move down one line
3204 text_y -= line_height;
3205 line_start = next_line;
3206 search_pos++;
3188 } 3207 }
3189 // move down one line 3208 if (mShowLineNumbers)
3190 text_y -= line_height;
3191 line_start = next_line;
3192 search_pos++;
3193 }
3194 if(mShowLineNumbers)
3195 {
3196 word_left += UI_TEXTEDITOR_LINE_NUMBER_MARGIN;
3197 word_right += UI_TEXTEDITOR_LINE_NUMBER_MARGIN;
3198 }
3199 // Draw the cursor
3200 if( word_visible )
3201 {
3202 //end cursos code mod
3203 gGL.color4ub(255,0,0,200);
3204 while(word_left<word_right)
3205 { 3209 {
3206 gl_line_2d(word_left,word_bottom-2,word_left+3,word_bottom+1); 3210 word_left += UI_TEXTEDITOR_LINE_NUMBER_MARGIN;
3207 gl_line_2d(word_left+3,word_bottom+1,word_left+6,word_bottom-2); 3211 word_right += UI_TEXTEDITOR_LINE_NUMBER_MARGIN;
3208 word_left+=6; 3212 }
3213 // Draw the cursor
3214 if (word_visible)
3215 {
3216 //end cursor code mod
3217 gGL.color4ub(255,0,0,200);
3218 while (word_left<word_right)
3219 {
3220 gl_line_2d(word_left,word_bottom-2, word_left+3,word_bottom+1);
3221 gl_line_2d(word_left+3,word_bottom+1, word_left+6,word_bottom-2);
3222 word_left += 6;
3223 }
3209 } 3224 }
3210 } 3225 }
3211 } 3226 }
@@ -3214,8 +3229,7 @@ void LLTextEditor::drawMisspelled()
3214 3229
3215void LLTextEditor::drawCursor() 3230void LLTextEditor::drawCursor()
3216{ 3231{
3217 if( gFocusMgr.getKeyboardFocus() == this 3232 if (!mReadOnly && gFocusMgr.getKeyboardFocus() == this && gShowTextEditCursor)
3218 && gShowTextEditCursor && !mReadOnly)
3219 { 3233 {
3220 const LLWString &text = mWText; 3234 const LLWString &text = mWText;
3221 const S32 text_len = getLength(); 3235 const S32 text_len = getLength();
@@ -3696,10 +3710,7 @@ void LLTextEditor::draw()
3696 drawPreeditMarker(); 3710 drawPreeditMarker();
3697 drawText(); 3711 drawText();
3698 drawCursor(); 3712 drawCursor();
3699 if(!mShowLineNumbers || mOverRideAndShowMisspellings) 3713 drawMisspelled();
3700 {
3701 drawMisspelled();
3702 }
3703 resetSpellDirty(); 3714 resetSpellDirty();
3704 unbindEmbeddedChars(mGLFont); 3715 unbindEmbeddedChars(mGLFont);
3705 3716
@@ -4879,6 +4890,8 @@ void LLTextEditor::setTextEditorParameters(LLXMLNodePtr node)
4879 4890
4880 node->getAttributeBOOL("track_bottom", mTrackBottom); 4891 node->getAttributeBOOL("track_bottom", mTrackBottom);
4881 4892
4893 node->getAttributeBOOL("spell_check", mShowMisspellings);
4894
4882 LLColor4 color; 4895 LLColor4 color;
4883 if (LLUICtrlFactory::getAttributeColor(node,"cursor_color", color)) 4896 if (LLUICtrlFactory::getAttributeColor(node,"cursor_color", color))
4884 { 4897 {
diff --git a/linden/indra/llui/lltexteditor.h b/linden/indra/llui/lltexteditor.h
index 6b372d7..c5c3af8 100644
--- a/linden/indra/llui/lltexteditor.h
+++ b/linden/indra/llui/lltexteditor.h
@@ -229,7 +229,7 @@ public:
229 void setThumbColor( const LLColor4& color ); 229 void setThumbColor( const LLColor4& color );
230 void setHighlightColor( const LLColor4& color ); 230 void setHighlightColor( const LLColor4& color );
231 void setShadowColor( const LLColor4& color ); 231 void setShadowColor( const LLColor4& color );
232 void setOverRideAndShowMisspellings(BOOL b){ mOverRideAndShowMisspellings =b;} 232 void setShowMisspellings(BOOL b) { mShowMisspellings = b; }
233 233
234 // Hacky methods to make it into a word-wrapping, potentially scrolling, 234 // Hacky methods to make it into a word-wrapping, potentially scrolling,
235 // read-only text box. 235 // read-only text box.
@@ -526,7 +526,7 @@ private:
526 S32 spellStart; 526 S32 spellStart;
527 S32 spellEnd; 527 S32 spellEnd;
528 std::vector<S32> misspellLocations; // where all the mispelled words are 528 std::vector<S32> misspellLocations; // where all the mispelled words are
529 BOOL mOverRideAndShowMisspellings; 529 BOOL mShowMisspellings; // set in xui as "spell_check". Default value for a field
530 530
531 S32 mMaxTextByteLength; // Maximum length mText is allowed to be in bytes 531 S32 mMaxTextByteLength; // Maximum length mText is allowed to be in bytes
532 532
diff --git a/linden/indra/newview/lgghunspell_wrapper.cpp b/linden/indra/newview/lgghunspell_wrapper.cpp
index 5879bac..632c117 100644
--- a/linden/indra/newview/lgghunspell_wrapper.cpp
+++ b/linden/indra/newview/lgghunspell_wrapper.cpp
@@ -468,53 +468,64 @@ static char * languageCodesraw[]={
468}; 468};
469//#define LANGUAGE_CODES_RAW_SIZE ((__LINE__ - 1 - LANGUAGE_CODES_RAW_START_LINE) * 2) 469//#define LANGUAGE_CODES_RAW_SIZE ((__LINE__ - 1 - LANGUAGE_CODES_RAW_START_LINE) * 2)
470#define LANGUAGE_CODES_RAW_SIZE 368 470#define LANGUAGE_CODES_RAW_SIZE 368
471
471lggHunSpell_Wrapper::lggHunSpell_Wrapper() 472lggHunSpell_Wrapper::lggHunSpell_Wrapper()
473 :
474 mSpellCheckHighlight(false)
472{ 475{
473 highlightInRed=false;
474 //languageCodes(begin(languageCodesraw), end(languageCodesraw)); 476 //languageCodes(begin(languageCodesraw), end(languageCodesraw));
475} 477}
476lggHunSpell_Wrapper::~lggHunSpell_Wrapper(){} 478
479lggHunSpell_Wrapper::~lggHunSpell_Wrapper()
480{
481}
482
477std::string lggHunSpell_Wrapper::getCorrectPath(std::string file) 483std::string lggHunSpell_Wrapper::getCorrectPath(std::string file)
478{ 484{
479 //finds out if it is in user dir, if not, takes it from app dir 485 //finds out if it is in user dir, if not, takes it from app dir
480 std::string dicpath1(gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "dictionaries", file).c_str()); 486 std::string dicpath1(gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "dictionaries", file).c_str());
481 if(!gDirUtilp->fileExists(dicpath1)) 487 if (!gDirUtilp->fileExists(dicpath1))
488 {
482 dicpath1=gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "dictionaries", file).c_str(); 489 dicpath1=gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "dictionaries", file).c_str();
483 490 }
484 return dicpath1; 491 return dicpath1;
485} 492}
493
486void lggHunSpell_Wrapper::setNewDictionary(std::string newDict) 494void lggHunSpell_Wrapper::setNewDictionary(std::string newDict)
487{ 495{
488 496
489 llinfos << "Setting new base dictionary long name is-> " << newDict.c_str() << llendl; 497 llinfos << "Setting new base dictionary long name is-> " << newDict.c_str() << llendl;
490 498
491 currentBaseDic=newDict; 499 currentBaseDic = newDict;
492 500
493 //expecting a full name comming in 501 //expecting a full name comming in
494 newDict = fullName2DictName(newDict); 502 newDict = fullName2DictName(newDict);
495 503
496 if(myHunspell)delete myHunspell; 504 if (myHunspell)
505 {
506 delete myHunspell;
507 }
497 508
498 std::string dicaffpath=getCorrectPath(newDict+".aff"); 509 std::string dicaffpath = getCorrectPath(newDict+".aff");
499 std::string dicdicpath=getCorrectPath(newDict+".dic"); 510 std::string dicdicpath = getCorrectPath(newDict+".dic");
500 511
501 llinfos << "Setting new base dictionary -> " << dicaffpath.c_str() << llendl; 512 llinfos << "Setting new base dictionary -> " << dicaffpath.c_str() << llendl;
502 513
503 myHunspell = new Hunspell(dicaffpath.c_str(),dicdicpath.c_str()); 514 myHunspell = new Hunspell(dicaffpath.c_str(), dicdicpath.c_str());
504 llinfos << "Adding custom dictionary " << llendl; 515 llinfos << "Adding custom dictionary " << llendl;
505 createCustomDic(); 516 createCustomDic();
506 addDictionary("custom"); 517 addDictionary("custom");
507 std::vector<std::string> toInstall = getInstalledDicts(); 518 std::vector<std::string> toInstall = getInstalledDicts();
508 for(int i =0;i<(int)toInstall.size();i++) 519 for (int i = 0; i < (int)toInstall.size(); i++)
520 {
509 addDictionary(toInstall[i]); 521 addDictionary(toInstall[i]);
510 522 }
511
512} 523}
524
513void lggHunSpell_Wrapper::createCustomDic() 525void lggHunSpell_Wrapper::createCustomDic()
514{ 526{
515 std::string filename(gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, 527 std::string filename(gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "dictionaries", "custom.dic"));
516 "dictionaries", "custom.dic")); 528 if (!gDirUtilp->fileExists(filename))
517 if(!gDirUtilp->fileExists(filename))
518 { 529 {
519 llofstream export_file; 530 llofstream export_file;
520 export_file.open(filename); 531 export_file.open(filename);
@@ -523,49 +534,67 @@ void lggHunSpell_Wrapper::createCustomDic()
523 export_file.close(); 534 export_file.close();
524 } 535 }
525} 536}
537
526void lggHunSpell_Wrapper::addWordToCustomDictionary(std::string wordToAdd) 538void lggHunSpell_Wrapper::addWordToCustomDictionary(std::string wordToAdd)
527{ 539{
528 if(!myHunspell)return; 540 if (!myHunspell)
541 {
542 return;
543 }
544
529 myHunspell->add(wordToAdd.c_str()); 545 myHunspell->add(wordToAdd.c_str());
530 std::string filename(gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "dictionaries", "custom.dic")); 546 std::string filename(gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "dictionaries", "custom.dic"));
531 std::vector<std::string> lines; 547 std::vector<std::string> lines;
532 if(gDirUtilp->fileExists(filename)) 548 if (gDirUtilp->fileExists(filename))
533 { 549 {
534 //get words already there.. 550 //get words already there..
535 llifstream importer(filename); 551 llifstream importer(filename);
536 std::string line; 552 std::string line;
537 if(getline( importer, line ))//ignored the size 553 if (getline( importer, line ))//ignored the size
538 { 554 {
539 while( getline( importer, line ) ) lines.push_back(line); 555 while ( getline( importer, line ) ) lines.push_back(line);
540 } 556 }
541 importer.close(); 557 importer.close();
542 } 558 }
559
543 llofstream export_file; 560 llofstream export_file;
544 export_file.open(filename); 561 export_file.open(filename);
545 std::string sizePart(llformat("%i",(int)(lines.size()+1))+"\n"); 562 std::string sizePart(llformat("%i", (int)(lines.size()+1)) + "\n");
546 export_file.write(sizePart.c_str(),sizePart.length()); 563 export_file.write(sizePart.c_str(), sizePart.length());
547 for(int i=0;i<(int)lines.size();i++) 564 for (int i = 0; i < (int)lines.size() ;i++)
565 {
548 export_file.write(std::string(lines[i]+"\n").c_str(),lines[i].length()+1); 566 export_file.write(std::string(lines[i]+"\n").c_str(),lines[i].length()+1);
567 }
549 //LLStringUtil::toLower(wordToAdd); 568 //LLStringUtil::toLower(wordToAdd);
550 wordToAdd=wordToAdd+std::string("\n"); 569 wordToAdd = wordToAdd+std::string("\n");
551 export_file.write(wordToAdd.c_str(),wordToAdd.length()); 570 export_file.write(wordToAdd.c_str(), wordToAdd.length());
552 //export_file << std::hex << 10 ; 571 //export_file << std::hex << 10 ;
553 export_file.close(); 572 export_file.close();
554} 573}
574
555BOOL lggHunSpell_Wrapper::isSpelledRight(std::string wordToCheck) 575BOOL lggHunSpell_Wrapper::isSpelledRight(std::string wordToCheck)
556{ 576{
557 if(!myHunspell)return TRUE; 577 if (!myHunspell || wordToCheck.length() < 3)
558 if(wordToCheck.length()<3)return TRUE; 578 {
579 return TRUE;
580 }
559 return myHunspell->spell(wordToCheck.c_str()); 581 return myHunspell->spell(wordToCheck.c_str());
560} 582}
583
561std::vector<std::string> lggHunSpell_Wrapper::getSuggestionList(std::string badWord) 584std::vector<std::string> lggHunSpell_Wrapper::getSuggestionList(std::string badWord)
562{ 585{
563 std::vector<std::string> toReturn; 586 std::vector<std::string> toReturn;
564 if(!myHunspell)return toReturn; 587 if (!myHunspell)
565 char ** suggestionList; 588 {
589 return toReturn;
590 }
591
592 char** suggestionList;
566 int numberOfSuggestions = myHunspell->suggest(&suggestionList, badWord.c_str()); 593 int numberOfSuggestions = myHunspell->suggest(&suggestionList, badWord.c_str());
567 if(numberOfSuggestions <= 0) 594 if (numberOfSuggestions <= 0)
568 return toReturn; 595 {
596 return toReturn;
597 }
569 for (int i = 0; i < numberOfSuggestions; i++) 598 for (int i = 0; i < numberOfSuggestions; i++)
570 { 599 {
571 std::string tempSugg(suggestionList[i]); 600 std::string tempSugg(suggestionList[i]);
@@ -574,14 +603,16 @@ std::vector<std::string> lggHunSpell_Wrapper::getSuggestionList(std::string badW
574 myHunspell->free_list(&suggestionList,numberOfSuggestions); 603 myHunspell->free_list(&suggestionList,numberOfSuggestions);
575 return toReturn; 604 return toReturn;
576} 605}
606
577void lggHunSpell_Wrapper::debugTest(std::string testWord) 607void lggHunSpell_Wrapper::debugTest(std::string testWord)
578{ 608{
579 llinfos << "Testing to see if " << testWord.c_str() << " is spelled correct" << llendl; 609 llinfos << "Testing to see if " << testWord.c_str() << " is spelled correct" << llendl;
580 610
581 if( isSpelledRight(testWord)) 611 if (isSpelledRight(testWord))
582 { 612 {
583 llinfos << testWord.c_str() << " is spelled correctly" << llendl; 613 llinfos << testWord.c_str() << " is spelled correctly" << llendl;
584 }else 614 }
615 else
585 { 616 {
586 llinfos << testWord.c_str() << " is not spelled correctly, getting suggestions" << llendl; 617 llinfos << testWord.c_str() << " is not spelled correctly, getting suggestions" << llendl;
587 std::vector<std::string> suggList; 618 std::vector<std::string> suggList;
@@ -589,148 +620,167 @@ void lggHunSpell_Wrapper::debugTest(std::string testWord)
589 suggList = getSuggestionList(testWord); 620 suggList = getSuggestionList(testWord);
590 llinfos << "Got suggestions.. " << llendl; 621 llinfos << "Got suggestions.. " << llendl;
591 622
592 for(int i = 0; i<(int)suggList.size();i++) 623 for (int i = 0; i < (int)suggList.size(); i++)
593 { 624 {
594 llinfos << "Suggestion for " << testWord.c_str() << ":" << suggList[i].c_str() << llendl; 625 llinfos << "Suggestion for " << testWord.c_str() << ":" << suggList[i].c_str() << llendl;
595 } 626 }
596
597 } 627 }
598
599} 628}
629
600void lggHunSpell_Wrapper::initSettings() 630void lggHunSpell_Wrapper::initSettings()
601{ 631{
602 glggHunSpell = new lggHunSpell_Wrapper(); 632 glggHunSpell = new lggHunSpell_Wrapper();
603 glggHunSpell->processSettings(); 633 glggHunSpell->processSettings();
604} 634}
635
605void lggHunSpell_Wrapper::processSettings() 636void lggHunSpell_Wrapper::processSettings()
606{ 637{
607 //expects everything to already be in saved settings 638 //expects everything to already be in saved settings
608 //this will also reload and read the installed dicts 639 //this will also reload and read the installed dicts
609 setNewDictionary(gSavedSettings.getString("EmeraldSpellBase")); 640 setNewDictionary(gSavedSettings.getString("EmeraldSpellBase"));
610 highlightInRed= gSavedSettings.getBOOL("EmeraldSpellDisplay"); 641 mSpellCheckHighlight = gSavedSettings.getBOOL("EmeraldSpellDisplay");
611 642
612} 643}
644
613void lggHunSpell_Wrapper::addDictionary(std::string additionalDictionary) 645void lggHunSpell_Wrapper::addDictionary(std::string additionalDictionary)
614{ 646{
615 if(!myHunspell)return; 647 if (!myHunspell || additionalDictionary.empty())
616 if(additionalDictionary=="")return; 648 {
649 return;
650 }
651
617 //expecting a full name here 652 //expecting a full name here
618 std::string dicpath=getCorrectPath(fullName2DictName(additionalDictionary)+".dic"); 653 std::string dicpath = getCorrectPath(fullName2DictName(additionalDictionary)+".dic");
619 if(gDirUtilp->fileExists(dicpath)) 654 if (gDirUtilp->fileExists(dicpath))
620 { 655 {
621 llinfos << "Adding additional dictionary -> " << dicpath.c_str() << llendl; 656 llinfos << "Adding additional dictionary -> " << dicpath.c_str() << llendl;
622 myHunspell->add_dic(dicpath.c_str()); 657 myHunspell->add_dic(dicpath.c_str());
623 } 658 }
624} 659}
660
625std::string lggHunSpell_Wrapper::dictName2FullName(std::string dictName) 661std::string lggHunSpell_Wrapper::dictName2FullName(std::string dictName)
626{ 662{
627 if(dictName==std::string(""))return std::string(""); 663 if (dictName.empty())
628 std::string countryCode=""; 664 {
629 std::string languageCode=""; 665 return dictName;
666 }
667
668 std::string countryCode("");
669 std::string languageCode("");
670
630 //remove extension 671 //remove extension
631 dictName = dictName.substr(0,dictName.find(".")); 672 dictName = dictName.substr(0,dictName.find("."));
673
632 //break it up by - or _ 674 //break it up by - or _
633 S32 breakPoint = dictName.find("-"); 675 S32 breakPoint = dictName.find("-");
634 if(breakPoint==std::string::npos) 676 if (breakPoint == std::string::npos)
677 {
635 breakPoint = dictName.find("_"); 678 breakPoint = dictName.find("_");
636 if(breakPoint==std::string::npos) 679 }
680 if (breakPoint == std::string::npos)
637 { 681 {
638 //no country code given 682 //no country code given
639 languageCode=dictName; 683 languageCode = dictName;
640 }else 684 }
685 else
641 { 686 {
642 languageCode=dictName.substr(0,breakPoint); 687 languageCode = dictName.substr(0,breakPoint);
643 countryCode=dictName.substr(breakPoint+1); 688 countryCode = dictName.substr(breakPoint+1);
644 } 689 }
690
645 //get long language code 691 //get long language code
646 for(int i =0;i<LANGUAGE_CODES_RAW_SIZE;i++) 692 for (int i = 0; i<LANGUAGE_CODES_RAW_SIZE; i++)
647 { 693 {
648 if(0==LLStringUtil::compareInsensitive(languageCode,std::string(languageCodesraw[i]))) 694 if (0 == LLStringUtil::compareInsensitive(languageCode, std::string(languageCodesraw[i])))
649 { 695 {
650 languageCode=languageCodesraw[i+1]; 696 languageCode = languageCodesraw[i+1];
651 break; 697 break;
652 } 698 }
653 } 699 }
700
654 //get long country code 701 //get long country code
655 if(countryCode!="") 702 if (!countryCode.empty())
656 { 703 {
657 for(int i =0;i<COUNTRY_CODES_RAW_SIZE;i++) 704 for (int i =0; i<COUNTRY_CODES_RAW_SIZE; i++)
658 { 705 {
659 //llinfos << i << llendl; 706 //llinfos << i << llendl;
660 if(0==LLStringUtil::compareInsensitive(countryCode,std::string(countryCodesraw[i]))) 707 if (0 == LLStringUtil::compareInsensitive(countryCode, std::string(countryCodesraw[i])))
661 { 708 {
662 countryCode=countryCodesraw[i+1]; 709 countryCode = countryCodesraw[i+1];
663 break; 710 break;
664 } 711 }
665 } 712 }
666 countryCode=" ("+countryCode+")"; 713 countryCode = " (" + countryCode + ")";
667 } 714 }
668 715
669 return std::string(languageCode+countryCode); 716 return std::string(languageCode+countryCode);
670} 717}
718
671std::string lggHunSpell_Wrapper::fullName2DictName(std::string fullName) 719std::string lggHunSpell_Wrapper::fullName2DictName(std::string fullName)
672{ 720{
673 std::string countryCode(""); 721 std::string countryCode("");
674 std::string languageCode(""); 722 std::string languageCode("");
675 S32 breakPoint = fullName.find(" ("); 723 S32 breakPoint = fullName.find(" (");
676 if(breakPoint==std::string::npos) 724 if (breakPoint == std::string::npos)
677 { 725 {
678 languageCode=fullName; 726 languageCode = fullName;
679 }else 727 }
728 else
680 { 729 {
681 languageCode=fullName.substr(0,breakPoint); 730 languageCode = fullName.substr(0, breakPoint);
682 countryCode=fullName.substr(breakPoint+2,fullName.length()-3-breakPoint); 731 countryCode = fullName.substr(breakPoint+2, fullName.length()-3-breakPoint);
683 } 732 }
684 //get long language code 733 //get long language code
685 for(int i =1;i<LANGUAGE_CODES_RAW_SIZE;i+=2) 734 for (int i = 1; i<LANGUAGE_CODES_RAW_SIZE; i+=2)
686 { 735 {
687 //llinfos << i << llendl; 736 //llinfos << i << llendl;
688 if(0==LLStringUtil::compareInsensitive(languageCode,std::string(languageCodesraw[i]))) 737 if (0 == LLStringUtil::compareInsensitive(languageCode, std::string(languageCodesraw[i])))
689 { 738 {
690 languageCode=std::string(languageCodesraw[i-1]); 739 languageCode = std::string(languageCodesraw[i-1]);
691 break; 740 break;
692 } 741 }
693 } 742 }
694 //get long country code 743 //get long country code
695 if(countryCode!="") 744 std::string toReturn = languageCode;
696 for(int i =1;i<COUNTRY_CODES_RAW_SIZE;i+=2) 745 if (!countryCode.empty())
746 {
747 for (int i = 1; i<COUNTRY_CODES_RAW_SIZE; i+=2)
697 { 748 {
698 //llinfos << i << " comparing " <<countryCode<<" and "<<std::string(countryCodesraw[i]).c_str()<< llendl; 749 //llinfos << i << " comparing " <<countryCode<<" and "<<std::string(countryCodesraw[i]).c_str()<< llendl;
699 if(0==LLStringUtil::compareInsensitive(countryCode,std::string(countryCodesraw[i]))) 750 if (0 == LLStringUtil::compareInsensitive(countryCode, std::string(countryCodesraw[i])))
700 { 751 {
701 countryCode=std::string(countryCodesraw[i-1]); 752 countryCode = std::string(countryCodesraw[i-1]);
702 break; 753 break;
703 } 754 }
704 } 755 }
705 std::string toReturn = languageCode; 756 toReturn += "_" + countryCode;
706 if(countryCode!="") 757 }
707 { 758
708 toReturn+="_"+countryCode; 759 LLStringUtil::toLower(toReturn);
709 } 760 return toReturn;
710 LLStringUtil::toLower(toReturn);
711 return toReturn;
712} 761}
762
713std::vector <std::string> lggHunSpell_Wrapper::getDicts() 763std::vector <std::string> lggHunSpell_Wrapper::getDicts()
714{ 764{
715 std::vector<std::string> names; 765 std::vector<std::string> names;
716 std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "dictionaries", "")); 766 std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "dictionaries", ""));
717 bool found = true; 767 bool found = true;
718 while(found) 768 while (found)
719 { 769 {
720 std::string name; 770 std::string name;
721 found = gDirUtilp->getNextFileInDir(path_name, "*.aff", name, false); 771 found = gDirUtilp->getNextFileInDir(path_name, "*.aff", name, false);
722 if(found) 772 if (found)
723 { 773 {
724 names.push_back(dictName2FullName(name)); 774 names.push_back(dictName2FullName(name));
725 } 775 }
726 } 776 }
727 path_name=gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "dictionaries", ""); 777 path_name = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "dictionaries", "");
728 found=true; 778 found = true;
729 while(found) 779 while (found)
730 { 780 {
731 std::string name; 781 std::string name;
732 found = gDirUtilp->getNextFileInDir(path_name, "*.aff", name, false); 782 found = gDirUtilp->getNextFileInDir(path_name, "*.aff", name, false);
733 if(found) 783 if (found)
734 { 784 {
735 names.push_back(dictName2FullName(name)); 785 names.push_back(dictName2FullName(name));
736 } 786 }
@@ -738,123 +788,159 @@ std::vector <std::string> lggHunSpell_Wrapper::getDicts()
738 788
739 return names; 789 return names;
740} 790}
791
741std::vector <std::string> lggHunSpell_Wrapper::getExtraDicts() 792std::vector <std::string> lggHunSpell_Wrapper::getExtraDicts()
742{ 793{
743 std::vector<std::string> names; 794 std::vector<std::string> names;
744 std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "dictionaries", "")); 795 std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "dictionaries", ""));
745 bool found = true; 796 bool found = true;
746 while(found) 797 while (found)
747 { 798 {
748 std::string name; 799 std::string name;
749 found = gDirUtilp->getNextFileInDir(path_name, "*.dic", name, false); 800 found = gDirUtilp->getNextFileInDir(path_name, "*.dic", name, false);
750 if(found) 801 if (found)
751 { 802 {
752 names.push_back(dictName2FullName(name)); 803 names.push_back(dictName2FullName(name));
753 } 804 }
754 } 805 }
755 path_name=gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "dictionaries", ""); 806 path_name = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "dictionaries", "");
756 found=true; 807 found = true;
757 while(found) 808 while (found)
758 { 809 {
759 std::string name; 810 std::string name;
760 found = gDirUtilp->getNextFileInDir(path_name, "*.dic", name, false); 811 found = gDirUtilp->getNextFileInDir(path_name, "*.dic", name, false);
761 if(found) 812 if (found)
762 { 813 {
763 names.push_back(dictName2FullName(name)); 814 names.push_back(dictName2FullName(name));
764 } 815 }
765 } 816 }
766 return names; 817 return names;
767} 818}
819
768std::vector<std::string> lggHunSpell_Wrapper::getInstalledDicts() 820std::vector<std::string> lggHunSpell_Wrapper::getInstalledDicts()
769{ 821{
770 std::vector<std::string> toReturn; 822 std::vector<std::string> toReturn;
771 //expecting short names to be stored... 823 //expecting short names to be stored...
772 std::vector<std::string> shortNames = CSV2VEC(gSavedSettings.getString("EmeraldSpellInstalled")); 824 std::vector<std::string> shortNames = CSV2VEC(gSavedSettings.getString("EmeraldSpellInstalled"));
773 for(int i =0;i<(int)shortNames.size();i++) 825 for (int i =0; i < (int)shortNames.size(); i++)
826 {
774 toReturn.push_back(dictName2FullName(shortNames[i])); 827 toReturn.push_back(dictName2FullName(shortNames[i]));
828 }
775 return toReturn; 829 return toReturn;
776} 830}
831
777std::vector<std::string> lggHunSpell_Wrapper::getAvailDicts() 832std::vector<std::string> lggHunSpell_Wrapper::getAvailDicts()
778{ 833{
779 std::vector<std::string> toReturn; 834 std::vector<std::string> toReturn;
780 std::vector<std::string> dics = getExtraDicts(); 835 std::vector<std::string> dics = getExtraDicts();
781 std::vector<std::string> installedDics = getInstalledDicts(); 836 std::vector<std::string> installedDics = getInstalledDicts();
782 for(int i =0;i<(int)dics.size();i++) 837 for (int i = 0; i < (int)dics.size(); i++)
783 { 838 {
784 bool found = false; 839 bool found = false;
785 for(int j=0;j<(int)installedDics.size();j++) 840 for (int j = 0; j < (int)installedDics.size(); j++)
841 {
842 if (0 == LLStringUtil::compareInsensitive(dics[i], installedDics[j]))
843 {
844 found = true;//this dic is already installed
845 }
846 }
847 if (0 == LLStringUtil::compareInsensitive(dics[i], currentBaseDic))
786 { 848 {
787 if(0==LLStringUtil::compareInsensitive(dics[i],installedDics[j])) 849 found = true;
788 found=true;//this dic is already installed 850 }
851 if (0 == LLStringUtil::compareInsensitive(dics[i], "Emerald (CUSTOM)"))
852 {
853 found = true;
854 }
855 if (!found)
856 {
857 toReturn.push_back(dics[i]);
789 } 858 }
790 if(0==LLStringUtil::compareInsensitive(dics[i],currentBaseDic))
791 found=true;
792 if(0==LLStringUtil::compareInsensitive(dics[i],"Emerald (CUSTOM)"))
793 found=true;
794 if(!found)toReturn.push_back(dics[i]);
795 } 859 }
796 return toReturn; 860 return toReturn;
797} 861}
862
798std::vector<std::string> lggHunSpell_Wrapper::CSV2VEC(std::string csv) 863std::vector<std::string> lggHunSpell_Wrapper::CSV2VEC(std::string csv)
799{ 864{
800 std::vector<std::string> toReturn; 865 std::vector<std::string> toReturn;
801 boost::regex re(","); 866 boost::regex re(",");
802 boost::sregex_token_iterator i(csv.begin(), csv.end(), re, -1); 867 boost::sregex_token_iterator i(csv.begin(), csv.end(), re, -1);
803 boost::sregex_token_iterator j; 868 boost::sregex_token_iterator j;
804 while(i != j) 869 while (i != j)
870 {
805 toReturn.push_back(*i++); 871 toReturn.push_back(*i++);
872 }
806 return toReturn; 873 return toReturn;
807} 874}
875
808std::string lggHunSpell_Wrapper::VEC2CSV(std::vector<std::string> vec) 876std::string lggHunSpell_Wrapper::VEC2CSV(std::vector<std::string> vec)
809{ 877{
810 std::string toReturn=""; 878 std::string toReturn("");
811 if(vec.size()<1)return toReturn; 879 if (vec.size() < 1)
812 for(int i = 0;i<(int)vec.size();i++) 880 {
813 toReturn+=vec[i]+","; 881 return toReturn;
882 }
883
884 for (int i = 0;i < (int)vec.size() ;i++)
885 {
886 toReturn += vec[i] + ",";
887 }
814 return toReturn.erase(toReturn.length()-1); 888 return toReturn.erase(toReturn.length()-1);
815} 889}
890
816void lggHunSpell_Wrapper::addButton(std::string selection) 891void lggHunSpell_Wrapper::addButton(std::string selection)
817{ 892{
818 if(selection=="")return; 893 if (selection.empty())
894 {
895 return;
896 }
819 addDictionary(selection); 897 addDictionary(selection);
820 std::vector<std::string> alreadyInstalled = CSV2VEC(gSavedSettings.getString("EmeraldSpellInstalled")); 898 std::vector<std::string> alreadyInstalled = CSV2VEC(gSavedSettings.getString("EmeraldSpellInstalled"));
821 alreadyInstalled.push_back(fullName2DictName(selection)); 899 alreadyInstalled.push_back(fullName2DictName(selection));
822 gSavedSettings.setString("EmeraldSpellInstalled",VEC2CSV(alreadyInstalled)); 900 gSavedSettings.setString("EmeraldSpellInstalled", VEC2CSV(alreadyInstalled));
823} 901}
902
824void lggHunSpell_Wrapper::removeButton(std::string selection) 903void lggHunSpell_Wrapper::removeButton(std::string selection)
825{ 904{
826 if(selection=="")return; 905 if (selection.empty())
906 {
907 return;
908 }
827 std::vector<std::string> newInstalledDics; 909 std::vector<std::string> newInstalledDics;
828 std::vector<std::string> currentlyInstalled = getInstalledDicts(); 910 std::vector<std::string> currentlyInstalled = getInstalledDicts();
829 for(int i =0;i<(int)currentlyInstalled.size();i++) 911 for (int i = 0; i < (int)currentlyInstalled.size(); i++)
830 { 912 {
831 if(0!=LLStringUtil::compareInsensitive(selection,currentlyInstalled[i])) 913 if (0 != LLStringUtil::compareInsensitive(selection, currentlyInstalled[i]))
914 {
832 newInstalledDics.push_back(fullName2DictName(currentlyInstalled[i])); 915 newInstalledDics.push_back(fullName2DictName(currentlyInstalled[i]));
916 }
833 } 917 }
834 gSavedSettings.setString("EmeraldSpellInstalled",VEC2CSV(newInstalledDics)); 918 gSavedSettings.setString("EmeraldSpellInstalled", VEC2CSV(newInstalledDics));
835 processSettings(); 919 processSettings();
836} 920}
921
837void lggHunSpell_Wrapper::newDictSelection(std::string selection) 922void lggHunSpell_Wrapper::newDictSelection(std::string selection)
838{ 923{
839 currentBaseDic=selection; 924 currentBaseDic = selection;
840 gSavedSettings.setString("EmeraldSpellBase",selection); 925 gSavedSettings.setString("EmeraldSpellBase", selection);
841 //better way to do this would be to check and see if there is a installed conflict 926 //better way to do this would be to check and see if there is a installed conflict
842 //and then only remove that one.. messy 927 //and then only remove that one.. messy
843 gSavedSettings.setString("EmeraldSpellInstalled","en_sl"); 928 gSavedSettings.setString("EmeraldSpellInstalled", "en_sl");
844 processSettings(); 929 processSettings();
845} 930}
846void lggHunSpell_Wrapper::getMoreButton(void * data) 931
932void lggHunSpell_Wrapper::getMoreButton(void* data)
847{ 933{
848 std::vector<std::string> shortNames; 934 std::vector<std::string> shortNames;
849 std::vector<std::string> longNames; 935 std::vector<std::string> longNames;
850 LLSD response = LLHTTPClient::blockingGet(gSavedSettings.getString("DicDownloadBaseURL")+"dic_list.xml"); 936 LLSD response = LLHTTPClient::blockingGet(gSavedSettings.getString("DicDownloadBaseURL")+"dic_list.xml");
851 if(response.has("body")) 937 if (response.has("body"))
852 { 938 {
853 const LLSD &dict_list = response["body"]; 939 const LLSD &dict_list = response["body"];
854 if(dict_list.has("isComplete")) 940 if (dict_list.has("isComplete"))
855 { 941 {
856 LLSD dics = dict_list["data"]; 942 LLSD dics = dict_list["data"];
857 for(int i = 0; i < dics.size(); i++) 943 for (int i = 0; i < dics.size(); i++)
858 { 944 {
859 std::string dicFullName = dictName2FullName(dics[i].asString()); 945 std::string dicFullName = dictName2FullName(dics[i].asString());
860 longNames.push_back(dicFullName); 946 longNames.push_back(dicFullName);
@@ -864,11 +950,12 @@ void lggHunSpell_Wrapper::getMoreButton(void * data)
864 } 950 }
865 } 951 }
866} 952}
953
867void lggHunSpell_Wrapper::editCustomButton() 954void lggHunSpell_Wrapper::editCustomButton()
868{ 955{
869 std::string dicdicpath(gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "dictionaries", std::string("custom.dic")).c_str()); 956 std::string dicdicpath(gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "dictionaries", std::string("custom.dic")).c_str());
870 957
871 if(!gDirUtilp->fileExists(dicdicpath)) 958 if (!gDirUtilp->fileExists(dicdicpath))
872 { 959 {
873 createCustomDic(); 960 createCustomDic();
874 //glggHunSpell->addWordToCustomDictionary("temp"); 961 //glggHunSpell->addWordToCustomDictionary("temp");
@@ -877,7 +964,7 @@ void lggHunSpell_Wrapper::editCustomButton()
877 gViewerWindow->getWindow()->ShellEx(dicdicpath); 964 gViewerWindow->getWindow()->ShellEx(dicdicpath);
878} 965}
879 966
880void lggHunSpell_Wrapper::setNewHighlightSetting( BOOL highlight ) 967void lggHunSpell_Wrapper::setNewHighlightSetting(BOOL highlight)
881{ 968{
882 highlightInRed=highlight; 969 mSpellCheckHighlight = highlight;
883} 970}
diff --git a/linden/indra/newview/lgghunspell_wrapper.h b/linden/indra/newview/lgghunspell_wrapper.h
index 348f479..4d07ff8 100644
--- a/linden/indra/newview/lgghunspell_wrapper.h
+++ b/linden/indra/newview/lgghunspell_wrapper.h
@@ -28,9 +28,9 @@ class lggHunSpell_Wrapper
28{ 28{
29 29
30public: 30public:
31 static Hunspell * myHunspell; 31 static Hunspell* myHunspell;
32 32
33 BOOL highlightInRed; 33 BOOL mSpellCheckHighlight;
34 34
35 static void initSettings(); 35 static void initSettings();
36 void processSettings(); 36 void processSettings();
@@ -69,6 +69,6 @@ private:
69 //std::vector<std::string> countryCodes; 69 //std::vector<std::string> countryCodes;
70}; 70};
71 71
72extern lggHunSpell_Wrapper *glggHunSpell; // the singleton hunspell wrapper 72extern lggHunSpell_Wrapper* glggHunSpell; // the singleton hunspell wrapper
73 73
74#endif 74#endif