diff options
author | Loren Shih <seraph@lindenlab.com> | 2010-11-08 12:57:26 -0500 |
---|---|---|
committer | Loren Shih <seraph@lindenlab.com> | 2010-11-08 12:57:26 -0500 |
commit | a5e63b1dc0ce6c706de46dfea10784838e2d0257 (patch) | |
tree | 15c7d26720fe56bfc6adf796b20af4e3a5e94110 /indra/llui/lltextbase.cpp | |
parent | b3ab10923d74e64e543b15d773639a856f9989e7 (diff) | |
parent | 124a59263184391b0b4ec418c532b7a715e9b5a3 (diff) |
Merge
Diffstat (limited to 'indra/llui/lltextbase.cpp')
-rw-r--r-- | indra/llui/lltextbase.cpp | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp index d58e4808df..f85cfa902f 100644 --- a/indra/llui/lltextbase.cpp +++ b/indra/llui/lltextbase.cpp @@ -2216,19 +2216,39 @@ bool LLTextBase::scrolledToEnd() return mScroller->isAtBottom(); } - bool LLTextBase::setCursor(S32 row, S32 column) { - if (0 <= row && row < (S32)mLineInfoList.size()) + if (row < 0 || column < 0) return false; + + S32 n_lines = mLineInfoList.size(); + for (S32 line = row; line < n_lines; ++line) { - S32 doc_pos = mLineInfoList[row].mDocIndexStart; - column = llclamp(column, 0, mLineInfoList[row].mDocIndexEnd - mLineInfoList[row].mDocIndexStart - 1); - doc_pos += column; - updateCursorXPos(); + const line_info& li = mLineInfoList[line]; + + if (li.mLineNum < row) + { + continue; + } + else if (li.mLineNum > row) + { + break; // invalid column specified + } + + // Found the given row. + S32 line_length = li.mDocIndexEnd - li.mDocIndexStart;; + if (column >= line_length) + { + column -= line_length; + continue; + } + // Found the given column. + updateCursorXPos(); + S32 doc_pos = li.mDocIndexStart + column; return setCursorPos(doc_pos); } - return false; + + return false; // invalid row or column specified } |