diff options
author | richard <none@none> | 2009-11-04 18:28:45 -0800 |
---|---|---|
committer | richard <none@none> | 2009-11-04 18:28:45 -0800 |
commit | 83fb99a9ac2f07334233e7307cc18a4d340c8527 (patch) | |
tree | 8e3655f7c84acb9f560f8d840340d31fcffbf0e1 /indra/llui | |
parent | 85073874b53eecbe3e3a2827fa051d73a32c70e8 (diff) |
ext-2038 - script editor, cursor becomes stuck in some rows
ext-2037 0 Script editor, garbage characters inserted in text
Diffstat (limited to 'indra/llui')
-rw-r--r-- | indra/llui/lltextbase.cpp | 28 | ||||
-rw-r--r-- | indra/llui/lltextbase.h | 6 |
2 files changed, 25 insertions, 9 deletions
diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp index e5aac0d5e7..97ba691341 100644 --- a/indra/llui/lltextbase.cpp +++ b/indra/llui/lltextbase.cpp @@ -1108,7 +1108,7 @@ void LLTextBase::reflow(S32 start_index) S32_MAX); S32 segment_width, segment_height; - segment->getDimensions(seg_offset, character_count, segment_width, segment_height); + bool force_newline = segment->getDimensions(seg_offset, character_count, segment_width, segment_height); // grow line height as necessary based on reported height of this segment line_height = llmax(line_height, segment_height); remaining_pixels -= segment_width; @@ -1153,6 +1153,18 @@ void LLTextBase::reflow(S32 start_index) else { // subtract pixels used and increment segment + if (force_newline) + { + mLineInfoList.push_back(line_info( + line_start_index, + last_segment_char_on_line, + line_rect, + line_count)); + line_start_index = segment->getStart() + seg_offset; + cur_top -= llround((F32)line_height * mLineSpacingMult) + mLineSpacingPixels; + line_height = 0; + remaining_pixels = text_width; + } ++seg_iter; seg_offset = 0; } @@ -2124,7 +2136,7 @@ LLRect LLTextBase::getVisibleDocumentRect() const LLTextSegment::~LLTextSegment() {} -void LLTextSegment::getDimensions(S32 first_char, S32 num_chars, S32& width, S32& height) const { width = 0; height = 0; } +bool LLTextSegment::getDimensions(S32 first_char, S32 num_chars, S32& width, S32& height) const { width = 0; height = 0; return false;} S32 LLTextSegment::getOffset(S32 segment_local_x_coord, S32 start_offset, S32 num_chars, bool round) const { return 0; } S32 LLTextSegment::getNumChars(S32 num_pixels, S32 segment_offset, S32 line_offset, S32 max_chars) const { return 0; } void LLTextSegment::updateLayout(const LLTextBase& editor) {} @@ -2352,12 +2364,13 @@ void LLNormalTextSegment::setToolTip(const std::string& tooltip) mTooltip = tooltip; } -void LLNormalTextSegment::getDimensions(S32 first_char, S32 num_chars, S32& width, S32& height) const +bool LLNormalTextSegment::getDimensions(S32 first_char, S32 num_chars, S32& width, S32& height) const { LLWString text = mEditor.getWText(); height = mFontHeight; width = mStyle->getFont()->getWidth(text.c_str(), mStart + first_char, num_chars); + return num_chars >= 1 && text[mStart + num_chars - 1] == '\n'; } S32 LLNormalTextSegment::getOffset(S32 segment_local_x_coord, S32 start_offset, S32 num_chars, bool round) const @@ -2404,8 +2417,9 @@ S32 LLNormalTextSegment::getNumChars(S32 num_pixels, S32 segment_offset, S32 lin // but not both S32 last_char_in_run = mStart + segment_offset + num_chars; // check length first to avoid indexing off end of string - if (last_char_in_run >= mEditor.getLength() - || text[last_char_in_run] == '\n') + if (last_char_in_run < mEnd + && (last_char_in_run >= mEditor.getLength() + || text[last_char_in_run] == '\n')) { num_chars++; } @@ -2444,7 +2458,7 @@ LLInlineViewSegment::~LLInlineViewSegment() mView->die(); } -void LLInlineViewSegment::getDimensions(S32 first_char, S32 num_chars, S32& width, S32& height) const +bool LLInlineViewSegment::getDimensions(S32 first_char, S32 num_chars, S32& width, S32& height) const { if (first_char == 0 && num_chars == 0) { @@ -2458,6 +2472,8 @@ void LLInlineViewSegment::getDimensions(S32 first_char, S32 num_chars, S32& widt width = mLeftPad + mRightPad + mView->getRect().getWidth(); height = mBottomPad + mTopPad + mView->getRect().getHeight(); } + + return false; } S32 LLInlineViewSegment::getNumChars(S32 num_pixels, S32 segment_offset, S32 line_offset, S32 max_chars) const diff --git a/indra/llui/lltextbase.h b/indra/llui/lltextbase.h index 4cca522a23..8cae8fde22 100644 --- a/indra/llui/lltextbase.h +++ b/indra/llui/lltextbase.h @@ -370,7 +370,7 @@ public: LLTextSegment(S32 start, S32 end) : mStart(start), mEnd(end){}; virtual ~LLTextSegment(); - virtual void getDimensions(S32 first_char, S32 num_chars, S32& width, S32& height) const; + virtual bool getDimensions(S32 first_char, S32 num_chars, S32& width, S32& height) const; virtual S32 getOffset(S32 segment_local_x_coord, S32 start_offset, S32 num_chars, bool round) const; virtual S32 getNumChars(S32 num_pixels, S32 segment_offset, S32 line_offset, S32 max_chars) const; virtual void updateLayout(const class LLTextBase& editor); @@ -421,7 +421,7 @@ public: LLNormalTextSegment( const LLStyleSP& style, S32 start, S32 end, LLTextBase& editor ); LLNormalTextSegment( const LLColor4& color, S32 start, S32 end, LLTextBase& editor, BOOL is_visible = TRUE); - /*virtual*/ void getDimensions(S32 first_char, S32 num_chars, S32& width, S32& height) const; + /*virtual*/ bool getDimensions(S32 first_char, S32 num_chars, S32& width, S32& height) const; /*virtual*/ S32 getOffset(S32 segment_local_x_coord, S32 start_offset, S32 num_chars, bool round) const; /*virtual*/ S32 getNumChars(S32 num_pixels, S32 segment_offset, S32 line_offset, S32 max_chars) const; /*virtual*/ F32 draw(S32 start, S32 end, S32 selection_start, S32 selection_end, const LLRect& draw_rect); @@ -474,7 +474,7 @@ public: LLInlineViewSegment(const Params& p, S32 start, S32 end); ~LLInlineViewSegment(); - /*virtual*/ void getDimensions(S32 first_char, S32 num_chars, S32& width, S32& height) const; + /*virtual*/ bool getDimensions(S32 first_char, S32 num_chars, S32& width, S32& height) const; /*virtual*/ S32 getNumChars(S32 num_pixels, S32 segment_offset, S32 line_offset, S32 max_chars) const; /*virtual*/ void updateLayout(const class LLTextBase& editor); /*virtual*/ F32 draw(S32 start, S32 end, S32 selection_start, S32 selection_end, const LLRect& draw_rect); |