From fd096e5011c8d777f54c7fe473b12e6730dbedc0 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 18 Mar 2010 17:12:43 -0700 Subject: EXT-5549 - Can't Select Last Character In Chat Window --- indra/newview/llchathistory.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/indra/newview/llchathistory.cpp b/indra/newview/llchathistory.cpp index e1c96d4a16..78b258a82d 100644 --- a/indra/newview/llchathistory.cpp +++ b/indra/newview/llchathistory.cpp @@ -718,7 +718,7 @@ void LLChatHistory::appendMessage(const LLChat& chat, const LLSD &args, const LL view->reshape(target_rect.getWidth(), view->getRect().getHeight()); view->setOrigin(target_rect.mLeft, view->getRect().mBottom); - std::string widget_associated_text = "\n[" + chat.mTimeStr + "] "; + std::string widget_associated_text = "[" + chat.mTimeStr + "] "; if (utf8str_trim(chat.mFromName).size() != 0 && chat.mFromName != SYSTEM_FROM) widget_associated_text += chat.mFromName + delimiter; @@ -816,6 +816,8 @@ void LLChatHistory::appendMessage(const LLChat& chat, const LLSD &args, const LL { message = chat.mFromName + message; } + + message += "\n"; mEditor->appendText(message, FALSE, style_params); -- cgit v1.2.3 From 91b90b0a1749471a9016c4935b58c08a3dd66523 Mon Sep 17 00:00:00 2001 From: Richard Nelson Date: Tue, 23 Mar 2010 11:18:01 -0700 Subject: EXT-5549 Can't select last character in chat window --- indra/llrender/llfontgl.cpp | 2 +- indra/llui/lltextbase.cpp | 26 +++++++++++++++++++++----- indra/newview/llchathistory.cpp | 5 +---- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/indra/llrender/llfontgl.cpp b/indra/llrender/llfontgl.cpp index 768f042e69..d9e1976341 100644 --- a/indra/llrender/llfontgl.cpp +++ b/indra/llrender/llfontgl.cpp @@ -673,7 +673,7 @@ S32 LLFontGL::charFromPixelOffset(const llwchar* wchars, S32 begin_offset, F32 t target_x *= sScaleX; // max_chars is S32_MAX by default, so make sure we don't get overflow - const S32 max_index = begin_offset + llmin(S32_MAX - begin_offset, max_chars); + const S32 max_index = begin_offset + llmin(S32_MAX - begin_offset, max_chars - 1); F32 scaled_max_pixels = max_pixels * sScaleX; diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp index 633135382e..13201719f4 100644 --- a/indra/llui/lltextbase.cpp +++ b/indra/llui/lltextbase.cpp @@ -350,6 +350,8 @@ void LLTextBase::drawSelectionBackground() S32 segment_line_start = segmentp->getStart() + segment_offset; S32 segment_line_end = llmin(segmentp->getEnd(), line_iter->mDocIndexEnd); + if (segment_line_start > segment_line_end) break; + S32 segment_width = 0; S32 segment_height = 0; @@ -362,7 +364,7 @@ void LLTextBase::drawSelectionBackground() } // if selection spans end of current segment... - if (selection_right > segment_line_end) + if (selection_right >= segment_line_end) { // extend selection slightly beyond end of line // to indicate selection of newline character (use "n" character to determine width) @@ -1813,11 +1815,18 @@ S32 LLTextBase::getDocIndexFromLocalCoord( S32 local_x, S32 local_y, BOOL round, const LLTextSegmentPtr segmentp = *line_seg_iter; S32 segment_line_start = segmentp->getStart() + line_seg_offset; - S32 segment_line_length = llmin(segmentp->getEnd(), line_iter->mDocIndexEnd - 1) - segment_line_start; + S32 segment_line_length = llmin(segmentp->getEnd(), line_iter->mDocIndexEnd) - segment_line_start; S32 text_width, text_height; - segmentp->getDimensions(line_seg_offset, segment_line_length, text_width, text_height); - if (local_x < start_x + text_width // cursor to left of right edge of text - || (hit_past_end_of_line && (segmentp->getEnd() >= line_iter->mDocIndexEnd - 1))) // or this segment wraps to next line + bool newline = segmentp->getDimensions(line_seg_offset, segment_line_length, text_width, text_height); + + // if we've reached a line of text *below* the mouse cursor, doc index is first character on that line + if (hit_past_end_of_line && local_y - mVisibleTextRect.mBottom + visible_region.mBottom > line_iter->mRect.mTop) + { + pos = segment_line_start; + break; + } + if (local_x < start_x + text_width // cursor to left of right edge of text + || newline) // or this line ends with a newline, set doc pos to newline char { // Figure out which character we're nearest to. S32 offset; @@ -1841,6 +1850,13 @@ S32 LLTextBase::getDocIndexFromLocalCoord( S32 local_x, S32 local_y, BOOL round, pos = segment_line_start + offset; break; } + else if (hit_past_end_of_line && segmentp->getEnd() >= line_iter->mDocIndexEnd - 1) + { + // segment wraps to next line, so just set doc pos to start of next line + pos = llmin(getLength(), line_iter->mDocIndexEnd); + break; + } + start_x += text_width; } diff --git a/indra/newview/llchathistory.cpp b/indra/newview/llchathistory.cpp index 7a45637d42..fc906a8f8e 100644 --- a/indra/newview/llchathistory.cpp +++ b/indra/newview/llchathistory.cpp @@ -734,7 +734,7 @@ void LLChatHistory::appendMessage(const LLChat& chat, const LLSD &args, const LL view->reshape(target_rect.getWidth(), view->getRect().getHeight()); view->setOrigin(target_rect.mLeft, view->getRect().mBottom); - std::string widget_associated_text = "[" + chat.mTimeStr + "] "; + std::string widget_associated_text = "\n[" + chat.mTimeStr + "] "; if (utf8str_trim(chat.mFromName).size() != 0 && chat.mFromName != SYSTEM_FROM) widget_associated_text += chat.mFromName + delimiter; @@ -835,9 +835,6 @@ void LLChatHistory::appendMessage(const LLChat& chat, const LLSD &args, const LL message = chat.mFromName + message; } - message += "\n"; - - mEditor->appendText(message, FALSE, style_params); } mEditor->blockUndo(); -- cgit v1.2.3 From 07bc1f0ba52cfcd107f6cf12ab4e5372640b2143 Mon Sep 17 00:00:00 2001 From: Richard Nelson Date: Tue, 23 Mar 2010 11:22:46 -0700 Subject: fixed line ending style where I copied from araxis merge window --- indra/llui/lltextbase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp index 13201719f4..f0b3a1a56c 100644 --- a/indra/llui/lltextbase.cpp +++ b/indra/llui/lltextbase.cpp @@ -1825,7 +1825,7 @@ S32 LLTextBase::getDocIndexFromLocalCoord( S32 local_x, S32 local_y, BOOL round, pos = segment_line_start; break; } - if (local_x < start_x + text_width // cursor to left of right edge of text + if (local_x < start_x + text_width // cursor to left of right edge of text || newline) // or this line ends with a newline, set doc pos to newline char { // Figure out which character we're nearest to. -- cgit v1.2.3 From e3e50bf7ed48c6ee0a199d27fce7ba888793429d Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 23 Mar 2010 12:47:11 -0700 Subject: added some comments for fix to EXT-5549 --- indra/llui/lltextbase.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp index f0b3a1a56c..5f4b16ec9e 100644 --- a/indra/llui/lltextbase.cpp +++ b/indra/llui/lltextbase.cpp @@ -363,7 +363,10 @@ void LLTextBase::drawSelectionBackground() selection_rect.mLeft += segment_width; } - // if selection spans end of current segment... + // if selection_right == segment_line_end then that means we are the first character of the next segment + // or first character of the next line, in either case we want to add the length of the current segment + // to the selection rectangle and continue. + // if selection right > segment_line_end then selection spans end of current segment... if (selection_right >= segment_line_end) { // extend selection slightly beyond end of line @@ -1852,7 +1855,7 @@ S32 LLTextBase::getDocIndexFromLocalCoord( S32 local_x, S32 local_y, BOOL round, } else if (hit_past_end_of_line && segmentp->getEnd() >= line_iter->mDocIndexEnd - 1) { - // segment wraps to next line, so just set doc pos to start of next line + // segment wraps to next line, so just set doc pos to start of next line (represented by mDocIndexEnd) pos = llmin(getLength(), line_iter->mDocIndexEnd); break; } -- cgit v1.2.3