OSDN Git Service

Add SCI Edit to GitBlameView
[tortoisegit/TortoiseGitJp.git] / src / TortoiseGitBlame / TortoiseGitBlameView.cpp
1 // TortoiseGitBlame - a Viewer for Git Blames\r
2 \r
3 // Copyright (C) 2003-2008 - TortoiseSVN\r
4 \r
5 // This program is free software; you can redistribute it and/or\r
6 // modify it under the terms of the GNU General Public License\r
7 // as published by the Free Software Foundation; either version 2\r
8 // of the License, or (at your option) any later version.\r
9 \r
10 // This program is distributed in the hope that it will be useful,\r
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of\r
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
13 // GNU General Public License for more details.\r
14 \r
15 // You should have received a copy of the GNU General Public License\r
16 // along with this program; if not, write to the Free Software Foundation,\r
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\r
18 \r
19 // CTortoiseGitBlameView.cpp : implementation of the CTortoiseGitBlameView class\r
20 //\r
21 \r
22 #include "stdafx.h"\r
23 #include "TortoiseGitBlame.h"\r
24 \r
25 #include "TortoiseGitBlameDoc.h"\r
26 #include "TortoiseGitBlameView.h"\r
27 \r
28 #ifdef _DEBUG\r
29 #define new DEBUG_NEW\r
30 #endif\r
31 \r
32 \r
33 // CTortoiseGitBlameView\r
34 \r
35 IMPLEMENT_DYNCREATE(CTortoiseGitBlameView, CView)\r
36 \r
37 BEGIN_MESSAGE_MAP(CTortoiseGitBlameView, CView)\r
38         // Standard printing commands\r
39         ON_COMMAND(ID_FILE_PRINT, &CView::OnFilePrint)\r
40         ON_COMMAND(ID_FILE_PRINT_DIRECT, &CView::OnFilePrint)\r
41         ON_COMMAND(ID_FILE_PRINT_PREVIEW, &CTortoiseGitBlameView::OnFilePrintPreview)\r
42         ON_WM_CREATE()\r
43         ON_WM_SIZE()\r
44 END_MESSAGE_MAP()\r
45 \r
46 // CTortoiseGitBlameView construction/destruction\r
47 \r
48 CTortoiseGitBlameView::CTortoiseGitBlameView()\r
49 {\r
50         // TODO: add construction code here\r
51         hInstance = 0;\r
52         hResource = 0;\r
53         currentDialog = 0;\r
54         wMain = 0;\r
55         wEditor = 0;\r
56         wLocator = 0;\r
57 \r
58         m_font = 0;\r
59         m_italicfont = 0;\r
60         m_blamewidth = 100;\r
61         m_revwidth = 0;\r
62         m_datewidth = 0;\r
63         m_authorwidth = 0;\r
64         m_pathwidth = 0;\r
65         m_linewidth = 0;\r
66 \r
67         m_windowcolor = ::GetSysColor(COLOR_WINDOW);\r
68         m_textcolor = ::GetSysColor(COLOR_WINDOWTEXT);\r
69         m_texthighlightcolor = ::GetSysColor(COLOR_HIGHLIGHTTEXT);\r
70         m_mouserevcolor = InterColor(m_windowcolor, m_textcolor, 20);\r
71         m_mouseauthorcolor = InterColor(m_windowcolor, m_textcolor, 10);\r
72         m_selectedrevcolor = ::GetSysColor(COLOR_HIGHLIGHT);\r
73         m_selectedauthorcolor = InterColor(m_selectedrevcolor, m_texthighlightcolor, 35);\r
74         m_mouserev = -2;\r
75 \r
76         m_selectedrev = -1;\r
77         m_selectedorigrev = -1;\r
78         m_SelectedLine = -1;\r
79         m_directPointer = 0;\r
80         m_directFunction = 0;\r
81 \r
82         m_lowestrev = LONG_MAX;\r
83         m_highestrev = 0;\r
84         m_colorage = true;\r
85 }\r
86 \r
87 CTortoiseGitBlameView::~CTortoiseGitBlameView()\r
88 {\r
89         if (m_font)\r
90                 DeleteObject(m_font);\r
91         if (m_italicfont)\r
92                 DeleteObject(m_italicfont);\r
93 }\r
94 \r
95 \r
96 int CTortoiseGitBlameView::OnCreate(LPCREATESTRUCT lpcs)\r
97 {\r
98 \r
99         CRect rect,rect1;\r
100         this->GetWindowRect(&rect1);\r
101         rect.left=m_blamewidth;\r
102         rect.right=rect.Width();\r
103         rect.top=0;\r
104         rect.bottom=rect.Height();\r
105         BOOL b=m_TextView.Create(_T("Scintilla"),_T("source"),0,rect,this,0,0);\r
106         m_TextView.Init(0);\r
107         m_TextView.ShowWindow( SW_SHOW);\r
108         //m_TextView.InsertText(_T("Abdadfasdf"));\r
109          \r
110         return CView::OnCreate(lpcs);\r
111 }\r
112 \r
113 void CTortoiseGitBlameView::OnSize(UINT nType,int cx, int cy)\r
114 {\r
115 \r
116         CRect rect;\r
117         rect.left=m_blamewidth;\r
118         rect.right=cx;\r
119         rect.top=0;\r
120         rect.bottom=cy;\r
121 \r
122         m_TextView.MoveWindow(&rect);\r
123 \r
124 }\r
125 BOOL CTortoiseGitBlameView::PreCreateWindow(CREATESTRUCT& cs)\r
126 {\r
127         // TODO: Modify the Window class or styles here by modifying\r
128         //  the CREATESTRUCT cs\r
129 \r
130         return CView::PreCreateWindow(cs);\r
131 }\r
132 \r
133 // CTortoiseGitBlameView drawing\r
134 \r
135 void CTortoiseGitBlameView::OnDraw(CDC* /*pDC*/)\r
136 {\r
137         CTortoiseGitBlameDoc* pDoc = GetDocument();\r
138         ASSERT_VALID(pDoc);\r
139         if (!pDoc)\r
140                 return;\r
141 \r
142         // TODO: add draw code for native data here\r
143 }\r
144 \r
145 \r
146 // CTortoiseGitBlameView printing\r
147 \r
148 \r
149 void CTortoiseGitBlameView::OnFilePrintPreview()\r
150 {\r
151         AFXPrintPreview(this);\r
152 }\r
153 \r
154 BOOL CTortoiseGitBlameView::OnPreparePrinting(CPrintInfo* pInfo)\r
155 {\r
156         // default preparation\r
157         return DoPreparePrinting(pInfo);\r
158 }\r
159 \r
160 void CTortoiseGitBlameView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)\r
161 {\r
162         // TODO: add extra initialization before printing\r
163 }\r
164 \r
165 void CTortoiseGitBlameView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)\r
166 {\r
167         // TODO: add cleanup after printing\r
168 }\r
169 \r
170 void CTortoiseGitBlameView::OnRButtonUp(UINT nFlags, CPoint point)\r
171 {\r
172         ClientToScreen(&point);\r
173         OnContextMenu(this, point);\r
174 }\r
175 \r
176 void CTortoiseGitBlameView::OnContextMenu(CWnd* pWnd, CPoint point)\r
177 {\r
178         theApp.GetContextMenuManager()->ShowPopupMenu(IDR_POPUP_EDIT, point.x, point.y, this, TRUE);\r
179 }\r
180 \r
181 \r
182 // CTortoiseGitBlameView diagnostics\r
183 \r
184 #ifdef _DEBUG\r
185 void CTortoiseGitBlameView::AssertValid() const\r
186 {\r
187         CView::AssertValid();\r
188 }\r
189 \r
190 void CTortoiseGitBlameView::Dump(CDumpContext& dc) const\r
191 {\r
192         CView::Dump(dc);\r
193 }\r
194 \r
195 CTortoiseGitBlameDoc* CTortoiseGitBlameView::GetDocument() const // non-debug version is inline\r
196 {\r
197         ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CTortoiseGitBlameDoc)));\r
198         return (CTortoiseGitBlameDoc*)m_pDocument;\r
199 }\r
200 #endif //_DEBUG\r
201 \r
202 \r
203 // CTortoiseGitBlameView message handlers\r
204 CString CTortoiseGitBlameView::GetAppDirectory()\r
205 {\r
206         CString path;\r
207         DWORD len = 0;\r
208         DWORD bufferlen = MAX_PATH;             // MAX_PATH is not the limit here!\r
209         do \r
210         {\r
211                 bufferlen += MAX_PATH;          // MAX_PATH is not the limit here!\r
212                 TCHAR * pBuf = new TCHAR[bufferlen];\r
213                 len = GetModuleFileName(NULL, pBuf, bufferlen); \r
214                 path = CString(pBuf, len);\r
215                 delete [] pBuf;\r
216         } while(len == bufferlen);\r
217 \r
218         path = path.Left(path.ReverseFind(_T('\\')));\r
219         //path = path.substr(0, path.rfind('\\') + 1);\r
220 \r
221         return path;\r
222 }\r
223 \r
224 // Return a color which is interpolated between c1 and c2.\r
225 // Slider controls the relative proportions as a percentage:\r
226 // Slider = 0   represents pure c1\r
227 // Slider = 50  represents equal mixture\r
228 // Slider = 100 represents pure c2\r
229 COLORREF CTortoiseGitBlameView::InterColor(COLORREF c1, COLORREF c2, int Slider)\r
230 {\r
231         int r, g, b;\r
232         \r
233         // Limit Slider to 0..100% range\r
234         if (Slider < 0)\r
235                 Slider = 0;\r
236         if (Slider > 100)\r
237                 Slider = 100;\r
238         \r
239         // The color components have to be treated individually.\r
240         r = (GetRValue(c2) * Slider + GetRValue(c1) * (100 - Slider)) / 100;\r
241         g = (GetGValue(c2) * Slider + GetGValue(c1) * (100 - Slider)) / 100;\r
242         b = (GetBValue(c2) * Slider + GetBValue(c1) * (100 - Slider)) / 100;\r
243         \r
244         return RGB(r, g, b);\r
245 }\r
246 \r
247 LRESULT CTortoiseGitBlameView::SendEditor(UINT Msg, WPARAM wParam, LPARAM lParam)\r
248 {\r
249         if (m_directFunction)\r
250         {\r
251                 return ((SciFnDirect) m_directFunction)(m_directPointer, Msg, wParam, lParam);\r
252         }\r
253         return ::SendMessage(wEditor, Msg, wParam, lParam);     \r
254 }\r
255 \r
256 void CTortoiseGitBlameView::GetRange(int start, int end, char *text) \r
257 {\r
258 #if 0\r
259         TEXTRANGE tr;\r
260         tr.chrg.cpMin = start;\r
261         tr.chrg.cpMax = end;\r
262         tr.lpstrText = text;\r
263         SendMessage(wEditor, EM_GETTEXTRANGE, 0, reinterpret_cast<LPARAM>(&tr));\r
264 #endif\r
265 }\r
266 \r
267 void CTortoiseGitBlameView::SetTitle() \r
268 {\r
269 #if 0\r
270         char title[MAX_PATH + 100];\r
271         strcpy_s(title, MAX_PATH + 100, szTitle);\r
272         strcat_s(title, MAX_PATH + 100, " - ");\r
273         strcat_s(title, MAX_PATH + 100, szViewtitle);\r
274         ::SetWindowText(wMain, title);\r
275 #endif\r
276 }\r
277 \r
278 BOOL CTortoiseGitBlameView::OpenLogFile(const char *fileName)\r
279 {\r
280 #if 0\r
281         char logmsgbuf[10000+1];\r
282         FILE * File;\r
283         fopen_s(&File, fileName, "rb");\r
284         if (File == 0)\r
285         {\r
286                 return FALSE;\r
287         }\r
288         LONG rev = 0;\r
289         CString msg;\r
290         int slength = 0;\r
291         int reallength = 0;\r
292         size_t len = 0;\r
293         wchar_t wbuf[MAX_LOG_LENGTH+6];\r
294         for (;;)\r
295         {\r
296                 len = fread(&rev, sizeof(LONG), 1, File);\r
297                 if (len == 0)\r
298                 {\r
299                         fclose(File);\r
300             InitSize();\r
301                         return TRUE;\r
302                 }\r
303                 len = fread(&slength, sizeof(int), 1, File);\r
304                 if (len == 0)\r
305                 {\r
306                         fclose(File);\r
307             InitSize();\r
308                         return FALSE;\r
309                 }\r
310                 if (slength > MAX_LOG_LENGTH)\r
311                 {\r
312                         reallength = slength;\r
313                         slength = MAX_LOG_LENGTH;\r
314                 }\r
315                 else\r
316                         reallength = 0;\r
317                 len = fread(logmsgbuf, sizeof(char), slength, File);\r
318                 if (len < (size_t)slength)\r
319                 {\r
320                         fclose(File);\r
321             InitSize();\r
322                         return FALSE;\r
323                 }\r
324                 msg = CString(logmsgbuf, slength);\r
325                 if (reallength)\r
326                 {\r
327                         fseek(File, reallength-MAX_LOG_LENGTH, SEEK_CUR);\r
328                         msg = msg + _T("\n...");\r
329                 }\r
330                 int len2 = ::MultiByteToWideChar(CP_UTF8, NULL, msg.c_str(), min(msg.size(), MAX_LOG_LENGTH+5), wbuf, MAX_LOG_LENGTH+5);\r
331                 wbuf[len2] = 0;\r
332                 len2 = ::WideCharToMultiByte(CP_ACP, NULL, wbuf, len2, logmsgbuf, MAX_LOG_LENGTH+5, NULL, NULL);\r
333                 logmsgbuf[len2] = 0;\r
334                 msg = CString(logmsgbuf);\r
335                 logmessages[rev] = msg;\r
336         }\r
337 #endif\r
338         return TRUE;\r
339 }\r
340 \r
341 BOOL CTortoiseGitBlameView::OpenFile(const char *fileName) \r
342 {\r
343 #if 0\r
344         SendEditor(SCI_SETREADONLY, FALSE);\r
345         SendEditor(SCI_CLEARALL);\r
346         SendEditor(EM_EMPTYUNDOBUFFER);\r
347         SetTitle();\r
348         SendEditor(SCI_SETSAVEPOINT);\r
349         SendEditor(SCI_CANCEL);\r
350         SendEditor(SCI_SETUNDOCOLLECTION, 0);\r
351         ::ShowWindow(wEditor, SW_HIDE);\r
352         std::ifstream File;\r
353         File.open(fileName);\r
354         if (!File.good())\r
355         {\r
356                 return FALSE;\r
357         }\r
358         char line[100*1024];\r
359         char * lineptr = NULL;\r
360         char * trimptr = NULL;\r
361         //ignore the first two lines, they're of no interest to us\r
362         File.getline(line, sizeof(line)/sizeof(char));\r
363         File.getline(line, sizeof(line)/sizeof(char));\r
364         m_lowestrev = LONG_MAX;\r
365         m_highestrev = 0;\r
366         bool bUTF8 = true;\r
367         do\r
368         {\r
369                 File.getline(line, sizeof(line)/sizeof(TCHAR));\r
370                 if (File.gcount()>139)\r
371                 {\r
372                         mergelines.push_back((line[0] != ' '));\r
373                         lineptr = &line[9];\r
374                         long rev = _ttol(lineptr);\r
375                         revs.push_back(rev);\r
376                         m_lowestrev = min(m_lowestrev, rev);\r
377                         m_highestrev = max(m_highestrev, rev);\r
378                         lineptr += 7;\r
379                         rev = _ttol(lineptr);\r
380                         origrevs.push_back(rev);\r
381                         lineptr += 7;\r
382                         dates.push_back(CString(lineptr, 30));\r
383                         lineptr += 31;\r
384                         // unfortunately, the 'path' entry can be longer than the 60 chars\r
385                         // we made the column. We therefore have to step through the path\r
386                         // string until we find a space\r
387                         trimptr = lineptr;\r
388                         do \r
389                         {\r
390                                 // TODO: how can we deal with the situation where the path has\r
391                                 // a space in it, but the space is after the 60 chars reserved\r
392                                 // for it?\r
393                                 // The only way to deal with that would be to use a custom\r
394                                 // binary format for the blame file.\r
395                                 trimptr++;\r
396                                 trimptr = _tcschr(trimptr, ' ');\r
397                         } while ((trimptr)&&(trimptr+1 < lineptr+61));\r
398                         if (trimptr)\r
399                                 *trimptr = 0;\r
400                         else\r
401                                 trimptr = lineptr;\r
402                         paths.push_back(CString(lineptr));\r
403                         if (trimptr+1 < lineptr+61)\r
404                                 lineptr +=61;\r
405                         else\r
406                                 lineptr = (trimptr+1);\r
407                         trimptr = lineptr+30;\r
408                         while ((*trimptr == ' ')&&(trimptr > lineptr))\r
409                                 trimptr--;\r
410                         *(trimptr+1) = 0;\r
411                         authors.push_back(CString(lineptr));\r
412                         lineptr += 31;\r
413                         // in case we find an UTF8 BOM at the beginning of the line, we remove it\r
414                         if (((unsigned char)lineptr[0] == 0xEF)&&((unsigned char)lineptr[1] == 0xBB)&&((unsigned char)lineptr[2] == 0xBF))\r
415                         {\r
416                                 lineptr += 3;\r
417                         }\r
418                         if (((unsigned char)lineptr[0] == 0xBB)&&((unsigned char)lineptr[1] == 0xEF)&&((unsigned char)lineptr[2] == 0xBF))\r
419                         {\r
420                                 lineptr += 3;\r
421                         }\r
422                         // check each line for illegal utf8 sequences. If one is found, we treat\r
423                         // the file as ASCII, otherwise we assume an UTF8 file.\r
424                         char * utf8CheckBuf = lineptr;\r
425                         while ((bUTF8)&&(*utf8CheckBuf))\r
426                         {\r
427                                 if ((*utf8CheckBuf == 0xC0)||(*utf8CheckBuf == 0xC1)||(*utf8CheckBuf >= 0xF5))\r
428                                 {\r
429                                         bUTF8 = false;\r
430                                         break;\r
431                                 }\r
432                                 if ((*utf8CheckBuf & 0xE0)==0xC0)\r
433                                 {\r
434                                         utf8CheckBuf++;\r
435                                         if (*utf8CheckBuf == 0)\r
436                                                 break;\r
437                                         if ((*utf8CheckBuf & 0xC0)!=0x80)\r
438                                         {\r
439                                                 bUTF8 = false;\r
440                                                 break;\r
441                                         }\r
442                                 }\r
443                                 if ((*utf8CheckBuf & 0xF0)==0xE0)\r
444                                 {\r
445                                         utf8CheckBuf++;\r
446                                         if (*utf8CheckBuf == 0)\r
447                                                 break;\r
448                                         if ((*utf8CheckBuf & 0xC0)!=0x80)\r
449                                         {\r
450                                                 bUTF8 = false;\r
451                                                 break;\r
452                                         }\r
453                                         utf8CheckBuf++;\r
454                                         if (*utf8CheckBuf == 0)\r
455                                                 break;\r
456                                         if ((*utf8CheckBuf & 0xC0)!=0x80)\r
457                                         {\r
458                                                 bUTF8 = false;\r
459                                                 break;\r
460                                         }\r
461                                 }\r
462                                 if ((*utf8CheckBuf & 0xF8)==0xF0)\r
463                                 {\r
464                                         utf8CheckBuf++;\r
465                                         if (*utf8CheckBuf == 0)\r
466                                                 break;\r
467                                         if ((*utf8CheckBuf & 0xC0)!=0x80)\r
468                                         {\r
469                                                 bUTF8 = false;\r
470                                                 break;\r
471                                         }\r
472                                         utf8CheckBuf++;\r
473                                         if (*utf8CheckBuf == 0)\r
474                                                 break;\r
475                                         if ((*utf8CheckBuf & 0xC0)!=0x80)\r
476                                         {\r
477                                                 bUTF8 = false;\r
478                                                 break;\r
479                                         }\r
480                                         utf8CheckBuf++;\r
481                                         if (*utf8CheckBuf == 0)\r
482                                                 break;\r
483                                         if ((*utf8CheckBuf & 0xC0)!=0x80)\r
484                                         {\r
485                                                 bUTF8 = false;\r
486                                                 break;\r
487                                         }\r
488                                 }\r
489 \r
490                                 utf8CheckBuf++;\r
491                         }\r
492                         SendEditor(SCI_ADDTEXT, _tcslen(lineptr), reinterpret_cast<LPARAM>(static_cast<char *>(lineptr)));\r
493                         SendEditor(SCI_ADDTEXT, 2, (LPARAM)_T("\r\n"));\r
494                 }\r
495         } while (File.gcount() > 0);\r
496 \r
497         if (bUTF8)\r
498                 SendEditor(SCI_SETCODEPAGE, SC_CP_UTF8);\r
499 \r
500         SendEditor(SCI_SETUNDOCOLLECTION, 1);\r
501         ::SetFocus(wEditor);\r
502         SendEditor(EM_EMPTYUNDOBUFFER);\r
503         SendEditor(SCI_SETSAVEPOINT);\r
504         SendEditor(SCI_GOTOPOS, 0);\r
505         SendEditor(SCI_SETSCROLLWIDTHTRACKING, TRUE);\r
506         SendEditor(SCI_SETREADONLY, TRUE);\r
507 \r
508         //check which lexer to use, depending on the filetype\r
509         SetupLexer(fileName);\r
510         ::ShowWindow(wEditor, SW_SHOW);\r
511         m_blamewidth = 0;\r
512         ::InvalidateRect(wMain, NULL, TRUE);\r
513         RECT rc;\r
514         GetWindowRect(wMain, &rc);\r
515         SetWindowPos(wMain, 0, rc.left, rc.top, rc.right-rc.left-1, rc.bottom - rc.top, 0);\r
516 #endif\r
517         return TRUE;\r
518 }\r
519 \r
520 void CTortoiseGitBlameView::SetAStyle(int style, COLORREF fore, COLORREF back, int size, const char *face) \r
521 {\r
522         SendEditor(SCI_STYLESETFORE, style, fore);\r
523         SendEditor(SCI_STYLESETBACK, style, back);\r
524         if (size >= 1)\r
525                 SendEditor(SCI_STYLESETSIZE, style, size);\r
526         if (face) \r
527                 SendEditor(SCI_STYLESETFONT, style, reinterpret_cast<LPARAM>(face));\r
528 }\r
529 \r
530 void CTortoiseGitBlameView::InitialiseEditor() \r
531 {\r
532 #if 0\r
533         m_directFunction = SendMessage(wEditor, SCI_GETDIRECTFUNCTION, 0, 0);\r
534         m_directPointer = SendMessage(wEditor, SCI_GETDIRECTPOINTER, 0, 0);\r
535         // Set up the global default style. These attributes are used wherever no explicit choices are made.\r
536         SetAStyle(STYLE_DEFAULT, black, white, (DWORD)CRegStdWORD(_T("Software\\TortoiseGit\\BlameFontSize"), 10), \r
537                 ((stdstring)(CRegStdString(_T("Software\\TortoiseGit\\BlameFontName"), _T("Courier New")))).c_str());\r
538         SendEditor(SCI_SETTABWIDTH, (DWORD)CRegStdWORD(_T("Software\\TortoiseGit\\BlameTabSize"), 4));\r
539         SendEditor(SCI_SETREADONLY, TRUE);\r
540         LRESULT pix = SendEditor(SCI_TEXTWIDTH, STYLE_LINENUMBER, (LPARAM)_T("_99999"));\r
541         if (ShowLine)\r
542                 SendEditor(SCI_SETMARGINWIDTHN, 0, pix);\r
543         else\r
544                 SendEditor(SCI_SETMARGINWIDTHN, 0);\r
545         SendEditor(SCI_SETMARGINWIDTHN, 1);\r
546         SendEditor(SCI_SETMARGINWIDTHN, 2);\r
547         //Set the default windows colors for edit controls\r
548         SendEditor(SCI_STYLESETFORE, STYLE_DEFAULT, ::GetSysColor(COLOR_WINDOWTEXT));\r
549         SendEditor(SCI_STYLESETBACK, STYLE_DEFAULT, ::GetSysColor(COLOR_WINDOW));\r
550         SendEditor(SCI_SETSELFORE, TRUE, ::GetSysColor(COLOR_HIGHLIGHTTEXT));\r
551         SendEditor(SCI_SETSELBACK, TRUE, ::GetSysColor(COLOR_HIGHLIGHT));\r
552         SendEditor(SCI_SETCARETFORE, ::GetSysColor(COLOR_WINDOWTEXT));\r
553         m_regOldLinesColor = CRegStdWORD(_T("Software\\TortoiseGit\\BlameOldColor"), RGB(230, 230, 255));\r
554         m_regNewLinesColor = CRegStdWORD(_T("Software\\TortoiseGit\\BlameNewColor"), RGB(255, 230, 230));\r
555 #endif\r
556 }\r
557 \r
558 void CTortoiseGitBlameView::StartSearch()\r
559 {\r
560         if (currentDialog)\r
561                 return;\r
562         bool bCase = false;\r
563         // Initialize FINDREPLACE\r
564         if (fr.Flags & FR_MATCHCASE)\r
565                 bCase = true;\r
566         SecureZeroMemory(&fr, sizeof(fr));\r
567         fr.lStructSize = sizeof(fr);\r
568         fr.hwndOwner = wMain;\r
569         fr.lpstrFindWhat = szFindWhat;\r
570         fr.wFindWhatLen = 80;\r
571         fr.Flags = FR_HIDEUPDOWN | FR_HIDEWHOLEWORD;\r
572         fr.Flags |= bCase ? FR_MATCHCASE : 0;\r
573 \r
574         currentDialog = FindText(&fr);\r
575 }\r
576 \r
577 bool CTortoiseGitBlameView::DoSearch(LPSTR what, DWORD flags)\r
578 {\r
579 #if 0\r
580         TCHAR szWhat[80];\r
581         int pos = SendEditor(SCI_GETCURRENTPOS);\r
582         int line = SendEditor(SCI_LINEFROMPOSITION, pos);\r
583         bool bFound = false;\r
584         bool bCaseSensitive = !!(flags & FR_MATCHCASE);\r
585 \r
586         strcpy_s(szWhat, sizeof(szWhat), what);\r
587 \r
588         if(!bCaseSensitive)\r
589         {\r
590                 char *p;\r
591                 size_t len = strlen(szWhat);\r
592                 for (p = szWhat; p < szWhat + len; p++)\r
593                 {\r
594                         if (isupper(*p)&&__isascii(*p))\r
595                                 *p = _tolower(*p);\r
596                 }\r
597         }\r
598 \r
599         CString sWhat = CString(szWhat);\r
600         \r
601         char buf[20];\r
602         int i=0;\r
603         for (i=line; (i<(int)authors.size())&&(!bFound); ++i)\r
604         {\r
605                 int bufsize = SendEditor(SCI_GETLINE, i);\r
606                 char * linebuf = new char[bufsize+1];\r
607                 SecureZeroMemory(linebuf, bufsize+1);\r
608                 SendEditor(SCI_GETLINE, i, (LPARAM)linebuf);\r
609                 if (!bCaseSensitive)\r
610                 {\r
611                         char *p;\r
612                         for (p = linebuf; p < linebuf + bufsize; p++)\r
613                         {\r
614                                 if (isupper(*p)&&__isascii(*p))\r
615                                         *p = _tolower(*p);\r
616                         }\r
617                 }\r
618                 _stprintf_s(buf, 20, _T("%ld"), revs[i]);\r
619                 if (authors[i].compare(sWhat)==0)\r
620                         bFound = true;\r
621                 else if ((!bCaseSensitive)&&(_stricmp(authors[i].c_str(), szWhat)==0))\r
622                         bFound = true;\r
623                 else if (strcmp(buf, szWhat) == 0)\r
624                         bFound = true;\r
625                 else if (strstr(linebuf, szWhat))\r
626                         bFound = true;\r
627                 delete [] linebuf;\r
628         }\r
629         if (!bFound)\r
630         {\r
631                 for (i=0; (i<line)&&(!bFound); ++i)\r
632                 {\r
633                         int bufsize = SendEditor(SCI_GETLINE, i);\r
634                         char * linebuf = new char[bufsize+1];\r
635                         SecureZeroMemory(linebuf, bufsize+1);\r
636                         SendEditor(SCI_GETLINE, i, (LPARAM)linebuf);\r
637                         if (!bCaseSensitive)\r
638                         {\r
639                                 char *p;\r
640                                 for (p = linebuf; p < linebuf + bufsize; p++)\r
641                                 {\r
642                                         if (isupper(*p)&&__isascii(*p))\r
643                                                 *p = _tolower(*p);\r
644                                 }\r
645                         }\r
646                         _stprintf_s(buf, 20, _T("%ld"), revs[i]);\r
647                         if (authors[i].compare(sWhat)==0)\r
648                                 bFound = true;\r
649                         else if ((!bCaseSensitive)&&(_stricmp(authors[i].c_str(), szWhat)==0))\r
650                                 bFound = true;\r
651                         else if (strcmp(buf, szWhat) == 0)\r
652                                 bFound = true;\r
653                         else if (strstr(linebuf, szWhat))\r
654                                 bFound = true;\r
655                         delete [] linebuf;\r
656                 }\r
657         }\r
658         if (bFound)\r
659         {\r
660                 GotoLine(i);\r
661                 int selstart = SendEditor(SCI_GETCURRENTPOS);\r
662                 int selend = SendEditor(SCI_POSITIONFROMLINE, i);\r
663                 SendEditor(SCI_SETSELECTIONSTART, selstart);\r
664                 SendEditor(SCI_SETSELECTIONEND, selend);\r
665                 m_SelectedLine = i-1;\r
666         }\r
667         else\r
668         {\r
669                 ::MessageBox(wMain, searchstringnotfound, "CTortoiseGitBlameView", MB_ICONINFORMATION);\r
670         }\r
671 #endif\r
672         return true;\r
673 }\r
674 \r
675 bool CTortoiseGitBlameView::GotoLine(long line)\r
676 {\r
677         --line;\r
678         if (line < 0)\r
679                 return false;\r
680         if ((unsigned long)line >= authors.size())\r
681         {\r
682                 line = authors.size()-1;\r
683         }\r
684 \r
685         int nCurrentPos = SendEditor(SCI_GETCURRENTPOS);\r
686         int nCurrentLine = SendEditor(SCI_LINEFROMPOSITION,nCurrentPos);\r
687         int nFirstVisibleLine = SendEditor(SCI_GETFIRSTVISIBLELINE);\r
688         int nLinesOnScreen = SendEditor(SCI_LINESONSCREEN);\r
689 \r
690         if ( line>=nFirstVisibleLine && line<=nFirstVisibleLine+nLinesOnScreen)\r
691         {\r
692                 // no need to scroll\r
693                 SendEditor(SCI_GOTOLINE, line);\r
694         }\r
695         else\r
696         {\r
697                 // Place the requested line one third from the top\r
698                 if ( line > nCurrentLine )\r
699                 {\r
700                         SendEditor(SCI_GOTOLINE, (WPARAM)(line+(int)nLinesOnScreen*(2/3.0)));\r
701                 }\r
702                 else\r
703                 {\r
704                         SendEditor(SCI_GOTOLINE, (WPARAM)(line-(int)nLinesOnScreen*(1/3.0)));\r
705                 }\r
706         }\r
707 \r
708         // Highlight the line\r
709         int nPosStart = SendEditor(SCI_POSITIONFROMLINE,line);\r
710         int nPosEnd = SendEditor(SCI_GETLINEENDPOSITION,line);\r
711         SendEditor(SCI_SETSEL,nPosEnd,nPosStart);\r
712 \r
713         return true;\r
714 }\r
715 \r
716 bool CTortoiseGitBlameView::ScrollToLine(long line)\r
717 {\r
718         if (line < 0)\r
719                 return false;\r
720 \r
721         int nCurrentLine = SendEditor(SCI_GETFIRSTVISIBLELINE);\r
722 \r
723         int scrolldelta = line - nCurrentLine;\r
724         SendEditor(SCI_LINESCROLL, 0, scrolldelta);\r
725 \r
726         return true;\r
727 }\r
728 \r
729 void CTortoiseGitBlameView::CopySelectedLogToClipboard()\r
730 {\r
731 #if 0\r
732         if (m_selectedrev <= 0)\r
733                 return;\r
734         std::map<LONG, CString>::iterator iter;\r
735         if ((iter = app.logmessages.find(m_selectedrev)) != app.logmessages.end())\r
736         {\r
737                 CString msg;\r
738                 msg += m_selectedauthor;\r
739                 msg += "  ";\r
740                 msg += app.m_selecteddate;\r
741                 msg += '\n';\r
742                 msg += iter->second;\r
743                 msg += _T("\n");\r
744                 if (OpenClipboard(app.wBlame))\r
745                 {\r
746                         EmptyClipboard();\r
747                         HGLOBAL hClipboardData;\r
748                         hClipboardData = GlobalAlloc(GMEM_DDESHARE, msg.size()+1);\r
749                         char * pchData;\r
750                         pchData = (char*)GlobalLock(hClipboardData);\r
751                         strcpy_s(pchData, msg.size()+1, msg.c_str());\r
752                         GlobalUnlock(hClipboardData);\r
753                         SetClipboardData(CF_TEXT,hClipboardData);\r
754                         CloseClipboard();\r
755                 }\r
756         }\r
757 #endif\r
758 }\r
759 \r
760 void CTortoiseGitBlameView::BlamePreviousRevision()\r
761 {\r
762 #if 0\r
763         LONG nRevisionTo = m_selectedorigrev - 1;\r
764         if ( nRevisionTo<1 )\r
765         {\r
766                 return;\r
767         }\r
768 \r
769         // We now determine the smallest revision number in the blame file (but ignore "-1")\r
770         // We do this for two reasons:\r
771         // 1. we respect the "From revision" which the user entered\r
772         // 2. we speed up the call of "svn blame" because previous smaller revision numbers don't have any effect on the result\r
773         LONG nSmallestRevision = -1;\r
774         for (LONG line=0;line<(LONG)app.revs.size();line++)\r
775         {\r
776                 const LONG nRevision = app.revs[line];\r
777                 if ( nRevision > 0 )\r
778                 {\r
779                         if ( nSmallestRevision < 1 )\r
780                         {\r
781                                 nSmallestRevision = nRevision;\r
782                         }\r
783                         else\r
784                         {\r
785                                 nSmallestRevision = min(nSmallestRevision,nRevision);\r
786                         }\r
787                 }\r
788         }\r
789 \r
790         char bufStartRev[20];\r
791         _stprintf_s(bufStartRev, 20, _T("%d"), nSmallestRevision);\r
792 \r
793         char bufEndRev[20];\r
794         _stprintf_s(bufEndRev, 20, _T("%d"), nRevisionTo);\r
795 \r
796         char bufLine[20];\r
797         _stprintf_s(bufLine, 20, _T("%d"), m_SelectedLine+1); //using the current line is a good guess.\r
798 \r
799         STARTUPINFO startup;\r
800         PROCESS_INFORMATION process;\r
801         memset(&startup, 0, sizeof(startup));\r
802         startup.cb = sizeof(startup);\r
803         memset(&process, 0, sizeof(process));\r
804         stdstring tortoiseProcPath = GetAppDirectory() + _T("TortoiseProc.exe");\r
805         stdstring svnCmd = _T(" /command:blame ");\r
806         svnCmd += _T(" /path:\"");\r
807         svnCmd += szOrigPath;\r
808         svnCmd += _T("\"");\r
809         svnCmd += _T(" /startrev:");\r
810         svnCmd += bufStartRev;\r
811         svnCmd += _T(" /endrev:");\r
812         svnCmd += bufEndRev;\r
813         svnCmd += _T(" /line:");\r
814         svnCmd += bufLine;\r
815         if (bIgnoreEOL)\r
816                 svnCmd += _T(" /ignoreeol");\r
817         if (bIgnoreSpaces)\r
818                 svnCmd += _T(" /ignorespaces");\r
819         if (bIgnoreAllSpaces)\r
820                 svnCmd += _T(" /ignoreallspaces");\r
821     if (CreateProcess(tortoiseProcPath.c_str(), const_cast<TCHAR*>(svnCmd.c_str()), NULL, NULL, FALSE, 0, 0, 0, &startup, &process))\r
822         {\r
823                 CloseHandle(process.hThread);\r
824                 CloseHandle(process.hProcess);\r
825         }\r
826 #endif\r
827 }\r
828 \r
829 void CTortoiseGitBlameView::DiffPreviousRevision()\r
830 {\r
831 #if 0\r
832         LONG nRevisionTo = m_selectedorigrev;\r
833         if ( nRevisionTo<1 )\r
834         {\r
835                 return;\r
836         }\r
837 \r
838         LONG nRevisionFrom = nRevisionTo-1;\r
839 \r
840         char bufStartRev[20];\r
841         _stprintf_s(bufStartRev, 20, _T("%d"), nRevisionFrom);\r
842 \r
843         char bufEndRev[20];\r
844         _stprintf_s(bufEndRev, 20, _T("%d"), nRevisionTo);\r
845 \r
846         STARTUPINFO startup;\r
847         PROCESS_INFORMATION process;\r
848         memset(&startup, 0, sizeof(startup));\r
849         startup.cb = sizeof(startup);\r
850         memset(&process, 0, sizeof(process));\r
851         stdstring tortoiseProcPath = GetAppDirectory() + _T("TortoiseProc.exe");\r
852         stdstring svnCmd = _T(" /command:diff ");\r
853         svnCmd += _T(" /path:\"");\r
854         svnCmd += szOrigPath;\r
855         svnCmd += _T("\"");\r
856         svnCmd += _T(" /startrev:");\r
857         svnCmd += bufStartRev;\r
858         svnCmd += _T(" /endrev:");\r
859         svnCmd += bufEndRev;\r
860         if (CreateProcess(tortoiseProcPath.c_str(), const_cast<TCHAR*>(svnCmd.c_str()), NULL, NULL, FALSE, 0, 0, 0, &startup, &process))\r
861         {\r
862                 CloseHandle(process.hThread);\r
863                 CloseHandle(process.hProcess);\r
864         }\r
865 #endif\r
866 }\r
867 \r
868 void CTortoiseGitBlameView::ShowLog()\r
869 {\r
870 #if 0\r
871         char bufRev[20];\r
872         _stprintf_s(bufRev, 20, _T("%d"), m_selectedorigrev);\r
873 \r
874         STARTUPINFO startup;\r
875         PROCESS_INFORMATION process;\r
876         memset(&startup, 0, sizeof(startup));\r
877         startup.cb = sizeof(startup);\r
878         memset(&process, 0, sizeof(process));\r
879         stdstring tortoiseProcPath = GetAppDirectory() + _T("TortoiseProc.exe");\r
880         stdstring svnCmd = _T(" /command:log ");\r
881         svnCmd += _T(" /path:\"");\r
882         svnCmd += szOrigPath;\r
883         svnCmd += _T("\"");\r
884         svnCmd += _T(" /startrev:");\r
885         svnCmd += bufRev;\r
886         svnCmd += _T(" /pegrev:");\r
887         svnCmd += bufRev;\r
888         if (CreateProcess(tortoiseProcPath.c_str(), const_cast<TCHAR*>(svnCmd.c_str()), NULL, NULL, FALSE, 0, 0, 0, &startup, &process))\r
889         {\r
890                 CloseHandle(process.hThread);\r
891                 CloseHandle(process.hProcess);\r
892         }\r
893 #endif\r
894 }\r
895 \r
896 void CTortoiseGitBlameView::Notify(SCNotification *notification) \r
897 {\r
898         switch (notification->nmhdr.code) \r
899         {\r
900         case SCN_SAVEPOINTREACHED:\r
901                 break;\r
902 \r
903         case SCN_SAVEPOINTLEFT:\r
904                 break;\r
905         case SCN_PAINTED:\r
906 //              InvalidateRect(wBlame, NULL, FALSE);\r
907 //              InvalidateRect(wLocator, NULL, FALSE);\r
908                 break;\r
909         case SCN_GETBKCOLOR:\r
910                 if ((m_colorage)&&(notification->line < (int)revs.size()))\r
911                 {\r
912                         notification->lParam = InterColor(DWORD(m_regOldLinesColor), DWORD(m_regNewLinesColor), (revs[notification->line]-m_lowestrev)*100/((m_highestrev-m_lowestrev)+1));\r
913                 }\r
914                 break;\r
915         }\r
916 }\r
917 \r
918 void CTortoiseGitBlameView::Command(int id)\r
919 {\r
920 #if 0\r
921         switch (id) \r
922         {\r
923 //      case IDM_EXIT:\r
924 //              ::PostQuitMessage(0);\r
925 //              break;\r
926         case ID_EDIT_FIND:\r
927                 StartSearch();\r
928                 break;\r
929         case ID_COPYTOCLIPBOARD:\r
930                 CopySelectedLogToClipboard();\r
931                 break;\r
932         case ID_BLAME_PREVIOUS_REVISION:\r
933                 BlamePreviousRevision();\r
934                 break;\r
935         case ID_DIFF_PREVIOUS_REVISION:\r
936                 DiffPreviousRevision();\r
937                 break;\r
938         case ID_SHOWLOG:\r
939                 ShowLog();\r
940                 break;\r
941         case ID_EDIT_GOTOLINE:\r
942                 GotoLineDlg();\r
943                 break;\r
944         case ID_VIEW_COLORAGEOFLINES:\r
945                 {\r
946                         m_colorage = !m_colorage;\r
947                         HMENU hMenu = GetMenu(wMain);\r
948                         UINT uCheck = MF_BYCOMMAND;\r
949                         uCheck |= m_colorage ? MF_CHECKED : MF_UNCHECKED;\r
950                         CheckMenuItem(hMenu, ID_VIEW_COLORAGEOFLINES, uCheck);\r
951                         m_blamewidth = 0;\r
952                         InitSize();\r
953                 }\r
954                 break;\r
955         case ID_VIEW_MERGEPATH:\r
956                 {\r
957                         ShowPath = !ShowPath;\r
958                         HMENU hMenu = GetMenu(wMain);\r
959                         UINT uCheck = MF_BYCOMMAND;\r
960                         uCheck |= ShowPath ? MF_CHECKED : MF_UNCHECKED;\r
961                         CheckMenuItem(hMenu, ID_VIEW_MERGEPATH, uCheck);\r
962                         m_blamewidth = 0;\r
963                         InitSize();\r
964                 }\r
965         default:\r
966                 break;\r
967         };\r
968 #endif\r
969 }\r
970 \r
971 void CTortoiseGitBlameView::GotoLineDlg()\r
972 {\r
973 #if 0\r
974         if (DialogBox(hResource, MAKEINTRESOURCE(IDD_GOTODLG), wMain, GotoDlgProc)==IDOK)\r
975         {\r
976                 GotoLine(m_gotoline);\r
977         }\r
978 #endif\r
979 }\r
980 \r
981 LONG CTortoiseGitBlameView::GetBlameWidth()\r
982 {\r
983 #if 0\r
984         if (m_blamewidth)\r
985                 return m_blamewidth;\r
986         LONG blamewidth = 0;\r
987         SIZE width;\r
988         CreateFont();\r
989         HDC hDC = ::GetDC(wBlame);\r
990         HFONT oldfont = (HFONT)::SelectObject(hDC, m_font);\r
991         TCHAR buf[MAX_PATH];\r
992         _stprintf_s(buf, MAX_PATH, _T("%8ld "), 88888888);\r
993         ::GetTextExtentPoint(hDC, buf, _tcslen(buf), &width);\r
994         m_revwidth = width.cx + BLAMESPACE;\r
995         blamewidth += m_revwidth;\r
996         if (ShowDate)\r
997         {\r
998                 _stprintf_s(buf, MAX_PATH, _T("%30s"), _T("31.08.2001 06:24:14"));\r
999                 ::GetTextExtentPoint32(hDC, buf, _tcslen(buf), &width);\r
1000                 m_datewidth = width.cx + BLAMESPACE;\r
1001                 blamewidth += m_datewidth;\r
1002         }\r
1003         if (ShowAuthor)\r
1004         {\r
1005                 SIZE maxwidth = {0};\r
1006                 for (std::vector<CString>::iterator I = authors.begin(); I != authors.end(); ++I)\r
1007                 {\r
1008                         ::GetTextExtentPoint32(hDC, I->c_str(), I->size(), &width);\r
1009                         if (width.cx > maxwidth.cx)\r
1010                                 maxwidth = width;\r
1011                 }\r
1012                 m_authorwidth = maxwidth.cx + BLAMESPACE;\r
1013                 blamewidth += m_authorwidth;\r
1014         }\r
1015         if (ShowPath)\r
1016         {\r
1017                 SIZE maxwidth = {0};\r
1018                 for (std::vector<CString>::iterator I = paths.begin(); I != paths.end(); ++I)\r
1019                 {\r
1020                         ::GetTextExtentPoint32(hDC, I->c_str(), I->size(), &width);\r
1021                         if (width.cx > maxwidth.cx)\r
1022                                 maxwidth = width;\r
1023                 }\r
1024                 m_pathwidth = maxwidth.cx + BLAMESPACE;\r
1025                 blamewidth += m_pathwidth;\r
1026         }\r
1027         ::SelectObject(hDC, oldfont);\r
1028         POINT pt = {blamewidth, 0};\r
1029         LPtoDP(hDC, &pt, 1);\r
1030         m_blamewidth = pt.x;\r
1031         ReleaseDC(wBlame, hDC);\r
1032 #endif\r
1033         //return m_blamewidth;\r
1034         return 100;\r
1035 }\r
1036 \r
1037 void CTortoiseGitBlameView::CreateFont()\r
1038 {\r
1039         if (m_font)\r
1040                 return;\r
1041         LOGFONT lf = {0};\r
1042         lf.lfWeight = 400;\r
1043         HDC hDC = ::GetDC(wBlame);\r
1044         lf.lfHeight = -MulDiv((DWORD)CRegStdWORD(_T("Software\\TortoiseGit\\BlameFontSize"), 10), GetDeviceCaps(hDC, LOGPIXELSY), 72);\r
1045         lf.lfCharSet = DEFAULT_CHARSET;\r
1046         CRegStdString fontname = CRegStdString(_T("Software\\TortoiseGit\\BlameFontName"), _T("Courier New"));\r
1047         _tcscpy_s(lf.lfFaceName, 32, ((stdstring)fontname).c_str());\r
1048         m_font = ::CreateFontIndirect(&lf);\r
1049 \r
1050         lf.lfItalic = TRUE;\r
1051         m_italicfont = ::CreateFontIndirect(&lf);\r
1052 \r
1053         ::ReleaseDC(wBlame, hDC);\r
1054 \r
1055 }\r
1056 \r
1057 void CTortoiseGitBlameView::DrawBlame(HDC hDC)\r
1058 {\r
1059 #if 0\r
1060         if (hDC == NULL)\r
1061                 return;\r
1062         if (m_font == NULL)\r
1063                 return;\r
1064 \r
1065         HFONT oldfont = NULL;\r
1066         LONG_PTR line = SendEditor(SCI_GETFIRSTVISIBLELINE);\r
1067         LONG_PTR linesonscreen = SendEditor(SCI_LINESONSCREEN);\r
1068         LONG_PTR height = SendEditor(SCI_TEXTHEIGHT);\r
1069         LONG_PTR Y = 0;\r
1070         TCHAR buf[MAX_PATH];\r
1071         RECT rc;\r
1072         BOOL sel = FALSE;\r
1073         ::GetClientRect(wBlame, &rc);\r
1074         for (LRESULT i=line; i<(line+linesonscreen); ++i)\r
1075         {\r
1076                 sel = FALSE;\r
1077                 if (i < (int)revs.size())\r
1078                 {\r
1079                         if (mergelines[i])\r
1080                                 oldfont = (HFONT)::SelectObject(hDC, m_italicfont);\r
1081                         else\r
1082                                 oldfont = (HFONT)::SelectObject(hDC, m_font);\r
1083                         ::SetBkColor(hDC, m_windowcolor);\r
1084                         ::SetTextColor(hDC, m_textcolor);\r
1085                         if (authors[i].GetLength()>0)\r
1086                         {\r
1087                                 if (authors[i].Compare(m_mouseauthor)==0)\r
1088                                         ::SetBkColor(hDC, m_mouseauthorcolor);\r
1089                                 if (authors[i].Compare(m_selectedauthor)==0)\r
1090                                 {\r
1091                                         ::SetBkColor(hDC, m_selectedauthorcolor);\r
1092                                         ::SetTextColor(hDC, m_texthighlightcolor);\r
1093                                         sel = TRUE;\r
1094                                 }\r
1095                         }\r
1096                         if ((revs[i] == m_mouserev)&&(!sel))\r
1097                                 ::SetBkColor(hDC, m_mouserevcolor);\r
1098                         if (revs[i] == m_selectedrev)\r
1099                         {\r
1100                                 ::SetBkColor(hDC, m_selectedrevcolor);\r
1101                                 ::SetTextColor(hDC, m_texthighlightcolor);\r
1102                         }\r
1103                         _stprintf_s(buf, MAX_PATH, _T("%8ld       "), revs[i]);\r
1104                         rc.right = rc.left + m_revwidth;\r
1105                         ::ExtTextOut(hDC, 0, Y, ETO_CLIPPED, &rc, buf, _tcslen(buf), 0);\r
1106                         int Left = m_revwidth;\r
1107                         if (ShowDate)\r
1108                         {\r
1109                                 rc.right = rc.left + Left + m_datewidth;\r
1110                                 _stprintf_s(buf, MAX_PATH, _T("%30s            "), dates[i].c_str());\r
1111                                 ::ExtTextOut(hDC, Left, Y, ETO_CLIPPED, &rc, buf, _tcslen(buf), 0);\r
1112                                 Left += m_datewidth;\r
1113                         }\r
1114                         if (ShowAuthor)\r
1115                         {\r
1116                                 rc.right = rc.left + Left + m_authorwidth;\r
1117                                 _stprintf_s(buf, MAX_PATH, _T("%-30s            "), authors[i].c_str());\r
1118                                 ::ExtTextOut(hDC, Left, Y, ETO_CLIPPED, &rc, buf, _tcslen(buf), 0);\r
1119                                 Left += m_authorwidth;\r
1120                         }\r
1121                         if (ShowPath)\r
1122                         {\r
1123                                 rc.right = rc.left + Left + m_pathwidth;\r
1124                                 _stprintf_s(buf, MAX_PATH, _T("%-60s            "), paths[i].c_str());\r
1125                                 ::ExtTextOut(hDC, Left, Y, ETO_CLIPPED, &rc, buf, _tcslen(buf), 0);\r
1126                                 Left += m_authorwidth;\r
1127                         }\r
1128                         if ((i==m_SelectedLine)&&(currentDialog))\r
1129                         {\r
1130                                 LOGBRUSH brush;\r
1131                                 brush.lbColor = m_textcolor;\r
1132                                 brush.lbHatch = 0;\r
1133                                 brush.lbStyle = BS_SOLID;\r
1134                                 HPEN pen = ExtCreatePen(PS_SOLID | PS_GEOMETRIC, 2, &brush, 0, NULL);\r
1135                                 HGDIOBJ hPenOld = SelectObject(hDC, pen);\r
1136                                 RECT rc2 = rc;\r
1137                                 rc2.top = Y;\r
1138                                 rc2.bottom = Y + height;\r
1139                                 ::MoveToEx(hDC, rc2.left, rc2.top, NULL);\r
1140                                 ::LineTo(hDC, rc2.right, rc2.top);\r
1141                                 ::LineTo(hDC, rc2.right, rc2.bottom);\r
1142                                 ::LineTo(hDC, rc2.left, rc2.bottom);\r
1143                                 ::LineTo(hDC, rc2.left, rc2.top);\r
1144                                 SelectObject(hDC, hPenOld); \r
1145                                 DeleteObject(pen); \r
1146                         }\r
1147                         Y += height;\r
1148                         ::SelectObject(hDC, oldfont);\r
1149                 }\r
1150                 else\r
1151                 {\r
1152                         ::SetBkColor(hDC, m_windowcolor);\r
1153                         for (int j=0; j< MAX_PATH; ++j)\r
1154                                 buf[j]=' ';\r
1155                         ::ExtTextOut(hDC, 0, Y, ETO_CLIPPED, &rc, buf, MAX_PATH-1, 0);\r
1156                         Y += height;\r
1157                 }\r
1158         }\r
1159 #endif\r
1160 }\r
1161 \r
1162 void CTortoiseGitBlameView::DrawHeader(HDC hDC)\r
1163 {\r
1164 #if 0\r
1165         if (hDC == NULL)\r
1166                 return;\r
1167 \r
1168         RECT rc;\r
1169         HFONT oldfont = (HFONT)::SelectObject(hDC, GetStockObject(DEFAULT_GUI_FONT));\r
1170         ::GetClientRect(wHeader, &rc);\r
1171 \r
1172         ::SetBkColor(hDC, ::GetSysColor(COLOR_BTNFACE));\r
1173 \r
1174         TCHAR szText[MAX_LOADSTRING];\r
1175         LoadString(app.hResource, IDS_HEADER_REVISION, szText, MAX_LOADSTRING);\r
1176         ::ExtTextOut(hDC, LOCATOR_WIDTH, 0, ETO_CLIPPED, &rc, szText, _tcslen(szText), 0);\r
1177         int Left = m_revwidth+LOCATOR_WIDTH;\r
1178         if (ShowDate)\r
1179         {\r
1180                 LoadString(app.hResource, IDS_HEADER_DATE, szText, MAX_LOADSTRING);\r
1181                 ::ExtTextOut(hDC, Left, 0, ETO_CLIPPED, &rc, szText, _tcslen(szText), 0);\r
1182                 Left += m_datewidth;\r
1183         }\r
1184         if (ShowAuthor)\r
1185         {\r
1186                 LoadString(app.hResource, IDS_HEADER_AUTHOR, szText, MAX_LOADSTRING);\r
1187                 ::ExtTextOut(hDC, Left, 0, ETO_CLIPPED, &rc, szText, _tcslen(szText), 0);\r
1188                 Left += m_authorwidth;\r
1189         }\r
1190         if (ShowPath)\r
1191         {\r
1192                 LoadString(app.hResource, IDS_HEADER_PATH, szText, MAX_LOADSTRING);\r
1193                 ::ExtTextOut(hDC, Left, 0, ETO_CLIPPED, &rc, szText, _tcslen(szText), 0);\r
1194                 Left += m_pathwidth;\r
1195         }\r
1196         LoadString(app.hResource, IDS_HEADER_LINE, szText, MAX_LOADSTRING);\r
1197         ::ExtTextOut(hDC, Left, 0, ETO_CLIPPED, &rc, szText, _tcslen(szText), 0);\r
1198 \r
1199         ::SelectObject(hDC, oldfont);\r
1200 #endif\r
1201 }\r
1202 \r
1203 void CTortoiseGitBlameView::DrawLocatorBar(HDC hDC)\r
1204 {\r
1205         if (hDC == NULL)\r
1206                 return;\r
1207 \r
1208         LONG_PTR line = SendEditor(SCI_GETFIRSTVISIBLELINE);\r
1209         LONG_PTR linesonscreen = SendEditor(SCI_LINESONSCREEN);\r
1210         LONG_PTR Y = 0;\r
1211         COLORREF blackColor = GetSysColor(COLOR_WINDOWTEXT);\r
1212 \r
1213         RECT rc;\r
1214         ::GetClientRect(wLocator, &rc);\r
1215         RECT lineRect = rc;\r
1216         LONG height = rc.bottom-rc.top;\r
1217         LONG currentLine = 0;\r
1218 \r
1219         // draw the colored bar\r
1220         for (std::vector<LONG>::const_iterator it = revs.begin(); it != revs.end(); ++it)\r
1221         {\r
1222                 currentLine++;\r
1223                 // get the line color\r
1224                 COLORREF cr = InterColor(DWORD(m_regOldLinesColor), DWORD(m_regNewLinesColor), (*it - m_lowestrev)*100/((m_highestrev-m_lowestrev)+1));\r
1225                 if ((currentLine > line)&&(currentLine <= (line + linesonscreen)))\r
1226                 {\r
1227                         cr = InterColor(cr, blackColor, 10);\r
1228                 }\r
1229                 SetBkColor(hDC, cr);\r
1230                 lineRect.top = Y;\r
1231                 lineRect.bottom = (currentLine * height / revs.size());\r
1232                 ::ExtTextOut(hDC, 0, 0, ETO_OPAQUE, &lineRect, NULL, 0, NULL);\r
1233                 Y = lineRect.bottom;\r
1234         }\r
1235 \r
1236         if (revs.size())\r
1237         {\r
1238                 // now draw two lines indicating the scroll position of the source view\r
1239                 SetBkColor(hDC, blackColor);\r
1240                 lineRect.top = line * height / revs.size();\r
1241                 lineRect.bottom = lineRect.top+1;\r
1242                 ::ExtTextOut(hDC, 0, 0, ETO_OPAQUE, &lineRect, NULL, 0, NULL);\r
1243                 lineRect.top = (line + linesonscreen) * height / revs.size();\r
1244                 lineRect.bottom = lineRect.top+1;\r
1245                 ::ExtTextOut(hDC, 0, 0, ETO_OPAQUE, &lineRect, NULL, 0, NULL);\r
1246         }\r
1247 }\r
1248 \r
1249 void CTortoiseGitBlameView::StringExpand(LPSTR str)\r
1250 {\r
1251         char * cPos = str;\r
1252         do\r
1253         {\r
1254                 cPos = strchr(cPos, '\n');\r
1255                 if (cPos)\r
1256                 {\r
1257                         memmove(cPos+1, cPos, strlen(cPos)*sizeof(char));\r
1258                         *cPos = '\r';\r
1259                         cPos++;\r
1260                         cPos++;\r
1261                 }\r
1262         } while (cPos != NULL);\r
1263 }\r
1264 void CTortoiseGitBlameView::StringExpand(LPWSTR str)\r
1265 {\r
1266         wchar_t * cPos = str;\r
1267         do\r
1268         {\r
1269                 cPos = wcschr(cPos, '\n');\r
1270                 if (cPos)\r
1271                 {\r
1272                         memmove(cPos+1, cPos, wcslen(cPos)*sizeof(wchar_t));\r
1273                         *cPos = '\r';\r
1274                         cPos++;\r
1275                         cPos++;\r
1276                 }\r
1277         } while (cPos != NULL);\r
1278 }\r
1279 \r
1280 // Forward declarations of functions included in this code module:\r
1281 ATOM                            MyRegisterClass(HINSTANCE hResource);\r
1282 ATOM                            MyRegisterBlameClass(HINSTANCE hResource);\r
1283 ATOM                            MyRegisterHeaderClass(HINSTANCE hResource);\r
1284 ATOM                            MyRegisterLocatorClass(HINSTANCE hResource);\r
1285 BOOL                            InitInstance(HINSTANCE, int);\r
1286 LRESULT CALLBACK        WndProc(HWND, UINT, WPARAM, LPARAM);\r
1287 LRESULT CALLBACK        WndBlameProc(HWND, UINT, WPARAM, LPARAM);\r
1288 LRESULT CALLBACK        WndHeaderProc(HWND, UINT, WPARAM, LPARAM);\r
1289 LRESULT CALLBACK        WndLocatorProc(HWND, UINT, WPARAM, LPARAM);\r
1290 UINT                            uFindReplaceMsg;\r
1291 \r
1292 #if 0\r
1293 int APIENTRY _tWinMain(HINSTANCE hInstance,\r
1294                      HINSTANCE /*hPrevInstance*/,\r
1295                      LPTSTR    lpCmdLine,\r
1296                      int       nCmdShow)\r
1297 {\r
1298         app.hInstance = hInstance;\r
1299         MSG msg;\r
1300         HACCEL hAccelTable;\r
1301 \r
1302         if (::LoadLibrary("SciLexer.DLL") == NULL)\r
1303                 return FALSE;\r
1304 \r
1305         CRegStdWORD loc = CRegStdWORD(_T("Software\\TortoiseGit\\LanguageID"), 1033);\r
1306         long langId = loc;\r
1307 \r
1308         CLangDll langDLL;\r
1309         app.hResource = langDLL.Init(_T("CTortoiseGitBlameView"), langId);\r
1310         if (app.hResource == NULL)\r
1311                 app.hResource = app.hInstance;\r
1312 \r
1313         // Initialize global strings\r
1314         LoadString(app.hResource, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);\r
1315         LoadString(app.hResource, IDC_TortoiseGitBlameView, szWindowClass, MAX_LOADSTRING);\r
1316         LoadString(app.hResource, IDS_SEARCHNOTFOUND, searchstringnotfound, MAX_LOADSTRING);\r
1317         MyRegisterClass(app.hResource);\r
1318         MyRegisterBlameClass(app.hResource);\r
1319         MyRegisterHeaderClass(app.hResource);\r
1320         MyRegisterLocatorClass(app.hResource);\r
1321 \r
1322         // Perform application initialization:\r
1323         if (!InitInstance (app.hResource, nCmdShow)) \r
1324         {\r
1325                 langDLL.Close();\r
1326                 return FALSE;\r
1327         }\r
1328 \r
1329         SecureZeroMemory(szViewtitle, MAX_PATH);\r
1330         SecureZeroMemory(szOrigPath, MAX_PATH);\r
1331         char blamefile[MAX_PATH] = {0};\r
1332         char logfile[MAX_PATH] = {0};\r
1333 \r
1334         CCmdLineParser parser(lpCmdLine);\r
1335 \r
1336 \r
1337         if (__argc > 1)\r
1338         {\r
1339                 _tcscpy_s(blamefile, MAX_PATH, __argv[1]);\r
1340         }\r
1341         if (__argc > 2)\r
1342         {\r
1343                 _tcscpy_s(logfile, MAX_PATH, __argv[2]);\r
1344         }\r
1345         if (__argc > 3)\r
1346         {\r
1347                 _tcscpy_s(szViewtitle, MAX_PATH, __argv[3]);\r
1348                 if (parser.HasVal(_T("revrange")))\r
1349                 {\r
1350                         _tcscat_s(szViewtitle, MAX_PATH, _T(" : "));\r
1351                         _tcscat_s(szViewtitle, MAX_PATH, parser.GetVal(_T("revrange")));\r
1352                 }\r
1353         }\r
1354         if ((_tcslen(blamefile)==0) || parser.HasKey(_T("?")) || parser.HasKey(_T("help")))\r
1355         {\r
1356                 TCHAR szInfo[MAX_LOADSTRING];\r
1357                 LoadString(app.hResource, IDS_COMMANDLINE_INFO, szInfo, MAX_LOADSTRING);\r
1358                 MessageBox(NULL, szInfo, _T("CTortoiseGitBlameView"), MB_ICONERROR);\r
1359                 langDLL.Close();\r
1360                 return 0;\r
1361         }\r
1362 \r
1363         if ( parser.HasKey(_T("path")) )\r
1364         {\r
1365                 _tcscpy_s(szOrigPath, MAX_PATH, parser.GetVal(_T("path")));\r
1366         }\r
1367         app.bIgnoreEOL = parser.HasKey(_T("ignoreeol"));\r
1368         app.bIgnoreSpaces = parser.HasKey(_T("ignorespaces"));\r
1369         app.bIgnoreAllSpaces = parser.HasKey(_T("ignoreallspaces"));\r
1370 \r
1371         app.SendEditor(SCI_SETCODEPAGE, GetACP());\r
1372         app.OpenFile(blamefile);\r
1373         if (_tcslen(logfile)>0)\r
1374                 app.OpenLogFile(logfile);\r
1375 \r
1376         if (parser.HasKey(_T("line")))\r
1377         {\r
1378                 app.GotoLine(parser.GetLongVal(_T("line")));\r
1379         }\r
1380 \r
1381         CheckMenuItem(GetMenu(app.wMain), ID_VIEW_COLORAGEOFLINES, MF_CHECKED|MF_BYCOMMAND);\r
1382 \r
1383 \r
1384         hAccelTable = LoadAccelerators(app.hResource, (LPCTSTR)IDC_TortoiseGitBlameView);\r
1385 \r
1386         BOOL going = TRUE;\r
1387         msg.wParam = 0;\r
1388         while (going) \r
1389         {\r
1390                 going = GetMessage(&msg, NULL, 0, 0);\r
1391                 if (app.currentDialog && going) \r
1392                 {\r
1393                         if (!IsDialogMessage(app.currentDialog, &msg)) \r
1394                         {\r
1395                                 if (TranslateAccelerator(msg.hwnd, hAccelTable, &msg) == 0) \r
1396                                 {\r
1397                                         TranslateMessage(&msg);\r
1398                                         DispatchMessage(&msg);\r
1399                                 }\r
1400                         }\r
1401                 } \r
1402                 else if (going) \r
1403                 {\r
1404                         if (TranslateAccelerator(app.wMain, hAccelTable, &msg) == 0) \r
1405                         {\r
1406                                 TranslateMessage(&msg);\r
1407                                 DispatchMessage(&msg);\r
1408                         }\r
1409                 }\r
1410         }\r
1411         langDLL.Close();\r
1412         return msg.wParam;\r
1413 }\r
1414 \r
1415 ATOM MyRegisterClass(HINSTANCE hResource)\r
1416 {\r
1417         WNDCLASSEX wcex;\r
1418 \r
1419         wcex.cbSize = sizeof(WNDCLASSEX); \r
1420 \r
1421         wcex.style                      = CS_HREDRAW | CS_VREDRAW;\r
1422         wcex.lpfnWndProc        = (WNDPROC)WndProc;\r
1423         wcex.cbClsExtra         = 0;\r
1424         wcex.cbWndExtra         = 0;\r
1425         wcex.hInstance          = hResource;\r
1426         wcex.hIcon                      = LoadIcon(hResource, (LPCTSTR)IDI_TortoiseGitBlameView);\r
1427         wcex.hCursor            = LoadCursor(NULL, IDC_ARROW);\r
1428         wcex.hbrBackground      = (HBRUSH)(COLOR_WINDOW+1);\r
1429         wcex.lpszMenuName       = (LPCTSTR)IDC_TortoiseGitBlameView;\r
1430         wcex.lpszClassName      = szWindowClass;\r
1431         wcex.hIconSm            = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);\r
1432 \r
1433         return RegisterClassEx(&wcex);\r
1434 }\r
1435 \r
1436 ATOM MyRegisterBlameClass(HINSTANCE hResource)\r
1437 {\r
1438         WNDCLASSEX wcex;\r
1439 \r
1440         wcex.cbSize = sizeof(WNDCLASSEX); \r
1441 \r
1442         wcex.style                      = CS_HREDRAW | CS_VREDRAW;\r
1443         wcex.lpfnWndProc        = (WNDPROC)WndBlameProc;\r
1444         wcex.cbClsExtra         = 0;\r
1445         wcex.cbWndExtra         = 0;\r
1446         wcex.hInstance          = hResource;\r
1447         wcex.hIcon                      = LoadIcon(hResource, (LPCTSTR)IDI_TortoiseGitBlameView);\r
1448         wcex.hCursor            = LoadCursor(NULL, IDC_ARROW);\r
1449         wcex.hbrBackground      = (HBRUSH)(COLOR_WINDOW+1);\r
1450         wcex.lpszMenuName       = 0;\r
1451         wcex.lpszClassName      = _T("TortoiseGitBlameViewBlame");\r
1452         wcex.hIconSm            = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);\r
1453 \r
1454         return RegisterClassEx(&wcex);\r
1455 }\r
1456 \r
1457 ATOM MyRegisterHeaderClass(HINSTANCE hResource)\r
1458 {\r
1459         WNDCLASSEX wcex;\r
1460 \r
1461         wcex.cbSize = sizeof(WNDCLASSEX); \r
1462 \r
1463         wcex.style                      = CS_HREDRAW | CS_VREDRAW;\r
1464         wcex.lpfnWndProc        = (WNDPROC)WndHeaderProc;\r
1465         wcex.cbClsExtra         = 0;\r
1466         wcex.cbWndExtra         = 0;\r
1467         wcex.hInstance          = hResource;\r
1468         wcex.hIcon                      = LoadIcon(hResource, (LPCTSTR)IDI_TortoiseGitBlameView);\r
1469         wcex.hCursor            = LoadCursor(NULL, IDC_ARROW);\r
1470         wcex.hbrBackground      = (HBRUSH)(COLOR_BTNFACE+1);\r
1471         wcex.lpszMenuName       = 0;\r
1472         wcex.lpszClassName      = _T("TortoiseGitBlameViewHeader");\r
1473         wcex.hIconSm            = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);\r
1474 \r
1475         return RegisterClassEx(&wcex);\r
1476 }\r
1477 \r
1478 ATOM MyRegisterLocatorClass(HINSTANCE hResource)\r
1479 {\r
1480         WNDCLASSEX wcex;\r
1481 \r
1482         wcex.cbSize = sizeof(WNDCLASSEX); \r
1483 \r
1484         wcex.style                      = CS_HREDRAW | CS_VREDRAW;\r
1485         wcex.lpfnWndProc        = (WNDPROC)WndLocatorProc;\r
1486         wcex.cbClsExtra         = 0;\r
1487         wcex.cbWndExtra         = 0;\r
1488         wcex.hInstance          = hResource;\r
1489         wcex.hIcon                      = LoadIcon(hResource, (LPCTSTR)IDI_TortoiseGitBlameView);\r
1490         wcex.hCursor            = LoadCursor(NULL, IDC_ARROW);\r
1491         wcex.hbrBackground      = (HBRUSH)(COLOR_WINDOW+1);\r
1492         wcex.lpszMenuName       = 0;\r
1493         wcex.lpszClassName      = _T("TortoiseGitBlameViewLocator");\r
1494         wcex.hIconSm            = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);\r
1495 \r
1496         return RegisterClassEx(&wcex);\r
1497 }\r
1498 \r
1499 BOOL InitInstance(HINSTANCE hResource, int nCmdShow)\r
1500 {\r
1501    app.wMain = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,\r
1502       CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hResource, NULL);   \r
1503 \r
1504    if (!app.wMain)\r
1505    {\r
1506       return FALSE;\r
1507    }\r
1508 \r
1509    CRegStdWORD pos(_T("Software\\TortoiseGit\\TBlamePos"), 0);\r
1510    CRegStdWORD width(_T("Software\\TortoiseGit\\TBlameSize"), 0);\r
1511    CRegStdWORD state(_T("Software\\TortoiseGit\\TBlameState"), 0);\r
1512    if (DWORD(pos) && DWORD(width))\r
1513    {\r
1514            RECT rc;\r
1515            rc.left = LOWORD(DWORD(pos));\r
1516            rc.top = HIWORD(DWORD(pos));\r
1517            rc.right = rc.left + LOWORD(DWORD(width));\r
1518            rc.bottom = rc.top + HIWORD(DWORD(width));\r
1519            HMONITOR hMon = MonitorFromRect(&rc, MONITOR_DEFAULTTONULL);\r
1520            if (hMon)\r
1521            {\r
1522                    // only restore the window position if the monitor is valid\r
1523                    MoveWindow(app.wMain, LOWORD(DWORD(pos)), HIWORD(DWORD(pos)),\r
1524                            LOWORD(DWORD(width)), HIWORD(DWORD(width)), FALSE);\r
1525            }\r
1526    }\r
1527    if (DWORD(state) == SW_MAXIMIZE)\r
1528            ShowWindow(app.wMain, SW_MAXIMIZE);\r
1529    else\r
1530            ShowWindow(app.wMain, nCmdShow);\r
1531    UpdateWindow(app.wMain);\r
1532 \r
1533    //Create the tooltips\r
1534 \r
1535    INITCOMMONCONTROLSEX iccex; \r
1536    app.hwndTT;                 // handle to the ToolTip control\r
1537    TOOLINFO ti;\r
1538    RECT rect;                  // for client area coordinates\r
1539    iccex.dwICC = ICC_WIN95_CLASSES;\r
1540    iccex.dwSize = sizeof(INITCOMMONCONTROLSEX);\r
1541    InitCommonControlsEx(&iccex);\r
1542 \r
1543    /* CREATE A TOOLTIP WINDOW */\r
1544    app.hwndTT = CreateWindowEx(WS_EX_TOPMOST,\r
1545            TOOLTIPS_CLASS,\r
1546            NULL,\r
1547            WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP,             \r
1548            CW_USEDEFAULT,\r
1549            CW_USEDEFAULT,\r
1550            CW_USEDEFAULT,\r
1551            CW_USEDEFAULT,\r
1552            app.wBlame,\r
1553            NULL,\r
1554            app.hResource,\r
1555            NULL\r
1556            );\r
1557 \r
1558    SetWindowPos(app.hwndTT,\r
1559            HWND_TOPMOST,\r
1560            0,\r
1561            0,\r
1562            0,\r
1563            0,\r
1564            SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);\r
1565 \r
1566    /* GET COORDINATES OF THE MAIN CLIENT AREA */\r
1567    GetClientRect (app.wBlame, &rect);\r
1568 \r
1569    /* INITIALIZE MEMBERS OF THE TOOLINFO STRUCTURE */\r
1570    ti.cbSize = sizeof(TOOLINFO);\r
1571    ti.uFlags = TTF_TRACK | TTF_ABSOLUTE;//TTF_SUBCLASS | TTF_PARSELINKS;\r
1572    ti.hwnd = app.wBlame;\r
1573    ti.hinst = app.hResource;\r
1574    ti.uId = 0;\r
1575    ti.lpszText = LPSTR_TEXTCALLBACK;\r
1576    // ToolTip control will cover the whole window\r
1577    ti.rect.left = rect.left;    \r
1578    ti.rect.top = rect.top;\r
1579    ti.rect.right = rect.right;\r
1580    ti.rect.bottom = rect.bottom;\r
1581 \r
1582    /* SEND AN ADDTOOL MESSAGE TO THE TOOLTIP CONTROL WINDOW */\r
1583    SendMessage(app.hwndTT, TTM_ADDTOOL, 0, (LPARAM) (LPTOOLINFO) &ti);  \r
1584    SendMessage(app.hwndTT, TTM_SETMAXTIPWIDTH, 0, 600);\r
1585    //SendMessage(app.hwndTT, TTM_SETDELAYTIME, TTDT_AUTOPOP, MAKELONG(50000, 0));\r
1586    //SendMessage(app.hwndTT, TTM_SETDELAYTIME, TTDT_RESHOW, MAKELONG(1000, 0));\r
1587    \r
1588    uFindReplaceMsg = RegisterWindowMessage(FINDMSGSTRING);\r
1589    \r
1590    return TRUE;\r
1591 }\r
1592 #endif\r
1593 void CTortoiseGitBlameView::InitSize()\r
1594 {\r
1595     RECT rc;\r
1596     RECT blamerc;\r
1597     RECT sourcerc;\r
1598     ::GetClientRect(wMain, &rc);\r
1599     ::SetWindowPos(wHeader, 0, rc.left, rc.top, rc.right-rc.left, HEADER_HEIGHT, 0);\r
1600     rc.top += HEADER_HEIGHT;\r
1601     blamerc.left = rc.left;\r
1602     blamerc.top = rc.top;\r
1603         LONG w = GetBlameWidth();\r
1604     blamerc.right = w > abs(rc.right - rc.left) ? rc.right : w + rc.left;\r
1605     blamerc.bottom = rc.bottom;\r
1606     sourcerc.left = blamerc.right;\r
1607     sourcerc.top = rc.top;\r
1608     sourcerc.bottom = rc.bottom;\r
1609     sourcerc.right = rc.right;\r
1610         if (m_colorage)\r
1611         {\r
1612                 ::OffsetRect(&blamerc, LOCATOR_WIDTH, 0);\r
1613                 ::OffsetRect(&sourcerc, LOCATOR_WIDTH, 0);\r
1614                 sourcerc.right -= LOCATOR_WIDTH;\r
1615         }\r
1616         ::InvalidateRect(wMain, NULL, FALSE);\r
1617     ::SetWindowPos(wEditor, 0, sourcerc.left, sourcerc.top, sourcerc.right - sourcerc.left, sourcerc.bottom - sourcerc.top, 0);\r
1618         ::SetWindowPos(wBlame, 0, blamerc.left, blamerc.top, blamerc.right - blamerc.left, blamerc.bottom - blamerc.top, 0);\r
1619         if (m_colorage)\r
1620                 ::SetWindowPos(wLocator, 0, 0, blamerc.top, LOCATOR_WIDTH, blamerc.bottom - blamerc.top, SWP_SHOWWINDOW);\r
1621         else\r
1622                 ::ShowWindow(wLocator, SW_HIDE);\r
1623 }\r
1624 \r
1625 #if 0\r
1626 LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)\r
1627 {\r
1628         if (message == uFindReplaceMsg)\r
1629         {\r
1630                 LPFINDREPLACE lpfr = (LPFINDREPLACE)lParam;\r
1631 \r
1632                 // If the FR_DIALOGTERM flag is set, \r
1633                 // invalidate the handle identifying the dialog box. \r
1634                 if (lpfr->Flags & FR_DIALOGTERM)\r
1635                 {\r
1636                         app.currentDialog = NULL; \r
1637                         return 0; \r
1638                 } \r
1639                 if (lpfr->Flags & FR_FINDNEXT)\r
1640                 {\r
1641                         app.DoSearch(lpfr->lpstrFindWhat, lpfr->Flags);\r
1642                 }\r
1643                 return 0; \r
1644         }\r
1645         switch (message) \r
1646         {\r
1647         case WM_CREATE:\r
1648                 app.wEditor = ::CreateWindow(\r
1649                         "Scintilla",\r
1650                         "Source",\r
1651                         WS_CHILD | WS_VSCROLL | WS_HSCROLL | WS_CLIPCHILDREN,\r
1652                         0, 0,\r
1653                         100, 100,\r
1654                         hWnd,\r
1655                         0,\r
1656                         app.hResource,\r
1657                         0);\r
1658                 app.InitialiseEditor();\r
1659                 ::ShowWindow(app.wEditor, SW_SHOW);\r
1660                 ::SetFocus(app.wEditor);\r
1661                 app.wBlame = ::CreateWindow(\r
1662                         _T("TortoiseGitBlameViewBlame"), \r
1663                         _T("blame"), \r
1664                         WS_CHILD | WS_CLIPCHILDREN,\r
1665                         CW_USEDEFAULT, 0, \r
1666                         CW_USEDEFAULT, 0, \r
1667                         hWnd, \r
1668                         NULL, \r
1669                         app.hResource, \r
1670                         NULL);\r
1671                 ::ShowWindow(app.wBlame, SW_SHOW);\r
1672                 app.wHeader = ::CreateWindow(\r
1673                         _T("TortoiseGitBlameViewHeader"), \r
1674                         _T("header"), \r
1675                         WS_CHILD | WS_CLIPCHILDREN | WS_BORDER,\r
1676                         CW_USEDEFAULT, 0, \r
1677                         CW_USEDEFAULT, 0, \r
1678                         hWnd, \r
1679                         NULL, \r
1680                         app.hResource, \r
1681                         NULL);\r
1682                 ::ShowWindow(app.wHeader, SW_SHOW);\r
1683                 app.wLocator = ::CreateWindow(\r
1684                         _T("TortoiseGitBlameViewLocator"), \r
1685                         _T("locator"), \r
1686                         WS_CHILD | WS_CLIPCHILDREN | WS_BORDER,\r
1687                         CW_USEDEFAULT, 0, \r
1688                         CW_USEDEFAULT, 0, \r
1689                         hWnd, \r
1690                         NULL, \r
1691                         app.hResource, \r
1692                         NULL);\r
1693                 ::ShowWindow(app.wLocator, SW_SHOW);\r
1694                 return 0;\r
1695 \r
1696         case WM_SIZE:\r
1697                 if (wParam != 1) \r
1698                 {\r
1699             app.InitSize();\r
1700                 }\r
1701                 return 0;\r
1702 \r
1703         case WM_COMMAND:\r
1704                 app.Command(LOWORD(wParam));\r
1705                 break;\r
1706         case WM_NOTIFY:\r
1707                 app.Notify(reinterpret_cast<SCNotification *>(lParam));\r
1708                 return 0;\r
1709         case WM_DESTROY:\r
1710                 PostQuitMessage(0);\r
1711                 break;\r
1712         case WM_CLOSE:\r
1713                 {\r
1714                         CRegStdWORD pos(_T("Software\\TortoiseGit\\TBlamePos"), 0);\r
1715                         CRegStdWORD width(_T("Software\\TortoiseGit\\TBlameSize"), 0);\r
1716                         CRegStdWORD state(_T("Software\\TortoiseGit\\TBlameState"), 0);\r
1717                         RECT rc;\r
1718                         GetWindowRect(app.wMain, &rc);\r
1719                         if ((rc.left >= 0)&&(rc.top >= 0))\r
1720                         {\r
1721                                 pos = MAKELONG(rc.left, rc.top);\r
1722                                 width = MAKELONG(rc.right-rc.left, rc.bottom-rc.top);\r
1723                         }\r
1724                         WINDOWPLACEMENT wp = {0};\r
1725                         wp.length = sizeof(WINDOWPLACEMENT);\r
1726                         GetWindowPlacement(app.wMain, &wp);\r
1727                         state = wp.showCmd;\r
1728                         ::DestroyWindow(app.wEditor);\r
1729                         ::PostQuitMessage(0);\r
1730                 }\r
1731                 return 0;\r
1732         case WM_SETFOCUS:\r
1733                 ::SetFocus(app.wBlame);\r
1734                 break;\r
1735         default:\r
1736                 return DefWindowProc(hWnd, message, wParam, lParam);\r
1737         }\r
1738         return 0;\r
1739 }\r
1740 \r
1741 LRESULT CALLBACK WndBlameProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)\r
1742 {\r
1743         PAINTSTRUCT ps;\r
1744         TRACKMOUSEEVENT mevt;\r
1745         HDC hDC;\r
1746         switch (message) \r
1747         {\r
1748         case WM_CREATE:\r
1749                 return 0;\r
1750         case WM_PAINT:\r
1751                 hDC = BeginPaint(app.wBlame, &ps);\r
1752                 app.DrawBlame(hDC);\r
1753                 EndPaint(app.wBlame, &ps);\r
1754                 break;\r
1755         case WM_COMMAND:\r
1756                 app.Command(LOWORD(wParam));\r
1757                 break;\r
1758         case WM_NOTIFY:\r
1759                 switch (((LPNMHDR)lParam)->code)\r
1760                 {\r
1761                 case TTN_GETDISPINFO:\r
1762                         {\r
1763                                 LPNMHDR pNMHDR = (LPNMHDR)lParam;\r
1764                                 NMTTDISPINFOA* pTTTA = (NMTTDISPINFOA*)pNMHDR;\r
1765                                 NMTTDISPINFOW* pTTTW = (NMTTDISPINFOW*)pNMHDR;\r
1766                                 POINT point;\r
1767                                 DWORD ptW = GetMessagePos();\r
1768                                 point.x = GET_X_LPARAM(ptW);\r
1769                                 point.y = GET_Y_LPARAM(ptW);\r
1770                                 ::ScreenToClient(app.wBlame, &point);\r
1771                                 LONG_PTR line = app.SendEditor(SCI_GETFIRSTVISIBLELINE);\r
1772                                 LONG_PTR height = app.SendEditor(SCI_TEXTHEIGHT);\r
1773                                 line = line + (point.y/height);\r
1774                                 if (line >= (LONG)app.revs.size())\r
1775                                         break;\r
1776                                 if (line < 0)\r
1777                                         break;\r
1778                                 LONG rev = app.revs[line];\r
1779                                 if (line >= (LONG)app.revs.size())\r
1780                                         break;\r
1781 \r
1782                                 SecureZeroMemory(app.m_szTip, sizeof(app.m_szTip));\r
1783                                 SecureZeroMemory(app.m_wszTip, sizeof(app.m_wszTip));\r
1784                                 std::map<LONG, CString>::iterator iter;\r
1785                                 if ((iter = app.logmessages.find(rev)) != app.logmessages.end())\r
1786                                 {\r
1787                                         CString msg;\r
1788                                         if (!ShowAuthor)\r
1789                                         {\r
1790                                                 msg += app.authors[line];\r
1791                                         }\r
1792                                         if (!ShowDate)\r
1793                                         {\r
1794                                                 if (!ShowAuthor) msg += "  ";\r
1795                                                 msg += app.dates[line];\r
1796                                         }\r
1797                                         if (!ShowAuthor || !ShowDate)\r
1798                                                 msg += '\n';\r
1799                                         msg += iter->second;\r
1800                                         // an empty tooltip string will deactivate the tooltips,\r
1801                                         // which means we must make sure that the tooltip won't\r
1802                                         // be empty.\r
1803                                         if (msg.empty())\r
1804                                                 msg = _T(" ");\r
1805                                         if (pNMHDR->code == TTN_NEEDTEXTA)\r
1806                                         {\r
1807                                                 lstrcpyn(app.m_szTip, msg.c_str(), MAX_LOG_LENGTH*2);\r
1808                                                 app.StringExpand(app.m_szTip);\r
1809                                                 pTTTA->lpszText = app.m_szTip;\r
1810                                         }\r
1811                                         else\r
1812                                         {\r
1813                                                 pTTTW->lpszText = app.m_wszTip;\r
1814                                                 ::MultiByteToWideChar( CP_ACP , 0, msg.c_str(), min(msg.size(), MAX_LOG_LENGTH*2), app.m_wszTip, MAX_LOG_LENGTH*2);\r
1815                                                 app.StringExpand(app.m_wszTip);\r
1816                                         }\r
1817                                 }\r
1818                         }\r
1819                         break;\r
1820                 }\r
1821                 return 0;\r
1822         case WM_DESTROY:\r
1823                 break;\r
1824         case WM_CLOSE:\r
1825                 return 0;\r
1826         case WM_MOUSELEAVE:\r
1827                 app.m_mouserev = -2;\r
1828                 app.m_mouseauthor.clear();\r
1829                 app.ttVisible = FALSE;\r
1830                 SendMessage(app.hwndTT, TTM_TRACKACTIVATE, FALSE, 0);\r
1831                 ::InvalidateRect(app.wBlame, NULL, FALSE);\r
1832                 break;\r
1833         case WM_MOUSEMOVE:\r
1834                 {\r
1835                         mevt.cbSize = sizeof(TRACKMOUSEEVENT);\r
1836                         mevt.dwFlags = TME_LEAVE;\r
1837                         mevt.dwHoverTime = HOVER_DEFAULT;\r
1838                         mevt.hwndTrack = app.wBlame;\r
1839                         ::TrackMouseEvent(&mevt);\r
1840                         POINT pt = {((int)(short)LOWORD(lParam)), ((int)(short)HIWORD(lParam))};\r
1841                         ClientToScreen(app.wBlame, &pt);\r
1842                         pt.x += 15;\r
1843                         pt.y += 15;\r
1844                         SendMessage(app.hwndTT, TTM_TRACKPOSITION, 0, MAKELONG(pt.x, pt.y));\r
1845                         if (!app.ttVisible)\r
1846                         {\r
1847                                 TOOLINFO ti;\r
1848                                 ti.cbSize = sizeof(TOOLINFO);\r
1849                                 ti.hwnd = app.wBlame;\r
1850                                 ti.uId = 0;\r
1851                                 SendMessage(app.hwndTT, TTM_TRACKACTIVATE, TRUE, (LPARAM)&ti);\r
1852                         }\r
1853                         int y = ((int)(short)HIWORD(lParam));\r
1854                         LONG_PTR line = app.SendEditor(SCI_GETFIRSTVISIBLELINE);\r
1855                         LONG_PTR height = app.SendEditor(SCI_TEXTHEIGHT);\r
1856                         line = line + (y/height);\r
1857                         app.ttVisible = (line < (LONG)app.revs.size());\r
1858                         if ( app.ttVisible )\r
1859                         {\r
1860                                 if (app.authors[line].compare(app.m_mouseauthor) != 0)\r
1861                                 {\r
1862                                         app.m_mouseauthor = app.authors[line];\r
1863                                 }\r
1864                                 if (app.revs[line] != app.m_mouserev)\r
1865                                 {\r
1866                                         app.m_mouserev = app.revs[line];\r
1867                                         ::InvalidateRect(app.wBlame, NULL, FALSE);\r
1868                                         SendMessage(app.hwndTT, TTM_UPDATE, 0, 0);\r
1869                                 }\r
1870                         }\r
1871                 }\r
1872                 break;\r
1873         case WM_RBUTTONDOWN:\r
1874                 // fall through\r
1875         case WM_LBUTTONDOWN:\r
1876                 {\r
1877                         int y = ((int)(short)HIWORD(lParam));\r
1878                         LONG_PTR line = app.SendEditor(SCI_GETFIRSTVISIBLELINE);\r
1879                         LONG_PTR height = app.SendEditor(SCI_TEXTHEIGHT);\r
1880                         line = line + (y/height);\r
1881                         if (line < (LONG)app.revs.size())\r
1882                         {\r
1883                                 app.SetSelectedLine(line);\r
1884                                 if (app.revs[line] != app.m_selectedrev)\r
1885                                 {\r
1886                                         app.m_selectedrev = app.revs[line];\r
1887                                         app.m_selectedorigrev = app.origrevs[line];\r
1888                                         app.m_selectedauthor = app.authors[line];\r
1889                                         app.m_selecteddate = app.dates[line];\r
1890                                 }\r
1891                                 else\r
1892                                 {\r
1893                                         app.m_selectedauthor.clear();\r
1894                                         app.m_selecteddate.clear();\r
1895                                         app.m_selectedrev = -2;\r
1896                                         app.m_selectedorigrev = -2;\r
1897                                 }\r
1898                                 ::InvalidateRect(app.wBlame, NULL, FALSE);\r
1899                         }\r
1900                         else\r
1901                         {\r
1902                                 app.SetSelectedLine(-1);\r
1903                         }\r
1904                 }\r
1905                 break;\r
1906         case WM_SETFOCUS:\r
1907                 ::SetFocus(app.wBlame);\r
1908                 app.SendEditor(SCI_GRABFOCUS);\r
1909                 break;\r
1910         case WM_CONTEXTMENU:\r
1911                 {\r
1912                         if (app.m_selectedrev <= 0)\r
1913                                 break;;\r
1914                         int xPos = GET_X_LPARAM(lParam);\r
1915                         int yPos = GET_Y_LPARAM(lParam);\r
1916                         if ((xPos < 0)||(yPos < 0))\r
1917                         {\r
1918                                 // requested from keyboard, not mouse pointer\r
1919                                 // use the center of the window\r
1920                                 RECT rect;\r
1921                                 GetClientRect(app.wBlame, &rect);\r
1922                                 xPos = rect.right-rect.left;\r
1923                                 yPos = rect.bottom-rect.top;\r
1924                         }\r
1925                         HMENU hMenu = LoadMenu(app.hResource, MAKEINTRESOURCE(IDR_BLAMEPOPUP));\r
1926                         HMENU hPopMenu = GetSubMenu(hMenu, 0);\r
1927 \r
1928                         if ( _tcslen(szOrigPath)==0 )\r
1929                         {\r
1930                                 // Without knowing the original path we cannot blame the previous revision\r
1931                                 // because we don't know which filename to pass to tortoiseproc.\r
1932                                 EnableMenuItem(hPopMenu,ID_BLAME_PREVIOUS_REVISION, MF_DISABLED|MF_GRAYED);\r
1933                         }\r
1934                         \r
1935                         TrackPopupMenu(hPopMenu, TPM_LEFTALIGN | TPM_RIGHTBUTTON, xPos, yPos, 0, app.wBlame, NULL); \r
1936                         DestroyMenu(hMenu);\r
1937                 }\r
1938                 break;\r
1939         default:\r
1940                 return DefWindowProc(hWnd, message, wParam, lParam);\r
1941         }\r
1942         return 0;\r
1943 }\r
1944 \r
1945 LRESULT CALLBACK WndHeaderProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)\r
1946 {\r
1947         PAINTSTRUCT ps;\r
1948         HDC hDC;\r
1949         switch (message) \r
1950         {\r
1951         case WM_CREATE:\r
1952                 return 0;\r
1953         case WM_PAINT:\r
1954                 hDC = BeginPaint(app.wHeader, &ps);\r
1955                 app.DrawHeader(hDC);\r
1956                 EndPaint(app.wHeader, &ps);\r
1957                 break;\r
1958         case WM_COMMAND:\r
1959                 break;\r
1960         case WM_DESTROY:\r
1961                 break;\r
1962         case WM_CLOSE:\r
1963                 return 0;\r
1964         default:\r
1965                 return DefWindowProc(hWnd, message, wParam, lParam);\r
1966         }\r
1967         return 0;\r
1968 }\r
1969 \r
1970 LRESULT CALLBACK WndLocatorProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)\r
1971 {\r
1972         PAINTSTRUCT ps;\r
1973         HDC hDC;\r
1974         switch (message) \r
1975         {\r
1976         case WM_PAINT:\r
1977                 hDC = BeginPaint(app.wLocator, &ps);\r
1978                 app.DrawLocatorBar(hDC);\r
1979                 EndPaint(app.wLocator, &ps);\r
1980                 break;\r
1981         case WM_LBUTTONDOWN:\r
1982         case WM_MOUSEMOVE:\r
1983                 if (wParam & MK_LBUTTON)\r
1984                 {\r
1985                         RECT rect;\r
1986                         ::GetClientRect(hWnd, &rect); \r
1987                         int nLine = HIWORD(lParam)*app.revs.size()/(rect.bottom-rect.top);\r
1988 \r
1989                         if (nLine < 0)\r
1990                                 nLine = 0;\r
1991                         app.ScrollToLine(nLine);\r
1992                 }\r
1993                 break;\r
1994         default:\r
1995                 return DefWindowProc(hWnd, message, wParam, lParam);\r
1996         }\r
1997         return 0;\r
1998 }\r
1999 #endif\r
2000 \r
2001 void CTortoiseGitBlameView::SetupLexer(LPCSTR filename)\r
2002 {\r
2003 #if 0\r
2004         char line[20];\r
2005         const char * lineptr = _tcsrchr(filename, '.');\r
2006 \r
2007         if (lineptr)\r
2008         {\r
2009                 _tcscpy_s(line, 20, lineptr+1);\r
2010                 _tcslwr_s(line, 20);\r
2011                 if ((_tcscmp(line, _T("py"))==0)||\r
2012                         (_tcscmp(line, _T("pyw"))==0)||\r
2013                         (_tcscmp(line, _T("pyw"))==0))\r
2014                 {\r
2015                         SendEditor(SCI_SETLEXER, SCLEX_PYTHON);\r
2016                         SendEditor(SCI_SETKEYWORDS, 0, (LPARAM)_T("and assert break class continue def del elif \\r
2017 else except exec finally for from global if import in is lambda None \\r
2018 not or pass print raise return try while yield"));\r
2019                         SetAStyle(SCE_P_DEFAULT, black);\r
2020                         SetAStyle(SCE_P_COMMENTLINE, darkGreen);\r
2021                         SetAStyle(SCE_P_NUMBER, RGB(0, 0x80, 0x80));\r
2022                         SetAStyle(SCE_P_STRING, RGB(0, 0, 0x80));\r
2023                         SetAStyle(SCE_P_CHARACTER, RGB(0, 0, 0x80));\r
2024                         SetAStyle(SCE_P_WORD, RGB(0x80, 0, 0x80));\r
2025                         SetAStyle(SCE_P_TRIPLE, black);\r
2026                         SetAStyle(SCE_P_TRIPLEDOUBLE, black);\r
2027                         SetAStyle(SCE_P_CLASSNAME, darkBlue);\r
2028                         SetAStyle(SCE_P_DEFNAME, darkBlue);\r
2029                         SetAStyle(SCE_P_OPERATOR, darkBlue);\r
2030                         SetAStyle(SCE_P_IDENTIFIER, darkBlue);\r
2031                         SetAStyle(SCE_P_COMMENTBLOCK, darkGreen);\r
2032                         SetAStyle(SCE_P_STRINGEOL, red);\r
2033                 }\r
2034                 if ((_tcscmp(line, _T("c"))==0)||\r
2035                         (_tcscmp(line, _T("cc"))==0)||\r
2036                         (_tcscmp(line, _T("cpp"))==0)||\r
2037                         (_tcscmp(line, _T("cxx"))==0)||\r
2038                         (_tcscmp(line, _T("h"))==0)||\r
2039                         (_tcscmp(line, _T("hh"))==0)||\r
2040                         (_tcscmp(line, _T("hpp"))==0)||\r
2041                         (_tcscmp(line, _T("hxx"))==0)||\r
2042                         (_tcscmp(line, _T("dlg"))==0)||\r
2043                         (_tcscmp(line, _T("mak"))==0))\r
2044                 {\r
2045                         SendEditor(SCI_SETLEXER, SCLEX_CPP);\r
2046                         SendEditor(SCI_SETKEYWORDS, 0, (LPARAM)_T("and and_eq asm auto bitand bitor bool break \\r
2047 case catch char class compl const const_cast continue \\r
2048 default delete do double dynamic_cast else enum explicit export extern false float for \\r
2049 friend goto if inline int long mutable namespace new not not_eq \\r
2050 operator or or_eq private protected public \\r
2051 register reinterpret_cast return short signed sizeof static static_cast struct switch \\r
2052 template this throw true try typedef typeid typename union unsigned using \\r
2053 virtual void volatile wchar_t while xor xor_eq"));\r
2054                         SendEditor(SCI_SETKEYWORDS, 3, (LPARAM)_T("a addindex addtogroup anchor arg attention \\r
2055 author b brief bug c class code date def defgroup deprecated dontinclude \\r
2056 e em endcode endhtmlonly endif endlatexonly endlink endverbatim enum example exception \\r
2057 f$ f[ f] file fn hideinitializer htmlinclude htmlonly \\r
2058 if image include ingroup internal invariant interface latexonly li line link \\r
2059 mainpage name namespace nosubgrouping note overload \\r
2060 p page par param post pre ref relates remarks return retval \\r
2061 sa section see showinitializer since skip skipline struct subsection \\r
2062 test throw todo typedef union until \\r
2063 var verbatim verbinclude version warning weakgroup $ @ \\ & < > # { }"));\r
2064                         SetupCppLexer();\r
2065                 }\r
2066                 if (_tcscmp(line, _T("cs"))==0)\r
2067                 {\r
2068                         SendEditor(SCI_SETLEXER, SCLEX_CPP);\r
2069                         SendEditor(SCI_SETKEYWORDS, 0, (LPARAM)_T("abstract as base bool break byte case catch char checked class \\r
2070 const continue decimal default delegate do double else enum \\r
2071 event explicit extern false finally fixed float for foreach goto if \\r
2072 implicit in int interface internal is lock long namespace new null \\r
2073 object operator out override params private protected public \\r
2074 readonly ref return sbyte sealed short sizeof stackalloc static \\r
2075 string struct switch this throw true try typeof uint ulong \\r
2076 unchecked unsafe ushort using virtual void while"));\r
2077                         SetupCppLexer();\r
2078                 }\r
2079                 if ((_tcscmp(line, _T("rc"))==0)||\r
2080                         (_tcscmp(line, _T("rc2"))==0))\r
2081                 {\r
2082                         SendEditor(SCI_SETLEXER, SCLEX_CPP);\r
2083                         SendEditor(SCI_SETKEYWORDS, 0, (LPARAM)_T("ACCELERATORS ALT AUTO3STATE AUTOCHECKBOX AUTORADIOBUTTON \\r
2084 BEGIN BITMAP BLOCK BUTTON CAPTION CHARACTERISTICS CHECKBOX CLASS \\r
2085 COMBOBOX CONTROL CTEXT CURSOR DEFPUSHBUTTON DIALOG DIALOGEX DISCARDABLE \\r
2086 EDITTEXT END EXSTYLE FONT GROUPBOX ICON LANGUAGE LISTBOX LTEXT \\r
2087 MENU MENUEX MENUITEM MESSAGETABLE POPUP \\r
2088 PUSHBUTTON RADIOBUTTON RCDATA RTEXT SCROLLBAR SEPARATOR SHIFT STATE3 \\r
2089 STRINGTABLE STYLE TEXTINCLUDE VALUE VERSION VERSIONINFO VIRTKEY"));\r
2090                         SetupCppLexer();\r
2091                 }\r
2092                 if ((_tcscmp(line, _T("idl"))==0)||\r
2093                         (_tcscmp(line, _T("odl"))==0))\r
2094                 {\r
2095                         SendEditor(SCI_SETLEXER, SCLEX_CPP);\r
2096                         SendEditor(SCI_SETKEYWORDS, 0, (LPARAM)_T("aggregatable allocate appobject arrays async async_uuid \\r
2097 auto_handle \\r
2098 bindable boolean broadcast byte byte_count \\r
2099 call_as callback char coclass code comm_status \\r
2100 const context_handle context_handle_noserialize \\r
2101 context_handle_serialize control cpp_quote custom \\r
2102 decode default defaultbind defaultcollelem \\r
2103 defaultvalue defaultvtable dispinterface displaybind dllname \\r
2104 double dual \\r
2105 enable_allocate encode endpoint entry enum error_status_t \\r
2106 explicit_handle \\r
2107 fault_status first_is float \\r
2108 handle_t heap helpcontext helpfile helpstring \\r
2109 helpstringcontext helpstringdll hidden hyper \\r
2110 id idempotent ignore iid_as iid_is immediatebind implicit_handle \\r
2111 import importlib in include in_line int __int64 __int3264 interface \\r
2112 last_is lcid length_is library licensed local long \\r
2113 max_is maybe message methods midl_pragma \\r
2114 midl_user_allocate midl_user_free min_is module ms_union \\r
2115 ncacn_at_dsp ncacn_dnet_nsp ncacn_http ncacn_ip_tcp \\r
2116 ncacn_nb_ipx ncacn_nb_nb ncacn_nb_tcp ncacn_np \\r
2117 ncacn_spx ncacn_vns_spp ncadg_ip_udp ncadg_ipx ncadg_mq \\r
2118 ncalrpc nocode nonbrowsable noncreatable nonextensible notify \\r
2119 object odl oleautomation optimize optional out out_of_line \\r
2120 pipe pointer_default pragma properties propget propput propputref \\r
2121 ptr public \\r
2122 range readonly ref represent_as requestedit restricted retval \\r
2123 shape short signed size_is small source strict_context_handle \\r
2124 string struct switch switch_is switch_type \\r
2125 transmit_as typedef \\r
2126 uidefault union unique unsigned user_marshal usesgetlasterror uuid \\r
2127 v1_enum vararg version void wchar_t wire_marshal"));\r
2128                         SetupCppLexer();\r
2129                 }\r
2130                 if (_tcscmp(line, _T("java"))==0)\r
2131                 {\r
2132                         SendEditor(SCI_SETLEXER, SCLEX_CPP);\r
2133                         SendEditor(SCI_SETKEYWORDS, 0, (LPARAM)_T("abstract assert boolean break byte case catch char class \\r
2134 const continue default do double else extends final finally float for future \\r
2135 generic goto if implements import inner instanceof int interface long \\r
2136 native new null outer package private protected public rest \\r
2137 return short static super switch synchronized this throw throws \\r
2138 transient try var void volatile while"));\r
2139                         SetupCppLexer();\r
2140                 }\r
2141                 if (_tcscmp(line, _T("js"))==0)\r
2142                 {\r
2143                         SendEditor(SCI_SETLEXER, SCLEX_CPP);\r
2144                         SendEditor(SCI_SETKEYWORDS, 0, (LPARAM)_T("abstract boolean break byte case catch char class \\r
2145 const continue debugger default delete do double else enum export extends \\r
2146 final finally float for function goto if implements import in instanceof \\r
2147 int interface long native new package private protected public \\r
2148 return short static super switch synchronized this throw throws \\r
2149 transient try typeof var void volatile while with"));\r
2150                         SetupCppLexer();\r
2151                 }\r
2152                 if ((_tcscmp(line, _T("pas"))==0)||\r
2153                         (_tcscmp(line, _T("dpr"))==0)||\r
2154                         (_tcscmp(line, _T("pp"))==0))\r
2155                 {\r
2156                         SendEditor(SCI_SETLEXER, SCLEX_PASCAL);\r
2157                         SendEditor(SCI_SETKEYWORDS, 0, (LPARAM)_T("and array as begin case class const constructor \\r
2158 destructor div do downto else end except file finally \\r
2159 for function goto if implementation in inherited \\r
2160 interface is mod not object of on or packed \\r
2161 procedure program property raise record repeat \\r
2162 set shl shr then threadvar to try type unit \\r
2163 until uses var while with xor"));\r
2164                         SetupCppLexer();\r
2165                 }\r
2166                 if ((_tcscmp(line, _T("as"))==0)||\r
2167                         (_tcscmp(line, _T("asc"))==0)||\r
2168                         (_tcscmp(line, _T("jsfl"))==0))\r
2169                 {\r
2170                         SendEditor(SCI_SETLEXER, SCLEX_CPP);\r
2171                         SendEditor(SCI_SETKEYWORDS, 0, (LPARAM)_T("add and break case catch class continue default delete do \\r
2172 dynamic else eq extends false finally for function ge get gt if implements import in \\r
2173 instanceof interface intrinsic le lt ne new not null or private public return \\r
2174 set static super switch this throw true try typeof undefined var void while with"));\r
2175                         SendEditor(SCI_SETKEYWORDS, 1, (LPARAM)_T("Array Arguments Accessibility Boolean Button Camera Color \\r
2176 ContextMenu ContextMenuItem Date Error Function Key LoadVars LocalConnection Math \\r
2177 Microphone Mouse MovieClip MovieClipLoader NetConnection NetStream Number Object \\r
2178 PrintJob Selection SharedObject Sound Stage String StyleSheet System TextField \\r
2179 TextFormat TextSnapshot Video Void XML XMLNode XMLSocket \\r
2180 _accProps _focusrect _global _highquality _parent _quality _root _soundbuftime \\r
2181 arguments asfunction call capabilities chr clearInterval duplicateMovieClip \\r
2182 escape eval fscommand getProperty getTimer getURL getVersion gotoAndPlay gotoAndStop \\r
2183 ifFrameLoaded Infinity -Infinity int isFinite isNaN length loadMovie loadMovieNum \\r
2184 loadVariables loadVariablesNum maxscroll mbchr mblength mbord mbsubstring MMExecute \\r
2185 NaN newline nextFrame nextScene on onClipEvent onUpdate ord parseFloat parseInt play \\r
2186 prevFrame prevScene print printAsBitmap printAsBitmapNum printNum random removeMovieClip \\r
2187 scroll set setInterval setProperty startDrag stop stopAllSounds stopDrag substring \\r
2188 targetPath tellTarget toggleHighQuality trace unescape unloadMovie unLoadMovieNum updateAfterEvent"));\r
2189                         SetupCppLexer();\r
2190                 }\r
2191                 if ((_tcscmp(line, _T("html"))==0)||\r
2192                         (_tcscmp(line, _T("htm"))==0)||\r
2193                         (_tcscmp(line, _T("shtml"))==0)||\r
2194                         (_tcscmp(line, _T("htt"))==0)||\r
2195                         (_tcscmp(line, _T("xml"))==0)||\r
2196                         (_tcscmp(line, _T("asp"))==0)||\r
2197                         (_tcscmp(line, _T("xsl"))==0)||\r
2198                         (_tcscmp(line, _T("php"))==0)||\r
2199                         (_tcscmp(line, _T("xhtml"))==0)||\r
2200                         (_tcscmp(line, _T("phtml"))==0)||\r
2201                         (_tcscmp(line, _T("cfm"))==0)||\r
2202                         (_tcscmp(line, _T("tpl"))==0)||\r
2203                         (_tcscmp(line, _T("dtd"))==0)||\r
2204                         (_tcscmp(line, _T("hta"))==0)||\r
2205                         (_tcscmp(line, _T("htd"))==0)||\r
2206                         (_tcscmp(line, _T("wxs"))==0))\r
2207                 {\r
2208                         SendEditor(SCI_SETLEXER, SCLEX_HTML);\r
2209                         SendEditor(SCI_SETSTYLEBITS, 7);\r
2210                         SendEditor(SCI_SETKEYWORDS, 0, (LPARAM)_T("a abbr acronym address applet area b base basefont \\r
2211 bdo big blockquote body br button caption center \\r
2212 cite code col colgroup dd del dfn dir div dl dt em \\r
2213 fieldset font form frame frameset h1 h2 h3 h4 h5 h6 \\r
2214 head hr html i iframe img input ins isindex kbd label \\r
2215 legend li link map menu meta noframes noscript \\r
2216 object ol optgroup option p param pre q s samp \\r
2217 script select small span strike strong style sub sup \\r
2218 table tbody td textarea tfoot th thead title tr tt u ul \\r
2219 var xml xmlns abbr accept-charset accept accesskey action align alink \\r
2220 alt archive axis background bgcolor border \\r
2221 cellpadding cellspacing char charoff charset checked cite \\r
2222 class classid clear codebase codetype color cols colspan \\r
2223 compact content coords \\r
2224 data datafld dataformatas datapagesize datasrc datetime \\r
2225 declare defer dir disabled enctype event \\r
2226 face for frame frameborder \\r
2227 headers height href hreflang hspace http-equiv \\r
2228 id ismap label lang language leftmargin link longdesc \\r
2229 marginwidth marginheight maxlength media method multiple \\r
2230 name nohref noresize noshade nowrap \\r
2231 object onblur onchange onclick ondblclick onfocus \\r
2232 onkeydown onkeypress onkeyup onload onmousedown \\r
2233 onmousemove onmouseover onmouseout onmouseup \\r
2234 onreset onselect onsubmit onunload \\r
2235 profile prompt readonly rel rev rows rowspan rules \\r
2236 scheme scope selected shape size span src standby start style \\r
2237 summary tabindex target text title topmargin type usemap \\r
2238 valign value valuetype version vlink vspace width \\r
2239 text password checkbox radio submit reset \\r
2240 file hidden image"));\r
2241                         SendEditor(SCI_SETKEYWORDS, 1, (LPARAM)_T("assign audio block break catch choice clear disconnect else elseif \\r
2242 emphasis enumerate error exit field filled form goto grammar help \\r
2243 if initial link log menu meta noinput nomatch object option p paragraph \\r
2244 param phoneme prompt property prosody record reprompt return s say-as \\r
2245 script sentence subdialog submit throw transfer value var voice vxml"));\r
2246                         SendEditor(SCI_SETKEYWORDS, 2, (LPARAM)_T("accept age alphabet anchor application base beep bridge category charset \\r
2247 classid cond connecttimeout content contour count dest destexpr dtmf dtmfterm \\r
2248 duration enctype event eventexpr expr expritem fetchtimeout finalsilence \\r
2249 gender http-equiv id level maxage maxstale maxtime message messageexpr \\r
2250 method mime modal mode name namelist next nextitem ph pitch range rate \\r
2251 scope size sizeexpr skiplist slot src srcexpr sub time timeexpr timeout \\r
2252 transferaudio type value variant version volume xml:lang"));\r
2253                         SendEditor(SCI_SETKEYWORDS, 3, (LPARAM)_T("and assert break class continue def del elif \\r
2254 else except exec finally for from global if import in is lambda None \\r
2255 not or pass print raise return try while yield"));\r
2256                         SendEditor(SCI_SETKEYWORDS, 4, (LPARAM)_T("and argv as argc break case cfunction class continue declare default do \\r
2257 die echo else elseif empty enddeclare endfor endforeach endif endswitch \\r
2258 endwhile e_all e_parse e_error e_warning eval exit extends false for \\r
2259 foreach function global http_cookie_vars http_get_vars http_post_vars \\r
2260 http_post_files http_env_vars http_server_vars if include include_once \\r
2261 list new not null old_function or parent php_os php_self php_version \\r
2262 print require require_once return static switch stdclass this true var \\r
2263 xor virtual while __file__ __line__ __sleep __wakeup"));\r
2264 \r
2265                         SetAStyle(SCE_H_TAG, darkBlue);\r
2266                         SetAStyle(SCE_H_TAGUNKNOWN, red);\r
2267                         SetAStyle(SCE_H_ATTRIBUTE, darkBlue);\r
2268                         SetAStyle(SCE_H_ATTRIBUTEUNKNOWN, red);\r
2269                         SetAStyle(SCE_H_NUMBER, RGB(0x80,0,0x80));\r
2270                         SetAStyle(SCE_H_DOUBLESTRING, RGB(0,0x80,0));\r
2271                         SetAStyle(SCE_H_SINGLESTRING, RGB(0,0x80,0));\r
2272                         SetAStyle(SCE_H_OTHER, RGB(0x80,0,0x80));\r
2273                         SetAStyle(SCE_H_COMMENT, RGB(0x80,0x80,0));\r
2274                         SetAStyle(SCE_H_ENTITY, RGB(0x80,0,0x80));\r
2275 \r
2276                         SetAStyle(SCE_H_TAGEND, darkBlue);\r
2277                         SetAStyle(SCE_H_XMLSTART, darkBlue);    // <?\r
2278                         SetAStyle(SCE_H_QUESTION, darkBlue);    // <?\r
2279                         SetAStyle(SCE_H_XMLEND, darkBlue);              // ?>\r
2280                         SetAStyle(SCE_H_SCRIPT, darkBlue);              // <script\r
2281                         SetAStyle(SCE_H_ASP, RGB(0x4F, 0x4F, 0), RGB(0xFF, 0xFF, 0));   // <% ... %>\r
2282                         SetAStyle(SCE_H_ASPAT, RGB(0x4F, 0x4F, 0), RGB(0xFF, 0xFF, 0)); // <%@ ... %>\r
2283 \r
2284                         SetAStyle(SCE_HB_DEFAULT, black);\r
2285                         SetAStyle(SCE_HB_COMMENTLINE, darkGreen);\r
2286                         SetAStyle(SCE_HB_NUMBER, RGB(0,0x80,0x80));\r
2287                         SetAStyle(SCE_HB_WORD, darkBlue);\r
2288                         SendEditor(SCI_STYLESETBOLD, SCE_HB_WORD, 1);\r
2289                         SetAStyle(SCE_HB_STRING, RGB(0x80,0,0x80));\r
2290                         SetAStyle(SCE_HB_IDENTIFIER, black);\r
2291 \r
2292                         // This light blue is found in the windows system palette so is safe to use even in 256 colour modes.\r
2293                         // Show the whole section of VBScript with light blue background\r
2294                         for (int bstyle=SCE_HB_DEFAULT; bstyle<=SCE_HB_STRINGEOL; bstyle++) {\r
2295                                 SendEditor(SCI_STYLESETFONT, bstyle, \r
2296                                         reinterpret_cast<LPARAM>("Lucida Console"));\r
2297                                 SendEditor(SCI_STYLESETBACK, bstyle, lightBlue);\r
2298                                 // This call extends the backround colour of the last style on the line to the edge of the window\r
2299                                 SendEditor(SCI_STYLESETEOLFILLED, bstyle, 1);\r
2300                         }\r
2301                         SendEditor(SCI_STYLESETBACK, SCE_HB_STRINGEOL, RGB(0x7F,0x7F,0xFF));\r
2302                         SendEditor(SCI_STYLESETFONT, SCE_HB_COMMENTLINE, \r
2303                                 reinterpret_cast<LPARAM>("Lucida Console"));\r
2304 \r
2305                         SetAStyle(SCE_HBA_DEFAULT, black);\r
2306                         SetAStyle(SCE_HBA_COMMENTLINE, darkGreen);\r
2307                         SetAStyle(SCE_HBA_NUMBER, RGB(0,0x80,0x80));\r
2308                         SetAStyle(SCE_HBA_WORD, darkBlue);\r
2309                         SendEditor(SCI_STYLESETBOLD, SCE_HBA_WORD, 1);\r
2310                         SetAStyle(SCE_HBA_STRING, RGB(0x80,0,0x80));\r
2311                         SetAStyle(SCE_HBA_IDENTIFIER, black);\r
2312 \r
2313                         // Show the whole section of ASP VBScript with bright yellow background\r
2314                         for (int bastyle=SCE_HBA_DEFAULT; bastyle<=SCE_HBA_STRINGEOL; bastyle++) {\r
2315                                 SendEditor(SCI_STYLESETFONT, bastyle, \r
2316                                         reinterpret_cast<LPARAM>("Lucida Console"));\r
2317                                 SendEditor(SCI_STYLESETBACK, bastyle, RGB(0xFF, 0xFF, 0));\r
2318                                 // This call extends the backround colour of the last style on the line to the edge of the window\r
2319                                 SendEditor(SCI_STYLESETEOLFILLED, bastyle, 1);\r
2320                         }\r
2321                         SendEditor(SCI_STYLESETBACK, SCE_HBA_STRINGEOL, RGB(0xCF,0xCF,0x7F));\r
2322                         SendEditor(SCI_STYLESETFONT, SCE_HBA_COMMENTLINE, \r
2323                                 reinterpret_cast<LPARAM>("Lucida Console"));\r
2324 \r
2325                         // If there is no need to support embedded Javascript, the following code can be dropped.\r
2326                         // Javascript will still be correctly processed but will be displayed in just the default style.\r
2327 \r
2328                         SetAStyle(SCE_HJ_START, RGB(0x80,0x80,0));\r
2329                         SetAStyle(SCE_HJ_DEFAULT, black);\r
2330                         SetAStyle(SCE_HJ_COMMENT, darkGreen);\r
2331                         SetAStyle(SCE_HJ_COMMENTLINE, darkGreen);\r
2332                         SetAStyle(SCE_HJ_COMMENTDOC, darkGreen);\r
2333                         SetAStyle(SCE_HJ_NUMBER, RGB(0,0x80,0x80));\r
2334                         SetAStyle(SCE_HJ_WORD, black);\r
2335                         SetAStyle(SCE_HJ_KEYWORD, darkBlue);\r
2336                         SetAStyle(SCE_HJ_DOUBLESTRING, RGB(0x80,0,0x80));\r
2337                         SetAStyle(SCE_HJ_SINGLESTRING, RGB(0x80,0,0x80));\r
2338                         SetAStyle(SCE_HJ_SYMBOLS, black);\r
2339 \r
2340                         SetAStyle(SCE_HJA_START, RGB(0x80,0x80,0));\r
2341                         SetAStyle(SCE_HJA_DEFAULT, black);\r
2342                         SetAStyle(SCE_HJA_COMMENT, darkGreen);\r
2343                         SetAStyle(SCE_HJA_COMMENTLINE, darkGreen);\r
2344                         SetAStyle(SCE_HJA_COMMENTDOC, darkGreen);\r
2345                         SetAStyle(SCE_HJA_NUMBER, RGB(0,0x80,0x80));\r
2346                         SetAStyle(SCE_HJA_WORD, black);\r
2347                         SetAStyle(SCE_HJA_KEYWORD, darkBlue);\r
2348                         SetAStyle(SCE_HJA_DOUBLESTRING, RGB(0x80,0,0x80));\r
2349                         SetAStyle(SCE_HJA_SINGLESTRING, RGB(0x80,0,0x80));\r
2350                         SetAStyle(SCE_HJA_SYMBOLS, black);\r
2351 \r
2352                         SetAStyle(SCE_HPHP_DEFAULT, black);\r
2353                         SetAStyle(SCE_HPHP_HSTRING,  RGB(0x80,0,0x80));\r
2354                         SetAStyle(SCE_HPHP_SIMPLESTRING,  RGB(0x80,0,0x80));\r
2355                         SetAStyle(SCE_HPHP_WORD, darkBlue);\r
2356                         SetAStyle(SCE_HPHP_NUMBER, RGB(0,0x80,0x80));\r
2357                         SetAStyle(SCE_HPHP_VARIABLE, red);\r
2358                         SetAStyle(SCE_HPHP_HSTRING_VARIABLE, red);\r
2359                         SetAStyle(SCE_HPHP_COMPLEX_VARIABLE, red);\r
2360                         SetAStyle(SCE_HPHP_COMMENT, darkGreen);\r
2361                         SetAStyle(SCE_HPHP_COMMENTLINE, darkGreen);\r
2362                         SetAStyle(SCE_HPHP_OPERATOR, darkBlue);\r
2363 \r
2364                         // Show the whole section of Javascript with off white background\r
2365                         for (int jstyle=SCE_HJ_DEFAULT; jstyle<=SCE_HJ_SYMBOLS; jstyle++) {\r
2366                                 SendEditor(SCI_STYLESETFONT, jstyle, \r
2367                                         reinterpret_cast<LPARAM>("Lucida Console"));\r
2368                                 SendEditor(SCI_STYLESETBACK, jstyle, offWhite);\r
2369                                 SendEditor(SCI_STYLESETEOLFILLED, jstyle, 1);\r
2370                         }\r
2371                         SendEditor(SCI_STYLESETBACK, SCE_HJ_STRINGEOL, RGB(0xDF, 0xDF, 0x7F));\r
2372                         SendEditor(SCI_STYLESETEOLFILLED, SCE_HJ_STRINGEOL, 1);\r
2373 \r
2374                         // Show the whole section of Javascript with brown background\r
2375                         for (int jastyle=SCE_HJA_DEFAULT; jastyle<=SCE_HJA_SYMBOLS; jastyle++) {\r
2376                                 SendEditor(SCI_STYLESETFONT, jastyle, \r
2377                                         reinterpret_cast<LPARAM>("Lucida Console"));\r
2378                                 SendEditor(SCI_STYLESETBACK, jastyle, RGB(0xDF, 0xDF, 0x7F));\r
2379                                 SendEditor(SCI_STYLESETEOLFILLED, jastyle, 1);\r
2380                         }\r
2381                         SendEditor(SCI_STYLESETBACK, SCE_HJA_STRINGEOL, RGB(0x0,0xAF,0x5F));\r
2382                         SendEditor(SCI_STYLESETEOLFILLED, SCE_HJA_STRINGEOL, 1);\r
2383                 }\r
2384         }\r
2385         else\r
2386         {\r
2387                 SendEditor(SCI_SETLEXER, SCLEX_CPP);\r
2388                 SetupCppLexer();\r
2389         }\r
2390         SendEditor(SCI_COLOURISE, 0, -1);\r
2391 #endif\r
2392 }\r
2393 \r
2394 void CTortoiseGitBlameView::SetupCppLexer()\r
2395 {\r
2396         SetAStyle(SCE_C_DEFAULT, RGB(0, 0, 0));\r
2397         SetAStyle(SCE_C_COMMENT, RGB(0, 0x80, 0));\r
2398         SetAStyle(SCE_C_COMMENTLINE, RGB(0, 0x80, 0));\r
2399         SetAStyle(SCE_C_COMMENTDOC, RGB(0, 0x80, 0));\r
2400         SetAStyle(SCE_C_COMMENTLINEDOC, RGB(0, 0x80, 0));\r
2401         SetAStyle(SCE_C_COMMENTDOCKEYWORD, RGB(0, 0x80, 0));\r
2402         SetAStyle(SCE_C_COMMENTDOCKEYWORDERROR, RGB(0, 0x80, 0));\r
2403         SetAStyle(SCE_C_NUMBER, RGB(0, 0x80, 0x80));\r
2404         SetAStyle(SCE_C_WORD, RGB(0, 0, 0x80));\r
2405         SendEditor(SCE_C_WORD, 1);\r
2406         SetAStyle(SCE_C_STRING, RGB(0x80, 0, 0x80));\r
2407         SetAStyle(SCE_C_IDENTIFIER, RGB(0, 0, 0));\r
2408         SetAStyle(SCE_C_PREPROCESSOR, RGB(0x80, 0, 0));\r
2409         SetAStyle(SCE_C_OPERATOR, RGB(0x80, 0x80, 0));\r
2410 }\r