MAINT-3967 FIXED Up arrow key does not move the cursor up in chat field.

Reverted previous two fixes and modified LLTextBase::changeLine()
andreykproductengine 2014-08-28 19:36:47 +03:00
parent 3656d80cf8
commit 208fe31200
3 changed files with 11 additions and 88 deletions

View File

@ -218,8 +218,7 @@ LLTextBase::LLTextBase(const LLTextBase::Params &p)
mParseHighlights(p.parse_highlights),
mBGVisible(p.bg_visible),
mScroller(NULL),
mStyleDirty(true),
mDrawRightmostCursor(false)
mStyleDirty(true)
{
if(p.allow_scroll)
{
@ -1505,11 +1504,6 @@ void LLTextBase::reflow()
// find and erase line info structs starting at start_index and going to end of document
if (!mLineInfoList.empty())
{
if (mDrawRightmostCursor)
{
start_index--;
}
// find first element whose end comes after start_index
line_list_t::iterator iter = std::upper_bound(mLineInfoList.begin(), mLineInfoList.end(), start_index, line_end_compare());
line_start_index = iter->mDocIndexStart;
@ -1698,11 +1692,6 @@ S32 LLTextBase::getLineNumFromDocIndex( S32 doc_index, bool include_wordwrap) co
}
else
{
if (mDrawRightmostCursor)
{
doc_index--;
}
line_list_t::const_iterator iter = std::upper_bound(mLineInfoList.begin(), mLineInfoList.end(), doc_index, line_end_compare());
if (include_wordwrap)
{
@ -1731,11 +1720,6 @@ S32 LLTextBase::getLineOffsetFromDocIndex( S32 startpos, bool include_wordwrap)
}
else
{
if (mDrawRightmostCursor)
{
startpos--;
}
line_list_t::const_iterator iter = std::upper_bound(mLineInfoList.begin(), mLineInfoList.end(), startpos, line_end_compare());
return startpos - iter->mDocIndexStart;
}
@ -2456,7 +2440,7 @@ S32 LLTextBase::getDocIndexFromLocalCoord( S32 local_x, S32 local_y, BOOL round,
}
else if (hit_past_end_of_line && segmentp->getEnd() >= line_iter->mDocIndexEnd)
{
if (getLineNumFromDocIndex(line_iter->mDocIndexEnd - 1) == line_iter->mLineNum && !mDrawRightmostCursor)
if (getLineNumFromDocIndex(line_iter->mDocIndexEnd - 1) == line_iter->mLineNum)
{
// if segment wraps to the next line we should step one char back
// to compensate for the space char between words
@ -2489,13 +2473,7 @@ LLRect LLTextBase::getDocRectFromDocIndex(S32 pos) const
// clamp pos to valid values
pos = llclamp(pos, 0, mLineInfoList.back().mDocIndexEnd - 1);
S32 corrected_pos = pos;
if (mDrawRightmostCursor && pos > 0)
{
corrected_pos--;
}
line_list_t::const_iterator line_iter = std::upper_bound(mLineInfoList.begin(), mLineInfoList.end(), corrected_pos, line_end_compare());
line_list_t::const_iterator line_iter = std::upper_bound(mLineInfoList.begin(), mLineInfoList.end(), pos, line_end_compare());
doc_rect.mLeft = line_iter->mRect.mLeft;
doc_rect.mBottom = line_iter->mRect.mBottom;
@ -2670,6 +2648,12 @@ void LLTextBase::changeLine( S32 delta )
LLRect visible_region = getVisibleDocumentRect();
S32 new_cursor_pos = getDocIndexFromLocalCoord(mDesiredXPixel,
mLineInfoList[new_line].mRect.mBottom + mVisibleTextRect.mBottom - visible_region.mBottom, TRUE);
S32 actual_line = getLineNumFromDocIndex(new_cursor_pos);
if (actual_line != new_line)
{
// line edge, correcting position by 1 to move onto proper line
new_cursor_pos += new_line - actual_line;
}
setCursorPos(new_cursor_pos, true);
}
}

View File

@ -618,7 +618,6 @@ protected:
// cursor
S32 mCursorPos; // I-beam is just after the mCursorPos-th character.
bool mDrawRightmostCursor; // When cursor is on the rightmost position on the line
S32 mDesiredXPixel; // X pixel position where the user wants the cursor to be
LLFrameTimer mCursorBlinkTimer; // timer that controls cursor blinking

View File

@ -1124,13 +1124,6 @@ void LLTextEditor::addChar(llwchar wc)
setCursorPos(new_cursor_pos);
}
}
if (mCursorPos > 0)
{
LLRect current_cursor_rect = getDocRectFromDocIndex(mCursorPos);
LLRect prev_cursor_rect = getDocRectFromDocIndex(mCursorPos - 1);
mDrawRightmostCursor = current_cursor_rect.mBottom < prev_cursor_rect.mBottom;
}
}
void LLTextEditor::addLineBreakChar(BOOL group_together)
@ -1277,12 +1270,6 @@ BOOL LLTextEditor::handleNavigationKey(const KEY key, const MASK mask)
break;
case KEY_HOME:
if(mDrawRightmostCursor && mCursorPos > 0)
{
mCursorPos--;
mDrawRightmostCursor = false;
}
startOfLine();
break;
@ -1297,23 +1284,6 @@ BOOL LLTextEditor::handleNavigationKey(const KEY key, const MASK mask)
case KEY_END:
endOfLine();
{
S32 last_line_index = mLineInfoList.size() - 1;
if (getLineNumFromDocIndex(mCursorPos, true) < last_line_index)
{
mDrawRightmostCursor = true;
setCursorPos(mCursorPos + 1);
}
else if (last_line_index > 0) // only for two and more lines
{
S32 prev_line_width = mLineInfoList[last_line_index - 1].mRect.getWidth();
S32 last_line_width = mLineInfoList[last_line_index].mRect.getWidth();
if (prev_line_width <= last_line_width)
{
mDrawRightmostCursor = true;
}
}
}
break;
case KEY_LEFT:
@ -1325,18 +1295,7 @@ BOOL LLTextEditor::handleNavigationKey(const KEY key, const MASK mask)
{
if( 0 < mCursorPos )
{
LLRect current_cursor_rect = getDocRectFromDocIndex(mCursorPos);
LLRect next_cursor_rect = getDocRectFromDocIndex(mCursorPos - 1);
if (current_cursor_rect.mBottom < next_cursor_rect.mBottom)
{
mDrawRightmostCursor = true;
}
else
{
mDrawRightmostCursor = false;
setCursorPos(mCursorPos - 1);
}
setCursorPos(mCursorPos - 1);
}
else
{
@ -1354,26 +1313,7 @@ BOOL LLTextEditor::handleNavigationKey(const KEY key, const MASK mask)
{
if( mCursorPos < getLength() )
{
LLRect current_cursor_rect = getDocRectFromDocIndex(mCursorPos);
LLRect next_cursor_rect = getDocRectFromDocIndex(mCursorPos + 1);
if (current_cursor_rect.mBottom > next_cursor_rect.mBottom)
{
if (mDrawRightmostCursor)
{
mDrawRightmostCursor = false;
}
else
{
mDrawRightmostCursor = true;
setCursorPos(mCursorPos + 1);
}
}
else
{
mDrawRightmostCursor = false;
setCursorPos(mCursorPos + 1);
}
setCursorPos(mCursorPos + 1);
}
else
{