diff options
author | simon <none@none> | 2013-08-26 15:45:09 -0700 |
---|---|---|
committer | simon <none@none> | 2013-08-26 15:45:09 -0700 |
commit | 90d1c5b3676fe4e8ea8668b41fdf92613d5f102d (patch) | |
tree | 8d5afd9678fd44444bcc7b5d311b5cfb7abe5217 /indra/llui/lltexteditor.cpp | |
parent | ac2dc34ed0abbac8d5a8eb7f887037fe387c6a7a (diff) | |
parent | 27d637d0f14fdfff496256222dc1343d2d7ee9ae (diff) |
Merge downstream code for CHUIStorm
Diffstat (limited to 'indra/llui/lltexteditor.cpp')
-rwxr-xr-x | indra/llui/lltexteditor.cpp | 82 |
1 files changed, 54 insertions, 28 deletions
diff --git a/indra/llui/lltexteditor.cpp b/indra/llui/lltexteditor.cpp index 834f213097..0c16e06109 100755 --- a/indra/llui/lltexteditor.cpp +++ b/indra/llui/lltexteditor.cpp @@ -1125,7 +1125,8 @@ void LLTextEditor::addChar(llwchar wc) } } -void LLTextEditor::addLineBreakChar() + +void LLTextEditor::addLineBreakChar(BOOL group_together) { if( !getEnabled() ) { @@ -1143,7 +1144,7 @@ void LLTextEditor::addLineBreakChar() LLStyleConstSP sp(new LLStyle(LLStyle::Params())); LLTextSegmentPtr segment = new LLLineBreakTextSegment(sp, mCursorPos); - S32 pos = execute(new TextCmdAddChar(mCursorPos, FALSE, '\n', segment)); + S32 pos = execute(new TextCmdAddChar(mCursorPos, group_together, '\n', segment)); setCursorPos(mCursorPos + pos); } @@ -1484,21 +1485,28 @@ void LLTextEditor::pasteTextWithLinebreaks(LLWString & clean_string) std::basic_string<llwchar>::size_type start = 0; std::basic_string<llwchar>::size_type pos = clean_string.find('\n',start); - while(pos!=-1) + while((pos != -1) && (pos != clean_string.length() -1)) { if(pos!=start) { std::basic_string<llwchar> str = std::basic_string<llwchar>(clean_string,start,pos-start); - setCursorPos(mCursorPos + insert(mCursorPos, str, FALSE, LLTextSegmentPtr())); + setCursorPos(mCursorPos + insert(mCursorPos, str, TRUE, LLTextSegmentPtr())); } - addLineBreakChar(); - + addLineBreakChar(TRUE); // Add a line break and group with the next addition. + start = pos+1; pos = clean_string.find('\n',start); } - std::basic_string<llwchar> str = std::basic_string<llwchar>(clean_string,start,clean_string.length()-start); - setCursorPos(mCursorPos + insert(mCursorPos, str, FALSE, LLTextSegmentPtr())); + if (pos != start) + { + std::basic_string<llwchar> str = std::basic_string<llwchar>(clean_string,start,clean_string.length()-start); + setCursorPos(mCursorPos + insert(mCursorPos, str, FALSE, LLTextSegmentPtr())); + } + else + { + addLineBreakChar(FALSE); // Add a line break and end the grouping. + } } // copy selection to primary @@ -1964,8 +1972,7 @@ void LLTextEditor::onFocusReceived() updateAllowingLanguageInput(); } -// virtual, from LLView -void LLTextEditor::onFocusLost() +void LLTextEditor::focusLostHelper() { updateAllowingLanguageInput(); @@ -1982,7 +1989,11 @@ void LLTextEditor::onFocusLost() // Make sure cursor is shown again getWindow()->showCursorFromMouseMove(); +} +void LLTextEditor::onFocusLost() +{ + focusLostHelper(); LLTextBase::onFocusLost(); } @@ -2128,12 +2139,17 @@ void LLTextEditor::drawPreeditMarker() continue; } - S32 preedit_left = mVisibleTextRect.mLeft; + line_info& line = mLineInfoList[cur_line]; + LLRect text_rect(line.mRect); + text_rect.mRight = mDocumentView->getRect().getWidth(); // clamp right edge to document extents + text_rect.translate(mDocumentView->getRect().mLeft, mDocumentView->getRect().mBottom); // adjust by scroll position + + S32 preedit_left = text_rect.mLeft; if (left > line_start) { preedit_left += mFont->getWidth(text, line_start, left - line_start); } - S32 preedit_right = mVisibleTextRect.mLeft; + S32 preedit_right = text_rect.mLeft; if (right < line_end) { preedit_right += mFont->getWidth(text, line_start, right - line_start); @@ -2146,18 +2162,18 @@ void LLTextEditor::drawPreeditMarker() if (mPreeditStandouts[i]) { gl_rect_2d(preedit_left + preedit_standout_gap, - line_y + preedit_standout_position, - preedit_right - preedit_standout_gap - 1, - line_y + preedit_standout_position - preedit_standout_thickness, - (mCursorColor.get() * preedit_standout_brightness + mWriteableBgColor.get() * (1 - preedit_standout_brightness)).setAlpha(1.0f)); + text_rect.mBottom + mFont->getDescenderHeight() - 1, + preedit_right - preedit_standout_gap - 1, + text_rect.mBottom + mFont->getDescenderHeight() - 1 - preedit_standout_thickness, + (mCursorColor.get() * preedit_standout_brightness + mWriteableBgColor.get() * (1 - preedit_standout_brightness)).setAlpha(1.0f)); } else { gl_rect_2d(preedit_left + preedit_marker_gap, - line_y + preedit_marker_position, - preedit_right - preedit_marker_gap - 1, - line_y + preedit_marker_position - preedit_marker_thickness, - (mCursorColor.get() * preedit_marker_brightness + mWriteableBgColor.get() * (1 - preedit_marker_brightness)).setAlpha(1.0f)); + text_rect.mBottom + mFont->getDescenderHeight() - 1, + preedit_right - preedit_marker_gap - 1, + text_rect.mBottom + mFont->getDescenderHeight() - 1 - preedit_marker_thickness, + (mCursorColor.get() * preedit_marker_brightness + mWriteableBgColor.get() * (1 - preedit_marker_brightness)).setAlpha(1.0f)); } } } @@ -2240,12 +2256,13 @@ void LLTextEditor::draw() LLRect clip_rect(mVisibleTextRect); clip_rect.stretch(1); LLLocalClipRect clip(clip_rect); - drawPreeditMarker(); } LLTextBase::draw(); drawLineNumbers(); + drawPreeditMarker(); + //RN: the decision was made to always show the orange border for keyboard focus but do not put an insertion caret // when in readonly mode mBorder->setKeyboardFocusHighlight( hasFocus() );// && !mReadOnly); @@ -2695,14 +2712,20 @@ BOOL LLTextEditor::hasPreeditString() const void LLTextEditor::resetPreedit() { + if (hasSelection()) + { + if (hasPreeditString()) + { + llwarns << "Preedit and selection!" << llendl; + deselect(); + } + else + { + deleteSelection(TRUE); + } + } if (hasPreeditString()) { - if (hasSelection()) - { - llwarns << "Preedit and selection!" << llendl; - deselect(); - } - setCursorPos(mPreeditPositions.front()); removeStringNoUndo(mCursorPos, mPreeditPositions.back() - mCursorPos); insertStringNoUndo(mCursorPos, mPreeditOverwrittenWString); @@ -2750,7 +2773,10 @@ void LLTextEditor::updatePreedit(const LLWString &preedit_string, { mPreeditOverwrittenWString.clear(); } - insertStringNoUndo(insert_preedit_at, mPreeditWString); + + segment_vec_t segments; + //pass empty segments to let "insertStringNoUndo" make new LLNormalTextSegment and insert it, if needed. + insertStringNoUndo(insert_preedit_at, mPreeditWString, &segments); mPreeditStandouts = preedit_standouts; |