1 // TortoiseGitBlame - a Viewer for Git Blames
3 // Copyright (C) 2003-2008 - TortoiseSVN
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 // CTortoiseGitBlameView.cpp : implementation of the CTortoiseGitBlameView class
23 #include "TortoiseGitBlame.h"
25 #include "TortoiseGitBlameDoc.h"
26 #include "TortoiseGitBlameView.h"
35 // CTortoiseGitBlameView
37 IMPLEMENT_DYNCREATE(CTortoiseGitBlameView
, CView
)
39 BEGIN_MESSAGE_MAP(CTortoiseGitBlameView
, CView
)
40 // Standard printing commands
41 ON_COMMAND(ID_FILE_PRINT
, &CView::OnFilePrint
)
42 ON_COMMAND(ID_FILE_PRINT_DIRECT
, &CView::OnFilePrint
)
43 ON_COMMAND(ID_FILE_PRINT_PREVIEW
, &CTortoiseGitBlameView::OnFilePrintPreview
)
44 ON_COMMAND(ID_EDIT_FIND
,OnEditFind
)
45 ON_COMMAND(ID_EDIT_GOTO
,OnEditGoto
)
53 ON_NOTIFY(SCN_PAINTED
,0,OnSciPainted
)
54 ON_NOTIFY(SCN_GETBKCOLOR
,0,OnSciGetBkColor
)
57 // CTortoiseGitBlameView construction/destruction
59 CTortoiseGitBlameView::CTortoiseGitBlameView()
61 // TODO: add construction code here
78 m_windowcolor
= ::GetSysColor(COLOR_WINDOW
);
79 m_textcolor
= ::GetSysColor(COLOR_WINDOWTEXT
);
80 m_texthighlightcolor
= ::GetSysColor(COLOR_HIGHLIGHTTEXT
);
81 m_mouserevcolor
= InterColor(m_windowcolor
, m_textcolor
, 20);
82 m_mouseauthorcolor
= InterColor(m_windowcolor
, m_textcolor
, 10);
83 m_selectedrevcolor
= ::GetSysColor(COLOR_HIGHLIGHT
);
84 m_selectedauthorcolor
= InterColor(m_selectedrevcolor
, m_texthighlightcolor
, 35);
88 m_selectedorigrev
= -1;
93 m_lowestrev
= LONG_MAX
;
103 CTortoiseGitBlameView::~CTortoiseGitBlameView()
106 DeleteObject(m_font
);
108 DeleteObject(m_italicfont
);
112 int CTortoiseGitBlameView::OnCreate(LPCREATESTRUCT lpcs
)
116 this->GetWindowRect(&rect1
);
117 rect
.left
=m_blamewidth
+LOCATOR_WIDTH
;
118 rect
.right
=rect
.Width();
120 rect
.bottom
=rect
.Height();
121 BOOL b
=m_TextView
.Create(_T("Scintilla"),_T("source"),0,rect
,this,0,0);
123 m_TextView
.ShowWindow( SW_SHOW
);
124 //m_TextView.InsertText(_T("Abdadfasdf"));
125 m_wEditor
= m_TextView
.m_hWnd
;
128 m_ToolTip
.Create(this->GetParent());
129 m_ToolTip
.AddTool(this,_T("Test"));
131 return CView::OnCreate(lpcs
);
134 void CTortoiseGitBlameView::OnSize(UINT nType
,int cx
, int cy
)
138 rect
.left
=m_blamewidth
;
143 m_TextView
.MoveWindow(&rect
);
146 BOOL
CTortoiseGitBlameView::PreCreateWindow(CREATESTRUCT
& cs
)
148 // TODO: Modify the Window class or styles here by modifying
149 // the CREATESTRUCT cs
151 return CView::PreCreateWindow(cs
);
154 // CTortoiseGitBlameView drawing
156 void CTortoiseGitBlameView::OnDraw(CDC
* /*pDC*/)
158 CTortoiseGitBlameDoc
* pDoc
= GetDocument();
163 DrawBlame(this->GetDC()->m_hDC
);
164 DrawLocatorBar(this->GetDC()->m_hDC
);
165 // TODO: add draw code for native data here
169 // CTortoiseGitBlameView printing
172 void CTortoiseGitBlameView::OnFilePrintPreview()
174 AFXPrintPreview(this);
177 BOOL
CTortoiseGitBlameView::OnPreparePrinting(CPrintInfo
* pInfo
)
179 // default preparation
180 return DoPreparePrinting(pInfo
);
183 void CTortoiseGitBlameView::OnBeginPrinting(CDC
* /*pDC*/, CPrintInfo
* /*pInfo*/)
185 // TODO: add extra initialization before printing
188 void CTortoiseGitBlameView::OnEndPrinting(CDC
* /*pDC*/, CPrintInfo
* /*pInfo*/)
190 // TODO: add cleanup after printing
193 void CTortoiseGitBlameView::OnRButtonUp(UINT nFlags
, CPoint point
)
195 ClientToScreen(&point
);
196 OnContextMenu(this, point
);
199 void CTortoiseGitBlameView::OnContextMenu(CWnd
* pWnd
, CPoint point
)
201 theApp
.GetContextMenuManager()->ShowPopupMenu(IDR_POPUP_EDIT
, point
.x
, point
.y
, this, TRUE
);
205 // CTortoiseGitBlameView diagnostics
208 void CTortoiseGitBlameView::AssertValid() const
210 CView::AssertValid();
213 void CTortoiseGitBlameView::Dump(CDumpContext
& dc
) const
218 CTortoiseGitBlameDoc
* CTortoiseGitBlameView::GetDocument() const // non-debug version is inline
220 ASSERT(m_pDocument
->IsKindOf(RUNTIME_CLASS(CTortoiseGitBlameDoc
)));
221 return (CTortoiseGitBlameDoc
*)m_pDocument
;
226 // CTortoiseGitBlameView message handlers
227 CString
CTortoiseGitBlameView::GetAppDirectory()
231 DWORD bufferlen
= MAX_PATH
; // MAX_PATH is not the limit here!
234 bufferlen
+= MAX_PATH
; // MAX_PATH is not the limit here!
235 TCHAR
* pBuf
= new TCHAR
[bufferlen
];
236 len
= GetModuleFileName(NULL
, pBuf
, bufferlen
);
237 path
= CString(pBuf
, len
);
239 } while(len
== bufferlen
);
241 path
= path
.Left(path
.ReverseFind(_T('\\')));
242 //path = path.substr(0, path.rfind('\\') + 1);
247 // Return a color which is interpolated between c1 and c2.
248 // Slider controls the relative proportions as a percentage:
249 // Slider = 0 represents pure c1
250 // Slider = 50 represents equal mixture
251 // Slider = 100 represents pure c2
252 COLORREF
CTortoiseGitBlameView::InterColor(COLORREF c1
, COLORREF c2
, int Slider
)
256 // Limit Slider to 0..100% range
262 // The color components have to be treated individually.
263 r
= (GetRValue(c2
) * Slider
+ GetRValue(c1
) * (100 - Slider
)) / 100;
264 g
= (GetGValue(c2
) * Slider
+ GetGValue(c1
) * (100 - Slider
)) / 100;
265 b
= (GetBValue(c2
) * Slider
+ GetBValue(c1
) * (100 - Slider
)) / 100;
270 LRESULT
CTortoiseGitBlameView::SendEditor(UINT Msg
, WPARAM wParam
, LPARAM lParam
)
272 if (m_directFunction
)
274 return ((SciFnDirect
) m_directFunction
)(m_directPointer
, Msg
, wParam
, lParam
);
276 return ::SendMessage(m_wEditor
, Msg
, wParam
, lParam
);
279 void CTortoiseGitBlameView::GetRange(int start
, int end
, char *text
)
283 tr
.chrg
.cpMin
= start
;
287 SendMessage(m_wEditor
, EM_GETTEXTRANGE
, 0, reinterpret_cast<LPARAM
>(&tr
));
291 void CTortoiseGitBlameView::SetTitle()
294 char title
[MAX_PATH
+ 100];
295 strcpy_s(title
, MAX_PATH
+ 100, szTitle
);
296 strcat_s(title
, MAX_PATH
+ 100, " - ");
297 strcat_s(title
, MAX_PATH
+ 100, szViewtitle
);
298 ::SetWindowText(wMain
, title
);
302 BOOL
CTortoiseGitBlameView::OpenLogFile(const char *fileName
)
305 char logmsgbuf
[10000+1];
307 fopen_s(&File
, fileName
, "rb");
317 wchar_t wbuf
[MAX_LOG_LENGTH
+6];
320 len
= fread(&rev
, sizeof(LONG
), 1, File
);
327 len
= fread(&slength
, sizeof(int), 1, File
);
334 if (slength
> MAX_LOG_LENGTH
)
336 reallength
= slength
;
337 slength
= MAX_LOG_LENGTH
;
341 len
= fread(logmsgbuf
, sizeof(char), slength
, File
);
342 if (len
< (size_t)slength
)
348 msg
= CString(logmsgbuf
, slength
);
351 fseek(File
, reallength
-MAX_LOG_LENGTH
, SEEK_CUR
);
352 msg
= msg
+ _T("\n...");
354 int len2
= ::MultiByteToWideChar(CP_UTF8
, NULL
, msg
.c_str(), min(msg
.size(), MAX_LOG_LENGTH
+5), wbuf
, MAX_LOG_LENGTH
+5);
356 len2
= ::WideCharToMultiByte(CP_ACP
, NULL
, wbuf
, len2
, logmsgbuf
, MAX_LOG_LENGTH
+5, NULL
, NULL
);
358 msg
= CString(logmsgbuf
);
359 logmessages
[rev
] = msg
;
365 BOOL
CTortoiseGitBlameView::OpenFile(const char *fileName
)
368 SendEditor(SCI_SETREADONLY
, FALSE
);
369 SendEditor(SCI_CLEARALL
);
370 SendEditor(EM_EMPTYUNDOBUFFER
);
372 SendEditor(SCI_SETSAVEPOINT
);
373 SendEditor(SCI_CANCEL
);
374 SendEditor(SCI_SETUNDOCOLLECTION
, 0);
375 ::ShowWindow(m_wEditor
, SW_HIDE
);
383 char * lineptr
= NULL
;
384 char * trimptr
= NULL
;
385 //ignore the first two lines, they're of no interest to us
386 File
.getline(line
, sizeof(line
)/sizeof(char));
387 File
.getline(line
, sizeof(line
)/sizeof(char));
388 m_lowestrev
= LONG_MAX
;
393 File
.getline(line
, sizeof(line
)/sizeof(TCHAR
));
394 if (File
.gcount()>139)
396 mergelines
.push_back((line
[0] != ' '));
398 long rev
= _ttol(lineptr
);
400 m_lowestrev
= min(m_lowestrev
, rev
);
401 m_highestrev
= max(m_highestrev
, rev
);
403 rev
= _ttol(lineptr
);
404 origrevs
.push_back(rev
);
406 dates
.push_back(CString(lineptr
, 30));
408 // unfortunately, the 'path' entry can be longer than the 60 chars
409 // we made the column. We therefore have to step through the path
410 // string until we find a space
414 // TODO: how can we deal with the situation where the path has
415 // a space in it, but the space is after the 60 chars reserved
417 // The only way to deal with that would be to use a custom
418 // binary format for the blame file.
420 trimptr
= _tcschr(trimptr
, ' ');
421 } while ((trimptr
)&&(trimptr
+1 < lineptr
+61));
426 paths
.push_back(CString(lineptr
));
427 if (trimptr
+1 < lineptr
+61)
430 lineptr
= (trimptr
+1);
431 trimptr
= lineptr
+30;
432 while ((*trimptr
== ' ')&&(trimptr
> lineptr
))
435 authors
.push_back(CString(lineptr
));
437 // in case we find an UTF8 BOM at the beginning of the line, we remove it
438 if (((unsigned char)lineptr
[0] == 0xEF)&&((unsigned char)lineptr
[1] == 0xBB)&&((unsigned char)lineptr
[2] == 0xBF))
442 if (((unsigned char)lineptr
[0] == 0xBB)&&((unsigned char)lineptr
[1] == 0xEF)&&((unsigned char)lineptr
[2] == 0xBF))
446 // check each line for illegal utf8 sequences. If one is found, we treat
447 // the file as ASCII, otherwise we assume an UTF8 file.
448 char * utf8CheckBuf
= lineptr
;
449 while ((bUTF8
)&&(*utf8CheckBuf
))
451 if ((*utf8CheckBuf
== 0xC0)||(*utf8CheckBuf
== 0xC1)||(*utf8CheckBuf
>= 0xF5))
456 if ((*utf8CheckBuf
& 0xE0)==0xC0)
459 if (*utf8CheckBuf
== 0)
461 if ((*utf8CheckBuf
& 0xC0)!=0x80)
467 if ((*utf8CheckBuf
& 0xF0)==0xE0)
470 if (*utf8CheckBuf
== 0)
472 if ((*utf8CheckBuf
& 0xC0)!=0x80)
478 if (*utf8CheckBuf
== 0)
480 if ((*utf8CheckBuf
& 0xC0)!=0x80)
486 if ((*utf8CheckBuf
& 0xF8)==0xF0)
489 if (*utf8CheckBuf
== 0)
491 if ((*utf8CheckBuf
& 0xC0)!=0x80)
497 if (*utf8CheckBuf
== 0)
499 if ((*utf8CheckBuf
& 0xC0)!=0x80)
505 if (*utf8CheckBuf
== 0)
507 if ((*utf8CheckBuf
& 0xC0)!=0x80)
516 SendEditor(SCI_ADDTEXT
, _tcslen(lineptr
), reinterpret_cast<LPARAM
>(static_cast<char *>(lineptr
)));
517 SendEditor(SCI_ADDTEXT
, 2, (LPARAM
)_T("\r\n"));
519 } while (File
.gcount() > 0);
522 SendEditor(SCI_SETCODEPAGE
, SC_CP_UTF8
);
524 SendEditor(SCI_SETUNDOCOLLECTION
, 1);
525 ::SetFocus(m_wEditor
);
526 SendEditor(EM_EMPTYUNDOBUFFER
);
527 SendEditor(SCI_SETSAVEPOINT
);
528 SendEditor(SCI_GOTOPOS
, 0);
529 SendEditor(SCI_SETSCROLLWIDTHTRACKING
, TRUE
);
530 SendEditor(SCI_SETREADONLY
, TRUE
);
532 //check which lexer to use, depending on the filetype
533 SetupLexer(fileName
);
534 ::ShowWindow(m_wEditor
, SW_SHOW
);
536 ::InvalidateRect(wMain
, NULL
, TRUE
);
538 GetWindowRect(wMain
, &rc
);
539 SetWindowPos(wMain
, 0, rc
.left
, rc
.top
, rc
.right
-rc
.left
-1, rc
.bottom
- rc
.top
, 0);
544 void CTortoiseGitBlameView::SetAStyle(int style
, COLORREF fore
, COLORREF back
, int size
, CString
*face
)
546 SendEditor(SCI_STYLESETFORE
, style
, fore
);
547 SendEditor(SCI_STYLESETBACK
, style
, back
);
549 SendEditor(SCI_STYLESETSIZE
, style
, size
);
551 SendEditor(SCI_STYLESETFONT
, style
, reinterpret_cast<LPARAM
>(this->m_TextView
.StringForControl(*face
).GetBuffer()));
554 void CTortoiseGitBlameView::InitialiseEditor()
557 m_directFunction
= ::SendMessage(m_wEditor
, SCI_GETDIRECTFUNCTION
, 0, 0);
558 m_directPointer
= ::SendMessage(m_wEditor
, SCI_GETDIRECTPOINTER
, 0, 0);
559 // Set up the global default style. These attributes are used wherever no explicit choices are made.
560 SetAStyle(STYLE_DEFAULT
,
563 (DWORD
)CRegStdWORD(_T("Software\\TortoiseGit\\BlameFontSize"), 10),
564 &CString(((stdstring
)CRegStdString(_T("Software\\TortoiseGit\\BlameFontName"), _T("Courier New"))).c_str())
566 SendEditor(SCI_SETTABWIDTH
, (DWORD
)CRegStdWORD(_T("Software\\TortoiseGit\\BlameTabSize"), 4));
567 SendEditor(SCI_SETREADONLY
, TRUE
);
568 LRESULT pix
= SendEditor(SCI_TEXTWIDTH
, STYLE_LINENUMBER
, (LPARAM
)this->m_TextView
.StringForControl(_T("_99999")).GetBuffer());
570 SendEditor(SCI_SETMARGINWIDTHN
, 0, pix
);
572 SendEditor(SCI_SETMARGINWIDTHN
, 0);
573 SendEditor(SCI_SETMARGINWIDTHN
, 1);
574 SendEditor(SCI_SETMARGINWIDTHN
, 2);
575 //Set the default windows colors for edit controls
576 SendEditor(SCI_STYLESETFORE
, STYLE_DEFAULT
, ::GetSysColor(COLOR_WINDOWTEXT
));
577 SendEditor(SCI_STYLESETBACK
, STYLE_DEFAULT
, ::GetSysColor(COLOR_WINDOW
));
578 SendEditor(SCI_SETSELFORE
, TRUE
, ::GetSysColor(COLOR_HIGHLIGHTTEXT
));
579 SendEditor(SCI_SETSELBACK
, TRUE
, ::GetSysColor(COLOR_HIGHLIGHT
));
580 SendEditor(SCI_SETCARETFORE
, ::GetSysColor(COLOR_WINDOWTEXT
));
581 m_regOldLinesColor
= CRegStdWORD(_T("Software\\TortoiseGit\\BlameOldColor"), RGB(230, 230, 255));
582 m_regNewLinesColor
= CRegStdWORD(_T("Software\\TortoiseGit\\BlameNewColor"), RGB(255, 230, 230));
584 this->m_TextView
.Call(SCI_SETWRAPMODE
, SC_WRAP_NONE
);
588 void CTortoiseGitBlameView::StartSearch()
593 // Initialize FINDREPLACE
594 if (fr
.Flags
& FR_MATCHCASE
)
596 SecureZeroMemory(&fr
, sizeof(fr
));
597 fr
.lStructSize
= sizeof(fr
);
598 fr
.hwndOwner
= wMain
;
599 fr
.lpstrFindWhat
= szFindWhat
;
600 fr
.wFindWhatLen
= 80;
601 fr
.Flags
= FR_HIDEUPDOWN
| FR_HIDEWHOLEWORD
;
602 fr
.Flags
|= bCase
? FR_MATCHCASE
: 0;
604 currentDialog
= FindText(&fr
);
607 bool CTortoiseGitBlameView::DoSearch(LPSTR what
, DWORD flags
)
611 int pos
= SendEditor(SCI_GETCURRENTPOS
);
612 int line
= SendEditor(SCI_LINEFROMPOSITION
, pos
);
614 bool bCaseSensitive
= !!(flags
& FR_MATCHCASE
);
616 strcpy_s(szWhat
, sizeof(szWhat
), what
);
621 size_t len
= strlen(szWhat
);
622 for (p
= szWhat
; p
< szWhat
+ len
; p
++)
624 if (isupper(*p
)&&__isascii(*p
))
629 CString sWhat
= CString(szWhat
);
633 for (i
=line
; (i
<(int)authors
.size())&&(!bFound
); ++i
)
635 int bufsize
= SendEditor(SCI_GETLINE
, i
);
636 char * linebuf
= new char[bufsize
+1];
637 SecureZeroMemory(linebuf
, bufsize
+1);
638 SendEditor(SCI_GETLINE
, i
, (LPARAM
)linebuf
);
642 for (p
= linebuf
; p
< linebuf
+ bufsize
; p
++)
644 if (isupper(*p
)&&__isascii(*p
))
648 _stprintf_s(buf
, 20, _T("%ld"), revs
[i
]);
649 if (authors
[i
].compare(sWhat
)==0)
651 else if ((!bCaseSensitive
)&&(_stricmp(authors
[i
].c_str(), szWhat
)==0))
653 else if (strcmp(buf
, szWhat
) == 0)
655 else if (strstr(linebuf
, szWhat
))
661 for (i
=0; (i
<line
)&&(!bFound
); ++i
)
663 int bufsize
= SendEditor(SCI_GETLINE
, i
);
664 char * linebuf
= new char[bufsize
+1];
665 SecureZeroMemory(linebuf
, bufsize
+1);
666 SendEditor(SCI_GETLINE
, i
, (LPARAM
)linebuf
);
670 for (p
= linebuf
; p
< linebuf
+ bufsize
; p
++)
672 if (isupper(*p
)&&__isascii(*p
))
676 _stprintf_s(buf
, 20, _T("%ld"), revs
[i
]);
677 if (authors
[i
].compare(sWhat
)==0)
679 else if ((!bCaseSensitive
)&&(_stricmp(authors
[i
].c_str(), szWhat
)==0))
681 else if (strcmp(buf
, szWhat
) == 0)
683 else if (strstr(linebuf
, szWhat
))
691 int selstart
= SendEditor(SCI_GETCURRENTPOS
);
692 int selend
= SendEditor(SCI_POSITIONFROMLINE
, i
);
693 SendEditor(SCI_SETSELECTIONSTART
, selstart
);
694 SendEditor(SCI_SETSELECTIONEND
, selend
);
695 m_SelectedLine
= i
-1;
699 ::MessageBox(wMain
, searchstringnotfound
, "CTortoiseGitBlameView", MB_ICONINFORMATION
);
705 bool CTortoiseGitBlameView::GotoLine(long line
)
710 if ((unsigned long)line
>= m_CommitHash
.size())
712 line
= m_CommitHash
.size()-1;
715 int nCurrentPos
= SendEditor(SCI_GETCURRENTPOS
);
716 int nCurrentLine
= SendEditor(SCI_LINEFROMPOSITION
,nCurrentPos
);
717 int nFirstVisibleLine
= SendEditor(SCI_GETFIRSTVISIBLELINE
);
718 int nLinesOnScreen
= SendEditor(SCI_LINESONSCREEN
);
720 if ( line
>=nFirstVisibleLine
&& line
<=nFirstVisibleLine
+nLinesOnScreen
)
723 SendEditor(SCI_GOTOLINE
, line
);
727 // Place the requested line one third from the top
728 if ( line
> nCurrentLine
)
730 SendEditor(SCI_GOTOLINE
, (WPARAM
)(line
+(int)nLinesOnScreen
*(2/3.0)));
734 SendEditor(SCI_GOTOLINE
, (WPARAM
)(line
-(int)nLinesOnScreen
*(1/3.0)));
738 // Highlight the line
739 int nPosStart
= SendEditor(SCI_POSITIONFROMLINE
,line
);
740 int nPosEnd
= SendEditor(SCI_GETLINEENDPOSITION
,line
);
741 SendEditor(SCI_SETSEL
,nPosEnd
,nPosStart
);
746 bool CTortoiseGitBlameView::ScrollToLine(long line
)
751 int nCurrentLine
= SendEditor(SCI_GETFIRSTVISIBLELINE
);
753 int scrolldelta
= line
- nCurrentLine
;
754 SendEditor(SCI_LINESCROLL
, 0, scrolldelta
);
759 void CTortoiseGitBlameView::CopySelectedLogToClipboard()
762 if (m_selectedrev
<= 0)
764 std::map
<LONG
, CString
>::iterator iter
;
765 if ((iter
= app
.logmessages
.find(m_selectedrev
)) != app
.logmessages
.end())
768 msg
+= m_selectedauthor
;
770 msg
+= app
.m_selecteddate
;
774 if (OpenClipboard(app
.wBlame
))
777 HGLOBAL hClipboardData
;
778 hClipboardData
= GlobalAlloc(GMEM_DDESHARE
, msg
.size()+1);
780 pchData
= (char*)GlobalLock(hClipboardData
);
781 strcpy_s(pchData
, msg
.size()+1, msg
.c_str());
782 GlobalUnlock(hClipboardData
);
783 SetClipboardData(CF_TEXT
,hClipboardData
);
790 void CTortoiseGitBlameView::BlamePreviousRevision()
793 LONG nRevisionTo
= m_selectedorigrev
- 1;
799 // We now determine the smallest revision number in the blame file (but ignore "-1")
800 // We do this for two reasons:
801 // 1. we respect the "From revision" which the user entered
802 // 2. we speed up the call of "svn blame" because previous smaller revision numbers don't have any effect on the result
803 LONG nSmallestRevision
= -1;
804 for (LONG line
=0;line
<(LONG
)app
.revs
.size();line
++)
806 const LONG nRevision
= app
.revs
[line
];
809 if ( nSmallestRevision
< 1 )
811 nSmallestRevision
= nRevision
;
815 nSmallestRevision
= min(nSmallestRevision
,nRevision
);
820 char bufStartRev
[20];
821 _stprintf_s(bufStartRev
, 20, _T("%d"), nSmallestRevision
);
824 _stprintf_s(bufEndRev
, 20, _T("%d"), nRevisionTo
);
827 _stprintf_s(bufLine
, 20, _T("%d"), m_SelectedLine
+1); //using the current line is a good guess.
830 PROCESS_INFORMATION process
;
831 memset(&startup
, 0, sizeof(startup
));
832 startup
.cb
= sizeof(startup
);
833 memset(&process
, 0, sizeof(process
));
834 stdstring tortoiseProcPath
= GetAppDirectory() + _T("TortoiseProc.exe");
835 stdstring svnCmd
= _T(" /command:blame ");
836 svnCmd
+= _T(" /path:\"");
837 svnCmd
+= szOrigPath
;
839 svnCmd
+= _T(" /startrev:");
840 svnCmd
+= bufStartRev
;
841 svnCmd
+= _T(" /endrev:");
843 svnCmd
+= _T(" /line:");
846 svnCmd
+= _T(" /ignoreeol");
848 svnCmd
+= _T(" /ignorespaces");
849 if (bIgnoreAllSpaces
)
850 svnCmd
+= _T(" /ignoreallspaces");
851 if (CreateProcess(tortoiseProcPath
.c_str(), const_cast<TCHAR
*>(svnCmd
.c_str()), NULL
, NULL
, FALSE
, 0, 0, 0, &startup
, &process
))
853 CloseHandle(process
.hThread
);
854 CloseHandle(process
.hProcess
);
859 void CTortoiseGitBlameView::DiffPreviousRevision()
862 LONG nRevisionTo
= m_selectedorigrev
;
868 LONG nRevisionFrom
= nRevisionTo
-1;
870 char bufStartRev
[20];
871 _stprintf_s(bufStartRev
, 20, _T("%d"), nRevisionFrom
);
874 _stprintf_s(bufEndRev
, 20, _T("%d"), nRevisionTo
);
877 PROCESS_INFORMATION process
;
878 memset(&startup
, 0, sizeof(startup
));
879 startup
.cb
= sizeof(startup
);
880 memset(&process
, 0, sizeof(process
));
881 stdstring tortoiseProcPath
= GetAppDirectory() + _T("TortoiseProc.exe");
882 stdstring svnCmd
= _T(" /command:diff ");
883 svnCmd
+= _T(" /path:\"");
884 svnCmd
+= szOrigPath
;
886 svnCmd
+= _T(" /startrev:");
887 svnCmd
+= bufStartRev
;
888 svnCmd
+= _T(" /endrev:");
890 if (CreateProcess(tortoiseProcPath
.c_str(), const_cast<TCHAR
*>(svnCmd
.c_str()), NULL
, NULL
, FALSE
, 0, 0, 0, &startup
, &process
))
892 CloseHandle(process
.hThread
);
893 CloseHandle(process
.hProcess
);
898 void CTortoiseGitBlameView::ShowLog()
902 _stprintf_s(bufRev
, 20, _T("%d"), m_selectedorigrev
);
905 PROCESS_INFORMATION process
;
906 memset(&startup
, 0, sizeof(startup
));
907 startup
.cb
= sizeof(startup
);
908 memset(&process
, 0, sizeof(process
));
909 stdstring tortoiseProcPath
= GetAppDirectory() + _T("TortoiseProc.exe");
910 stdstring svnCmd
= _T(" /command:log ");
911 svnCmd
+= _T(" /path:\"");
912 svnCmd
+= szOrigPath
;
914 svnCmd
+= _T(" /startrev:");
916 svnCmd
+= _T(" /pegrev:");
918 if (CreateProcess(tortoiseProcPath
.c_str(), const_cast<TCHAR
*>(svnCmd
.c_str()), NULL
, NULL
, FALSE
, 0, 0, 0, &startup
, &process
))
920 CloseHandle(process
.hThread
);
921 CloseHandle(process
.hProcess
);
926 void CTortoiseGitBlameView::Notify(SCNotification
*notification
)
928 switch (notification
->nmhdr
.code
)
930 case SCN_SAVEPOINTREACHED
:
933 case SCN_SAVEPOINTLEFT
:
936 // InvalidateRect(wBlame, NULL, FALSE);
937 // InvalidateRect(wLocator, NULL, FALSE);
940 // if ((m_colorage)&&(notification->line < (int)revs.size()))
942 // notification->lParam = InterColor(DWORD(m_regOldLinesColor), DWORD(m_regNewLinesColor), (revs[notification->line]-m_lowestrev)*100/((m_highestrev-m_lowestrev)+1));
948 void CTortoiseGitBlameView::Command(int id
)
954 // ::PostQuitMessage(0);
959 case ID_COPYTOCLIPBOARD
:
960 CopySelectedLogToClipboard();
962 case ID_BLAME_PREVIOUS_REVISION
:
963 BlamePreviousRevision();
965 case ID_DIFF_PREVIOUS_REVISION
:
966 DiffPreviousRevision();
971 case ID_EDIT_GOTOLINE
:
974 case ID_VIEW_COLORAGEOFLINES
:
976 m_colorage
= !m_colorage
;
977 HMENU hMenu
= GetMenu(wMain
);
978 UINT uCheck
= MF_BYCOMMAND
;
979 uCheck
|= m_colorage
? MF_CHECKED
: MF_UNCHECKED
;
980 CheckMenuItem(hMenu
, ID_VIEW_COLORAGEOFLINES
, uCheck
);
985 case ID_VIEW_MERGEPATH
:
987 ShowPath
= !ShowPath
;
988 HMENU hMenu
= GetMenu(wMain
);
989 UINT uCheck
= MF_BYCOMMAND
;
990 uCheck
|= ShowPath
? MF_CHECKED
: MF_UNCHECKED
;
991 CheckMenuItem(hMenu
, ID_VIEW_MERGEPATH
, uCheck
);
1001 void CTortoiseGitBlameView::GotoLineDlg()
1004 if (DialogBox(hResource
, MAKEINTRESOURCE(IDD_GOTODLG
), wMain
, GotoDlgProc
)==IDOK
)
1006 GotoLine(m_gotoline
);
1011 LONG
CTortoiseGitBlameView::GetBlameWidth()
1013 LONG blamewidth
= 0;
1016 HDC hDC
= this->GetDC()->m_hDC
;
1017 HFONT oldfont
= (HFONT
)::SelectObject(hDC
, m_font
);
1019 TCHAR buf
[MAX_PATH
];
1020 //_stprintf_s(buf, MAX_PATH, _T("%8ld "), 88888888);
1021 //::GetTextExtentPoint(hDC, buf, _tcslen(buf), &width);
1022 //m_revwidth = width.cx + BLAMESPACE;
1023 //blamewidth += m_revwidth;
1026 for (int i
=0;i
<this->m_Authors
.size();i
++)
1031 _stprintf_s(buf
, MAX_PATH
, _T("%d."), maxnum
);
1032 ::GetTextExtentPoint(hDC
, buf
, _tcslen(buf
), &width
);
1033 m_revwidth
= width
.cx
+ BLAMESPACE
;
1034 blamewidth
+= m_revwidth
;
1037 _stprintf_s(buf
, MAX_PATH
, _T("%d"), m_CommitHash
.size());
1038 ::GetTextExtentPoint(hDC
, buf
, _tcslen(buf
), &width
);
1039 m_linewidth
= width
.cx
+ BLAMESPACE
;
1040 blamewidth
+= m_revwidth
;
1045 _stprintf_s(buf
, MAX_PATH
, _T("%30s"), _T("31.08.2001 06:24:14"));
1046 ::GetTextExtentPoint32(hDC
, buf
, _tcslen(buf
), &width
);
1047 m_datewidth
= width
.cx
+ BLAMESPACE
;
1048 blamewidth
+= m_datewidth
;
1052 SIZE maxwidth
= {0};
1054 for (int i
=0;i
<this->m_Authors
.size();i
++)
1055 //for (std::vector<CString>::iterator I = authors.begin(); I != authors.end(); ++I)
1057 ::GetTextExtentPoint32(hDC
,m_Authors
[i
] , m_Authors
[i
].GetLength(), &width
);
1058 if (width
.cx
> maxwidth
.cx
)
1061 m_authorwidth
= maxwidth
.cx
+ BLAMESPACE
;
1062 blamewidth
+= m_authorwidth
;
1067 SIZE maxwidth
= {0};
1068 for (std::vector
<CString
>::iterator I
= paths
.begin(); I
!= paths
.end(); ++I
)
1070 ::GetTextExtentPoint32(hDC
, I
->c_str(), I
->size(), &width
);
1071 if (width
.cx
> maxwidth
.cx
)
1074 m_pathwidth
= maxwidth
.cx
+ BLAMESPACE
;
1075 blamewidth
+= m_pathwidth
;
1078 ::SelectObject(hDC
, oldfont
);
1079 POINT pt
= {blamewidth
, 0};
1080 LPtoDP(hDC
, &pt
, 1);
1081 m_blamewidth
= pt
.x
;
1082 //::ReleaseDC(wBlame, hDC);
1084 //return m_blamewidth;
1089 void CTortoiseGitBlameView::CreateFont()
1095 HDC hDC
= ::GetDC(wBlame
);
1096 lf
.lfHeight
= -MulDiv((DWORD
)CRegStdWORD(_T("Software\\TortoiseGit\\BlameFontSize"), 10), GetDeviceCaps(hDC
, LOGPIXELSY
), 72);
1097 lf
.lfCharSet
= DEFAULT_CHARSET
;
1098 CRegStdString fontname
= CRegStdString(_T("Software\\TortoiseGit\\BlameFontName"), _T("Courier New"));
1099 _tcscpy_s(lf
.lfFaceName
, 32, ((stdstring
)fontname
).c_str());
1100 m_font
= ::CreateFontIndirect(&lf
);
1103 m_italicfont
= ::CreateFontIndirect(&lf
);
1105 ::ReleaseDC(wBlame
, hDC
);
1107 //m_TextView.SetFont(lf.lfFaceName,((DWORD)CRegStdWORD(_T("Software\\TortoiseGit\\BlameFontSize"), 10)));
1110 void CTortoiseGitBlameView::DrawBlame(HDC hDC
)
1118 HFONT oldfont
= NULL
;
1119 LONG_PTR line
= SendEditor(SCI_GETFIRSTVISIBLELINE
);
1120 LONG_PTR linesonscreen
= SendEditor(SCI_LINESONSCREEN
);
1121 LONG_PTR height
= SendEditor(SCI_TEXTHEIGHT
);
1123 TCHAR buf
[MAX_PATH
];
1126 //::GetClientRect(this->m_hWnd, &rc);
1127 for (LRESULT i
=line
; i
<(line
+linesonscreen
); ++i
)
1130 if (i
< (int)m_CommitHash
.size())
1132 // if (mergelines[i])
1133 // oldfont = (HFONT)::SelectObject(hDC, m_italicfont);
1135 oldfont
= (HFONT
)::SelectObject(hDC
, m_font
);
1136 ::SetBkColor(hDC
, m_windowcolor
);
1137 ::SetTextColor(hDC
, m_textcolor
);
1138 if (m_CommitHash
[i
].GetLength()>0)
1140 //if (m_CommitHash[i].Compare(m_MouseHash)==0)
1141 // ::SetBkColor(hDC, m_mouseauthorcolor);
1142 if (m_CommitHash
[i
].Compare(m_SelectedHash
)==0)
1144 ::SetBkColor(hDC
, m_selectedauthorcolor
);
1145 ::SetTextColor(hDC
, m_texthighlightcolor
);
1150 if(m_MouseLine
== i
)
1151 ::SetBkColor(hDC
, m_mouserevcolor
);
1153 //if ((revs[i] == m_mouserev)&&(!sel))
1154 // ::SetBkColor(hDC, m_mouserevcolor);
1155 //if (revs[i] == m_selectedrev)
1157 // ::SetBkColor(hDC, m_selectedrevcolor);
1158 // ::SetTextColor(hDC, m_texthighlightcolor);
1162 str
.Format(_T("%d"),m_ID
[i
]);
1164 //_stprintf_s(buf, MAX_PATH, _T("%8ld "), revs[i]);
1166 rc
.left
=LOCATOR_WIDTH
;
1168 rc
.right
= rc
.left
+ m_blamewidth
;
1169 ::ExtTextOut(hDC
, LOCATOR_WIDTH
, Y
, ETO_CLIPPED
, &rc
, str
, str
.GetLength(), 0);
1170 int Left
= m_revwidth
;
1174 rc
.right
= rc
.left
+ Left
+ m_authorwidth
;
1175 //_stprintf_s(buf, MAX_PATH, _T("%-30s "), authors[i].c_str());
1176 ::ExtTextOut(hDC
, Left
, Y
, ETO_CLIPPED
, &rc
, m_Authors
[i
], m_Authors
[i
].GetLength(), 0);
1177 Left
+= m_authorwidth
;
1182 rc
.right
= rc
.left
+ Left
+ m_datewidth
;
1183 _stprintf_s(buf
, MAX_PATH
, _T("%30s "), dates
[i
].c_str());
1184 ::ExtTextOut(hDC
, Left
, Y
, ETO_CLIPPED
, &rc
, buf
, _tcslen(buf
), 0);
1185 Left
+= m_datewidth
;
1192 rc
.right
= rc
.left
+ Left
+ m_pathwidth
;
1193 _stprintf_s(buf
, MAX_PATH
, _T("%-60s "), paths
[i
].c_str());
1194 ::ExtTextOut(hDC
, Left
, Y
, ETO_CLIPPED
, &rc
, buf
, _tcslen(buf
), 0);
1195 Left
+= m_authorwidth
;
1198 if ((i
==m_SelectedLine
)&&(currentDialog
))
1201 brush
.lbColor
= m_textcolor
;
1203 brush
.lbStyle
= BS_SOLID
;
1204 HPEN pen
= ExtCreatePen(PS_SOLID
| PS_GEOMETRIC
, 2, &brush
, 0, NULL
);
1205 HGDIOBJ hPenOld
= SelectObject(hDC
, pen
);
1208 rc2
.bottom
= Y
+ height
;
1209 ::MoveToEx(hDC
, rc2
.left
, rc2
.top
, NULL
);
1210 ::LineTo(hDC
, rc2
.right
, rc2
.top
);
1211 ::LineTo(hDC
, rc2
.right
, rc2
.bottom
);
1212 ::LineTo(hDC
, rc2
.left
, rc2
.bottom
);
1213 ::LineTo(hDC
, rc2
.left
, rc2
.top
);
1214 SelectObject(hDC
, hPenOld
);
1218 ::SelectObject(hDC
, oldfont
);
1222 ::SetBkColor(hDC
, m_windowcolor
);
1223 for (int j
=0; j
< MAX_PATH
; ++j
)
1225 ::ExtTextOut(hDC
, 0, Y
, ETO_CLIPPED
, &rc
, buf
, MAX_PATH
-1, 0);
1231 void CTortoiseGitBlameView::DrawHeader(HDC hDC
)
1238 HFONT oldfont
= (HFONT
)::SelectObject(hDC
, GetStockObject(DEFAULT_GUI_FONT
));
1239 ::GetClientRect(wHeader
, &rc
);
1241 ::SetBkColor(hDC
, ::GetSysColor(COLOR_BTNFACE
));
1243 TCHAR szText
[MAX_LOADSTRING
];
1244 LoadString(app
.hResource
, IDS_HEADER_REVISION
, szText
, MAX_LOADSTRING
);
1245 ::ExtTextOut(hDC
, LOCATOR_WIDTH
, 0, ETO_CLIPPED
, &rc
, szText
, _tcslen(szText
), 0);
1246 int Left
= m_revwidth
+LOCATOR_WIDTH
;
1249 LoadString(app
.hResource
, IDS_HEADER_DATE
, szText
, MAX_LOADSTRING
);
1250 ::ExtTextOut(hDC
, Left
, 0, ETO_CLIPPED
, &rc
, szText
, _tcslen(szText
), 0);
1251 Left
+= m_datewidth
;
1255 LoadString(app
.hResource
, IDS_HEADER_AUTHOR
, szText
, MAX_LOADSTRING
);
1256 ::ExtTextOut(hDC
, Left
, 0, ETO_CLIPPED
, &rc
, szText
, _tcslen(szText
), 0);
1257 Left
+= m_authorwidth
;
1261 LoadString(app
.hResource
, IDS_HEADER_PATH
, szText
, MAX_LOADSTRING
);
1262 ::ExtTextOut(hDC
, Left
, 0, ETO_CLIPPED
, &rc
, szText
, _tcslen(szText
), 0);
1263 Left
+= m_pathwidth
;
1265 LoadString(app
.hResource
, IDS_HEADER_LINE
, szText
, MAX_LOADSTRING
);
1266 ::ExtTextOut(hDC
, Left
, 0, ETO_CLIPPED
, &rc
, szText
, _tcslen(szText
), 0);
1268 ::SelectObject(hDC
, oldfont
);
1272 void CTortoiseGitBlameView::DrawLocatorBar(HDC hDC
)
1277 LONG_PTR line
= SendEditor(SCI_GETFIRSTVISIBLELINE
);
1278 LONG_PTR linesonscreen
= SendEditor(SCI_LINESONSCREEN
);
1280 COLORREF blackColor
= GetSysColor(COLOR_WINDOWTEXT
);
1283 //::GetClientRect(wLocator, &rc);
1284 this->GetClientRect(&rc
);
1286 rc
.right
=LOCATOR_WIDTH
;
1289 LONG height
= rc
.bottom
-rc
.top
;
1290 LONG currentLine
= 0;
1292 // draw the colored bar
1293 for (std::vector
<LONG
>::const_iterator it
= m_ID
.begin(); it
!= m_ID
.end(); ++it
)
1296 // get the line color
1297 COLORREF cr
= InterColor(DWORD(m_regOldLinesColor
), DWORD(m_regNewLinesColor
), (*it
- m_lowestrev
)*100/((m_highestrev
-m_lowestrev
)+1));
1298 if ((currentLine
> line
)&&(currentLine
<= (line
+ linesonscreen
)))
1300 cr
= InterColor(cr
, blackColor
, 10);
1302 SetBkColor(hDC
, cr
);
1304 lineRect
.bottom
= (currentLine
* height
/ m_ID
.size());
1305 ::ExtTextOut(hDC
, 0, 0, ETO_OPAQUE
, &lineRect
, NULL
, 0, NULL
);
1306 Y
= lineRect
.bottom
;
1311 // now draw two lines indicating the scroll position of the source view
1312 SetBkColor(hDC
, blackColor
);
1313 lineRect
.top
= line
* height
/ m_ID
.size();
1314 lineRect
.bottom
= lineRect
.top
+1;
1315 ::ExtTextOut(hDC
, 0, 0, ETO_OPAQUE
, &lineRect
, NULL
, 0, NULL
);
1316 lineRect
.top
= (line
+ linesonscreen
) * height
/ m_ID
.size();
1317 lineRect
.bottom
= lineRect
.top
+1;
1318 ::ExtTextOut(hDC
, 0, 0, ETO_OPAQUE
, &lineRect
, NULL
, 0, NULL
);
1323 void CTortoiseGitBlameView::StringExpand(LPSTR str
)
1328 cPos
= strchr(cPos
, '\n');
1331 memmove(cPos
+1, cPos
, strlen(cPos
)*sizeof(char));
1336 } while (cPos
!= NULL
);
1338 void CTortoiseGitBlameView::StringExpand(LPWSTR str
)
1340 wchar_t * cPos
= str
;
1343 cPos
= wcschr(cPos
, '\n');
1346 memmove(cPos
+1, cPos
, wcslen(cPos
)*sizeof(wchar_t));
1351 } while (cPos
!= NULL
);
1354 // Forward declarations of functions included in this code module:
1355 ATOM
MyRegisterClass(HINSTANCE hResource
);
1356 ATOM
MyRegisterBlameClass(HINSTANCE hResource
);
1357 ATOM
MyRegisterHeaderClass(HINSTANCE hResource
);
1358 ATOM
MyRegisterLocatorClass(HINSTANCE hResource
);
1359 BOOL
InitInstance(HINSTANCE
, int);
1360 LRESULT CALLBACK
WndProc(HWND
, UINT
, WPARAM
, LPARAM
);
1361 LRESULT CALLBACK
WndBlameProc(HWND
, UINT
, WPARAM
, LPARAM
);
1362 LRESULT CALLBACK
WndHeaderProc(HWND
, UINT
, WPARAM
, LPARAM
);
1363 LRESULT CALLBACK
WndLocatorProc(HWND
, UINT
, WPARAM
, LPARAM
);
1364 UINT uFindReplaceMsg
;
1367 int APIENTRY
_tWinMain(HINSTANCE hInstance
,
1368 HINSTANCE
/*hPrevInstance*/,
1372 app
.hInstance
= hInstance
;
1376 if (::LoadLibrary("SciLexer.DLL") == NULL
)
1379 CRegStdWORD loc
= CRegStdWORD(_T("Software\\TortoiseGit\\LanguageID"), 1033);
1383 app
.hResource
= langDLL
.Init(_T("CTortoiseGitBlameView"), langId
);
1384 if (app
.hResource
== NULL
)
1385 app
.hResource
= app
.hInstance
;
1387 // Initialize global strings
1388 LoadString(app
.hResource
, IDS_APP_TITLE
, szTitle
, MAX_LOADSTRING
);
1389 LoadString(app
.hResource
, IDC_TortoiseGitBlameView
, szWindowClass
, MAX_LOADSTRING
);
1390 LoadString(app
.hResource
, IDS_SEARCHNOTFOUND
, searchstringnotfound
, MAX_LOADSTRING
);
1391 MyRegisterClass(app
.hResource
);
1392 MyRegisterBlameClass(app
.hResource
);
1393 MyRegisterHeaderClass(app
.hResource
);
1394 MyRegisterLocatorClass(app
.hResource
);
1396 // Perform application initialization:
1397 if (!InitInstance (app
.hResource
, nCmdShow
))
1403 SecureZeroMemory(szViewtitle
, MAX_PATH
);
1404 SecureZeroMemory(szOrigPath
, MAX_PATH
);
1405 char blamefile
[MAX_PATH
] = {0};
1406 char logfile
[MAX_PATH
] = {0};
1408 CCmdLineParser
parser(lpCmdLine
);
1413 _tcscpy_s(blamefile
, MAX_PATH
, __argv
[1]);
1417 _tcscpy_s(logfile
, MAX_PATH
, __argv
[2]);
1421 _tcscpy_s(szViewtitle
, MAX_PATH
, __argv
[3]);
1422 if (parser
.HasVal(_T("revrange")))
1424 _tcscat_s(szViewtitle
, MAX_PATH
, _T(" : "));
1425 _tcscat_s(szViewtitle
, MAX_PATH
, parser
.GetVal(_T("revrange")));
1428 if ((_tcslen(blamefile
)==0) || parser
.HasKey(_T("?")) || parser
.HasKey(_T("help")))
1430 TCHAR szInfo
[MAX_LOADSTRING
];
1431 LoadString(app
.hResource
, IDS_COMMANDLINE_INFO
, szInfo
, MAX_LOADSTRING
);
1432 MessageBox(NULL
, szInfo
, _T("CTortoiseGitBlameView"), MB_ICONERROR
);
1437 if ( parser
.HasKey(_T("path")) )
1439 _tcscpy_s(szOrigPath
, MAX_PATH
, parser
.GetVal(_T("path")));
1441 app
.bIgnoreEOL
= parser
.HasKey(_T("ignoreeol"));
1442 app
.bIgnoreSpaces
= parser
.HasKey(_T("ignorespaces"));
1443 app
.bIgnoreAllSpaces
= parser
.HasKey(_T("ignoreallspaces"));
1445 app
.SendEditor(SCI_SETCODEPAGE
, GetACP());
1446 app
.OpenFile(blamefile
);
1447 if (_tcslen(logfile
)>0)
1448 app
.OpenLogFile(logfile
);
1450 if (parser
.HasKey(_T("line")))
1452 app
.GotoLine(parser
.GetLongVal(_T("line")));
1455 CheckMenuItem(GetMenu(app
.wMain
), ID_VIEW_COLORAGEOFLINES
, MF_CHECKED
|MF_BYCOMMAND
);
1458 hAccelTable
= LoadAccelerators(app
.hResource
, (LPCTSTR
)IDC_TortoiseGitBlameView
);
1464 going
= GetMessage(&msg
, NULL
, 0, 0);
1465 if (app
.currentDialog
&& going
)
1467 if (!IsDialogMessage(app
.currentDialog
, &msg
))
1469 if (TranslateAccelerator(msg
.hwnd
, hAccelTable
, &msg
) == 0)
1471 TranslateMessage(&msg
);
1472 DispatchMessage(&msg
);
1478 if (TranslateAccelerator(app
.wMain
, hAccelTable
, &msg
) == 0)
1480 TranslateMessage(&msg
);
1481 DispatchMessage(&msg
);
1489 ATOM
MyRegisterClass(HINSTANCE hResource
)
1493 wcex
.cbSize
= sizeof(WNDCLASSEX
);
1495 wcex
.style
= CS_HREDRAW
| CS_VREDRAW
;
1496 wcex
.lpfnWndProc
= (WNDPROC
)WndProc
;
1497 wcex
.cbClsExtra
= 0;
1498 wcex
.cbWndExtra
= 0;
1499 wcex
.hInstance
= hResource
;
1500 wcex
.hIcon
= LoadIcon(hResource
, (LPCTSTR
)IDI_TortoiseGitBlameView
);
1501 wcex
.hCursor
= LoadCursor(NULL
, IDC_ARROW
);
1502 wcex
.hbrBackground
= (HBRUSH
)(COLOR_WINDOW
+1);
1503 wcex
.lpszMenuName
= (LPCTSTR
)IDC_TortoiseGitBlameView
;
1504 wcex
.lpszClassName
= szWindowClass
;
1505 wcex
.hIconSm
= LoadIcon(wcex
.hInstance
, (LPCTSTR
)IDI_SMALL
);
1507 return RegisterClassEx(&wcex
);
1510 ATOM
MyRegisterBlameClass(HINSTANCE hResource
)
1514 wcex
.cbSize
= sizeof(WNDCLASSEX
);
1516 wcex
.style
= CS_HREDRAW
| CS_VREDRAW
;
1517 wcex
.lpfnWndProc
= (WNDPROC
)WndBlameProc
;
1518 wcex
.cbClsExtra
= 0;
1519 wcex
.cbWndExtra
= 0;
1520 wcex
.hInstance
= hResource
;
1521 wcex
.hIcon
= LoadIcon(hResource
, (LPCTSTR
)IDI_TortoiseGitBlameView
);
1522 wcex
.hCursor
= LoadCursor(NULL
, IDC_ARROW
);
1523 wcex
.hbrBackground
= (HBRUSH
)(COLOR_WINDOW
+1);
1524 wcex
.lpszMenuName
= 0;
1525 wcex
.lpszClassName
= _T("TortoiseGitBlameViewBlame");
1526 wcex
.hIconSm
= LoadIcon(wcex
.hInstance
, (LPCTSTR
)IDI_SMALL
);
1528 return RegisterClassEx(&wcex
);
1531 ATOM
MyRegisterHeaderClass(HINSTANCE hResource
)
1535 wcex
.cbSize
= sizeof(WNDCLASSEX
);
1537 wcex
.style
= CS_HREDRAW
| CS_VREDRAW
;
1538 wcex
.lpfnWndProc
= (WNDPROC
)WndHeaderProc
;
1539 wcex
.cbClsExtra
= 0;
1540 wcex
.cbWndExtra
= 0;
1541 wcex
.hInstance
= hResource
;
1542 wcex
.hIcon
= LoadIcon(hResource
, (LPCTSTR
)IDI_TortoiseGitBlameView
);
1543 wcex
.hCursor
= LoadCursor(NULL
, IDC_ARROW
);
1544 wcex
.hbrBackground
= (HBRUSH
)(COLOR_BTNFACE
+1);
1545 wcex
.lpszMenuName
= 0;
1546 wcex
.lpszClassName
= _T("TortoiseGitBlameViewHeader");
1547 wcex
.hIconSm
= LoadIcon(wcex
.hInstance
, (LPCTSTR
)IDI_SMALL
);
1549 return RegisterClassEx(&wcex
);
1552 ATOM
MyRegisterLocatorClass(HINSTANCE hResource
)
1556 wcex
.cbSize
= sizeof(WNDCLASSEX
);
1558 wcex
.style
= CS_HREDRAW
| CS_VREDRAW
;
1559 wcex
.lpfnWndProc
= (WNDPROC
)WndLocatorProc
;
1560 wcex
.cbClsExtra
= 0;
1561 wcex
.cbWndExtra
= 0;
1562 wcex
.hInstance
= hResource
;
1563 wcex
.hIcon
= LoadIcon(hResource
, (LPCTSTR
)IDI_TortoiseGitBlameView
);
1564 wcex
.hCursor
= LoadCursor(NULL
, IDC_ARROW
);
1565 wcex
.hbrBackground
= (HBRUSH
)(COLOR_WINDOW
+1);
1566 wcex
.lpszMenuName
= 0;
1567 wcex
.lpszClassName
= _T("TortoiseGitBlameViewLocator");
1568 wcex
.hIconSm
= LoadIcon(wcex
.hInstance
, (LPCTSTR
)IDI_SMALL
);
1570 return RegisterClassEx(&wcex
);
1573 BOOL
InitInstance(HINSTANCE hResource
, int nCmdShow
)
1575 app
.wMain
= CreateWindow(szWindowClass
, szTitle
, WS_OVERLAPPEDWINDOW
,
1576 CW_USEDEFAULT
, 0, CW_USEDEFAULT
, 0, NULL
, NULL
, hResource
, NULL
);
1583 CRegStdWORD
pos(_T("Software\\TortoiseGit\\TBlamePos"), 0);
1584 CRegStdWORD
width(_T("Software\\TortoiseGit\\TBlameSize"), 0);
1585 CRegStdWORD
state(_T("Software\\TortoiseGit\\TBlameState"), 0);
1586 if (DWORD(pos
) && DWORD(width
))
1589 rc
.left
= LOWORD(DWORD(pos
));
1590 rc
.top
= HIWORD(DWORD(pos
));
1591 rc
.right
= rc
.left
+ LOWORD(DWORD(width
));
1592 rc
.bottom
= rc
.top
+ HIWORD(DWORD(width
));
1593 HMONITOR hMon
= MonitorFromRect(&rc
, MONITOR_DEFAULTTONULL
);
1596 // only restore the window position if the monitor is valid
1597 MoveWindow(app
.wMain
, LOWORD(DWORD(pos
)), HIWORD(DWORD(pos
)),
1598 LOWORD(DWORD(width
)), HIWORD(DWORD(width
)), FALSE
);
1601 if (DWORD(state
) == SW_MAXIMIZE
)
1602 ShowWindow(app
.wMain
, SW_MAXIMIZE
);
1604 ShowWindow(app
.wMain
, nCmdShow
);
1605 UpdateWindow(app
.wMain
);
1607 //Create the tooltips
1609 INITCOMMONCONTROLSEX iccex
;
1610 app
.hwndTT
; // handle to the ToolTip control
1612 RECT rect
; // for client area coordinates
1613 iccex
.dwICC
= ICC_WIN95_CLASSES
;
1614 iccex
.dwSize
= sizeof(INITCOMMONCONTROLSEX
);
1615 InitCommonControlsEx(&iccex
);
1617 /* CREATE A TOOLTIP WINDOW */
1618 app
.hwndTT
= CreateWindowEx(WS_EX_TOPMOST
,
1621 WS_POPUP
| TTS_NOPREFIX
| TTS_ALWAYSTIP
,
1632 SetWindowPos(app
.hwndTT
,
1638 SWP_NOMOVE
| SWP_NOSIZE
| SWP_NOACTIVATE
);
1640 /* GET COORDINATES OF THE MAIN CLIENT AREA */
1641 GetClientRect (app
.wBlame
, &rect
);
1643 /* INITIALIZE MEMBERS OF THE TOOLINFO STRUCTURE */
1644 ti
.cbSize
= sizeof(TOOLINFO
);
1645 ti
.uFlags
= TTF_TRACK
| TTF_ABSOLUTE
;//TTF_SUBCLASS | TTF_PARSELINKS;
1646 ti
.hwnd
= app
.wBlame
;
1647 ti
.hinst
= app
.hResource
;
1649 ti
.lpszText
= LPSTR_TEXTCALLBACK
;
1650 // ToolTip control will cover the whole window
1651 ti
.rect
.left
= rect
.left
;
1652 ti
.rect
.top
= rect
.top
;
1653 ti
.rect
.right
= rect
.right
;
1654 ti
.rect
.bottom
= rect
.bottom
;
1656 /* SEND AN ADDTOOL MESSAGE TO THE TOOLTIP CONTROL WINDOW */
1657 SendMessage(app
.hwndTT
, TTM_ADDTOOL
, 0, (LPARAM
) (LPTOOLINFO
) &ti
);
1658 SendMessage(app
.hwndTT
, TTM_SETMAXTIPWIDTH
, 0, 600);
1659 //SendMessage(app.hwndTT, TTM_SETDELAYTIME, TTDT_AUTOPOP, MAKELONG(50000, 0));
1660 //SendMessage(app.hwndTT, TTM_SETDELAYTIME, TTDT_RESHOW, MAKELONG(1000, 0));
1662 uFindReplaceMsg
= RegisterWindowMessage(FINDMSGSTRING
);
1667 void CTortoiseGitBlameView::InitSize()
1672 ::GetClientRect(wMain
, &rc
);
1673 ::SetWindowPos(wHeader
, 0, rc
.left
, rc
.top
, rc
.right
-rc
.left
, HEADER_HEIGHT
, 0);
1674 rc
.top
+= HEADER_HEIGHT
;
1675 blamerc
.left
= rc
.left
;
1676 blamerc
.top
= rc
.top
;
1677 LONG w
= GetBlameWidth();
1678 blamerc
.right
= w
> abs(rc
.right
- rc
.left
) ? rc
.right
: w
+ rc
.left
;
1679 blamerc
.bottom
= rc
.bottom
;
1680 sourcerc
.left
= blamerc
.right
;
1681 sourcerc
.top
= rc
.top
;
1682 sourcerc
.bottom
= rc
.bottom
;
1683 sourcerc
.right
= rc
.right
;
1686 ::OffsetRect(&blamerc
, LOCATOR_WIDTH
, 0);
1687 ::OffsetRect(&sourcerc
, LOCATOR_WIDTH
, 0);
1688 sourcerc
.right
-= LOCATOR_WIDTH
;
1690 ::InvalidateRect(wMain
, NULL
, FALSE
);
1691 ::SetWindowPos(m_wEditor
, 0, sourcerc
.left
, sourcerc
.top
, sourcerc
.right
- sourcerc
.left
, sourcerc
.bottom
- sourcerc
.top
, 0);
1692 ::SetWindowPos(wBlame
, 0, blamerc
.left
, blamerc
.top
, blamerc
.right
- blamerc
.left
, blamerc
.bottom
- blamerc
.top
, 0);
1694 ::SetWindowPos(wLocator
, 0, 0, blamerc
.top
, LOCATOR_WIDTH
, blamerc
.bottom
- blamerc
.top
, SWP_SHOWWINDOW
);
1696 ::ShowWindow(wLocator
, SW_HIDE
);
1700 LRESULT CALLBACK
WndProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
1702 if (message
== uFindReplaceMsg
)
1704 LPFINDREPLACE lpfr
= (LPFINDREPLACE
)lParam
;
1706 // If the FR_DIALOGTERM flag is set,
1707 // invalidate the handle identifying the dialog box.
1708 if (lpfr
->Flags
& FR_DIALOGTERM
)
1710 app
.currentDialog
= NULL
;
1713 if (lpfr
->Flags
& FR_FINDNEXT
)
1715 app
.DoSearch(lpfr
->lpstrFindWhat
, lpfr
->Flags
);
1722 app
.m_wEditor
= ::CreateWindow(
1725 WS_CHILD
| WS_VSCROLL
| WS_HSCROLL
| WS_CLIPCHILDREN
,
1732 app
.InitialiseEditor();
1733 ::ShowWindow(app
.m_wEditor
, SW_SHOW
);
1734 ::SetFocus(app
.m_wEditor
);
1735 app
.wBlame
= ::CreateWindow(
1736 _T("TortoiseGitBlameViewBlame"),
1738 WS_CHILD
| WS_CLIPCHILDREN
,
1745 ::ShowWindow(app
.wBlame
, SW_SHOW
);
1746 app
.wHeader
= ::CreateWindow(
1747 _T("TortoiseGitBlameViewHeader"),
1749 WS_CHILD
| WS_CLIPCHILDREN
| WS_BORDER
,
1756 ::ShowWindow(app
.wHeader
, SW_SHOW
);
1757 app
.wLocator
= ::CreateWindow(
1758 _T("TortoiseGitBlameViewLocator"),
1760 WS_CHILD
| WS_CLIPCHILDREN
| WS_BORDER
,
1767 ::ShowWindow(app
.wLocator
, SW_SHOW
);
1778 app
.Command(LOWORD(wParam
));
1781 app
.Notify(reinterpret_cast<SCNotification
*>(lParam
));
1788 CRegStdWORD
pos(_T("Software\\TortoiseGit\\TBlamePos"), 0);
1789 CRegStdWORD
width(_T("Software\\TortoiseGit\\TBlameSize"), 0);
1790 CRegStdWORD
state(_T("Software\\TortoiseGit\\TBlameState"), 0);
1792 GetWindowRect(app
.wMain
, &rc
);
1793 if ((rc
.left
>= 0)&&(rc
.top
>= 0))
1795 pos
= MAKELONG(rc
.left
, rc
.top
);
1796 width
= MAKELONG(rc
.right
-rc
.left
, rc
.bottom
-rc
.top
);
1798 WINDOWPLACEMENT wp
= {0};
1799 wp
.length
= sizeof(WINDOWPLACEMENT
);
1800 GetWindowPlacement(app
.wMain
, &wp
);
1802 ::DestroyWindow(app
.m_wEditor
);
1803 ::PostQuitMessage(0);
1807 ::SetFocus(app
.wBlame
);
1810 return DefWindowProc(hWnd
, message
, wParam
, lParam
);
1815 LRESULT CALLBACK
WndBlameProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
1818 TRACKMOUSEEVENT mevt
;
1825 hDC
= BeginPaint(app
.wBlame
, &ps
);
1827 EndPaint(app
.wBlame
, &ps
);
1830 app
.Command(LOWORD(wParam
));
1833 switch (((LPNMHDR
)lParam
)->code
)
1835 case TTN_GETDISPINFO
:
1837 LPNMHDR pNMHDR
= (LPNMHDR
)lParam
;
1838 NMTTDISPINFOA
* pTTTA
= (NMTTDISPINFOA
*)pNMHDR
;
1839 NMTTDISPINFOW
* pTTTW
= (NMTTDISPINFOW
*)pNMHDR
;
1841 DWORD ptW
= GetMessagePos();
1842 point
.x
= GET_X_LPARAM(ptW
);
1843 point
.y
= GET_Y_LPARAM(ptW
);
1844 ::ScreenToClient(app
.wBlame
, &point
);
1845 LONG_PTR line
= app
.SendEditor(SCI_GETFIRSTVISIBLELINE
);
1846 LONG_PTR height
= app
.SendEditor(SCI_TEXTHEIGHT
);
1847 line
= line
+ (point
.y
/height
);
1848 if (line
>= (LONG
)app
.revs
.size())
1852 LONG rev
= app
.revs
[line
];
1853 if (line
>= (LONG
)app
.revs
.size())
1856 SecureZeroMemory(app
.m_szTip
, sizeof(app
.m_szTip
));
1857 SecureZeroMemory(app
.m_wszTip
, sizeof(app
.m_wszTip
));
1858 std::map
<LONG
, CString
>::iterator iter
;
1859 if ((iter
= app
.logmessages
.find(rev
)) != app
.logmessages
.end())
1864 msg
+= app
.authors
[line
];
1868 if (!ShowAuthor
) msg
+= " ";
1869 msg
+= app
.dates
[line
];
1871 if (!ShowAuthor
|| !ShowDate
)
1873 msg
+= iter
->second
;
1874 // an empty tooltip string will deactivate the tooltips,
1875 // which means we must make sure that the tooltip won't
1879 if (pNMHDR
->code
== TTN_NEEDTEXTA
)
1881 lstrcpyn(app
.m_szTip
, msg
.c_str(), MAX_LOG_LENGTH
*2);
1882 app
.StringExpand(app
.m_szTip
);
1883 pTTTA
->lpszText
= app
.m_szTip
;
1887 pTTTW
->lpszText
= app
.m_wszTip
;
1888 ::MultiByteToWideChar( CP_ACP
, 0, msg
.c_str(), min(msg
.size(), MAX_LOG_LENGTH
*2), app
.m_wszTip
, MAX_LOG_LENGTH
*2);
1889 app
.StringExpand(app
.m_wszTip
);
1901 app
.m_mouserev
= -2;
1902 app
.m_mouseauthor
.clear();
1903 app
.ttVisible
= FALSE
;
1904 SendMessage(app
.hwndTT
, TTM_TRACKACTIVATE
, FALSE
, 0);
1905 ::InvalidateRect(app
.wBlame
, NULL
, FALSE
);
1909 mevt
.cbSize
= sizeof(TRACKMOUSEEVENT
);
1910 mevt
.dwFlags
= TME_LEAVE
;
1911 mevt
.dwHoverTime
= HOVER_DEFAULT
;
1912 mevt
.hwndTrack
= app
.wBlame
;
1913 ::TrackMouseEvent(&mevt
);
1914 POINT pt
= {((int)(short)LOWORD(lParam
)), ((int)(short)HIWORD(lParam
))};
1915 ClientToScreen(app
.wBlame
, &pt
);
1918 SendMessage(app
.hwndTT
, TTM_TRACKPOSITION
, 0, MAKELONG(pt
.x
, pt
.y
));
1922 ti
.cbSize
= sizeof(TOOLINFO
);
1923 ti
.hwnd
= app
.wBlame
;
1925 SendMessage(app
.hwndTT
, TTM_TRACKACTIVATE
, TRUE
, (LPARAM
)&ti
);
1927 int y
= ((int)(short)HIWORD(lParam
));
1928 LONG_PTR line
= app
.SendEditor(SCI_GETFIRSTVISIBLELINE
);
1929 LONG_PTR height
= app
.SendEditor(SCI_TEXTHEIGHT
);
1930 line
= line
+ (y
/height
);
1931 app
.ttVisible
= (line
< (LONG
)app
.revs
.size());
1932 if ( app
.ttVisible
)
1934 if (app
.authors
[line
].compare(app
.m_mouseauthor
) != 0)
1936 app
.m_mouseauthor
= app
.authors
[line
];
1938 if (app
.revs
[line
] != app
.m_mouserev
)
1940 app
.m_mouserev
= app
.revs
[line
];
1941 ::InvalidateRect(app
.wBlame
, NULL
, FALSE
);
1942 SendMessage(app
.hwndTT
, TTM_UPDATE
, 0, 0);
1947 case WM_RBUTTONDOWN
:
1949 case WM_LBUTTONDOWN
:
1953 ::SetFocus(app
.wBlame
);
1954 app
.SendEditor(SCI_GRABFOCUS
);
1956 case WM_CONTEXTMENU
:
1958 if (app
.m_selectedrev
<= 0)
1960 int xPos
= GET_X_LPARAM(lParam
);
1961 int yPos
= GET_Y_LPARAM(lParam
);
1962 if ((xPos
< 0)||(yPos
< 0))
1964 // requested from keyboard, not mouse pointer
1965 // use the center of the window
1967 GetClientRect(app
.wBlame
, &rect
);
1968 xPos
= rect
.right
-rect
.left
;
1969 yPos
= rect
.bottom
-rect
.top
;
1971 HMENU hMenu
= LoadMenu(app
.hResource
, MAKEINTRESOURCE(IDR_BLAMEPOPUP
));
1972 HMENU hPopMenu
= GetSubMenu(hMenu
, 0);
1974 if ( _tcslen(szOrigPath
)==0 )
1976 // Without knowing the original path we cannot blame the previous revision
1977 // because we don't know which filename to pass to tortoiseproc.
1978 EnableMenuItem(hPopMenu
,ID_BLAME_PREVIOUS_REVISION
, MF_DISABLED
|MF_GRAYED
);
1981 TrackPopupMenu(hPopMenu
, TPM_LEFTALIGN
| TPM_RIGHTBUTTON
, xPos
, yPos
, 0, app
.wBlame
, NULL
);
1986 return DefWindowProc(hWnd
, message
, wParam
, lParam
);
1991 LRESULT CALLBACK
WndHeaderProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
2000 hDC
= BeginPaint(app
.wHeader
, &ps
);
2001 app
.DrawHeader(hDC
);
2002 EndPaint(app
.wHeader
, &ps
);
2011 return DefWindowProc(hWnd
, message
, wParam
, lParam
);
2016 LRESULT CALLBACK
WndLocatorProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
2023 hDC
= BeginPaint(app
.wLocator
, &ps
);
2024 app
.DrawLocatorBar(hDC
);
2025 EndPaint(app
.wLocator
, &ps
);
2027 case WM_LBUTTONDOWN
:
2029 if (wParam
& MK_LBUTTON
)
2032 ::GetClientRect(hWnd
, &rect
);
2033 int nLine
= HIWORD(lParam
)*app
.revs
.size()/(rect
.bottom
-rect
.top
);
2037 app
.ScrollToLine(nLine
);
2041 return DefWindowProc(hWnd
, message
, wParam
, lParam
);
2047 void CTortoiseGitBlameView::SetupLexer(CString filename
)
2051 //const char * lineptr = _tcsrchr(filename, '.');
2052 int start
=filename
.ReverseFind(_T('.'));
2055 //_tcscpy_s(line, 20, lineptr+1);
2056 //_tcslwr_s(line, 20);
2057 CString ext
=filename
.Right(filename
.GetLength()-start
-1);
2058 line
=ext
.GetBuffer();
2060 if ((_tcscmp(line
, _T("py"))==0)||
2061 (_tcscmp(line
, _T("pyw"))==0)||
2062 (_tcscmp(line
, _T("pyw"))==0))
2064 SendEditor(SCI_SETLEXER
, SCLEX_PYTHON
);
2065 SendEditor(SCI_SETKEYWORDS
, 0, (LPARAM
)(m_TextView
.StringForControl(_T("and assert break class continue def del elif \
2066 else except exec finally for from global if import in is lambda None \
2067 not or pass print raise return try while yield")).GetBuffer()));
2068 SetAStyle(SCE_P_DEFAULT
, black
);
2069 SetAStyle(SCE_P_COMMENTLINE
, darkGreen
);
2070 SetAStyle(SCE_P_NUMBER
, RGB(0, 0x80, 0x80));
2071 SetAStyle(SCE_P_STRING
, RGB(0, 0, 0x80));
2072 SetAStyle(SCE_P_CHARACTER
, RGB(0, 0, 0x80));
2073 SetAStyle(SCE_P_WORD
, RGB(0x80, 0, 0x80));
2074 SetAStyle(SCE_P_TRIPLE
, black
);
2075 SetAStyle(SCE_P_TRIPLEDOUBLE
, black
);
2076 SetAStyle(SCE_P_CLASSNAME
, darkBlue
);
2077 SetAStyle(SCE_P_DEFNAME
, darkBlue
);
2078 SetAStyle(SCE_P_OPERATOR
, darkBlue
);
2079 SetAStyle(SCE_P_IDENTIFIER
, darkBlue
);
2080 SetAStyle(SCE_P_COMMENTBLOCK
, darkGreen
);
2081 SetAStyle(SCE_P_STRINGEOL
, red
);
2083 if ((_tcscmp(line
, _T("c"))==0)||
2084 (_tcscmp(line
, _T("cc"))==0)||
2085 (_tcscmp(line
, _T("cpp"))==0)||
2086 (_tcscmp(line
, _T("cxx"))==0)||
2087 (_tcscmp(line
, _T("h"))==0)||
2088 (_tcscmp(line
, _T("hh"))==0)||
2089 (_tcscmp(line
, _T("hpp"))==0)||
2090 (_tcscmp(line
, _T("hxx"))==0)||
2091 (_tcscmp(line
, _T("dlg"))==0)||
2092 (_tcscmp(line
, _T("mak"))==0))
2094 SendEditor(SCI_SETLEXER
, SCLEX_CPP
);
2095 SendEditor(SCI_SETKEYWORDS
, 0, (LPARAM
)(m_TextView
.StringForControl(_T("and and_eq asm auto bitand bitor bool break \
2096 case catch char class compl const const_cast continue \
2097 default delete do double dynamic_cast else enum explicit export extern false float for \
2098 friend goto if inline int long mutable namespace new not not_eq \
2099 operator or or_eq private protected public \
2100 register reinterpret_cast return short signed sizeof static static_cast struct switch \
2101 template this throw true try typedef typeid typename union unsigned using \
2102 virtual void volatile wchar_t while xor xor_eq")).GetBuffer()));
2103 SendEditor(SCI_SETKEYWORDS
, 3, (LPARAM
)(m_TextView
.StringForControl(_T("a addindex addtogroup anchor arg attention \
2104 author b brief bug c class code date def defgroup deprecated dontinclude \
2105 e em endcode endhtmlonly endif endlatexonly endlink endverbatim enum example exception \
2106 f$ f[ f] file fn hideinitializer htmlinclude htmlonly \
2107 if image include ingroup internal invariant interface latexonly li line link \
2108 mainpage name namespace nosubgrouping note overload \
2109 p page par param post pre ref relates remarks return retval \
2110 sa section see showinitializer since skip skipline struct subsection \
2111 test throw todo typedef union until \
2112 var verbatim verbinclude version warning weakgroup $ @ \\ & < > # { }")).GetBuffer()));
2115 if (_tcscmp(line
, _T("cs"))==0)
2117 SendEditor(SCI_SETLEXER
, SCLEX_CPP
);
2118 SendEditor(SCI_SETKEYWORDS
, 0, (LPARAM
)(m_TextView
.StringForControl(_T("abstract as base bool break byte case catch char checked class \
2119 const continue decimal default delegate do double else enum \
2120 event explicit extern false finally fixed float for foreach goto if \
2121 implicit in int interface internal is lock long namespace new null \
2122 object operator out override params private protected public \
2123 readonly ref return sbyte sealed short sizeof stackalloc static \
2124 string struct switch this throw true try typeof uint ulong \
2125 unchecked unsafe ushort using virtual void while")).GetBuffer()));
2128 if ((_tcscmp(line
, _T("rc"))==0)||
2129 (_tcscmp(line
, _T("rc2"))==0))
2131 SendEditor(SCI_SETLEXER
, SCLEX_CPP
);
2132 SendEditor(SCI_SETKEYWORDS
, 0, (LPARAM
)(m_TextView
.StringForControl(_T("ACCELERATORS ALT AUTO3STATE AUTOCHECKBOX AUTORADIOBUTTON \
2133 BEGIN BITMAP BLOCK BUTTON CAPTION CHARACTERISTICS CHECKBOX CLASS \
2134 COMBOBOX CONTROL CTEXT CURSOR DEFPUSHBUTTON DIALOG DIALOGEX DISCARDABLE \
2135 EDITTEXT END EXSTYLE FONT GROUPBOX ICON LANGUAGE LISTBOX LTEXT \
2136 MENU MENUEX MENUITEM MESSAGETABLE POPUP \
2137 PUSHBUTTON RADIOBUTTON RCDATA RTEXT SCROLLBAR SEPARATOR SHIFT STATE3 \
2138 STRINGTABLE STYLE TEXTINCLUDE VALUE VERSION VERSIONINFO VIRTKEY")).GetBuffer()));
2141 if ((_tcscmp(line
, _T("idl"))==0)||
2142 (_tcscmp(line
, _T("odl"))==0))
2144 SendEditor(SCI_SETLEXER
, SCLEX_CPP
);
2145 SendEditor(SCI_SETKEYWORDS
, 0, (LPARAM
)(m_TextView
.StringForControl(_T("aggregatable allocate appobject arrays async async_uuid \
2147 bindable boolean broadcast byte byte_count \
2148 call_as callback char coclass code comm_status \
2149 const context_handle context_handle_noserialize \
2150 context_handle_serialize control cpp_quote custom \
2151 decode default defaultbind defaultcollelem \
2152 defaultvalue defaultvtable dispinterface displaybind dllname \
2154 enable_allocate encode endpoint entry enum error_status_t \
2156 fault_status first_is float \
2157 handle_t heap helpcontext helpfile helpstring \
2158 helpstringcontext helpstringdll hidden hyper \
2159 id idempotent ignore iid_as iid_is immediatebind implicit_handle \
2160 import importlib in include in_line int __int64 __int3264 interface \
2161 last_is lcid length_is library licensed local long \
2162 max_is maybe message methods midl_pragma \
2163 midl_user_allocate midl_user_free min_is module ms_union \
2164 ncacn_at_dsp ncacn_dnet_nsp ncacn_http ncacn_ip_tcp \
2165 ncacn_nb_ipx ncacn_nb_nb ncacn_nb_tcp ncacn_np \
2166 ncacn_spx ncacn_vns_spp ncadg_ip_udp ncadg_ipx ncadg_mq \
2167 ncalrpc nocode nonbrowsable noncreatable nonextensible notify \
2168 object odl oleautomation optimize optional out out_of_line \
2169 pipe pointer_default pragma properties propget propput propputref \
2171 range readonly ref represent_as requestedit restricted retval \
2172 shape short signed size_is small source strict_context_handle \
2173 string struct switch switch_is switch_type \
2174 transmit_as typedef \
2175 uidefault union unique unsigned user_marshal usesgetlasterror uuid \
2176 v1_enum vararg version void wchar_t wire_marshal")).GetBuffer()));
2179 if (_tcscmp(line
, _T("java"))==0)
2181 SendEditor(SCI_SETLEXER
, SCLEX_CPP
);
2182 SendEditor(SCI_SETKEYWORDS
, 0, (LPARAM
)(m_TextView
.StringForControl(_T("abstract assert boolean break byte case catch char class \
2183 const continue default do double else extends final finally float for future \
2184 generic goto if implements import inner instanceof int interface long \
2185 native new null outer package private protected public rest \
2186 return short static super switch synchronized this throw throws \
2187 transient try var void volatile while")).GetBuffer()));
2190 if (_tcscmp(line
, _T("js"))==0)
2192 SendEditor(SCI_SETLEXER
, SCLEX_CPP
);
2193 SendEditor(SCI_SETKEYWORDS
, 0, (LPARAM
)(m_TextView
.StringForControl(_T("abstract boolean break byte case catch char class \
2194 const continue debugger default delete do double else enum export extends \
2195 final finally float for function goto if implements import in instanceof \
2196 int interface long native new package private protected public \
2197 return short static super switch synchronized this throw throws \
2198 transient try typeof var void volatile while with")).GetBuffer()));
2201 if ((_tcscmp(line
, _T("pas"))==0)||
2202 (_tcscmp(line
, _T("dpr"))==0)||
2203 (_tcscmp(line
, _T("pp"))==0))
2205 SendEditor(SCI_SETLEXER
, SCLEX_PASCAL
);
2206 SendEditor(SCI_SETKEYWORDS
, 0, (LPARAM
)(m_TextView
.StringForControl(_T("and array as begin case class const constructor \
2207 destructor div do downto else end except file finally \
2208 for function goto if implementation in inherited \
2209 interface is mod not object of on or packed \
2210 procedure program property raise record repeat \
2211 set shl shr then threadvar to try type unit \
2212 until uses var while with xor")).GetBuffer()));
2215 if ((_tcscmp(line
, _T("as"))==0)||
2216 (_tcscmp(line
, _T("asc"))==0)||
2217 (_tcscmp(line
, _T("jsfl"))==0))
2219 SendEditor(SCI_SETLEXER
, SCLEX_CPP
);
2220 SendEditor(SCI_SETKEYWORDS
, 0, (LPARAM
)(m_TextView
.StringForControl(_T("add and break case catch class continue default delete do \
2221 dynamic else eq extends false finally for function ge get gt if implements import in \
2222 instanceof interface intrinsic le lt ne new not null or private public return \
2223 set static super switch this throw true try typeof undefined var void while with")).GetBuffer()));
2224 SendEditor(SCI_SETKEYWORDS
, 1, (LPARAM
)(m_TextView
.StringForControl(_T("Array Arguments Accessibility Boolean Button Camera Color \
2225 ContextMenu ContextMenuItem Date Error Function Key LoadVars LocalConnection Math \
2226 Microphone Mouse MovieClip MovieClipLoader NetConnection NetStream Number Object \
2227 PrintJob Selection SharedObject Sound Stage String StyleSheet System TextField \
2228 TextFormat TextSnapshot Video Void XML XMLNode XMLSocket \
2229 _accProps _focusrect _global _highquality _parent _quality _root _soundbuftime \
2230 arguments asfunction call capabilities chr clearInterval duplicateMovieClip \
2231 escape eval fscommand getProperty getTimer getURL getVersion gotoAndPlay gotoAndStop \
2232 ifFrameLoaded Infinity -Infinity int isFinite isNaN length loadMovie loadMovieNum \
2233 loadVariables loadVariablesNum maxscroll mbchr mblength mbord mbsubstring MMExecute \
2234 NaN newline nextFrame nextScene on onClipEvent onUpdate ord parseFloat parseInt play \
2235 prevFrame prevScene print printAsBitmap printAsBitmapNum printNum random removeMovieClip \
2236 scroll set setInterval setProperty startDrag stop stopAllSounds stopDrag substring \
2237 targetPath tellTarget toggleHighQuality trace unescape unloadMovie unLoadMovieNum updateAfterEvent")).GetBuffer()));
2240 if ((_tcscmp(line
, _T("html"))==0)||
2241 (_tcscmp(line
, _T("htm"))==0)||
2242 (_tcscmp(line
, _T("shtml"))==0)||
2243 (_tcscmp(line
, _T("htt"))==0)||
2244 (_tcscmp(line
, _T("xml"))==0)||
2245 (_tcscmp(line
, _T("asp"))==0)||
2246 (_tcscmp(line
, _T("xsl"))==0)||
2247 (_tcscmp(line
, _T("php"))==0)||
2248 (_tcscmp(line
, _T("xhtml"))==0)||
2249 (_tcscmp(line
, _T("phtml"))==0)||
2250 (_tcscmp(line
, _T("cfm"))==0)||
2251 (_tcscmp(line
, _T("tpl"))==0)||
2252 (_tcscmp(line
, _T("dtd"))==0)||
2253 (_tcscmp(line
, _T("hta"))==0)||
2254 (_tcscmp(line
, _T("htd"))==0)||
2255 (_tcscmp(line
, _T("wxs"))==0))
2257 SendEditor(SCI_SETLEXER
, SCLEX_HTML
);
2258 SendEditor(SCI_SETSTYLEBITS
, 7);
2259 SendEditor(SCI_SETKEYWORDS
, 0, (LPARAM
)(m_TextView
.StringForControl(_T("a abbr acronym address applet area b base basefont \
2260 bdo big blockquote body br button caption center \
2261 cite code col colgroup dd del dfn dir div dl dt em \
2262 fieldset font form frame frameset h1 h2 h3 h4 h5 h6 \
2263 head hr html i iframe img input ins isindex kbd label \
2264 legend li link map menu meta noframes noscript \
2265 object ol optgroup option p param pre q s samp \
2266 script select small span strike strong style sub sup \
2267 table tbody td textarea tfoot th thead title tr tt u ul \
2268 var xml xmlns abbr accept-charset accept accesskey action align alink \
2269 alt archive axis background bgcolor border \
2270 cellpadding cellspacing char charoff charset checked cite \
2271 class classid clear codebase codetype color cols colspan \
2272 compact content coords \
2273 data datafld dataformatas datapagesize datasrc datetime \
2274 declare defer dir disabled enctype event \
2275 face for frame frameborder \
2276 headers height href hreflang hspace http-equiv \
2277 id ismap label lang language leftmargin link longdesc \
2278 marginwidth marginheight maxlength media method multiple \
2279 name nohref noresize noshade nowrap \
2280 object onblur onchange onclick ondblclick onfocus \
2281 onkeydown onkeypress onkeyup onload onmousedown \
2282 onmousemove onmouseover onmouseout onmouseup \
2283 onreset onselect onsubmit onunload \
2284 profile prompt readonly rel rev rows rowspan rules \
2285 scheme scope selected shape size span src standby start style \
2286 summary tabindex target text title topmargin type usemap \
2287 valign value valuetype version vlink vspace width \
2288 text password checkbox radio submit reset \
2289 file hidden image")).GetBuffer()));
2290 SendEditor(SCI_SETKEYWORDS
, 1, (LPARAM
)(m_TextView
.StringForControl(_T("assign audio block break catch choice clear disconnect else elseif \
2291 emphasis enumerate error exit field filled form goto grammar help \
2292 if initial link log menu meta noinput nomatch object option p paragraph \
2293 param phoneme prompt property prosody record reprompt return s say-as \
2294 script sentence subdialog submit throw transfer value var voice vxml")).GetBuffer()));
2295 SendEditor(SCI_SETKEYWORDS
, 2, (LPARAM
)(m_TextView
.StringForControl(_T("accept age alphabet anchor application base beep bridge category charset \
2296 classid cond connecttimeout content contour count dest destexpr dtmf dtmfterm \
2297 duration enctype event eventexpr expr expritem fetchtimeout finalsilence \
2298 gender http-equiv id level maxage maxstale maxtime message messageexpr \
2299 method mime modal mode name namelist next nextitem ph pitch range rate \
2300 scope size sizeexpr skiplist slot src srcexpr sub time timeexpr timeout \
2301 transferaudio type value variant version volume xml:lang")).GetBuffer()));
2302 SendEditor(SCI_SETKEYWORDS
, 3, (LPARAM
)(m_TextView
.StringForControl(_T("and assert break class continue def del elif \
2303 else except exec finally for from global if import in is lambda None \
2304 not or pass print raise return try while yield")).GetBuffer()));
2305 SendEditor(SCI_SETKEYWORDS
, 4, (LPARAM
)(m_TextView
.StringForControl(_T("and argv as argc break case cfunction class continue declare default do \
2306 die echo else elseif empty enddeclare endfor endforeach endif endswitch \
2307 endwhile e_all e_parse e_error e_warning eval exit extends false for \
2308 foreach function global http_cookie_vars http_get_vars http_post_vars \
2309 http_post_files http_env_vars http_server_vars if include include_once \
2310 list new not null old_function or parent php_os php_self php_version \
2311 print require require_once return static switch stdclass this true var \
2312 xor virtual while __file__ __line__ __sleep __wakeup")).GetBuffer()));
2314 SetAStyle(SCE_H_TAG
, darkBlue
);
2315 SetAStyle(SCE_H_TAGUNKNOWN
, red
);
2316 SetAStyle(SCE_H_ATTRIBUTE
, darkBlue
);
2317 SetAStyle(SCE_H_ATTRIBUTEUNKNOWN
, red
);
2318 SetAStyle(SCE_H_NUMBER
, RGB(0x80,0,0x80));
2319 SetAStyle(SCE_H_DOUBLESTRING
, RGB(0,0x80,0));
2320 SetAStyle(SCE_H_SINGLESTRING
, RGB(0,0x80,0));
2321 SetAStyle(SCE_H_OTHER
, RGB(0x80,0,0x80));
2322 SetAStyle(SCE_H_COMMENT
, RGB(0x80,0x80,0));
2323 SetAStyle(SCE_H_ENTITY
, RGB(0x80,0,0x80));
2325 SetAStyle(SCE_H_TAGEND
, darkBlue
);
2326 SetAStyle(SCE_H_XMLSTART
, darkBlue
); // <?
2327 SetAStyle(SCE_H_QUESTION
, darkBlue
); // <?
2328 SetAStyle(SCE_H_XMLEND
, darkBlue
); // ?>
2329 SetAStyle(SCE_H_SCRIPT
, darkBlue
); // <script
2330 SetAStyle(SCE_H_ASP
, RGB(0x4F, 0x4F, 0), RGB(0xFF, 0xFF, 0)); // <% ... %>
2331 SetAStyle(SCE_H_ASPAT
, RGB(0x4F, 0x4F, 0), RGB(0xFF, 0xFF, 0)); // <%@ ... %>
2333 SetAStyle(SCE_HB_DEFAULT
, black
);
2334 SetAStyle(SCE_HB_COMMENTLINE
, darkGreen
);
2335 SetAStyle(SCE_HB_NUMBER
, RGB(0,0x80,0x80));
2336 SetAStyle(SCE_HB_WORD
, darkBlue
);
2337 SendEditor(SCI_STYLESETBOLD
, SCE_HB_WORD
, 1);
2338 SetAStyle(SCE_HB_STRING
, RGB(0x80,0,0x80));
2339 SetAStyle(SCE_HB_IDENTIFIER
, black
);
2341 // This light blue is found in the windows system palette so is safe to use even in 256 colour modes.
2342 // Show the whole section of VBScript with light blue background
2343 for (int bstyle
=SCE_HB_DEFAULT
; bstyle
<=SCE_HB_STRINGEOL
; bstyle
++) {
2344 SendEditor(SCI_STYLESETFONT
, bstyle
,
2345 reinterpret_cast<LPARAM
>(m_TextView
.StringForControl(_T("Lucida Console")).GetBuffer()));
2346 SendEditor(SCI_STYLESETBACK
, bstyle
, lightBlue
);
2347 // This call extends the backround colour of the last style on the line to the edge of the window
2348 SendEditor(SCI_STYLESETEOLFILLED
, bstyle
, 1);
2350 SendEditor(SCI_STYLESETBACK
, SCE_HB_STRINGEOL
, RGB(0x7F,0x7F,0xFF));
2351 SendEditor(SCI_STYLESETFONT
, SCE_HB_COMMENTLINE
,
2352 reinterpret_cast<LPARAM
>(m_TextView
.StringForControl(_T("Lucida Console")).GetBuffer()));
2354 SetAStyle(SCE_HBA_DEFAULT
, black
);
2355 SetAStyle(SCE_HBA_COMMENTLINE
, darkGreen
);
2356 SetAStyle(SCE_HBA_NUMBER
, RGB(0,0x80,0x80));
2357 SetAStyle(SCE_HBA_WORD
, darkBlue
);
2358 SendEditor(SCI_STYLESETBOLD
, SCE_HBA_WORD
, 1);
2359 SetAStyle(SCE_HBA_STRING
, RGB(0x80,0,0x80));
2360 SetAStyle(SCE_HBA_IDENTIFIER
, black
);
2362 // Show the whole section of ASP VBScript with bright yellow background
2363 for (int bastyle
=SCE_HBA_DEFAULT
; bastyle
<=SCE_HBA_STRINGEOL
; bastyle
++) {
2364 SendEditor(SCI_STYLESETFONT
, bastyle
,
2365 reinterpret_cast<LPARAM
>(m_TextView
.StringForControl(_T("Lucida Console")).GetBuffer()));
2366 SendEditor(SCI_STYLESETBACK
, bastyle
, RGB(0xFF, 0xFF, 0));
2367 // This call extends the backround colour of the last style on the line to the edge of the window
2368 SendEditor(SCI_STYLESETEOLFILLED
, bastyle
, 1);
2370 SendEditor(SCI_STYLESETBACK
, SCE_HBA_STRINGEOL
, RGB(0xCF,0xCF,0x7F));
2371 SendEditor(SCI_STYLESETFONT
, SCE_HBA_COMMENTLINE
,
2372 reinterpret_cast<LPARAM
>(m_TextView
.StringForControl(_T("Lucida Console")).GetBuffer()));
2374 // If there is no need to support embedded Javascript, the following code can be dropped.
2375 // Javascript will still be correctly processed but will be displayed in just the default style.
2377 SetAStyle(SCE_HJ_START
, RGB(0x80,0x80,0));
2378 SetAStyle(SCE_HJ_DEFAULT
, black
);
2379 SetAStyle(SCE_HJ_COMMENT
, darkGreen
);
2380 SetAStyle(SCE_HJ_COMMENTLINE
, darkGreen
);
2381 SetAStyle(SCE_HJ_COMMENTDOC
, darkGreen
);
2382 SetAStyle(SCE_HJ_NUMBER
, RGB(0,0x80,0x80));
2383 SetAStyle(SCE_HJ_WORD
, black
);
2384 SetAStyle(SCE_HJ_KEYWORD
, darkBlue
);
2385 SetAStyle(SCE_HJ_DOUBLESTRING
, RGB(0x80,0,0x80));
2386 SetAStyle(SCE_HJ_SINGLESTRING
, RGB(0x80,0,0x80));
2387 SetAStyle(SCE_HJ_SYMBOLS
, black
);
2389 SetAStyle(SCE_HJA_START
, RGB(0x80,0x80,0));
2390 SetAStyle(SCE_HJA_DEFAULT
, black
);
2391 SetAStyle(SCE_HJA_COMMENT
, darkGreen
);
2392 SetAStyle(SCE_HJA_COMMENTLINE
, darkGreen
);
2393 SetAStyle(SCE_HJA_COMMENTDOC
, darkGreen
);
2394 SetAStyle(SCE_HJA_NUMBER
, RGB(0,0x80,0x80));
2395 SetAStyle(SCE_HJA_WORD
, black
);
2396 SetAStyle(SCE_HJA_KEYWORD
, darkBlue
);
2397 SetAStyle(SCE_HJA_DOUBLESTRING
, RGB(0x80,0,0x80));
2398 SetAStyle(SCE_HJA_SINGLESTRING
, RGB(0x80,0,0x80));
2399 SetAStyle(SCE_HJA_SYMBOLS
, black
);
2401 SetAStyle(SCE_HPHP_DEFAULT
, black
);
2402 SetAStyle(SCE_HPHP_HSTRING
, RGB(0x80,0,0x80));
2403 SetAStyle(SCE_HPHP_SIMPLESTRING
, RGB(0x80,0,0x80));
2404 SetAStyle(SCE_HPHP_WORD
, darkBlue
);
2405 SetAStyle(SCE_HPHP_NUMBER
, RGB(0,0x80,0x80));
2406 SetAStyle(SCE_HPHP_VARIABLE
, red
);
2407 SetAStyle(SCE_HPHP_HSTRING_VARIABLE
, red
);
2408 SetAStyle(SCE_HPHP_COMPLEX_VARIABLE
, red
);
2409 SetAStyle(SCE_HPHP_COMMENT
, darkGreen
);
2410 SetAStyle(SCE_HPHP_COMMENTLINE
, darkGreen
);
2411 SetAStyle(SCE_HPHP_OPERATOR
, darkBlue
);
2413 // Show the whole section of Javascript with off white background
2414 for (int jstyle
=SCE_HJ_DEFAULT
; jstyle
<=SCE_HJ_SYMBOLS
; jstyle
++) {
2415 SendEditor(SCI_STYLESETFONT
, jstyle
,
2416 reinterpret_cast<LPARAM
>(m_TextView
.StringForControl(_T("Lucida Console")).GetBuffer()));
2417 SendEditor(SCI_STYLESETBACK
, jstyle
, offWhite
);
2418 SendEditor(SCI_STYLESETEOLFILLED
, jstyle
, 1);
2420 SendEditor(SCI_STYLESETBACK
, SCE_HJ_STRINGEOL
, RGB(0xDF, 0xDF, 0x7F));
2421 SendEditor(SCI_STYLESETEOLFILLED
, SCE_HJ_STRINGEOL
, 1);
2423 // Show the whole section of Javascript with brown background
2424 for (int jastyle
=SCE_HJA_DEFAULT
; jastyle
<=SCE_HJA_SYMBOLS
; jastyle
++) {
2425 SendEditor(SCI_STYLESETFONT
, jastyle
,
2426 reinterpret_cast<LPARAM
>(m_TextView
.StringForControl(_T("Lucida Console")).GetBuffer()));
2427 SendEditor(SCI_STYLESETBACK
, jastyle
, RGB(0xDF, 0xDF, 0x7F));
2428 SendEditor(SCI_STYLESETEOLFILLED
, jastyle
, 1);
2430 SendEditor(SCI_STYLESETBACK
, SCE_HJA_STRINGEOL
, RGB(0x0,0xAF,0x5F));
2431 SendEditor(SCI_STYLESETEOLFILLED
, SCE_HJA_STRINGEOL
, 1);
2436 SendEditor(SCI_SETLEXER
, SCLEX_CPP
);
2439 SendEditor(SCI_COLOURISE
, 0, -1);
2443 void CTortoiseGitBlameView::SetupCppLexer()
2445 SetAStyle(SCE_C_DEFAULT
, RGB(0, 0, 0));
2446 SetAStyle(SCE_C_COMMENT
, RGB(0, 0x80, 0));
2447 SetAStyle(SCE_C_COMMENTLINE
, RGB(0, 0x80, 0));
2448 SetAStyle(SCE_C_COMMENTDOC
, RGB(0, 0x80, 0));
2449 SetAStyle(SCE_C_COMMENTLINEDOC
, RGB(0, 0x80, 0));
2450 SetAStyle(SCE_C_COMMENTDOCKEYWORD
, RGB(0, 0x80, 0));
2451 SetAStyle(SCE_C_COMMENTDOCKEYWORDERROR
, RGB(0, 0x80, 0));
2452 SetAStyle(SCE_C_NUMBER
, RGB(0, 0x80, 0x80));
2453 SetAStyle(SCE_C_WORD
, RGB(0, 0, 0x80));
2454 SendEditor(SCE_C_WORD
, 1);
2455 SetAStyle(SCE_C_STRING
, RGB(0x80, 0, 0x80));
2456 SetAStyle(SCE_C_IDENTIFIER
, RGB(0, 0, 0));
2457 SetAStyle(SCE_C_PREPROCESSOR
, RGB(0x80, 0, 0));
2458 SetAStyle(SCE_C_OPERATOR
, RGB(0x80, 0x80, 0));
2462 void CTortoiseGitBlameView::UpdateInfo()
2464 CString
&data
= GetDocument()->m_BlameData
;
2468 CLogDataVector
* pRevs
= GetLogData();
2470 this->m_CommitHash
.clear();
2471 this->m_Authors
.clear();
2477 SendEditor(SCI_SETREADONLY
, FALSE
);
2478 SendEditor(SCI_CLEARALL
);
2479 SendEditor(EM_EMPTYUNDOBUFFER
);
2480 SendEditor(SCI_SETSAVEPOINT
);
2481 SendEditor(SCI_CANCEL
);
2482 SendEditor(SCI_SETUNDOCOLLECTION
, 0);
2486 one
=data
.Tokenize(_T("\n"),pos
);
2489 m_CommitHash
.push_back(one
.Left(40));
2491 start
=one
.Find(_T(')'),40);
2494 line
=one
.Right(one
.GetLength()-start
-2);
2495 this->m_TextView
.InsertText(line
,true);
2497 int id
=pRevs
->m_HashMap
[one
.Left(40)];
2498 if(id
>=0 && id
<GetLogData()->size())
2500 m_ID
.push_back(pRevs
->size()-id
);
2501 m_Authors
.push_back(pRevs
->at(id
).m_AuthorName
);
2508 SetupLexer(GetDocument()->m_CurrentFileName
);
2510 SendEditor(SCI_SETUNDOCOLLECTION
, 1);
2511 SendEditor(EM_EMPTYUNDOBUFFER
);
2512 SendEditor(SCI_SETSAVEPOINT
);
2513 SendEditor(SCI_GOTOPOS
, 0);
2514 SendEditor(SCI_SETSCROLLWIDTHTRACKING
, TRUE
);
2515 SendEditor(SCI_SETREADONLY
, TRUE
);
2518 m_highestrev
=this->GetLogData()->size();
2522 this->GetClientRect(rect
);
2523 //this->m_TextView.GetWindowRect(rect);
2524 //this->m_TextView.ScreenToClient(rect);
2525 rect
.left
=this->m_blamewidth
;
2526 this->m_TextView
.MoveWindow(rect
);
2531 CGitBlameLogList
* CTortoiseGitBlameView::GetLogList()
2533 return &(GetDocument()->GetMainFrame()->m_wndOutput
.m_LogList
);
2537 CLogDataVector
* CTortoiseGitBlameView::GetLogData()
2539 return &(GetDocument()->GetMainFrame()->m_wndOutput
.m_LogList
.m_logEntries
);
2542 void CTortoiseGitBlameView::OnSciPainted(NMHDR
*,LRESULT
*)
2547 void CTortoiseGitBlameView::OnLButtonDown(UINT nFlags
,CPoint point
)
2550 LONG_PTR line
= SendEditor(SCI_GETFIRSTVISIBLELINE
);
2551 LONG_PTR height
= SendEditor(SCI_TEXTHEIGHT
);
2552 line
= line
+ (point
.y
/height
);
2554 if (line
< (LONG
)m_CommitHash
.size())
2556 SetSelectedLine(line
);
2557 if (m_CommitHash
[line
] != m_SelectedHash
)
2559 m_SelectedHash
= m_CommitHash
[line
];
2560 // app.m_selectedorigrev = app.origrevs[line];
2561 // app.m_selectedauthor = app.authors[line];
2562 // app.m_selecteddate = app.dates[line];
2565 this->GetLogList()->SetItemState(this->GetLogList()->GetItemCount()-m_ID
[line
],
2570 pRev
=&this->GetLogData()->at(this->GetLogList()->GetItemCount()-m_ID
[line
]);
2571 this->GetDocument()->GetMainFrame()->m_wndProperties
.UpdateProperties(pRev
);
2575 m_SelectedHash
.Empty();
2576 // app.m_selecteddate.clear();
2577 // app.m_selectedrev = -2;
2578 // app.m_selectedorigrev = -2;
2580 //::InvalidateRect( NULL, FALSE);
2582 this->m_TextView
.Invalidate();
2587 SetSelectedLine(-1);
2590 CView::OnLButtonDown(nFlags
,point
);
2593 void CTortoiseGitBlameView::OnSciGetBkColor(NMHDR
* hdr
, LRESULT
* result
)
2596 SCNotification
*notification
=reinterpret_cast<SCNotification
*>(hdr
);
2598 if ((m_colorage
)&&(notification
->line
< (int)m_CommitHash
.size()))
2600 if(m_CommitHash
[notification
->line
] == this->m_SelectedHash
)
2601 notification
->lParam
= m_selectedauthorcolor
;
2603 notification
->lParam
= InterColor(DWORD(m_regOldLinesColor
), DWORD(m_regNewLinesColor
), (m_ID
[notification
->line
]-m_lowestrev
)*100/((m_highestrev
-m_lowestrev
)+1));
2608 void CTortoiseGitBlameView::FocusOn(GitRev
*pRev
)
2610 m_SelectedHash
= pRev
->m_CommitHash
;
2613 //pRev=&this->GetLogData()->at(this->GetLogList()->GetItemCount()-m_ID[line]);
2614 this->GetDocument()->GetMainFrame()->m_wndProperties
.UpdateProperties(pRev
);
2617 this->m_TextView
.Invalidate();
2621 void CTortoiseGitBlameView::OnMouseHover(UINT nFlags
, CPoint point
)
2624 LONG_PTR line
= SendEditor(SCI_GETFIRSTVISIBLELINE
);
2625 LONG_PTR height
= SendEditor(SCI_TEXTHEIGHT
);
2626 line
= line
+ (point
.y
/height
);
2628 if (line
< (LONG
)m_CommitHash
.size())
2630 if (line
!= m_MouseLine
)
2632 m_MouseLine
= line
;//m_CommitHash[line];
2633 // app.m_selectedorigrev = app.origrevs[line];
2634 // app.m_selectedauthor = app.authors[line];
2635 // app.m_selecteddate = app.dates[line];
2639 pRev
=&this->GetLogData()->at(this->GetLogList()->GetItemCount()-m_ID
[line
]);
2640 //this->GetDocument()->GetMainFrame()->m_wndProperties.UpdateProperties(pRev);
2641 this->ClientToScreen(&point
);
2643 //if(m_ToolTip.GetTool(this, bi))
2645 // bi.sBalloonTip=pRev->m_CommitHash;
2647 str
.Format(_T("%s\n<b>%s</b>\n%s\n%s"),pRev
->m_CommitHash
,
2649 pRev
->m_AuthorDate
.Format(_T("%Y-%m-%d %H:%M")),
2651 m_ToolTip
.AddTool(this,str
);
2652 m_ToolTip
.DisplayToolTip(&point
);
2656 this->ScreenToClient(&point
);
2657 rect
.left
=LOCATOR_WIDTH
;
2658 rect
.right
=this->m_blamewidth
+rect
.left
;
2659 rect
.top
=point
.y
-height
;
2660 rect
.bottom
=point
.y
+height
;
2661 this->InvalidateRect(rect
);
2667 // app.m_selecteddate.clear();
2668 // app.m_selectedrev = -2;
2669 // app.m_selectedorigrev = -2;
2671 //::InvalidateRect( NULL, FALSE);
2672 //this->Invalidate();
2675 // const CString str=_T("this is a <b>Message Balloon</b>\n<hr=100%>\n<ct=0x0000FF>Warning! Warning!</ct>\nSomething unexpected happened");
2676 //CBalloon::ShowBalloon(NULL, point,
2678 // FALSE, (HICON)IDI_EXCLAMATION,
2679 // (UINT)CBalloon ::BALLOON_RIGHT_TOP, (UINT)CBalloon ::BALLOON_EFFECT_SOLID,(COLORREF)NULL, (COLORREF)NULL, (COLORREF)NULL);
2682 void CTortoiseGitBlameView::OnMouseMove(UINT nFlags
, CPoint point
)
2684 TRACKMOUSEEVENT tme
;
2685 tme
.cbSize
=sizeof(TRACKMOUSEEVENT
);
2686 tme
.dwFlags
=TME_HOVER
|TME_LEAVE
;
2687 tme
.hwndTrack
=this->m_hWnd
;
2689 TrackMouseEvent(&tme
);
2693 BOOL
CTortoiseGitBlameView::PreTranslateMessage(MSG
* pMsg
)
2695 m_ToolTip
.RelayEvent(pMsg
);
2696 return CView::PreTranslateMessage(pMsg
);
2699 void CTortoiseGitBlameView::OnEditFind()
2703 void CTortoiseGitBlameView::OnEditGoto()