@@ -410,35 +410,61 @@ void ConsoleDialog::createOutputWindow(HWND hParentWindow)
410410void ConsoleDialog::writeText (int length, const char *text)
411411{
412412 ::SendMessage (m_scintilla, SCI_SETREADONLY, 0 , 0 );
413- ::SendMessage (m_scintilla, SCI_APPENDTEXT, length, reinterpret_cast <LPARAM>(text));
413+ for (int i = 0 ; i < length; ++i)
414+ {
415+ if (text[i] == ' \r ' )
416+ {
417+ ::SendMessage (m_scintilla, SCI_APPENDTEXT, i, reinterpret_cast <LPARAM>(text));
418+ text += i + 1 ;
419+ length -= i + 1 ;
420+ i = 0 ;
421+ }
422+ }
423+
424+ if (length > 0 )
425+ {
426+ ::SendMessage (m_scintilla, SCI_APPENDTEXT, length, reinterpret_cast <LPARAM>(text));
427+ }
428+
414429 ::SendMessage (m_scintilla, SCI_SETREADONLY, 1 , 0 );
415430
416-
417431 ::SendMessage (m_scintilla, SCI_GOTOPOS, ::SendMessage(m_scintilla, SCI_GETLENGTH, 0 , 0 ), 0);
418432
419433}
420434
421435
422436void ConsoleDialog::writeError (int length, const char *text)
423437{
424- /*
425- char *buffer = new char[length * 2];
426- for(int pos = 0; pos < length; ++pos)
427- {
428- buffer[pos * 2] = text[pos];
429- buffer[(pos * 2) + 1] = 1;
430- }
431- */
432438 int docLength = callScintilla (SCI_GETLENGTH);
439+ int realLength = length;
433440 callScintilla (SCI_SETREADONLY, 0 );
434- callScintilla (SCI_APPENDTEXT, length, reinterpret_cast <LPARAM>(text));
441+ for (int i = 0 ; i < length; ++i)
442+ {
443+ if (text[i] == ' \r ' )
444+ {
445+ if (i)
446+ {
447+ callScintilla (SCI_APPENDTEXT, i, reinterpret_cast <LPARAM>(text));
448+ }
449+ text += i + 1 ;
450+ length -= i + 1 ;
451+ realLength--;
452+ i = 0 ;
453+ }
454+ }
455+
456+ if (length > 0 )
457+ {
458+ callScintilla (SCI_APPENDTEXT, length, reinterpret_cast <LPARAM>(text));
459+ }
460+
435461 callScintilla (SCI_SETREADONLY, 1 );
436462 callScintilla (SCI_STARTSTYLING, docLength, 0x01 );
437- callScintilla (SCI_SETSTYLING, length , 1 );
438- // delete[] buffer;
463+ callScintilla (SCI_SETSTYLING, realLength , 1 );
464+
439465
440466 callScintilla (SCI_COLOURISE, docLength, -1 );
441- callScintilla (SCI_GOTOPOS, docLength + length );
467+ callScintilla (SCI_GOTOPOS, docLength + realLength );
442468}
443469
444470
0 commit comments