aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llui/lltexteditor.h
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:45:34 -0500
committerJacek Antonelli2008-08-15 23:45:34 -0500
commitcd17687f01420952712a500107e0f93e7ab8d5f8 (patch)
treece48c2b706f2c1176290e39fb555fbdf6648ce01 /linden/indra/llui/lltexteditor.h
parentSecond Life viewer sources 1.19.0.5 (diff)
downloadmeta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.zip
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.gz
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.bz2
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.xz
Second Life viewer sources 1.19.1.0
Diffstat (limited to '')
-rw-r--r--linden/indra/llui/lltexteditor.h314
1 files changed, 169 insertions, 145 deletions
diff --git a/linden/indra/llui/lltexteditor.h b/linden/indra/llui/lltexteditor.h
index 4c92297..82d9069 100644
--- a/linden/indra/llui/lltexteditor.h
+++ b/linden/indra/llui/lltexteditor.h
@@ -52,24 +52,16 @@ class LLKeywordToken;
52class LLTextCmd; 52class LLTextCmd;
53class LLUICtrlFactory; 53class LLUICtrlFactory;
54 54
55//
56// Constants
57//
58
59const llwchar FIRST_EMBEDDED_CHAR = 0x100000;
60const llwchar LAST_EMBEDDED_CHAR = 0x10ffff;
61const S32 MAX_EMBEDDED_ITEMS = LAST_EMBEDDED_CHAR - FIRST_EMBEDDED_CHAR + 1;
62
63//
64// Classes
65//
66class LLTextSegment;
67class LLTextCmd;
68
69class LLTextEditor : public LLUICtrl, LLEditMenuHandler, protected LLPreeditor 55class LLTextEditor : public LLUICtrl, LLEditMenuHandler, protected LLPreeditor
70{ 56{
71 friend class LLTextCmd;
72public: 57public:
58 //
59 // Constants
60 //
61 static const llwchar FIRST_EMBEDDED_CHAR = 0x100000;
62 static const llwchar LAST_EMBEDDED_CHAR = 0x10ffff;
63 static const S32 MAX_EMBEDDED_ITEMS = LAST_EMBEDDED_CHAR - FIRST_EMBEDDED_CHAR + 1;
64
73 LLTextEditor(const LLString& name, 65 LLTextEditor(const LLString& name,
74 const LLRect& rect, 66 const LLRect& rect,
75 S32 max_length, 67 S32 max_length,
@@ -80,10 +72,10 @@ public:
80 virtual ~LLTextEditor(); 72 virtual ~LLTextEditor();
81 73
82 virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_TEXT_EDITOR; } 74 virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_TEXT_EDITOR; }
83 virtual LLString getWidgetTag() const; 75 virtual LLString getWidgetTag() const { return LL_TEXT_EDITOR_TAG; }
84 76
85 virtual LLXMLNodePtr getXML(bool save_children = true) const; 77 virtual LLXMLNodePtr getXML(bool save_children = true) const;
86 static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory); 78 static LLView* fromXML(LLXMLNodePtr node, LLView *parent, class LLUICtrlFactory *factory);
87 void setTextEditorParameters(LLXMLNodePtr node); 79 void setTextEditorParameters(LLXMLNodePtr node);
88 void setParseHTML(BOOL parsing) {mParseHTML=parsing;} 80 void setParseHTML(BOOL parsing) {mParseHTML=parsing;}
89 81
@@ -102,7 +94,6 @@ public:
102 EAcceptance *accept, LLString& tooltip_msg); 94 EAcceptance *accept, LLString& tooltip_msg);
103 virtual void onMouseCaptureLost(); 95 virtual void onMouseCaptureLost();
104 96
105
106 // view overrides 97 // view overrides
107 virtual void reshape(S32 width, S32 height, BOOL called_from_parent); 98 virtual void reshape(S32 width, S32 height, BOOL called_from_parent);
108 virtual void draw(); 99 virtual void draw();
@@ -115,32 +106,25 @@ public:
115 virtual void clear(); 106 virtual void clear();
116 virtual void setFocus( BOOL b ); 107 virtual void setFocus( BOOL b );
117 virtual BOOL acceptsTextInput() const; 108 virtual BOOL acceptsTextInput() const;
118 virtual BOOL isDirty() const; 109 virtual BOOL isDirty() const { return( mLastCmd != NULL || (mPristineCmd && (mPristineCmd != mLastCmd)) ); }
119 110
120 // LLEditMenuHandler interface 111 // LLEditMenuHandler interface
121 virtual void undo(); 112 virtual void undo();
122 virtual BOOL canUndo(); 113 virtual BOOL canUndo() const;
123
124 virtual void redo(); 114 virtual void redo();
125 virtual BOOL canRedo(); 115 virtual BOOL canRedo() const;
126
127 virtual void cut(); 116 virtual void cut();
128 virtual BOOL canCut(); 117 virtual BOOL canCut() const;
129
130 virtual void copy(); 118 virtual void copy();
131 virtual BOOL canCopy(); 119 virtual BOOL canCopy() const;
132
133 virtual void paste(); 120 virtual void paste();
134 virtual BOOL canPaste(); 121 virtual BOOL canPaste() const;
135
136 virtual void doDelete(); 122 virtual void doDelete();
137 virtual BOOL canDoDelete(); 123 virtual BOOL canDoDelete() const;
138
139 virtual void selectAll(); 124 virtual void selectAll();
140 virtual BOOL canSelectAll(); 125 virtual BOOL canSelectAll() const;
141
142 virtual void deselect(); 126 virtual void deselect();
143 virtual BOOL canDeselect(); 127 virtual BOOL canDeselect() const;
144 128
145 void selectNext(const LLString& search_text_in, BOOL case_insensitive, BOOL wrap = TRUE); 129 void selectNext(const LLString& search_text_in, BOOL case_insensitive, BOOL wrap = TRUE);
146 BOOL replaceText(const LLString& search_text, const LLString& replace_text, BOOL case_insensitive, BOOL wrap = TRUE); 130 BOOL replaceText(const LLString& search_text, const LLString& replace_text, BOOL case_insensitive, BOOL wrap = TRUE);
@@ -152,6 +136,7 @@ public:
152 // Text editing 136 // Text editing
153 virtual void makePristine(); 137 virtual void makePristine();
154 BOOL isPristine() const; 138 BOOL isPristine() const;
139 BOOL allowsEmbeddedItems() const { return mAllowEmbeddedItems; }
155 140
156 // inserts text at cursor 141 // inserts text at cursor
157 void insertText(const LLString &text); 142 void insertText(const LLString &text);
@@ -180,18 +165,21 @@ public:
180 165
181 void getCurrentLineAndColumn( S32* line, S32* col, BOOL include_wordwrap ); 166 void getCurrentLineAndColumn( S32* line, S32* col, BOOL include_wordwrap );
182 167
168 // Keywords support
183 void loadKeywords(const LLString& filename, 169 void loadKeywords(const LLString& filename,
184 const LLDynamicArray<const char*>& funcs, 170 const LLDynamicArray<const char*>& funcs,
185 const LLDynamicArray<const char*>& tooltips, 171 const LLDynamicArray<const char*>& tooltips,
186 const LLColor3& func_color); 172 const LLColor3& func_color);
173 LLKeywords::keyword_iterator_t keywordsBegin() { return mKeywords.begin(); }
174 LLKeywords::keyword_iterator_t keywordsEnd() { return mKeywords.end(); }
187 175
176 // Color support
188 void setCursorColor(const LLColor4& c) { mCursorColor = c; } 177 void setCursorColor(const LLColor4& c) { mCursorColor = c; }
189 void setFgColor( const LLColor4& c ) { mFgColor = c; } 178 void setFgColor( const LLColor4& c ) { mFgColor = c; }
190 void setTextDefaultColor( const LLColor4& c ) { mDefaultColor = c; } 179 void setTextDefaultColor( const LLColor4& c ) { mDefaultColor = c; }
191 void setReadOnlyFgColor( const LLColor4& c ) { mReadOnlyFgColor = c; } 180 void setReadOnlyFgColor( const LLColor4& c ) { mReadOnlyFgColor = c; }
192 void setWriteableBgColor( const LLColor4& c ) { mWriteableBgColor = c; } 181 void setWriteableBgColor( const LLColor4& c ) { mWriteableBgColor = c; }
193 void setReadOnlyBgColor( const LLColor4& c ) { mReadOnlyBgColor = c; } 182 void setReadOnlyBgColor( const LLColor4& c ) { mReadOnlyBgColor = c; }
194
195 void setTrackColor( const LLColor4& color ); 183 void setTrackColor( const LLColor4& color );
196 void setThumbColor( const LLColor4& color ); 184 void setThumbColor( const LLColor4& color );
197 void setHighlightColor( const LLColor4& color ); 185 void setHighlightColor( const LLColor4& color );
@@ -200,11 +188,13 @@ public:
200 // Hacky methods to make it into a word-wrapping, potentially scrolling, 188 // Hacky methods to make it into a word-wrapping, potentially scrolling,
201 // read-only text box. 189 // read-only text box.
202 void setBorderVisible(BOOL b); 190 void setBorderVisible(BOOL b);
203 void setTakesNonScrollClicks(BOOL b); 191 BOOL isBorderVisible() const;
192 void setTakesNonScrollClicks(BOOL b) { mTakesNonScrollClicks = b; }
204 void setHideScrollbarForShortDocs(BOOL b); 193 void setHideScrollbarForShortDocs(BOOL b);
205 194
206 void setWordWrap( BOOL b ); 195 void setWordWrap( BOOL b );
207 void setTabToNextField(BOOL b) { mTabToNextField = b; } 196 void setTabsToNextField(BOOL b) { mTabsToNextField = b; }
197 BOOL tabsToNextField() const { return mTabsToNextField; }
208 void setCommitOnFocusLost(BOOL b) { mCommitOnFocusLost = b; } 198 void setCommitOnFocusLost(BOOL b) { mCommitOnFocusLost = b; }
209 199
210 // Hack to handle Notecards 200 // Hack to handle Notecards
@@ -215,7 +205,9 @@ public:
215 void setTakesFocus(BOOL b) { mTakesFocus = b; } 205 void setTakesFocus(BOOL b) { mTakesFocus = b; }
216 206
217 void setSourceID(const LLUUID& id) { mSourceID = id; } 207 void setSourceID(const LLUUID& id) { mSourceID = id; }
208 const LLUUID& getSourceID() const { return mSourceID; }
218 void setAcceptCallingCardNames(BOOL enable) { mAcceptCallingCardNames = enable; } 209 void setAcceptCallingCardNames(BOOL enable) { mAcceptCallingCardNames = enable; }
210 BOOL acceptsCallingCardNames() const { return mAcceptCallingCardNames; }
219 211
220 void setHandleEditKeysDirectly( BOOL b ) { mHandleEditKeysDirectly = b; } 212 void setHandleEditKeysDirectly( BOOL b ) { mHandleEditKeysDirectly = b; }
221 213
@@ -250,49 +242,46 @@ public:
250 BOOL isScrolledToBottom(); 242 BOOL isScrolledToBottom();
251 243
252 // Getters 244 // Getters
253 const LLWString& getWText() const; 245 const LLWString& getWText() const { return mWText; }
254 llwchar getWChar(S32 pos); 246 llwchar getWChar(S32 pos) const { return mWText[pos]; }
255 LLWString getWSubString(S32 pos, S32 len); 247 LLWString getWSubString(S32 pos, S32 len) const { return mWText.substr(pos, len); }
256 248
257 LLTextSegment* getCurrentSegment(); 249 const LLTextSegment* getCurrentSegment() { return getSegmentAtOffset(mCursorPos); }
258 LLTextSegment* getPreviousSegment(); 250 const LLTextSegment* getPreviousSegment();
259 void getSelectedSegments(std::vector<LLTextSegment*>& segments); 251 void getSelectedSegments(std::vector<const LLTextSegment*>& segments);
260 252
261protected: 253protected:
262 S32 getLength() const; 254 //
263 void getSegmentAndOffset( S32 startpos, S32* segidxp, S32* offsetp ); 255 // Methods
256 //
264 257
265 void drawBackground(); 258 S32 getLength() const { return mWText.length(); }
266 void drawSelectionBackground(); 259 void getSegmentAndOffset( S32 startpos, S32* segidxp, S32* offsetp ) const;
267 void drawCursor();
268 void drawText();
269 void drawClippedSegment(const LLWString &wtext, S32 seg_start, S32 seg_end, F32 x, F32 y, S32 selection_left, S32 selection_right, const LLStyle& color, F32* right_x);
270 void drawPreeditMarker(); 260 void drawPreeditMarker();
271 261
272 void updateLineStartList(S32 startpos = 0); 262 void updateLineStartList(S32 startpos = 0);
273 void updateScrollFromCursor(); 263 void updateScrollFromCursor();
274 void updateTextRect(); 264 void updateTextRect();
275 void updateSegments(); 265 const LLRect& getTextRect() const { return mTextRect; }
276 void pruneSegments();
277 266
278 void assignEmbedded(const LLString &s); 267 void assignEmbedded(const LLString &s);
279 BOOL truncate(); // Returns true if truncation occurs 268 BOOL truncate(); // Returns true if truncation occurs
280 269
281 static BOOL isPartOfWord(llwchar c); 270 static BOOL isPartOfWord(llwchar c) { return (c == '_') || isalnum(c); }
282 271
283 void removeCharOrTab(); 272 void removeCharOrTab();
284 void setCursorAtLocalPos(S32 x, S32 y, BOOL round); 273 void setCursorAtLocalPos(S32 x, S32 y, BOOL round);
285 S32 getCursorPosFromLocalCoord( S32 local_x, S32 local_y, BOOL round ); 274 S32 getCursorPosFromLocalCoord( S32 local_x, S32 local_y, BOOL round ) const;
286 275
287 void indentSelectedLines( S32 spaces ); 276 void indentSelectedLines( S32 spaces );
288 S32 indentLine( S32 pos, S32 spaces ); 277 S32 indentLine( S32 pos, S32 spaces );
289 void unindentLineBeforeCloseBrace(); 278 void unindentLineBeforeCloseBrace();
290 279
291 S32 getSegmentIdxAtOffset(S32 offset); 280 S32 getSegmentIdxAtOffset(S32 offset) const;
292 LLTextSegment* getSegmentAtLocalPos(S32 x, S32 y); 281 const LLTextSegment* getSegmentAtLocalPos(S32 x, S32 y) const;
293 LLTextSegment* getSegmentAtOffset(S32 offset); 282 const LLTextSegment* getSegmentAtOffset(S32 offset) const;
294 283
295 void reportBadKeystroke(); 284 void reportBadKeystroke() { make_ui_sound("UISndBadKeystroke"); }
296 285
297 BOOL handleNavigationKey(const KEY key, const MASK mask); 286 BOOL handleNavigationKey(const KEY key, const MASK mask);
298 BOOL handleSpecialKey(const KEY key, const MASK mask, BOOL* return_key_hit); 287 BOOL handleSpecialKey(const KEY key, const MASK mask, BOOL* return_key_hit);
@@ -309,29 +298,58 @@ protected:
309 S32 prevWordPos(S32 cursorPos) const; 298 S32 prevWordPos(S32 cursorPos) const;
310 S32 nextWordPos(S32 cursorPos) const; 299 S32 nextWordPos(S32 cursorPos) const;
311 300
312 S32 getLineCount() const; 301 S32 getLineCount() const { return mLineStartList.size(); }
313 S32 getLineStart( S32 line ) const; 302 S32 getLineStart( S32 line ) const;
314 void getLineAndOffset(S32 pos, S32* linep, S32* offsetp); 303 void getLineAndOffset(S32 pos, S32* linep, S32* offsetp) const;
315 S32 getPos(S32 line, S32 offset); 304 S32 getPos(S32 line, S32 offset);
316 305
317 void changePage(S32 delta); 306 void changePage(S32 delta);
318 void changeLine(S32 delta); 307 void changeLine(S32 delta);
319 308
320 void autoIndent(); 309 void autoIndent();
321
322 S32 execute(LLTextCmd* cmd);
323 310
324 void findEmbeddedItemSegments(); 311 void findEmbeddedItemSegments();
325 312
326 virtual BOOL handleMouseUpOverSegment(S32 x, S32 y, MASK mask); 313 virtual BOOL handleMouseUpOverSegment(S32 x, S32 y, MASK mask);
327 virtual llwchar pasteEmbeddedItem(llwchar ext_char); 314
328 virtual void bindEmbeddedChars(const LLFontGL* font); 315 virtual llwchar pasteEmbeddedItem(llwchar ext_char) { return ext_char; }
329 virtual void unbindEmbeddedChars(const LLFontGL* font); 316 virtual void bindEmbeddedChars(LLFontGL* font) const {}
317 virtual void unbindEmbeddedChars(LLFontGL* font) const {}
330 318
331 S32 findHTMLToken(const LLString &line, S32 pos, BOOL reverse); 319 S32 findHTMLToken(const LLString &line, S32 pos, BOOL reverse) const;
332 BOOL findHTML(const LLString &line, S32 *begin, S32 *end); 320 BOOL findHTML(const LLString &line, S32 *begin, S32 *end) const;
321
322 // Abstract inner base class representing an undoable editor command.
323 // Concrete sub-classes can be defined for operations such as insert, remove, etc.
324 // Used as arguments to the execute() method below.
325 class LLTextCmd
326 {
327 public:
328 LLTextCmd( S32 pos, BOOL group_with_next ) : mPos(pos), mGroupWithNext(group_with_next) {}
329 virtual ~LLTextCmd() {}
330 virtual BOOL execute(LLTextEditor* editor, S32* delta) = 0;
331 virtual S32 undo(LLTextEditor* editor) = 0;
332 virtual S32 redo(LLTextEditor* editor) = 0;
333 virtual BOOL canExtend(S32 pos) const { return FALSE; }
334 virtual void blockExtensions() {}
335 virtual BOOL extendAndExecute( LLTextEditor* editor, S32 pos, llwchar c, S32* delta ) { llassert(0); return 0; }
336 virtual BOOL hasExtCharValue( llwchar value ) const { return FALSE; }
337
338 // Defined here so they can access protected LLTextEditor editing methods
339 S32 insert(LLTextEditor* editor, S32 pos, const LLWString &wstr) { return editor->insertStringNoUndo( pos, wstr ); }
340 S32 remove(LLTextEditor* editor, S32 pos, S32 length) { return editor->removeStringNoUndo( pos, length ); }
341 S32 overwrite(LLTextEditor* editor, S32 pos, llwchar wc) { return editor->overwriteCharNoUndo(pos, wc); }
342
343 S32 getPosition() const { return mPos; }
344 BOOL groupWithNext() const { return mGroupWithNext; }
345
346 private:
347 const S32 mPos;
348 BOOL mGroupWithNext;
349 };
350 // Here's the method that takes and applies text commands.
351 S32 execute(LLTextCmd* cmd);
333 352
334protected:
335 // Undoable operations 353 // Undoable operations
336 void addChar(llwchar c); // at mCursorPos 354 void addChar(llwchar c); // at mCursorPos
337 S32 addChar(S32 pos, llwchar wc); 355 S32 addChar(S32 pos, llwchar wc);
@@ -342,12 +360,13 @@ protected:
342 S32 remove(const S32 pos, const S32 length, const BOOL group_with_next_op); 360 S32 remove(const S32 pos, const S32 length, const BOOL group_with_next_op);
343 S32 append(const LLWString &wstr, const BOOL group_with_next_op); 361 S32 append(const LLWString &wstr, const BOOL group_with_next_op);
344 362
345 // direct operations 363 // Direct operations
346 S32 insertStringNoUndo(S32 pos, const LLWString &wstr); // returns num of chars actually inserted 364 S32 insertStringNoUndo(S32 pos, const LLWString &wstr); // returns num of chars actually inserted
347 S32 removeStringNoUndo(S32 pos, S32 length); 365 S32 removeStringNoUndo(S32 pos, S32 length);
348 S32 overwriteCharNoUndo(S32 pos, llwchar wc); 366 S32 overwriteCharNoUndo(S32 pos, llwchar wc);
349 367
350protected: 368 void resetKeystrokeTimer() { mKeystrokeTimer.reset(); }
369
351 void updateAllowingLanguageInput(); 370 void updateAllowingLanguageInput();
352 BOOL hasPreeditString() const; 371 BOOL hasPreeditString() const;
353 372
@@ -360,14 +379,76 @@ protected:
360 virtual void getSelectionRange(S32 *position, S32 *length) const; 379 virtual void getSelectionRange(S32 *position, S32 *length) const;
361 virtual BOOL getPreeditLocation(S32 query_offset, LLCoordGL *coord, LLRect *bounds, LLRect *control) const; 380 virtual BOOL getPreeditLocation(S32 query_offset, LLCoordGL *coord, LLRect *bounds, LLRect *control) const;
362 virtual S32 getPreeditFontSize() const; 381 virtual S32 getPreeditFontSize() const;
382 //
383 // Protected data
384 //
385 // Probably deserves serious thought to hiding as many of these
386 // as possible behind protected accessor methods.
387 //
363 388
364public: 389 // I-beam is just after the mCursorPos-th character.
390 S32 mCursorPos;
391
392 // Use these to determine if a click on an embedded item is a drag or not.
393 S32 mMouseDownX;
394 S32 mMouseDownY;
395
396 // Are we in the middle of a drag-select? To figure out if there is a current
397 // selection, call hasSelection().
398 BOOL mIsSelecting;
399 S32 mSelectionStart;
400 S32 mSelectionEnd;
401 S32 mLastSelectionX;
402 S32 mLastSelectionY;
403
404 BOOL mParseHTML;
405 LLString mHTML;
406
407 typedef std::vector<LLTextSegment *> segment_list_t;
408 segment_list_t mSegments;
409 const LLTextSegment* mHoverSegment;
410
411 // Scrollbar data
412 class LLScrollbar* mScrollbar;
413 BOOL mHideScrollbarForShortDocs;
414 BOOL mTakesNonScrollClicks;
415 void (*mOnScrollEndCallback)(void*);
416 void *mOnScrollEndData;
417
418 LLWString mPreeditWString;
419 LLWString mPreeditOverwrittenWString;
420 std::vector<S32> mPreeditPositions;
421 std::vector<BOOL> mPreeditStandouts;
422
423private:
424
425 //
426 // Methods
427 //
428 void updateSegments();
429 void pruneSegments();
430
431 void drawBackground();
432 void drawSelectionBackground();
433 void drawCursor();
434 void drawText();
435 void drawClippedSegment(const LLWString &wtext, S32 seg_start, S32 seg_end, F32 x, F32 y, S32 selection_left, S32 selection_right, const LLStyle& color, F32* right_x);
436
437 //
438 // Data
439 //
365 LLKeywords mKeywords; 440 LLKeywords mKeywords;
366 static LLColor4 mLinkColor; 441 static LLColor4 mLinkColor;
367 static void (*mURLcallback) (const char* url); 442 static void (*mURLcallback) (const char* url);
368 static bool (*mSecondlifeURLcallback) (const std::string& url); 443 static bool (*mSecondlifeURLcallback) (const std::string& url);
369 static bool (*mSecondlifeURLcallbackRightClick) (const std::string& url); 444 static bool (*mSecondlifeURLcallbackRightClick) (const std::string& url);
370protected: 445
446 // Concrete LLTextCmd sub-classes used by the LLTextEditor base class
447 class LLTextCmdInsert;
448 class LLTextCmdAddChar;
449 class LLTextCmdOverwriteChar;
450 class LLTextCmdRemove;
451
371 LLWString mWText; 452 LLWString mWText;
372 mutable LLString mUTF8Text; 453 mutable LLString mUTF8Text;
373 mutable BOOL mTextIsUpToDate; 454 mutable BOOL mTextIsUpToDate;
@@ -376,8 +457,7 @@ protected:
376 457
377 const LLFontGL* mGLFont; 458 const LLFontGL* mGLFont;
378 459
379 LLScrollbar* mScrollbar; 460 class LLViewBorder* mBorder;
380 LLViewBorder* mBorder;
381 461
382 BOOL mBaseDocIsPristine; 462 BOOL mBaseDocIsPristine;
383 LLTextCmd* mPristineCmd; 463 LLTextCmd* mPristineCmd;
@@ -387,7 +467,6 @@ protected:
387 typedef std::deque<LLTextCmd*> undo_stack_t; 467 typedef std::deque<LLTextCmd*> undo_stack_t;
388 undo_stack_t mUndoStack; 468 undo_stack_t mUndoStack;
389 469
390 S32 mCursorPos; // I-beam is just after the mCursorPos-th character.
391 S32 mDesiredXPixel; // X pixel position where the user wants the cursor to be 470 S32 mDesiredXPixel; // X pixel position where the user wants the cursor to be
392 LLRect mTextRect; // The rect in which text is drawn. Excludes borders. 471 LLRect mTextRect; // The rect in which text is drawn. Excludes borders.
393 // List of offsets and segment index of the start of each line. Always has at least one node (0). 472 // List of offsets and segment index of the start of each line. Always has at least one node (0).
@@ -411,20 +490,7 @@ protected:
411 }; 490 };
412 typedef std::vector<line_info> line_list_t; 491 typedef std::vector<line_info> line_list_t;
413 line_list_t mLineStartList; 492 line_list_t mLineStartList;
414
415 // Are we in the middle of a drag-select? To figure out if there is a current
416 // selection, call hasSelection().
417 BOOL mIsSelecting;
418
419 S32 mSelectionStart;
420 S32 mSelectionEnd;
421
422 void (*mOnScrollEndCallback)(void*);
423 void *mOnScrollEndData;
424 493
425 typedef std::vector<LLTextSegment *> segment_list_t;
426 segment_list_t mSegments;
427 LLTextSegment* mHoverSegment;
428 LLFrameTimer mKeystrokeTimer; 494 LLFrameTimer mKeystrokeTimer;
429 495
430 LLColor4 mCursorColor; 496 LLColor4 mCursorColor;
@@ -439,11 +505,9 @@ protected:
439 BOOL mReadOnly; 505 BOOL mReadOnly;
440 BOOL mWordWrap; 506 BOOL mWordWrap;
441 507
442 BOOL mTabToNextField; // if true, tab moves focus to next field, else inserts spaces 508 BOOL mTabsToNextField; // if true, tab moves focus to next field, else inserts spaces
443 BOOL mCommitOnFocusLost; 509 BOOL mCommitOnFocusLost;
444 BOOL mTakesFocus; 510 BOOL mTakesFocus;
445 BOOL mHideScrollbarForShortDocs;
446 BOOL mTakesNonScrollClicks;
447 BOOL mTrackBottom; // if true, keeps scroll position at bottom during resize 511 BOOL mTrackBottom; // if true, keeps scroll position at bottom during resize
448 BOOL mScrolledToBottom; 512 BOOL mScrolledToBottom;
449 513
@@ -453,24 +517,14 @@ protected:
453 517
454 LLUUID mSourceID; 518 LLUUID mSourceID;
455 519
456 BOOL mHandleEditKeysDirectly; // If true, the standard edit keys (Ctrl-X, Delete, etc,) are handled here instead of routed by the menu system 520 // If true, the standard edit keys (Ctrl-X, Delete, etc,) are handled here
521 //instead of routed by the menu system
522 BOOL mHandleEditKeysDirectly;
457 523
458 // Use these to determine if a click on an embedded item is a drag 524 LLCoordGL mLastIMEPosition; // Last position of the IME editor
459 // or not. 525}; // end class LLTextEditor
460 S32 mMouseDownX;
461 S32 mMouseDownY;
462 526
463 S32 mLastSelectionX;
464 S32 mLastSelectionY;
465 527
466 BOOL mParseHTML;
467 LLString mHTML;
468
469 LLWString mPreeditWString;
470 LLWString mPreeditOverwrittenWString;
471 std::vector<S32> mPreeditPositions;
472 std::vector<BOOL> mPreeditStandouts;
473};
474 528
475class LLTextSegment 529class LLTextSegment
476{ 530{
@@ -482,21 +536,20 @@ public:
482 LLTextSegment( const LLColor4& color, S32 start, S32 end ); 536 LLTextSegment( const LLColor4& color, S32 start, S32 end );
483 LLTextSegment( const LLColor3& color, S32 start, S32 end ); 537 LLTextSegment( const LLColor3& color, S32 start, S32 end );
484 538
485 S32 getStart() { return mStart; } 539 S32 getStart() const { return mStart; }
486 S32 getEnd() { return mEnd; } 540 S32 getEnd() const { return mEnd; }
487 void setEnd( S32 end ) { mEnd = end; } 541 void setEnd( S32 end ) { mEnd = end; }
488 const LLColor4& getColor() { return mStyle.getColor(); } 542 const LLColor4& getColor() const { return mStyle.getColor(); }
489 void setColor(const LLColor4 &color) { mStyle.setColor(color); } 543 void setColor(const LLColor4 &color) { mStyle.setColor(color); }
490 const LLStyle& getStyle() { return mStyle; } 544 const LLStyle& getStyle() const { return mStyle; }
491 void setStyle(const LLStyle &style) { mStyle = style; } 545 void setStyle(const LLStyle &style) { mStyle = style; }
492 void setIsDefault(BOOL b) { mIsDefault = b; } 546 void setIsDefault(BOOL b) { mIsDefault = b; }
493 BOOL getIsDefault() { return mIsDefault; } 547 BOOL getIsDefault() const { return mIsDefault; }
494
495 void setToken( LLKeywordToken* token ) { mToken = token; } 548 void setToken( LLKeywordToken* token ) { mToken = token; }
496 LLKeywordToken* getToken() { return mToken; } 549 LLKeywordToken* getToken() const { return mToken; }
497 BOOL getToolTip( LLString& msg ); 550 BOOL getToolTip( LLString& msg ) const;
498 551
499 void dump(); 552 void dump() const;
500 553
501 struct compare 554 struct compare
502 { 555 {
@@ -514,34 +567,5 @@ private:
514 BOOL mIsDefault; 567 BOOL mIsDefault;
515}; 568};
516 569
517class LLTextCmd
518{
519public:
520 LLTextCmd( S32 pos, BOOL group_with_next )
521 : mPos(pos),
522 mGroupWithNext(group_with_next)
523 {
524 }
525 virtual ~LLTextCmd() {}
526 virtual BOOL execute(LLTextEditor* editor, S32* delta) = 0;
527 virtual S32 undo(LLTextEditor* editor) = 0;
528 virtual S32 redo(LLTextEditor* editor) = 0;
529 virtual BOOL canExtend(S32 pos);
530 virtual void blockExtensions();
531 virtual BOOL extendAndExecute( LLTextEditor* editor, S32 pos, llwchar c, S32* delta );
532 virtual BOOL hasExtCharValue( llwchar value );
533
534 // Define these here so they can access LLTextEditor through the friend relationship
535 S32 insert(LLTextEditor* editor, S32 pos, const LLWString &wstr);
536 S32 remove(LLTextEditor* editor, S32 pos, S32 length);
537 S32 overwrite(LLTextEditor* editor, S32 pos, llwchar wc);
538
539 BOOL groupWithNext() { return mGroupWithNext; }
540
541protected:
542 S32 mPos;
543 BOOL mGroupWithNext;
544};
545
546 570
547#endif // LL_TEXTEDITOR_ 571#endif // LL_TEXTEDITOR_