aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llconsole.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/newview/llconsole.cpp')
-rw-r--r--linden/indra/newview/llconsole.cpp34
1 files changed, 19 insertions, 15 deletions
diff --git a/linden/indra/newview/llconsole.cpp b/linden/indra/newview/llconsole.cpp
index 517e06f..08ef124 100644
--- a/linden/indra/newview/llconsole.cpp
+++ b/linden/indra/newview/llconsole.cpp
@@ -262,34 +262,38 @@ void LLConsole::addQueuedLines()
262 if (!wline.empty() && mFont != NULL) 262 if (!wline.empty() && mFont != NULL)
263 { 263 {
264 // Wrap lines that are longer than the view is wide. 264 // Wrap lines that are longer than the view is wide.
265 S32 offset = 0; 265 S32 line_start_offset = 0;
266 while( offset < (S32)wline.length() ) 266 while( line_start_offset < (S32)wline.length() )
267 { 267 {
268 S32 skip_chars; // skip '\n' 268 // Find the next '\n', if any
269 // Figure out if a word-wrapped line fits here. 269 LLWString::size_type line_end = wline.find_first_of(llwchar('\n'), line_start_offset);
270 LLWString::size_type line_end = wline.find_first_of(llwchar('\n'), offset); 270 if (LLWString::npos == line_end)
271 if (line_end != LLWString::npos)
272 {
273 skip_chars = 1; // skip '\n'
274 }
275 else
276 { 271 {
272 // no more '\n's, try to use the whole line
277 line_end = wline.size(); 273 line_end = wline.size();
278 skip_chars = 0;
279 } 274 }
280 U32 drawable = mFont->maxDrawableChars(wline.c_str()+offset, (F32)getRect().getWidth(), line_end-offset, TRUE); 275 // Find how many characters will reasonably fit in the allowed width
276 U32 drawable = mFont->maxDrawableChars(wline.c_str()+line_start_offset, (F32)getRect().getWidth(), line_end-line_start_offset, TRUE);
281 if (drawable != 0) 277 if (drawable != 0)
282 { 278 {
283 LLFixedBuffer::addLine(wline.substr(offset, drawable)); 279 LLFixedBuffer::addLine(wline.substr(line_start_offset, drawable));
284 mAddTimes[mAddTimes.size()-1] = line_info.add_time; 280 mAddTimes[mAddTimes.size()-1] = line_info.add_time;
281
282 // move the line_start_offset by the number of characters we were able to draw, up to an implicit or explicit line-break.
283 line_start_offset += drawable;
285 } 284 }
286 else 285 else
287 { 286 {
288 // force a blank line 287 // no drawable characters - force a blank line and try the next character.
289 LLFixedBuffer::addLine(" "); 288 LLFixedBuffer::addLine(" ");
289 line_start_offset++;
290 } 290 }
291 mColors.push_back(color); 291 mColors.push_back(color);
292 offset += (drawable + skip_chars); 292 // if this was an *explicit* line-break or the end of the text, then increment the offset for the start of the next line (if any).
293 if (line_start_offset == line_end)
294 {
295 line_start_offset++;
296 }
293 } 297 }
294 } 298 }
295 } 299 }