aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llui/lltexteditor.h
diff options
context:
space:
mode:
authorPatrick Sapinski2010-08-24 03:04:20 -0400
committerMcCabe Maxsted2010-08-30 17:04:59 -0700
commitded1245db74ae4c97d174c5779f8572ee2f032fa (patch)
treef42c33f233ed68e715a0ac4c74ddc043f43a68da /linden/indra/llui/lltexteditor.h
parentAdded debug setting UseLegacyChatLogsFolder for saving chat.txt and IM logs i... (diff)
downloadmeta-impy-ded1245db74ae4c97d174c5779f8572ee2f032fa.zip
meta-impy-ded1245db74ae4c97d174c5779f8572ee2f032fa.tar.gz
meta-impy-ded1245db74ae4c97d174c5779f8572ee2f032fa.tar.bz2
meta-impy-ded1245db74ae4c97d174c5779f8572ee2f032fa.tar.xz
added spellcheck + translation from Emerald Viewer. references to modularsystems.sl should be changed!
Diffstat (limited to 'linden/indra/llui/lltexteditor.h')
-rw-r--r--linden/indra/llui/lltexteditor.h74
1 files changed, 65 insertions, 9 deletions
diff --git a/linden/indra/llui/lltexteditor.h b/linden/indra/llui/lltexteditor.h
index f26bf3b..6b372d7 100644
--- a/linden/indra/llui/lltexteditor.h
+++ b/linden/indra/llui/lltexteditor.h
@@ -45,6 +45,7 @@
45#include "lldarray.h" 45#include "lldarray.h"
46 46
47#include "llpreeditor.h" 47#include "llpreeditor.h"
48#include "llmenugl.h"
48 49
49class LLFontGL; 50class LLFontGL;
50class LLScrollbar; 51class LLScrollbar;
@@ -84,6 +85,7 @@ public:
84 virtual BOOL handleHover(S32 x, S32 y, MASK mask); 85 virtual BOOL handleHover(S32 x, S32 y, MASK mask);
85 virtual BOOL handleScrollWheel(S32 x, S32 y, S32 clicks); 86 virtual BOOL handleScrollWheel(S32 x, S32 y, S32 clicks);
86 virtual BOOL handleDoubleClick(S32 x, S32 y, MASK mask ); 87 virtual BOOL handleDoubleClick(S32 x, S32 y, MASK mask );
88 virtual BOOL handleRightMouseDown( S32 x, S32 y, MASK mask );
87 virtual BOOL handleMiddleMouseDown(S32 x,S32 y,MASK mask); 89 virtual BOOL handleMiddleMouseDown(S32 x,S32 y,MASK mask);
88 90
89 virtual BOOL handleKeyHere(KEY key, MASK mask ); 91 virtual BOOL handleKeyHere(KEY key, MASK mask );
@@ -108,29 +110,55 @@ public:
108 virtual void setFocus( BOOL b ); 110 virtual void setFocus( BOOL b );
109 virtual BOOL acceptsTextInput() const; 111 virtual BOOL acceptsTextInput() const;
110 virtual BOOL isDirty() const { return( mLastCmd != NULL || (mPristineCmd && (mPristineCmd != mLastCmd)) ); } 112 virtual BOOL isDirty() const { return( mLastCmd != NULL || (mPristineCmd && (mPristineCmd != mLastCmd)) ); }
113 BOOL isSpellDirty() const { return mWText != mPrevSpelledText; } // Returns TRUE if user changed value at all
114 void resetSpellDirty() { mPrevSpelledText = mWText; } // Clear dirty state
111 115
116 struct SpellMenuBind
117 {
118 LLTextEditor* origin;
119 LLMenuItemCallGL * menuItem;
120 std::string word;
121 S32 wordPositionStart;
122 S32 wordPositionEnd;
123 S32 wordY;
124 };
125
112 // LLEditMenuHandler interface 126 // LLEditMenuHandler interface
113 virtual void undo(); 127 virtual void undo();
114 virtual BOOL canUndo() const; 128 virtual BOOL canUndo() const;
115 virtual void redo(); 129 virtual void redo();
116 virtual BOOL canRedo() const; 130 virtual BOOL canRedo() const;
117
118 virtual void cut(); 131 virtual void cut();
119 virtual BOOL canCut() const; 132 virtual BOOL canCut() const;
120 virtual void copy(); 133 virtual void copy();
121 virtual BOOL canCopy() const; 134 virtual BOOL canCopy() const;
122 virtual void paste(); 135 virtual void paste();
123 virtual BOOL canPaste() const; 136 virtual BOOL canPaste() const;
137
138 virtual void spellReplace(SpellMenuBind* spellData);
139
124 virtual void updatePrimary(); 140 virtual void updatePrimary();
125 virtual void copyPrimary(); 141 virtual void copyPrimary();
126 virtual void pastePrimary(); 142 virtual void pastePrimary();
127 virtual BOOL canPastePrimary() const; 143 virtual BOOL canPastePrimary() const;
144
128 virtual void doDelete(); 145 virtual void doDelete();
129 virtual BOOL canDoDelete() const; 146 virtual BOOL canDoDelete() const;
130 virtual void selectAll(); 147 virtual void selectAll();
131 virtual BOOL canSelectAll() const; 148 virtual BOOL canSelectAll() const;
132 virtual void deselect(); 149 virtual void deselect();
133 virtual BOOL canDeselect() const; 150 virtual BOOL canDeselect() const;
151 static void context_cut(void* data);
152
153 static void context_copy(void* data);
154 static void context_paste(void* data);
155 static void context_delete(void* data);
156 static void context_selectall(void* data);
157 static void translateText(void * data);
158 static void spell_correct(void* data);
159 static void spell_add(void* data);
160 static void spell_show(void* data);
161 std::vector<S32> getMisspelledWordsPositions();
134 162
135 void selectNext(const std::string& search_text_in, BOOL case_insensitive, BOOL wrap = TRUE); 163 void selectNext(const std::string& search_text_in, BOOL case_insensitive, BOOL wrap = TRUE);
136 BOOL replaceText(const std::string& search_text, const std::string& replace_text, BOOL case_insensitive, BOOL wrap = TRUE); 164 BOOL replaceText(const std::string& search_text, const std::string& replace_text, BOOL case_insensitive, BOOL wrap = TRUE);
@@ -145,17 +173,17 @@ public:
145 BOOL allowsEmbeddedItems() const { return mAllowEmbeddedItems; } 173 BOOL allowsEmbeddedItems() const { return mAllowEmbeddedItems; }
146 174
147 // inserts text at cursor 175 // inserts text at cursor
148 void insertText(const std::string &text); 176 void insertText(const std::string &text, BOOL deleteSelection = TRUE);
149 // appends text at end 177 // appends text at end
150 void appendText(const std::string &wtext, bool allow_undo, bool prepend_newline, 178 void appendText(const std::string &wtext, bool allow_undo, bool prepend_newline,
151 const LLStyleSP stylep = NULL); 179 const LLStyleSP stylep = NULL);
152 180
153 void appendColoredText(const std::string &wtext, bool allow_undo, 181 void appendColoredText(const std::string &wtext, bool allow_undo,
154 bool prepend_newline, 182 bool prepend_newline,
155 const LLColor4 &color, 183 const LLColor4 &color,
156 const std::string& font_name = LLStringUtil::null); 184 const std::string& font_name = LLStringUtil::null);
157 // if styled text starts a line, you need to prepend a newline. 185 // if styled text starts a line, you need to prepend a newline.
158 void appendStyledText(const std::string &new_text, bool allow_undo, 186 void appendStyledText(const std::string &new_text, bool allow_undo,
159 bool prepend_newline, 187 bool prepend_newline,
160 LLStyleSP stylep = NULL); 188 LLStyleSP stylep = NULL);
161 void appendHighlightedText(const std::string &new_text, bool allow_undo, 189 void appendHighlightedText(const std::string &new_text, bool allow_undo,
@@ -182,6 +210,11 @@ public:
182 const std::vector<std::string>& funcs, 210 const std::vector<std::string>& funcs,
183 const std::vector<std::string>& tooltips, 211 const std::vector<std::string>& tooltips,
184 const LLColor3& func_color); 212 const LLColor3& func_color);
213 void addToken(LLKeywordToken::TOKEN_TYPE type,
214 const std::string& key,
215 const LLColor3& color,
216 const std::string& tool_tip = LLStringUtil::null,
217 const std::string& delimiter = LLStringUtil::null);
185 LLKeywords::keyword_iterator_t keywordsBegin() { return mKeywords.begin(); } 218 LLKeywords::keyword_iterator_t keywordsBegin() { return mKeywords.begin(); }
186 LLKeywords::keyword_iterator_t keywordsEnd() { return mKeywords.end(); } 219 LLKeywords::keyword_iterator_t keywordsEnd() { return mKeywords.end(); }
187 220
@@ -196,6 +229,7 @@ public:
196 void setThumbColor( const LLColor4& color ); 229 void setThumbColor( const LLColor4& color );
197 void setHighlightColor( const LLColor4& color ); 230 void setHighlightColor( const LLColor4& color );
198 void setShadowColor( const LLColor4& color ); 231 void setShadowColor( const LLColor4& color );
232 void setOverRideAndShowMisspellings(BOOL b){ mOverRideAndShowMisspellings =b;}
199 233
200 // Hacky methods to make it into a word-wrapping, potentially scrolling, 234 // Hacky methods to make it into a word-wrapping, potentially scrolling,
201 // read-only text box. 235 // read-only text box.
@@ -262,7 +296,7 @@ public:
262 const LLTextSegment* getPreviousSegment() const; 296 const LLTextSegment* getPreviousSegment() const;
263 void getSelectedSegments(std::vector<const LLTextSegment*>& segments) const; 297 void getSelectedSegments(std::vector<const LLTextSegment*>& segments) const;
264 298
265 static bool isPartOfWord(llwchar c) { return (c == '_') || LLStringOps::isAlnum((char)c); } 299 static bool isPartOfWord(llwchar c) { return ( (c == '_') || (c == '\'') || LLStringOps::isAlnum((char)c)); }
266 300
267 BOOL isReadOnly() { return mReadOnly; } 301 BOOL isReadOnly() { return mReadOnly; }
268protected: 302protected:
@@ -270,11 +304,14 @@ protected:
270 // Methods 304 // Methods
271 // 305 //
272 306
307 LLHandle<LLView> mPopupMenuHandle;
308
273 S32 getLength() const { return mWText.length(); } 309 S32 getLength() const { return mWText.length(); }
274 void getSegmentAndOffset( S32 startpos, S32* segidxp, S32* offsetp ) const; 310 void getSegmentAndOffset( S32 startpos, S32* segidxp, S32* offsetp ) const;
275 void drawPreeditMarker(); 311 void drawPreeditMarker();
276 312public:
277 void updateLineStartList(S32 startpos = 0); 313 void updateLineStartList(S32 startpos = 0);
314protected:
278 void updateScrollFromCursor(); 315 void updateScrollFromCursor();
279 void updateTextRect(); 316 void updateTextRect();
280 const LLRect& getTextRect() const { return mTextRect; } 317 const LLRect& getTextRect() const { return mTextRect; }
@@ -301,8 +338,13 @@ protected:
301 BOOL handleSelectionKey(const KEY key, const MASK mask); 338 BOOL handleSelectionKey(const KEY key, const MASK mask);
302 BOOL handleControlKey(const KEY key, const MASK mask); 339 BOOL handleControlKey(const KEY key, const MASK mask);
303 BOOL handleEditKey(const KEY key, const MASK mask); 340 BOOL handleEditKey(const KEY key, const MASK mask);
304 341 // <edit>
342public:
343 // </edit>
305 BOOL hasSelection() const { return (mSelectionStart !=mSelectionEnd); } 344 BOOL hasSelection() const { return (mSelectionStart !=mSelectionEnd); }
345 // <edit>
346 protected:
347 // </edit>
306 BOOL selectionContainsLineBreaks(); 348 BOOL selectionContainsLineBreaks();
307 void startSelection(); 349 void startSelection();
308 void endSelection(); 350 void endSelection();
@@ -330,7 +372,7 @@ protected:
330 virtual void unbindEmbeddedChars(const LLFontGL* font) const {} 372 virtual void unbindEmbeddedChars(const LLFontGL* font) const {}
331 373
332 S32 findHTMLToken(const std::string &line, S32 pos, BOOL reverse) const; 374 S32 findHTMLToken(const std::string &line, S32 pos, BOOL reverse) const;
333 BOOL findHTML(const std::string &line, S32 *begin, S32 *end) const; 375 BOOL findHTML(const std::string &line, S32 *begin, S32 *end, std::string& url) const;
334 376
335 // Abstract inner base class representing an undoable editor command. 377 // Abstract inner base class representing an undoable editor command.
336 // Concrete sub-classes can be defined for operations such as insert, remove, etc. 378 // Concrete sub-classes can be defined for operations such as insert, remove, etc.
@@ -400,8 +442,9 @@ protected:
400 // 442 //
401 443
402 // I-beam is just after the mCursorPos-th character. 444 // I-beam is just after the mCursorPos-th character.
445public:
403 S32 mCursorPos; 446 S32 mCursorPos;
404 447protected:
405 // Use these to determine if a click on an embedded item is a drag or not. 448 // Use these to determine if a click on an embedded item is a drag or not.
406 S32 mMouseDownX; 449 S32 mMouseDownX;
407 S32 mMouseDownY; 450 S32 mMouseDownY;
@@ -447,6 +490,8 @@ private:
447 void drawBackground(); 490 void drawBackground();
448 void drawSelectionBackground(); 491 void drawSelectionBackground();
449 void drawCursor(); 492 void drawCursor();
493 void autoCorrectText();
494 void drawMisspelled();
450 void drawText(); 495 void drawText();
451 void drawClippedSegment(const LLWString &wtext, S32 seg_start, S32 seg_end, F32 x, F32 y, S32 selection_left, S32 selection_right, const LLStyleSP& color, F32* right_x); 496 void drawClippedSegment(const LLWString &wtext, S32 seg_start, S32 seg_end, F32 x, F32 y, S32 selection_left, S32 selection_right, const LLStyleSP& color, F32* right_x);
452 497
@@ -477,6 +522,12 @@ private:
477 mutable std::string mUTF8Text; 522 mutable std::string mUTF8Text;
478 mutable BOOL mTextIsUpToDate; 523 mutable BOOL mTextIsUpToDate;
479 524
525 LLWString mPrevSpelledText; // saved string so we know whether to respell or not
526 S32 spellStart;
527 S32 spellEnd;
528 std::vector<S32> misspellLocations; // where all the mispelled words are
529 BOOL mOverRideAndShowMisspellings;
530
480 S32 mMaxTextByteLength; // Maximum length mText is allowed to be in bytes 531 S32 mMaxTextByteLength; // Maximum length mText is allowed to be in bytes
481 532
482 const LLFontGL* mGLFont; 533 const LLFontGL* mGLFont;
@@ -513,11 +564,16 @@ private:
513 } 564 }
514 }; 565 };
515 typedef std::vector<line_info> line_list_t; 566 typedef std::vector<line_info> line_list_t;
567
568 //to keep track of what we have to remove before showing menu
569 std::vector<SpellMenuBind* > suggestionMenuItems;
570
516 line_list_t mLineStartList; 571 line_list_t mLineStartList;
517 BOOL mReflowNeeded; 572 BOOL mReflowNeeded;
518 BOOL mScrollNeeded; 573 BOOL mScrollNeeded;
519 574
520 LLFrameTimer mKeystrokeTimer; 575 LLFrameTimer mKeystrokeTimer;
576 LLFrameTimer mSpellTimer;
521 577
522 LLColor4 mCursorColor; 578 LLColor4 mCursorColor;
523 579