From 12762053e5aff372a9f8d473c71aa81e805bb474 Mon Sep 17 00:00:00 2001 From: Martin Reddy Date: Tue, 22 Sep 2009 18:00:16 +0000 Subject: EXT-944 EXT-1026: converted the LLUrlRegistry::findUrl() method to work on an LLWString instead of a std::string, so that we don't have to worry about character offsets for variable-length-encoded UTF-8 strings. This was causing crashes whenever we would try to show a textbox with a URL and foreign characters (> 1 byte chars). Damn, I suck! --- indra/llui/lltexteditor.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'indra/llui/lltexteditor.cpp') diff --git a/indra/llui/lltexteditor.cpp b/indra/llui/lltexteditor.cpp index 983777b747..f7680a0a2b 100644 --- a/indra/llui/lltexteditor.cpp +++ b/indra/llui/lltexteditor.cpp @@ -3525,7 +3525,7 @@ void LLTextEditor::appendStyledText(const std::string &new_text, S32 start=0,end=0; LLUrlMatch match; - std::string text = new_text; + LLWString text = utf8str_to_wstring(new_text); while ( LLUrlRegistry::instance().findUrl(text, match, boost::bind(&LLTextEditor::onUrlLabelUpdated, this, _1, _2)) ) { @@ -3549,8 +3549,8 @@ void LLTextEditor::appendStyledText(const std::string &new_text, { part = (S32)LLTextParser::MIDDLE; } - std::string subtext=text.substr(0,start); - appendHighlightedText(subtext,allow_undo, prepend_newline, part, style_params); + std::string subtext = wstring_to_utf8str(text.substr(0,start)); + appendHighlightedText(subtext, allow_undo, prepend_newline, part, style_params); prepend_newline = false; } @@ -3595,7 +3595,8 @@ void LLTextEditor::appendStyledText(const std::string &new_text, } } if (part != (S32)LLTextParser::WHOLE) part=(S32)LLTextParser::END; - if (end < (S32)text.length()) appendHighlightedText(text,allow_undo, prepend_newline, part, style_params); + if (end < (S32)text.length()) appendHighlightedText(wstring_to_utf8str(text), allow_undo, + prepend_newline, part, style_params); } else { @@ -4137,7 +4138,7 @@ void LLTextEditor::updateLinkSegments() LLUrlMatch match; LLStyleSP style = static_cast(segment->getStyle()); std::string url_label = getText().substr(segment->getStart(), segment->getEnd()-segment->getStart()); - if (LLUrlRegistry::instance().findUrl(url_label, match)) + if (LLUrlRegistry::instance().findUrl(utf8str_to_wstring(url_label), match)) { LLStringUtil::trim(url_label); style->setLinkHREF(url_label); -- cgit v1.2.3 From 47abd559082f6023dcdfadd2ec740195b1d07990 Mon Sep 17 00:00:00 2001 From: Martin Reddy Date: Wed, 23 Sep 2009 13:57:06 +0000 Subject: EXT-944 EXT-1026: reverting my previous fix for these crashes. This didn't work on Windows because wchar_t is 2 bytes on that platform, not 4 bytes (whereas llwchar is 4 bytes everywhere). Boost's regex methods need to work on wchar_t, but I believe that using a UTF-16 string would still be prone to crashing on Windows as UTF-16 is still a variable-length encoding. Besides, trying to compile a UTF-16 solution generates weird link errors. Instead, I'm going to fix this problem a different way. And I'm starting by reverting the previous attempt. Thanks Win32. --- indra/llui/lltexteditor.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'indra/llui/lltexteditor.cpp') diff --git a/indra/llui/lltexteditor.cpp b/indra/llui/lltexteditor.cpp index f7680a0a2b..983777b747 100644 --- a/indra/llui/lltexteditor.cpp +++ b/indra/llui/lltexteditor.cpp @@ -3525,7 +3525,7 @@ void LLTextEditor::appendStyledText(const std::string &new_text, S32 start=0,end=0; LLUrlMatch match; - LLWString text = utf8str_to_wstring(new_text); + std::string text = new_text; while ( LLUrlRegistry::instance().findUrl(text, match, boost::bind(&LLTextEditor::onUrlLabelUpdated, this, _1, _2)) ) { @@ -3549,8 +3549,8 @@ void LLTextEditor::appendStyledText(const std::string &new_text, { part = (S32)LLTextParser::MIDDLE; } - std::string subtext = wstring_to_utf8str(text.substr(0,start)); - appendHighlightedText(subtext, allow_undo, prepend_newline, part, style_params); + std::string subtext=text.substr(0,start); + appendHighlightedText(subtext,allow_undo, prepend_newline, part, style_params); prepend_newline = false; } @@ -3595,8 +3595,7 @@ void LLTextEditor::appendStyledText(const std::string &new_text, } } if (part != (S32)LLTextParser::WHOLE) part=(S32)LLTextParser::END; - if (end < (S32)text.length()) appendHighlightedText(wstring_to_utf8str(text), allow_undo, - prepend_newline, part, style_params); + if (end < (S32)text.length()) appendHighlightedText(text,allow_undo, prepend_newline, part, style_params); } else { @@ -4138,7 +4137,7 @@ void LLTextEditor::updateLinkSegments() LLUrlMatch match; LLStyleSP style = static_cast(segment->getStyle()); std::string url_label = getText().substr(segment->getStart(), segment->getEnd()-segment->getStart()); - if (LLUrlRegistry::instance().findUrl(utf8str_to_wstring(url_label), match)) + if (LLUrlRegistry::instance().findUrl(url_label, match)) { LLStringUtil::trim(url_label); style->setLinkHREF(url_label); -- cgit v1.2.3 From afcdda2e361855e2a02eb39c8cec080019ac769f Mon Sep 17 00:00:00 2001 From: Richard Nelson Date: Wed, 23 Sep 2009 22:25:18 +0000 Subject: EXT-904 Build tools does not show tooltips on any checkbox EXT-877 There is no tooltip with a date for Time indicator in Nav bar EXT-860 Crosshairs and "Press ESC to..." warning are dislocated in mouselook mode when UI Size is not exactly set to 1.00 (Menu Me -> Preferences-> Graphics) EXT-783 Script editor inserts text twice when using the editors paste, or choosing LSL elements from the pull-down list. EXT-764 mis-location of cursor in edit script panel (fixed cursor width) EXT-658 Inventory window's "Fetched Items" needs spacing reviewed by James --- indra/llui/lltexteditor.cpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'indra/llui/lltexteditor.cpp') diff --git a/indra/llui/lltexteditor.cpp b/indra/llui/lltexteditor.cpp index 983777b747..8d5f277b59 100644 --- a/indra/llui/lltexteditor.cpp +++ b/indra/llui/lltexteditor.cpp @@ -1120,21 +1120,12 @@ void LLTextEditor::updateCursorXPos() } // constraint cursor to editable segments of document +// NOTE: index must be within document range S32 LLTextEditor::getEditableIndex(S32 index, bool increasing_direction) { - //// always allow editable position at end of doc - //if (index == getLength()) - //{ - // return index; - //} - segment_set_t::iterator segment_iter; S32 offset; getSegmentAndOffset(index, &segment_iter, &offset); - if (segment_iter == mSegments.end()) - { - return 0; - } LLTextSegmentPtr segmentp = *segment_iter; @@ -3194,7 +3185,11 @@ void LLTextEditor::draw() drawLineNumbers(); { - LLLocalClipRect clip(mTextRect); + // pad clipping rectangle so that cursor can draw at full width + // when at left edge of mTextRect + LLRect clip_rect(mTextRect); + clip_rect.stretch(1); + LLLocalClipRect clip(clip_rect); drawSelectionBackground(); drawPreeditMarker(); drawText(); -- cgit v1.2.3