From 6ccbb0b27366b263042770d481a508dbe7335e34 Mon Sep 17 00:00:00 2001 From: leo Date: Sat, 11 Feb 2006 23:43:04 +0000 Subject: Better debug console colors. git-svn-id: http://svn.leocad.org/trunk@470 c7d43263-9d01-0410-8a33-9dba5d9f93d6 --- win/Mainfrm.cpp | 75 +++++++++++++++++++++++++-------------------------------- 1 file changed, 33 insertions(+), 42 deletions(-) (limited to 'win/Mainfrm.cpp') diff --git a/win/Mainfrm.cpp b/win/Mainfrm.cpp index 48fa128..ca4d5e4 100644 --- a/win/Mainfrm.cpp +++ b/win/Mainfrm.cpp @@ -39,53 +39,44 @@ void mainframe_listener (int message, void *data, void *user) static void mainframe_console_func (LC_CONSOLE_LEVEL level, const char* text, void* user_data) { - CRichEditCtrl& ctrl = ((CRichEditView *) user_data)->GetRichEditCtrl (); - CHARFORMAT cf; - int line, index, length; + CRichEditCtrl& ctrl = ((CRichEditView *) user_data)->GetRichEditCtrl (); + CHARFORMAT cf; - cf.cbSize = sizeof (cf); - cf.dwMask = CFM_COLOR; - cf.dwEffects = 0; + cf.cbSize = sizeof (cf); + cf.dwMask = CFM_COLOR; + cf.dwEffects = 0; - switch (level) - { - case LC_CONSOLE_ERROR: - cf.crTextColor = RGB (255, 0, 0); - break; - - case LC_CONSOLE_WARNING: - cf.crTextColor = RGB (0, 0, 255); - break; - - case LC_CONSOLE_DEBUG: - cf.crTextColor = RGB (0, 255, 0); - break; - - case LC_CONSOLE_MISC: - default: - cf.crTextColor = RGB (0, 0, 0); - break; - } + switch (level) + { + case LC_CONSOLE_ERROR: + cf.crTextColor = RGB (255, 0, 0); + break; + + case LC_CONSOLE_WARNING: + cf.crTextColor = RGB (0, 0, 255); + break; + + case LC_CONSOLE_DEBUG: + cf.crTextColor = RGB (0, 128, 0); + break; + + case LC_CONSOLE_MISC: + default: + cf.crTextColor = RGB (0, 0, 0); + break; + } ctrl.SetRedraw(FALSE); - // select the last line - line = ctrl.GetLineCount (); - index = ctrl.LineIndex (line - 1); - ctrl.SetSel (index, index); - - // print text - ctrl.ReplaceSel (text); - line = ctrl.GetLineCount (); - index = ctrl.LineIndex (line - 2); - length = ctrl.LineLength (line - 2); - ctrl.SetSel (index, index + length); - ctrl.SetSelectionCharFormat (cf); - - // select the last line - line = ctrl.GetLineCount (); - index = ctrl.LineIndex (line - 1); - ctrl.SetSel (index, index); + // Go to the end of the window text. + int TextStart = ctrl.GetWindowTextLength(); + ctrl.SetSel(TextStart, -1); + + // Change color. + ctrl.SetSelectionCharFormat(cf); + + // Append new text. + ctrl.ReplaceSel(text); ctrl.SetRedraw(TRUE); ctrl.InvalidateRect(NULL, FALSE); -- cgit v1.2.3