diff options
Diffstat (limited to 'linden/indra/llui/lltexteditor.cpp')
-rw-r--r-- | linden/indra/llui/lltexteditor.cpp | 42 |
1 files changed, 34 insertions, 8 deletions
diff --git a/linden/indra/llui/lltexteditor.cpp b/linden/indra/llui/lltexteditor.cpp index 8f22545..787eba5 100644 --- a/linden/indra/llui/lltexteditor.cpp +++ b/linden/indra/llui/lltexteditor.cpp | |||
@@ -4,6 +4,7 @@ | |||
4 | * | 4 | * |
5 | * Copyright (c) 2001-2007, Linden Research, Inc. | 5 | * Copyright (c) 2001-2007, Linden Research, Inc. |
6 | * | 6 | * |
7 | * Second Life Viewer Source Code | ||
7 | * The source code in this file ("Source Code") is provided by Linden Lab | 8 | * The source code in this file ("Source Code") is provided by Linden Lab |
8 | * to you under the terms of the GNU General Public License, version 2.0 | 9 | * to you under the terms of the GNU General Public License, version 2.0 |
9 | * ("GPL"), unless you have obtained a separate licensing agreement | 10 | * ("GPL"), unless you have obtained a separate licensing agreement |
@@ -812,6 +813,31 @@ LLWString LLTextEditor::getWSubString(S32 pos, S32 len) | |||
812 | return mWText.substr(pos, len); | 813 | return mWText.substr(pos, len); |
813 | } | 814 | } |
814 | 815 | ||
816 | LLTextSegment* LLTextEditor::getCurrentSegment() | ||
817 | { | ||
818 | return getSegmentAtOffset(mCursorPos); | ||
819 | } | ||
820 | |||
821 | LLTextSegment* LLTextEditor::getPreviousSegment() | ||
822 | { | ||
823 | // find segment index at character to left of cursor (or rightmost edge of selection) | ||
824 | S32 idx = llmax(0, getSegmentIdxAtOffset(mCursorPos) - 1); | ||
825 | return idx >= 0 ? mSegments[idx] : NULL; | ||
826 | } | ||
827 | |||
828 | void LLTextEditor::getSelectedSegments(std::vector<LLTextSegment*>& segments) | ||
829 | { | ||
830 | S32 left = hasSelection() ? llmin(mSelectionStart, mSelectionEnd) : mCursorPos; | ||
831 | S32 right = hasSelection() ? llmax(mSelectionStart, mSelectionEnd) : mCursorPos; | ||
832 | S32 first_idx = llmax(0, getSegmentIdxAtOffset(left)); | ||
833 | S32 last_idx = llmax(0, first_idx, getSegmentIdxAtOffset(right)); | ||
834 | |||
835 | for (S32 idx = first_idx; idx <= last_idx; ++idx) | ||
836 | { | ||
837 | segments.push_back(mSegments[idx]); | ||
838 | } | ||
839 | } | ||
840 | |||
815 | S32 LLTextEditor::getCursorPosFromLocalCoord( S32 local_x, S32 local_y, BOOL round ) | 841 | S32 LLTextEditor::getCursorPosFromLocalCoord( S32 local_x, S32 local_y, BOOL round ) |
816 | { | 842 | { |
817 | // If round is true, if the position is on the right half of a character, the cursor | 843 | // If round is true, if the position is on the right half of a character, the cursor |
@@ -1201,7 +1227,7 @@ BOOL LLTextEditor::handleMouseDown(S32 x, S32 y, MASK mask) | |||
1201 | setCursorAtLocalPos( x, y, TRUE ); | 1227 | setCursorAtLocalPos( x, y, TRUE ); |
1202 | startSelection(); | 1228 | startSelection(); |
1203 | } | 1229 | } |
1204 | gFocusMgr.setMouseCapture( this, &LLTextEditor::onMouseCaptureLost ); | 1230 | gFocusMgr.setMouseCapture( this ); |
1205 | } | 1231 | } |
1206 | 1232 | ||
1207 | handled = TRUE; | 1233 | handled = TRUE; |
@@ -1227,7 +1253,7 @@ BOOL LLTextEditor::handleHover(S32 x, S32 y, MASK mask) | |||
1227 | mHoverSegment = NULL; | 1253 | mHoverSegment = NULL; |
1228 | if( getVisible() ) | 1254 | if( getVisible() ) |
1229 | { | 1255 | { |
1230 | if(gFocusMgr.getMouseCapture() == this ) | 1256 | if(hasMouseCapture() ) |
1231 | { | 1257 | { |
1232 | if( mIsSelecting ) | 1258 | if( mIsSelecting ) |
1233 | { | 1259 | { |
@@ -1360,9 +1386,9 @@ BOOL LLTextEditor::handleMouseUp(S32 x, S32 y, MASK mask) | |||
1360 | // Delay cursor flashing | 1386 | // Delay cursor flashing |
1361 | mKeystrokeTimer.reset(); | 1387 | mKeystrokeTimer.reset(); |
1362 | 1388 | ||
1363 | if( gFocusMgr.getMouseCapture() == this ) | 1389 | if( hasMouseCapture() ) |
1364 | { | 1390 | { |
1365 | gFocusMgr.setMouseCapture( NULL, NULL ); | 1391 | gFocusMgr.setMouseCapture( NULL ); |
1366 | handled = TRUE; | 1392 | handled = TRUE; |
1367 | } | 1393 | } |
1368 | 1394 | ||
@@ -2473,6 +2499,8 @@ void LLTextEditor::onFocusLost() | |||
2473 | 2499 | ||
2474 | // Make sure cursor is shown again | 2500 | // Make sure cursor is shown again |
2475 | getWindow()->showCursorFromMouseMove(); | 2501 | getWindow()->showCursorFromMouseMove(); |
2502 | |||
2503 | LLUICtrl::onFocusLost(); | ||
2476 | } | 2504 | } |
2477 | 2505 | ||
2478 | void LLTextEditor::setEnabled(BOOL enabled) | 2506 | void LLTextEditor::setEnabled(BOOL enabled) |
@@ -3753,11 +3781,9 @@ S32 LLTextEditor::getSegmentIdxAtOffset(S32 offset) | |||
3753 | } | 3781 | } |
3754 | } | 3782 | } |
3755 | 3783 | ||
3756 | //static | 3784 | void LLTextEditor::onMouseCaptureLost() |
3757 | void LLTextEditor::onMouseCaptureLost( LLMouseHandler* old_captor ) | ||
3758 | { | 3785 | { |
3759 | LLTextEditor* self = (LLTextEditor*) old_captor; | 3786 | endSelection(); |
3760 | self->endSelection(); | ||
3761 | } | 3787 | } |
3762 | 3788 | ||
3763 | void LLTextEditor::setOnScrollEndCallback(void (*callback)(void*), void* userdata) | 3789 | void LLTextEditor::setOnScrollEndCallback(void (*callback)(void*), void* userdata) |