diff options
author | McCabe Maxsted | 2010-03-04 13:16:28 -0700 |
---|---|---|
committer | Jacek Antonelli | 2010-03-11 19:03:52 -0600 |
commit | 1ddfb4c5dd436fc1a9a867d0a2b9980483a3d3fd (patch) | |
tree | 4ce9ece8150a60ab7292bd6cef3ff3c0dfcc4025 /linden/indra/llui/lltexteditor.cpp | |
parent | Applied UnknownJointsCrashFix v2 from Cool Viewer. (diff) | |
download | meta-impy-1ddfb4c5dd436fc1a9a867d0a2b9980483a3d3fd.zip meta-impy-1ddfb4c5dd436fc1a9a867d0a2b9980483a3d3fd.tar.gz meta-impy-1ddfb4c5dd436fc1a9a867d0a2b9980483a3d3fd.tar.bz2 meta-impy-1ddfb4c5dd436fc1a9a867d0a2b9980483a3d3fd.tar.xz |
Applied Kitty Barnett's patch for Search/Replace in notecards.
Diffstat (limited to 'linden/indra/llui/lltexteditor.cpp')
-rw-r--r-- | linden/indra/llui/lltexteditor.cpp | 72 |
1 files changed, 39 insertions, 33 deletions
diff --git a/linden/indra/llui/lltexteditor.cpp b/linden/indra/llui/lltexteditor.cpp index 7c05239..b0229be 100644 --- a/linden/indra/llui/lltexteditor.cpp +++ b/linden/indra/llui/lltexteditor.cpp | |||
@@ -648,6 +648,7 @@ void LLTextEditor::selectNext(const std::string& search_text_in, BOOL case_insen | |||
648 | } | 648 | } |
649 | 649 | ||
650 | setCursorPos(loc); | 650 | setCursorPos(loc); |
651 | scrollToPos(mCursorPos); | ||
651 | 652 | ||
652 | mIsSelecting = TRUE; | 653 | mIsSelecting = TRUE; |
653 | mSelectionEnd = mCursorPos; | 654 | mSelectionEnd = mCursorPos; |
@@ -3413,6 +3414,43 @@ void LLTextEditor::setCursorAndScrollToEnd() | |||
3413 | needsScroll(); | 3414 | needsScroll(); |
3414 | } | 3415 | } |
3415 | 3416 | ||
3417 | void LLTextEditor::scrollToPos(S32 pos) | ||
3418 | { | ||
3419 | mScrollbar->setDocSize( getLineCount() ); | ||
3420 | |||
3421 | S32 line, offset; | ||
3422 | getLineAndOffset(pos, &line, &offset ); | ||
3423 | |||
3424 | S32 page_size = mScrollbar->getPageSize(); | ||
3425 | |||
3426 | if( line < mScrollbar->getDocPos() ) | ||
3427 | { | ||
3428 | // scroll so that the cursor is at the top of the page | ||
3429 | mScrollbar->setDocPos( line ); | ||
3430 | } | ||
3431 | else if( line >= mScrollbar->getDocPos() + page_size - 1 ) | ||
3432 | { | ||
3433 | S32 new_pos = 0; | ||
3434 | if( line < mScrollbar->getDocSize() - 1 ) | ||
3435 | { | ||
3436 | // scroll so that the cursor is one line above the bottom of the page, | ||
3437 | new_pos = line - page_size + 1; | ||
3438 | } | ||
3439 | else | ||
3440 | { | ||
3441 | // if there is less than a page of text remaining, scroll so that the cursor is at the bottom | ||
3442 | new_pos = mScrollbar->getDocPosMax(); | ||
3443 | } | ||
3444 | mScrollbar->setDocPos( new_pos ); | ||
3445 | } | ||
3446 | |||
3447 | // Check if we've scrolled to bottom for callback if asked for callback | ||
3448 | if (mOnScrollEndCallback && mOnScrollEndData && (mScrollbar->getDocPos() == mScrollbar->getDocPosMax())) | ||
3449 | { | ||
3450 | mOnScrollEndCallback(mOnScrollEndData); | ||
3451 | } | ||
3452 | } | ||
3453 | |||
3416 | void LLTextEditor::getLineAndColumnForPosition( S32 position, S32* line, S32* col, BOOL include_wordwrap ) | 3454 | void LLTextEditor::getLineAndColumnForPosition( S32 position, S32* line, S32* col, BOOL include_wordwrap ) |
3417 | { | 3455 | { |
3418 | if( include_wordwrap ) | 3456 | if( include_wordwrap ) |
@@ -3490,45 +3528,13 @@ void LLTextEditor::endOfDoc() | |||
3490 | // Sets the scrollbar from the cursor position | 3528 | // Sets the scrollbar from the cursor position |
3491 | void LLTextEditor::updateScrollFromCursor() | 3529 | void LLTextEditor::updateScrollFromCursor() |
3492 | { | 3530 | { |
3493 | mScrollbar->setDocSize( getLineCount() ); | ||
3494 | |||
3495 | if (mReadOnly) | 3531 | if (mReadOnly) |
3496 | { | 3532 | { |
3497 | // no cursor in read only mode | 3533 | // no cursor in read only mode |
3498 | return; | 3534 | return; |
3499 | } | 3535 | } |
3500 | 3536 | ||
3501 | S32 line, offset; | 3537 | scrollToPos(mCursorPos); |
3502 | getLineAndOffset( mCursorPos, &line, &offset ); | ||
3503 | |||
3504 | S32 page_size = mScrollbar->getPageSize(); | ||
3505 | |||
3506 | if( line < mScrollbar->getDocPos() ) | ||
3507 | { | ||
3508 | // scroll so that the cursor is at the top of the page | ||
3509 | mScrollbar->setDocPos( line ); | ||
3510 | } | ||
3511 | else if( line >= mScrollbar->getDocPos() + page_size - 1 ) | ||
3512 | { | ||
3513 | S32 new_pos = 0; | ||
3514 | if( line < mScrollbar->getDocSize() - 1 ) | ||
3515 | { | ||
3516 | // scroll so that the cursor is one line above the bottom of the page, | ||
3517 | new_pos = line - page_size + 1; | ||
3518 | } | ||
3519 | else | ||
3520 | { | ||
3521 | // if there is less than a page of text remaining, scroll so that the cursor is at the bottom | ||
3522 | new_pos = mScrollbar->getDocPosMax(); | ||
3523 | } | ||
3524 | mScrollbar->setDocPos( new_pos ); | ||
3525 | } | ||
3526 | |||
3527 | // Check if we've scrolled to bottom for callback if asked for callback | ||
3528 | if (mOnScrollEndCallback && mOnScrollEndData && (mScrollbar->getDocPos() == mScrollbar->getDocPosMax())) | ||
3529 | { | ||
3530 | mOnScrollEndCallback(mOnScrollEndData); | ||
3531 | } | ||
3532 | } | 3538 | } |
3533 | 3539 | ||
3534 | void LLTextEditor::reshape(S32 width, S32 height, BOOL called_from_parent) | 3540 | void LLTextEditor::reshape(S32 width, S32 height, BOOL called_from_parent) |