aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llui/lllineeditor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llui/lllineeditor.cpp')
-rw-r--r--linden/indra/llui/lllineeditor.cpp56
1 files changed, 54 insertions, 2 deletions
diff --git a/linden/indra/llui/lllineeditor.cpp b/linden/indra/llui/lllineeditor.cpp
index 98286fa..dca62d7 100644
--- a/linden/indra/llui/lllineeditor.cpp
+++ b/linden/indra/llui/lllineeditor.cpp
@@ -138,6 +138,8 @@ LLLineEditor::LLLineEditor(const LLString& name, const LLRect& rect,
138 mSelectionEnd( 0 ), 138 mSelectionEnd( 0 ),
139 mLastSelectionX(-1), 139 mLastSelectionX(-1),
140 mLastSelectionY(-1), 140 mLastSelectionY(-1),
141 mLastSelectionStart(-1),
142 mLastSelectionEnd(-1),
141 mPrevalidateFunc( prevalidate_func ), 143 mPrevalidateFunc( prevalidate_func ),
142 mCursorColor( LLUI::sColorsGroup->getColor( "TextCursorColor" ) ), 144 mCursorColor( LLUI::sColorsGroup->getColor( "TextCursorColor" ) ),
143 mFgColor( LLUI::sColorsGroup->getColor( "TextFgColor" ) ), 145 mFgColor( LLUI::sColorsGroup->getColor( "TextFgColor" ) ),
@@ -247,6 +249,19 @@ void LLLineEditor::onCommit()
247 selectAll(); 249 selectAll();
248} 250}
249 251
252// virtual
253BOOL LLLineEditor::isDirty() const
254{
255 return ( mText.getString() != mPrevText );
256}
257
258// virtual
259void LLLineEditor::resetDirty()
260{
261 mPrevText = mText.getString();
262}
263
264
250// line history support 265// line history support
251void LLLineEditor::updateHistory() 266void LLLineEditor::updateHistory()
252{ 267{
@@ -468,8 +483,38 @@ BOOL LLLineEditor::handleDoubleClick(S32 x, S32 y, MASK mask)
468 } 483 }
469 else 484 else
470 { 485 {
471 // otherwise select everything 486 const LLWString& wtext = mText.getWString();
472 selectAll(); 487
488 BOOL doSelectAll = TRUE;
489
490 // Select the word we're on
491 if( isPartOfWord( wtext[mCursorPos] ) )
492 {
493 S32 old_selection_start = mLastSelectionStart;
494 S32 old_selection_end = mLastSelectionEnd;
495
496 // Select word the cursor is over
497 while ((mCursorPos > 0) && isPartOfWord( wtext[mCursorPos-1] ))
498 { // Find the start of the word
499 mCursorPos--;
500 }
501 startSelection();
502
503 while ((mCursorPos < (S32)wtext.length()) && isPartOfWord( wtext[mCursorPos] ) )
504 { // Find the end of the word
505 mCursorPos++;
506 }
507 mSelectionEnd = mCursorPos;
508
509 // If nothing changed, then the word was already selected. Select the whole line.
510 doSelectAll = (old_selection_start == mSelectionStart) &&
511 (old_selection_end == mSelectionEnd);
512 }
513
514 if ( doSelectAll )
515 { // Select everything
516 selectAll();
517 }
473 } 518 }
474 519
475 // We don't want handleMouseUp() to "finish" the selection (and thereby 520 // We don't want handleMouseUp() to "finish" the selection (and thereby
@@ -496,6 +541,9 @@ BOOL LLLineEditor::handleMouseDown(S32 x, S32 y, MASK mask)
496 } 541 }
497 else 542 else
498 { 543 {
544 mLastSelectionStart = -1;
545 mLastSelectionStart = -1;
546
499 setFocus( TRUE ); 547 setFocus( TRUE );
500 548
501 if (mask & MASK_SHIFT) 549 if (mask & MASK_SHIFT)
@@ -539,6 +587,10 @@ BOOL LLLineEditor::handleMouseDown(S32 x, S32 y, MASK mask)
539 } 587 }
540 else 588 else
541 { 589 {
590 // Save selection for word/line selecting on double-click
591 mLastSelectionStart = mSelectionStart;
592 mLastSelectionEnd = mSelectionEnd;
593
542 // Move cursor and deselect for regular click 594 // Move cursor and deselect for regular click
543 setCursorAtLocalPos( x ); 595 setCursorAtLocalPos( x );
544 deselect(); 596 deselect();