00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00020
00025 #include "stdafx.h"
00026
00027 #include "MainFrm.h"
00028 #include "BuildOutputView.h"
00029
00030 BOOL CBuildOutputView::PreTranslateMessage(MSG* )
00031 {
00032 return FALSE;
00033 }
00034
00035
00036 LRESULT CBuildOutputView::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
00037 {
00038 COutputView::OnCreate(uMsg, wParam, lParam, bHandled);
00039
00040 SetReadOnly();
00041 return 0;
00042 }
00043
00044 LRESULT CBuildOutputView::OnWriteMsg(UINT , WPARAM , LPARAM lParam, BOOL& )
00045 {
00046 char buff[2000];
00047 SCStruct *pscs = (SCStruct *)lParam;
00048 if(pscs->type==t_printf) {
00049 vsprintf(buff, pscs->message, pscs->argptr);
00050 } else if(pscs->type==t_error) {
00051 static char *prefix[3]={ "Error", "Fatal", "Warning" };
00052 if(pscs->number!=0) {
00053 char *pre;
00054 pre = prefix[pscs->number/100];
00055 if(pscs->firstline>=0)
00056 sprintf(buff, "%s(%d - %d) : %s [%03d]: ", pscs->filename, pscs->firstline, pscs->lastline, pre, pscs->number);
00057 else
00058 sprintf(buff, "%s(%d) : %s [%03d]: ", pscs->filename, pscs->lastline, pre, pscs->number);
00059 WriteMsg(buff);
00060 }
00061 vsprintf(buff, pscs->message, pscs->argptr);
00062 }
00063 WriteMsg(buff);
00064 return 0;
00065 }
00066
00067 LRESULT CBuildOutputView::OnLButtonDoubleClick(UINT , WPARAM , LPARAM , BOOL& )
00068 {
00069
00070 CString strLineText;
00071 int nLineIndex = LineFromChar(LineIndex(-1));
00072 int nLineLength = LineLength(LineIndex(nLineIndex));
00073 int nRead = GetLine(nLineIndex, strLineText.GetBuffer(nLineLength + 3),
00074 nLineLength + 1);
00075 strLineText.ReleaseBuffer(nRead);
00076 strLineText.SpanExcluding(_T("\r\n"));
00077
00078
00079 if(strLineText.GetLength() > 0) {
00080 int show = strLineText.Find(") : Warning");
00081 if(show==-1) show = strLineText.Find(") : Error");
00082
00083 if(show >= 0) {
00084
00085 long lSelStart = LineIndex(nLineIndex);
00086 long lSelEnd = lSelStart + strLineText.GetLength();
00087 SetSel(lSelStart, lSelEnd);
00089 CString sFile = strLineText.Mid(0,show);
00090 int line = sFile.ReverseFind('(');
00091 CString sLine= sFile.Mid(line+1);
00092 m_pMainFrame->FileOpen(sFile.Mid(0,line),atol(sLine));
00093
00095 }
00096 }
00097 return 0;
00098 }
00099
00100 void CBuildOutputView::BeginBuildMsg(LPCTSTR lpszProject)
00101 {
00102 char line[500];
00103 m_sProject = lpszProject;
00104
00105 CHARFORMAT2 fmt;
00106 fmt.dwMask = CFM_SIZE | CFM_COLOR | CFM_FACE | CFM_FACE | CFM_BOLD;
00107 strcpy(fmt.szFaceName,"Courier New");
00108 fmt.dwEffects = 0;
00109 fmt.yHeight = 8*20;
00110 fmt.crTextColor = 0;
00111 fmt.cbSize = sizeof(CHARFORMAT2);
00112
00113 sprintf(line, "------ Build started: Project: %s, QuestDesigner ------\n\nCompiling...\n", m_sProject);
00114 COutputView::WriteMsg(line, &fmt);
00115 m_Errors = 0;
00116 m_Warnings = 0;
00117 }
00118
00119 void CBuildOutputView::EndBuildMsg()
00120 {
00121 char line[500];
00122
00123 CHARFORMAT2 fmt;
00124 fmt.dwMask = CFM_SIZE | CFM_COLOR | CFM_FACE | CFM_FACE | CFM_BOLD;
00125 strcpy(fmt.szFaceName,"Courier New");
00126 fmt.dwEffects = 0;
00127 fmt.yHeight = 8*20;
00128 fmt.crTextColor = 0;
00129 fmt.cbSize = sizeof(CHARFORMAT2);
00130
00131 sprintf(line, "\
00132 \n%s - %d error(s), %d warning(s)\n\n\
00133 ---------------------- Done ----------------------\n\n\
00134 Build: %d succeeded, %d failed\n\n\n\
00135 ", m_sProject, m_Errors, m_Warnings, m_Errors?0:1, m_Errors?1:0);
00136 COutputView::WriteMsg(line, &fmt);
00137 }
00138
00139 void CBuildOutputView::WriteMsg(LPCTSTR lpszNewText, CHARFORMAT2 *pcFmt)
00140 {
00141 COLORREF color = 0x000000;
00142 if(strstr(lpszNewText, "Small compiler")) return;
00143 if(strstr(lpszNewText, " Error.")) return;
00144 if(strstr(lpszNewText, " Errors.")) return;
00145 if(strstr(lpszNewText, " Warning.")) return;
00146 if(strstr(lpszNewText, " Warnings.")) return;
00147
00148 if(strstr(lpszNewText, ") : Warning")) { color=0x005500; m_Warnings++; }
00149 if(strstr(lpszNewText, ") : Error")) { color=0x000055; m_Errors++; }
00150 if(strstr(lpszNewText, ") : Fatal")) color=0x0000ff;
00151
00152 CHARFORMAT2 fmt;
00153 if(!pcFmt) {
00154 fmt.dwMask = CFM_SIZE | CFM_COLOR | CFM_FACE | CFM_FACE | CFM_BOLD;
00155 strcpy(fmt.szFaceName,"Courier New");
00156 fmt.dwEffects = 0;
00157 fmt.yHeight = 8*20;
00158 fmt.crTextColor = color;
00159 fmt.cbSize = sizeof(CHARFORMAT2);
00160 pcFmt = &fmt;
00161 }
00162
00163 COutputView::WriteMsg(lpszNewText, pcFmt);
00164 }