diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp index b12b6f5573e12ad9c1b3773aa332479ff61e7e61..bcafe27443fd839df6a74c033d36e81e217eae14 100644 --- a/indra/llui/lltextbase.cpp +++ b/indra/llui/lltextbase.cpp @@ -1764,7 +1764,10 @@ void LLTextBase::clearSegments() createDefaultSegment(); } -S32 LLTextBase::getLineStart( S32 line ) const +//S32 LLTextBase::getLineStart( S32 line ) const +// [SL:KB] - Patch: Control-TextEditor | Checked: 2013-12-31 (Catznip-3.6) +S32 LLTextBase::getLineStart(S32 line, bool include_wordwrap) const +// [/SL:KB] { S32 num_lines = getLineCount(); if (num_lines == 0) @@ -1772,6 +1775,21 @@ S32 LLTextBase::getLineStart( S32 line ) const return 0; } +// [SL:KB] - Patch: Control-TextEditor | Checked: 2013-12-31 (Catznip-3.6) + if (!include_wordwrap) + { + for (S32 line_it = line; line_it < num_lines; ++line_it) + { + const line_info& liLine = mLineInfoList[line_it]; + if (liLine.mLineNum == line) + { + line = line_it; + break; + } + } + } +// [/SL:KB] + line = llclamp(line, 0, num_lines-1); return mLineInfoList[line].mDocIndexStart; } @@ -2828,6 +2846,41 @@ void LLTextBase::changeLine( S32 delta ) } } +// [SL:KB] - Patch: Control-TextEditor | Checked: 2013-12-31 (Catznip-3.6) +void LLTextBase::scrollTo(S32 nLine, S32 nColumn) +{ + // Make sure we have an up-to-date mLineInfoList + reflow(); + + LLRect rctVisible = getVisibleDocumentRect(); + line_list_t::const_iterator itFirst = std::lower_bound(mLineInfoList.begin(), mLineInfoList.end(), rctVisible.mTop, compare_top()); + line_list_t::const_iterator itLast = std::upper_bound(mLineInfoList.begin(), mLineInfoList.end(), rctVisible.mBottom, compare_bottom()); + + // We'd like to scroll to three lines above, or three lines below the requested line + S32 nScrollPos = mCursorPos; + if (itFirst->mLineNum + 3 > nLine) + { + // Scroll up + nScrollPos = getLineStart(llmax(0, nLine - 3), false); + } + else if (itLast->mLineNum - 3 < nLine) + { + // Scroll down + nScrollPos = getLineStart(llmin(nLine + 3, getLineCount()), false); + } + + if ( (mScroller) && (nScrollPos != mCursorPos) ) + { + // Scroll so that the cursor is at the top of the page + LLRect rctDesired = getDocRectFromDocIndex(nScrollPos); + mScroller->scrollToShowRect(rctDesired, LLRect(0, rctVisible.getHeight() - 5, rctVisible.getWidth(), 5)); + } + + setCursor(nLine, nColumn); + mScrollNeeded = FALSE; +} +// [/SL:KB + bool LLTextBase::scrolledToStart() { return mScroller->isAtTop(); diff --git a/indra/llui/lltextbase.h b/indra/llui/lltextbase.h index 5d9c15bb19b06429302c0503056f2db3ea3eee78..c6a2c812fd31861fee8cd17797ea2d98ba07efeb 100644 --- a/indra/llui/lltextbase.h +++ b/indra/llui/lltextbase.h @@ -472,6 +472,9 @@ class LLTextBase void endOfDoc(); void changePage( S32 delta ); void changeLine( S32 delta ); +// [SL:KB] - Patch: Control-TextEditor | Checked: 2013-12-31 (Catznip-3.6) + void scrollTo(S32 nLine, S32 nColumn); +// [/SL:KB bool scrolledToStart(); bool scrolledToEnd(); @@ -596,7 +599,13 @@ class LLTextBase const LLStyle::Params& getStyleParams(); // manage lines - S32 getLineStart( S32 line ) const; +// [SL:KB] - Patch: Control-TextEditor | Checked: Catznip-5.2 +public: +// [/SL:KB +// S32 getLineStart( S32 line ) const; +// [SL:KB] - Patch: Control-TextEditor | Checked: 2013-12-31 (Catznip-3.6) + S32 getLineStart(S32 line, bool include_wordwrap = true) const; +// [/SL:KB] S32 getLineEnd( S32 line ) const; S32 getLineNumFromDocIndex( S32 doc_index, bool include_wordwrap = true) const; S32 getLineOffsetFromDocIndex( S32 doc_index, bool include_wordwrap = true) const; diff --git a/indra/newview/llfloatergotoline.cpp b/indra/newview/llfloatergotoline.cpp index 3b34f035321cccc95c95cb6cb965f5067e61ae41..ad690b4ad5a6dc0e136817807d878183ea3d0615 100644 --- a/indra/newview/llfloatergotoline.cpp +++ b/indra/newview/llfloatergotoline.cpp @@ -110,7 +110,10 @@ void LLFloaterGotoLine::handleBtnGoto() if (mEditorCore && mEditorCore->mEditor) { mEditorCore->mEditor->deselect(); - mEditorCore->mEditor->setCursor(row, column); +// [SL:KB] - Patch: UI-ScriptGoToLine | Checked: 2013-12-31 (Catznip-3.6) + mEditorCore->mEditor->scrollTo(row, column); +// [/SL:KB] +// mEditorCore->mEditor->setCursor(row, column); mEditorCore->mEditor->setFocus(TRUE); } } @@ -144,7 +147,10 @@ void LLFloaterGotoLine::onGotoBoxCommit() { if (mEditorCore && mEditorCore->mEditor) { - mEditorCore->mEditor->setCursor(row, column); +// [SL:KB] - Patch: UI-ScriptGoToLine | Checked: 2013-12-31 (Catznip-3.6) + mEditorCore->mEditor->scrollTo(row, column); +// [/SL:KB] +// mEditorCore->mEditor->setCursor(row, column); S32 rownew = 0; S32 columnnew = 0; diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index e0aba6610603959a9a87075b8b489446b5b8f530..3407ca9dd013a2ff2475e8232a2211b5cbef4631 100644 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -1108,7 +1108,10 @@ void LLScriptEdCore::onErrorList(LLUICtrl*, void* user_data) sscanf(line.c_str(), "%d %d", &row, &column); //LL_INFOS() << "LLScriptEdCore::onErrorList() - " << row << ", " //<< column << LL_ENDL; - self->mEditor->setCursor(row, column); +// [SL:KB] - Patch: UI-ScriptGoToLine | Checked: 2013-12-31 (Catznip-3.6) + self->mEditor->scrollTo(row, column); +// [/SL:KB] +// self->mEditor->setCursor(row, column); self->mEditor->setFocus(TRUE); } }