summaryrefslogtreecommitdiff
path: root/indra/llui/lltexteditor.cpp
diff options
context:
space:
mode:
authorRichard Nelson <richard@lindenlab.com>2007-04-05 00:59:55 +0000
committerRichard Nelson <richard@lindenlab.com>2007-04-05 00:59:55 +0000
commit2ce0fc5f185f22be79b9be5406b76c97ed91ee01 (patch)
treed70ea9faf02e4e1e7aeb14aa524644c23c703d55 /indra/llui/lltexteditor.cpp
parentfd5608a3e79397d4ebc8819dc9de75863f6fb9b3 (diff)
svn merge -r 59234:60086 svn+ssh://svn/svn/linden/branches/live_lsl_help2 -> release
Diffstat (limited to 'indra/llui/lltexteditor.cpp')
-rw-r--r--indra/llui/lltexteditor.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/indra/llui/lltexteditor.cpp b/indra/llui/lltexteditor.cpp
index 366b1956c4..651a421742 100644
--- a/indra/llui/lltexteditor.cpp
+++ b/indra/llui/lltexteditor.cpp
@@ -793,6 +793,31 @@ LLWString LLTextEditor::getWSubString(S32 pos, S32 len)
return mWText.substr(pos, len);
}
+LLTextSegment* LLTextEditor::getCurrentSegment()
+{
+ return getSegmentAtOffset(mCursorPos);
+}
+
+LLTextSegment* LLTextEditor::getPreviousSegment()
+{
+ // find segment index at character to left of cursor (or rightmost edge of selection)
+ S32 idx = llmax(0, getSegmentIdxAtOffset(mCursorPos) - 1);
+ return idx >= 0 ? mSegments[idx] : NULL;
+}
+
+void LLTextEditor::getSelectedSegments(std::vector<LLTextSegment*>& segments)
+{
+ S32 left = hasSelection() ? llmin(mSelectionStart, mSelectionEnd) : mCursorPos;
+ S32 right = hasSelection() ? llmax(mSelectionStart, mSelectionEnd) : mCursorPos;
+ S32 first_idx = llmax(0, getSegmentIdxAtOffset(left));
+ S32 last_idx = llmax(0, first_idx, getSegmentIdxAtOffset(right));
+
+ for (S32 idx = first_idx; idx <= last_idx; ++idx)
+ {
+ segments.push_back(mSegments[idx]);
+ }
+}
+
S32 LLTextEditor::getCursorPosFromLocalCoord( S32 local_x, S32 local_y, BOOL round )
{
// If round is true, if the position is on the right half of a character, the cursor