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"
29 #include "EditGotoDlg.h"
35 UINT
CTortoiseGitBlameView::m_FindDialogMessage
;
37 // CTortoiseGitBlameView
39 IMPLEMENT_DYNCREATE(CTortoiseGitBlameView
, CView
)
41 BEGIN_MESSAGE_MAP(CTortoiseGitBlameView
, CView
)
42 // Standard printing commands
43 ON_COMMAND(ID_FILE_PRINT
, &CView::OnFilePrint
)
44 ON_COMMAND(ID_FILE_PRINT_DIRECT
, &CView::OnFilePrint
)
45 ON_COMMAND(ID_FILE_PRINT_PREVIEW
, &CTortoiseGitBlameView::OnFilePrintPreview
)
46 ON_COMMAND(ID_EDIT_FIND
,OnEditFind
)
47 ON_COMMAND(ID_EDIT_GOTO
,OnEditGoto
)
55 ON_NOTIFY(SCN_PAINTED
,0,OnSciPainted
)
56 ON_NOTIFY(SCN_GETBKCOLOR
,0,OnSciGetBkColor
)
57 ON_REGISTERED_MESSAGE(m_FindDialogMessage
, OnFindDialogMessage
)
61 // CTortoiseGitBlameView construction/destruction
63 CTortoiseGitBlameView::CTortoiseGitBlameView()
65 // TODO: add construction code here
82 m_windowcolor
= ::GetSysColor(COLOR_WINDOW
);
83 m_textcolor
= ::GetSysColor(COLOR_WINDOWTEXT
);
84 m_texthighlightcolor
= ::GetSysColor(COLOR_HIGHLIGHTTEXT
);
85 m_mouserevcolor
= InterColor(m_windowcolor
, m_textcolor
, 20);
86 m_mouseauthorcolor
= InterColor(m_windowcolor
, m_textcolor
, 10);
87 m_selectedrevcolor
= ::GetSysColor(COLOR_HIGHLIGHT
);
88 m_selectedauthorcolor
= InterColor(m_selectedrevcolor
, m_texthighlightcolor
, 35);
92 m_selectedorigrev
= -1;
97 m_lowestrev
= LONG_MAX
;
106 m_FindDialogMessage
= ::RegisterWindowMessage(FINDMSGSTRING
);
107 m_pFindDialog
= NULL
;
110 CTortoiseGitBlameView::~CTortoiseGitBlameView()
113 DeleteObject(m_font
);
115 DeleteObject(m_italicfont
);
119 int CTortoiseGitBlameView::OnCreate(LPCREATESTRUCT lpcs
)
123 this->GetWindowRect(&rect1
);
124 rect
.left
=m_blamewidth
+LOCATOR_WIDTH
;
125 rect
.right
=rect
.Width();
127 rect
.bottom
=rect
.Height();
128 BOOL b
=m_TextView
.Create(_T("Scintilla"),_T("source"),0,rect
,this,0,0);
130 m_TextView
.ShowWindow( SW_SHOW
);
131 //m_TextView.InsertText(_T("Abdadfasdf"));
132 m_wEditor
= m_TextView
.m_hWnd
;
135 m_ToolTip
.Create(this->GetParent());
136 m_ToolTip
.AddTool(this,_T("Test"));
138 return CView::OnCreate(lpcs
);
141 void CTortoiseGitBlameView::OnSize(UINT nType
,int cx
, int cy
)
145 rect
.left
=m_blamewidth
;
150 m_TextView
.MoveWindow(&rect
);
153 BOOL
CTortoiseGitBlameView::PreCreateWindow(CREATESTRUCT
& cs
)
155 // TODO: Modify the Window class or styles here by modifying
156 // the CREATESTRUCT cs
158 return CView::PreCreateWindow(cs
);
161 // CTortoiseGitBlameView drawing
163 void CTortoiseGitBlameView::OnDraw(CDC
* /*pDC*/)
165 CTortoiseGitBlameDoc
* pDoc
= GetDocument();
170 DrawBlame(this->GetDC()->m_hDC
);
171 DrawLocatorBar(this->GetDC()->m_hDC
);
172 // TODO: add draw code for native data here
176 // CTortoiseGitBlameView printing
179 void CTortoiseGitBlameView::OnFilePrintPreview()
181 AFXPrintPreview(this);
184 BOOL
CTortoiseGitBlameView::OnPreparePrinting(CPrintInfo
* pInfo
)
186 // default preparation
187 return DoPreparePrinting(pInfo
);
190 void CTortoiseGitBlameView::OnBeginPrinting(CDC
* /*pDC*/, CPrintInfo
* /*pInfo*/)
192 // TODO: add extra initialization before printing
195 void CTortoiseGitBlameView::OnEndPrinting(CDC
* /*pDC*/, CPrintInfo
* /*pInfo*/)
197 // TODO: add cleanup after printing
200 void CTortoiseGitBlameView::OnRButtonUp(UINT nFlags
, CPoint point
)
202 ClientToScreen(&point
);
203 OnContextMenu(this, point
);
206 void CTortoiseGitBlameView::OnContextMenu(CWnd
* pWnd
, CPoint point
)
208 theApp
.GetContextMenuManager()->ShowPopupMenu(IDR_POPUP_EDIT
, point
.x
, point
.y
, this, TRUE
);
212 // CTortoiseGitBlameView diagnostics
215 void CTortoiseGitBlameView::AssertValid() const
217 CView::AssertValid();
220 void CTortoiseGitBlameView::Dump(CDumpContext
& dc
) const
225 CTortoiseGitBlameDoc
* CTortoiseGitBlameView::GetDocument() const // non-debug version is inline
227 ASSERT(m_pDocument
->IsKindOf(RUNTIME_CLASS(CTortoiseGitBlameDoc
)));
228 return (CTortoiseGitBlameDoc
*)m_pDocument
;
233 // CTortoiseGitBlameView message handlers
234 CString
CTortoiseGitBlameView::GetAppDirectory()
238 DWORD bufferlen
= MAX_PATH
; // MAX_PATH is not the limit here!
241 bufferlen
+= MAX_PATH
; // MAX_PATH is not the limit here!
242 TCHAR
* pBuf
= new TCHAR
[bufferlen
];
243 len
= GetModuleFileName(NULL
, pBuf
, bufferlen
);
244 path
= CString(pBuf
, len
);
246 } while(len
== bufferlen
);
248 path
= path
.Left(path
.ReverseFind(_T('\\')));
249 //path = path.substr(0, path.rfind('\\') + 1);
254 // Return a color which is interpolated between c1 and c2.
255 // Slider controls the relative proportions as a percentage:
256 // Slider = 0 represents pure c1
257 // Slider = 50 represents equal mixture
258 // Slider = 100 represents pure c2
259 COLORREF
CTortoiseGitBlameView::InterColor(COLORREF c1
, COLORREF c2
, int Slider
)
263 // Limit Slider to 0..100% range
269 // The color components have to be treated individually.
270 r
= (GetRValue(c2
) * Slider
+ GetRValue(c1
) * (100 - Slider
)) / 100;
271 g
= (GetGValue(c2
) * Slider
+ GetGValue(c1
) * (100 - Slider
)) / 100;
272 b
= (GetBValue(c2
) * Slider
+ GetBValue(c1
) * (100 - Slider
)) / 100;
277 LRESULT
CTortoiseGitBlameView::SendEditor(UINT Msg
, WPARAM wParam
, LPARAM lParam
)
279 if (m_directFunction
)
281 return ((SciFnDirect
) m_directFunction
)(m_directPointer
, Msg
, wParam
, lParam
);
283 return ::SendMessage(m_wEditor
, Msg
, wParam
, lParam
);
286 void CTortoiseGitBlameView::GetRange(int start
, int end
, char *text
)
290 tr
.chrg
.cpMin
= start
;
294 SendMessage(m_wEditor
, EM_GETTEXTRANGE
, 0, reinterpret_cast<LPARAM
>(&tr
));
298 void CTortoiseGitBlameView::SetTitle()
301 char title
[MAX_PATH
+ 100];
302 strcpy_s(title
, MAX_PATH
+ 100, szTitle
);
303 strcat_s(title
, MAX_PATH
+ 100, " - ");
304 strcat_s(title
, MAX_PATH
+ 100, szViewtitle
);
305 ::SetWindowText(wMain
, title
);
309 BOOL
CTortoiseGitBlameView::OpenLogFile(const char *fileName
)
312 char logmsgbuf
[10000+1];
314 fopen_s(&File
, fileName
, "rb");
324 wchar_t wbuf
[MAX_LOG_LENGTH
+6];
327 len
= fread(&rev
, sizeof(LONG
), 1, File
);
334 len
= fread(&slength
, sizeof(int), 1, File
);
341 if (slength
> MAX_LOG_LENGTH
)
343 reallength
= slength
;
344 slength
= MAX_LOG_LENGTH
;
348 len
= fread(logmsgbuf
, sizeof(char), slength
, File
);
349 if (len
< (size_t)slength
)
355 msg
= CString(logmsgbuf
, slength
);
358 fseek(File
, reallength
-MAX_LOG_LENGTH
, SEEK_CUR
);
359 msg
= msg
+ _T("\n...");
361 int len2
= ::MultiByteToWideChar(CP_UTF8
, NULL
, msg
.c_str(), min(msg
.size(), MAX_LOG_LENGTH
+5), wbuf
, MAX_LOG_LENGTH
+5);
363 len2
= ::WideCharToMultiByte(CP_ACP
, NULL
, wbuf
, len2
, logmsgbuf
, MAX_LOG_LENGTH
+5, NULL
, NULL
);
365 msg
= CString(logmsgbuf
);
366 logmessages
[rev
] = msg
;
372 BOOL
CTortoiseGitBlameView::OpenFile(const char *fileName
)
375 SendEditor(SCI_SETREADONLY
, FALSE
);
376 SendEditor(SCI_CLEARALL
);
377 SendEditor(EM_EMPTYUNDOBUFFER
);
379 SendEditor(SCI_SETSAVEPOINT
);
380 SendEditor(SCI_CANCEL
);
381 SendEditor(SCI_SETUNDOCOLLECTION
, 0);
382 ::ShowWindow(m_wEditor
, SW_HIDE
);
390 char * lineptr
= NULL
;
391 char * trimptr
= NULL
;
392 //ignore the first two lines, they're of no interest to us
393 File
.getline(line
, sizeof(line
)/sizeof(char));
394 File
.getline(line
, sizeof(line
)/sizeof(char));
395 m_lowestrev
= LONG_MAX
;
400 File
.getline(line
, sizeof(line
)/sizeof(TCHAR
));
401 if (File
.gcount()>139)
403 mergelines
.push_back((line
[0] != ' '));
405 long rev
= _ttol(lineptr
);
407 m_lowestrev
= min(m_lowestrev
, rev
);
408 m_highestrev
= max(m_highestrev
, rev
);
410 rev
= _ttol(lineptr
);
411 origrevs
.push_back(rev
);
413 dates
.push_back(CString(lineptr
, 30));
415 // unfortunately, the 'path' entry can be longer than the 60 chars
416 // we made the column. We therefore have to step through the path
417 // string until we find a space
421 // TODO: how can we deal with the situation where the path has
422 // a space in it, but the space is after the 60 chars reserved
424 // The only way to deal with that would be to use a custom
425 // binary format for the blame file.
427 trimptr
= _tcschr(trimptr
, ' ');
428 } while ((trimptr
)&&(trimptr
+1 < lineptr
+61));
433 paths
.push_back(CString(lineptr
));
434 if (trimptr
+1 < lineptr
+61)
437 lineptr
= (trimptr
+1);
438 trimptr
= lineptr
+30;
439 while ((*trimptr
== ' ')&&(trimptr
> lineptr
))
442 authors
.push_back(CString(lineptr
));
444 // in case we find an UTF8 BOM at the beginning of the line, we remove it
445 if (((unsigned char)lineptr
[0] == 0xEF)&&((unsigned char)lineptr
[1] == 0xBB)&&((unsigned char)lineptr
[2] == 0xBF))
449 if (((unsigned char)lineptr
[0] == 0xBB)&&((unsigned char)lineptr
[1] == 0xEF)&&((unsigned char)lineptr
[2] == 0xBF))
453 // check each line for illegal utf8 sequences. If one is found, we treat
454 // the file as ASCII, otherwise we assume an UTF8 file.
455 char * utf8CheckBuf
= lineptr
;
456 while ((bUTF8
)&&(*utf8CheckBuf
))
458 if ((*utf8CheckBuf
== 0xC0)||(*utf8CheckBuf
== 0xC1)||(*utf8CheckBuf
>= 0xF5))
463 if ((*utf8CheckBuf
& 0xE0)==0xC0)
466 if (*utf8CheckBuf
== 0)
468 if ((*utf8CheckBuf
& 0xC0)!=0x80)
474 if ((*utf8CheckBuf
& 0xF0)==0xE0)
477 if (*utf8CheckBuf
== 0)
479 if ((*utf8CheckBuf
& 0xC0)!=0x80)
485 if (*utf8CheckBuf
== 0)
487 if ((*utf8CheckBuf
& 0xC0)!=0x80)
493 if ((*utf8CheckBuf
& 0xF8)==0xF0)
496 if (*utf8CheckBuf
== 0)
498 if ((*utf8CheckBuf
& 0xC0)!=0x80)
504 if (*utf8CheckBuf
== 0)
506 if ((*utf8CheckBuf
& 0xC0)!=0x80)
512 if (*utf8CheckBuf
== 0)
514 if ((*utf8CheckBuf
& 0xC0)!=0x80)
523 SendEditor(SCI_ADDTEXT
, _tcslen(lineptr
), reinterpret_cast<LPARAM
>(static_cast<char *>(lineptr
)));
524 SendEditor(SCI_ADDTEXT
, 2, (LPARAM
)_T("\r\n"));
526 } while (File
.gcount() > 0);
529 SendEditor(SCI_SETCODEPAGE
, SC_CP_UTF8
);
531 SendEditor(SCI_SETUNDOCOLLECTION
, 1);
532 ::SetFocus(m_wEditor
);
533 SendEditor(EM_EMPTYUNDOBUFFER
);
534 SendEditor(SCI_SETSAVEPOINT
);
535 SendEditor(SCI_GOTOPOS
, 0);
536 SendEditor(SCI_SETSCROLLWIDTHTRACKING
, TRUE
);
537 SendEditor(SCI_SETREADONLY
, TRUE
);
539 //check which lexer to use, depending on the filetype
540 SetupLexer(fileName
);
541 ::ShowWindow(m_wEditor
, SW_SHOW
);
543 ::InvalidateRect(wMain
, NULL
, TRUE
);
545 GetWindowRect(wMain
, &rc
);
546 SetWindowPos(wMain
, 0, rc
.left
, rc
.top
, rc
.right
-rc
.left
-1, rc
.bottom
- rc
.top
, 0);
551 void CTortoiseGitBlameView::SetAStyle(int style
, COLORREF fore
, COLORREF back
, int size
, CString
*face
)
553 SendEditor(SCI_STYLESETFORE
, style
, fore
);
554 SendEditor(SCI_STYLESETBACK
, style
, back
);
556 SendEditor(SCI_STYLESETSIZE
, style
, size
);
558 SendEditor(SCI_STYLESETFONT
, style
, reinterpret_cast<LPARAM
>(this->m_TextView
.StringForControl(*face
).GetBuffer()));
561 void CTortoiseGitBlameView::InitialiseEditor()
564 m_directFunction
= ::SendMessage(m_wEditor
, SCI_GETDIRECTFUNCTION
, 0, 0);
565 m_directPointer
= ::SendMessage(m_wEditor
, SCI_GETDIRECTPOINTER
, 0, 0);
566 // Set up the global default style. These attributes are used wherever no explicit choices are made.
567 SetAStyle(STYLE_DEFAULT
,
570 (DWORD
)CRegStdWORD(_T("Software\\TortoiseGit\\BlameFontSize"), 10),
571 &CString(((stdstring
)CRegStdString(_T("Software\\TortoiseGit\\BlameFontName"), _T("Courier New"))).c_str())
573 SendEditor(SCI_SETTABWIDTH
, (DWORD
)CRegStdWORD(_T("Software\\TortoiseGit\\BlameTabSize"), 4));
574 SendEditor(SCI_SETREADONLY
, TRUE
);
575 LRESULT pix
= SendEditor(SCI_TEXTWIDTH
, STYLE_LINENUMBER
, (LPARAM
)this->m_TextView
.StringForControl(_T("_99999")).GetBuffer());
577 SendEditor(SCI_SETMARGINWIDTHN
, 0, pix
);
579 SendEditor(SCI_SETMARGINWIDTHN
, 0);
580 SendEditor(SCI_SETMARGINWIDTHN
, 1);
581 SendEditor(SCI_SETMARGINWIDTHN
, 2);
582 //Set the default windows colors for edit controls
583 SendEditor(SCI_STYLESETFORE
, STYLE_DEFAULT
, ::GetSysColor(COLOR_WINDOWTEXT
));
584 SendEditor(SCI_STYLESETBACK
, STYLE_DEFAULT
, ::GetSysColor(COLOR_WINDOW
));
585 SendEditor(SCI_SETSELFORE
, TRUE
, ::GetSysColor(COLOR_HIGHLIGHTTEXT
));
586 SendEditor(SCI_SETSELBACK
, TRUE
, ::GetSysColor(COLOR_HIGHLIGHT
));
587 SendEditor(SCI_SETCARETFORE
, ::GetSysColor(COLOR_WINDOWTEXT
));
588 m_regOldLinesColor
= CRegStdWORD(_T("Software\\TortoiseGit\\BlameOldColor"), RGB(230, 230, 255));
589 m_regNewLinesColor
= CRegStdWORD(_T("Software\\TortoiseGit\\BlameNewColor"), RGB(255, 230, 230));
591 this->m_TextView
.Call(SCI_SETWRAPMODE
, SC_WRAP_NONE
);
595 void CTortoiseGitBlameView::StartSearch()
600 // Initialize FINDREPLACE
601 if (fr
.Flags
& FR_MATCHCASE
)
603 SecureZeroMemory(&fr
, sizeof(fr
));
604 fr
.lStructSize
= sizeof(fr
);
605 fr
.hwndOwner
= wMain
;
606 fr
.lpstrFindWhat
= szFindWhat
;
607 fr
.wFindWhatLen
= 80;
608 fr
.Flags
= FR_HIDEUPDOWN
| FR_HIDEWHOLEWORD
;
609 fr
.Flags
|= bCase
? FR_MATCHCASE
: 0;
611 currentDialog
= FindText(&fr
);
614 bool CTortoiseGitBlameView::DoSearch(CString what
, DWORD flags
)
618 int pos
= SendEditor(SCI_GETCURRENTPOS
);
619 int line
= SendEditor(SCI_LINEFROMPOSITION
, pos
);
621 bool bCaseSensitive
= !!(flags
& FR_MATCHCASE
);
623 //strcpy_s(szWhat, sizeof(szWhat), what);
627 what
=what
.MakeLower();
630 //CString sWhat = CString(szWhat);
637 int bufsize
= SendEditor(SCI_GETLINE
, i
);
638 char * linebuf
= new char[bufsize
+1];
639 SecureZeroMemory(linebuf
, bufsize
+1);
640 SendEditor(SCI_GETLINE
, i
, (LPARAM
)linebuf
);
641 CString oneline
=this->m_TextView
.StringFromControl(linebuf
);
644 oneline
=oneline
.MakeLower();
646 //_stprintf_s(buf, 20, _T("%ld"), revs[i]);
647 if (this->m_Authors
[i
].Find(what
)>=0)
649 else if ((!bCaseSensitive
)&&(this->m_Authors
[i
].MakeLower().Find(what
)>=0))
651 else if (oneline
.Find(what
) >=0)
657 if(i
>=m_CommitHash
.size())
659 }while(i
!=line
&&(!bFound
));
664 int selstart
= SendEditor(SCI_GETCURRENTPOS
);
665 int selend
= SendEditor(SCI_POSITIONFROMLINE
, i
);
666 SendEditor(SCI_SETSELECTIONSTART
, selstart
);
667 SendEditor(SCI_SETSELECTIONEND
, selend
);
668 m_SelectedLine
= i
-1;
672 ::MessageBox(wMain
, what
+_T(" not found"), _T("CTortoiseGitBlameView"), MB_ICONINFORMATION
);
678 bool CTortoiseGitBlameView::GotoLine(long line
)
683 if ((unsigned long)line
>= m_CommitHash
.size())
685 line
= m_CommitHash
.size()-1;
688 int nCurrentPos
= SendEditor(SCI_GETCURRENTPOS
);
689 int nCurrentLine
= SendEditor(SCI_LINEFROMPOSITION
,nCurrentPos
);
690 int nFirstVisibleLine
= SendEditor(SCI_GETFIRSTVISIBLELINE
);
691 int nLinesOnScreen
= SendEditor(SCI_LINESONSCREEN
);
693 if ( line
>=nFirstVisibleLine
&& line
<=nFirstVisibleLine
+nLinesOnScreen
)
696 SendEditor(SCI_GOTOLINE
, line
);
700 // Place the requested line one third from the top
701 if ( line
> nCurrentLine
)
703 SendEditor(SCI_GOTOLINE
, (WPARAM
)(line
+(int)nLinesOnScreen
*(2/3.0)));
707 SendEditor(SCI_GOTOLINE
, (WPARAM
)(line
-(int)nLinesOnScreen
*(1/3.0)));
711 // Highlight the line
712 int nPosStart
= SendEditor(SCI_POSITIONFROMLINE
,line
);
713 int nPosEnd
= SendEditor(SCI_GETLINEENDPOSITION
,line
);
714 SendEditor(SCI_SETSEL
,nPosEnd
,nPosStart
);
719 bool CTortoiseGitBlameView::ScrollToLine(long line
)
724 int nCurrentLine
= SendEditor(SCI_GETFIRSTVISIBLELINE
);
726 int scrolldelta
= line
- nCurrentLine
;
727 SendEditor(SCI_LINESCROLL
, 0, scrolldelta
);
732 void CTortoiseGitBlameView::CopySelectedLogToClipboard()
735 if (m_selectedrev
<= 0)
737 std::map
<LONG
, CString
>::iterator iter
;
738 if ((iter
= app
.logmessages
.find(m_selectedrev
)) != app
.logmessages
.end())
741 msg
+= m_selectedauthor
;
743 msg
+= app
.m_selecteddate
;
747 if (OpenClipboard(app
.wBlame
))
750 HGLOBAL hClipboardData
;
751 hClipboardData
= GlobalAlloc(GMEM_DDESHARE
, msg
.size()+1);
753 pchData
= (char*)GlobalLock(hClipboardData
);
754 strcpy_s(pchData
, msg
.size()+1, msg
.c_str());
755 GlobalUnlock(hClipboardData
);
756 SetClipboardData(CF_TEXT
,hClipboardData
);
763 void CTortoiseGitBlameView::BlamePreviousRevision()
766 LONG nRevisionTo
= m_selectedorigrev
- 1;
772 // We now determine the smallest revision number in the blame file (but ignore "-1")
773 // We do this for two reasons:
774 // 1. we respect the "From revision" which the user entered
775 // 2. we speed up the call of "svn blame" because previous smaller revision numbers don't have any effect on the result
776 LONG nSmallestRevision
= -1;
777 for (LONG line
=0;line
<(LONG
)app
.revs
.size();line
++)
779 const LONG nRevision
= app
.revs
[line
];
782 if ( nSmallestRevision
< 1 )
784 nSmallestRevision
= nRevision
;
788 nSmallestRevision
= min(nSmallestRevision
,nRevision
);
793 char bufStartRev
[20];
794 _stprintf_s(bufStartRev
, 20, _T("%d"), nSmallestRevision
);
797 _stprintf_s(bufEndRev
, 20, _T("%d"), nRevisionTo
);
800 _stprintf_s(bufLine
, 20, _T("%d"), m_SelectedLine
+1); //using the current line is a good guess.
803 PROCESS_INFORMATION process
;
804 memset(&startup
, 0, sizeof(startup
));
805 startup
.cb
= sizeof(startup
);
806 memset(&process
, 0, sizeof(process
));
807 stdstring tortoiseProcPath
= GetAppDirectory() + _T("TortoiseProc.exe");
808 stdstring svnCmd
= _T(" /command:blame ");
809 svnCmd
+= _T(" /path:\"");
810 svnCmd
+= szOrigPath
;
812 svnCmd
+= _T(" /startrev:");
813 svnCmd
+= bufStartRev
;
814 svnCmd
+= _T(" /endrev:");
816 svnCmd
+= _T(" /line:");
819 svnCmd
+= _T(" /ignoreeol");
821 svnCmd
+= _T(" /ignorespaces");
822 if (bIgnoreAllSpaces
)
823 svnCmd
+= _T(" /ignoreallspaces");
824 if (CreateProcess(tortoiseProcPath
.c_str(), const_cast<TCHAR
*>(svnCmd
.c_str()), NULL
, NULL
, FALSE
, 0, 0, 0, &startup
, &process
))
826 CloseHandle(process
.hThread
);
827 CloseHandle(process
.hProcess
);
832 void CTortoiseGitBlameView::DiffPreviousRevision()
835 LONG nRevisionTo
= m_selectedorigrev
;
841 LONG nRevisionFrom
= nRevisionTo
-1;
843 char bufStartRev
[20];
844 _stprintf_s(bufStartRev
, 20, _T("%d"), nRevisionFrom
);
847 _stprintf_s(bufEndRev
, 20, _T("%d"), nRevisionTo
);
850 PROCESS_INFORMATION process
;
851 memset(&startup
, 0, sizeof(startup
));
852 startup
.cb
= sizeof(startup
);
853 memset(&process
, 0, sizeof(process
));
854 stdstring tortoiseProcPath
= GetAppDirectory() + _T("TortoiseProc.exe");
855 stdstring svnCmd
= _T(" /command:diff ");
856 svnCmd
+= _T(" /path:\"");
857 svnCmd
+= szOrigPath
;
859 svnCmd
+= _T(" /startrev:");
860 svnCmd
+= bufStartRev
;
861 svnCmd
+= _T(" /endrev:");
863 if (CreateProcess(tortoiseProcPath
.c_str(), const_cast<TCHAR
*>(svnCmd
.c_str()), NULL
, NULL
, FALSE
, 0, 0, 0, &startup
, &process
))
865 CloseHandle(process
.hThread
);
866 CloseHandle(process
.hProcess
);
871 void CTortoiseGitBlameView::ShowLog()
875 _stprintf_s(bufRev
, 20, _T("%d"), m_selectedorigrev
);
878 PROCESS_INFORMATION process
;
879 memset(&startup
, 0, sizeof(startup
));
880 startup
.cb
= sizeof(startup
);
881 memset(&process
, 0, sizeof(process
));
882 stdstring tortoiseProcPath
= GetAppDirectory() + _T("TortoiseProc.exe");
883 stdstring svnCmd
= _T(" /command:log ");
884 svnCmd
+= _T(" /path:\"");
885 svnCmd
+= szOrigPath
;
887 svnCmd
+= _T(" /startrev:");
889 svnCmd
+= _T(" /pegrev:");
891 if (CreateProcess(tortoiseProcPath
.c_str(), const_cast<TCHAR
*>(svnCmd
.c_str()), NULL
, NULL
, FALSE
, 0, 0, 0, &startup
, &process
))
893 CloseHandle(process
.hThread
);
894 CloseHandle(process
.hProcess
);
899 void CTortoiseGitBlameView::Notify(SCNotification
*notification
)
901 switch (notification
->nmhdr
.code
)
903 case SCN_SAVEPOINTREACHED
:
906 case SCN_SAVEPOINTLEFT
:
909 // InvalidateRect(wBlame, NULL, FALSE);
910 // InvalidateRect(wLocator, NULL, FALSE);
913 // if ((m_colorage)&&(notification->line < (int)revs.size()))
915 // notification->lParam = InterColor(DWORD(m_regOldLinesColor), DWORD(m_regNewLinesColor), (revs[notification->line]-m_lowestrev)*100/((m_highestrev-m_lowestrev)+1));
921 void CTortoiseGitBlameView::Command(int id
)
927 // ::PostQuitMessage(0);
932 case ID_COPYTOCLIPBOARD
:
933 CopySelectedLogToClipboard();
935 case ID_BLAME_PREVIOUS_REVISION
:
936 BlamePreviousRevision();
938 case ID_DIFF_PREVIOUS_REVISION
:
939 DiffPreviousRevision();
944 case ID_EDIT_GOTOLINE
:
947 case ID_VIEW_COLORAGEOFLINES
:
949 m_colorage
= !m_colorage
;
950 HMENU hMenu
= GetMenu(wMain
);
951 UINT uCheck
= MF_BYCOMMAND
;
952 uCheck
|= m_colorage
? MF_CHECKED
: MF_UNCHECKED
;
953 CheckMenuItem(hMenu
, ID_VIEW_COLORAGEOFLINES
, uCheck
);
958 case ID_VIEW_MERGEPATH
:
960 ShowPath
= !ShowPath
;
961 HMENU hMenu
= GetMenu(wMain
);
962 UINT uCheck
= MF_BYCOMMAND
;
963 uCheck
|= ShowPath
? MF_CHECKED
: MF_UNCHECKED
;
964 CheckMenuItem(hMenu
, ID_VIEW_MERGEPATH
, uCheck
);
974 void CTortoiseGitBlameView::GotoLineDlg()
977 if (DialogBox(hResource
, MAKEINTRESOURCE(IDD_GOTODLG
), wMain
, GotoDlgProc
)==IDOK
)
979 GotoLine(m_gotoline
);
984 LONG
CTortoiseGitBlameView::GetBlameWidth()
989 HDC hDC
= this->GetDC()->m_hDC
;
990 HFONT oldfont
= (HFONT
)::SelectObject(hDC
, m_font
);
993 //_stprintf_s(buf, MAX_PATH, _T("%8ld "), 88888888);
994 //::GetTextExtentPoint(hDC, buf, _tcslen(buf), &width);
995 //m_revwidth = width.cx + BLAMESPACE;
996 //blamewidth += m_revwidth;
999 for (int i
=0;i
<this->m_Authors
.size();i
++)
1004 _stprintf_s(buf
, MAX_PATH
, _T("%d."), maxnum
);
1005 ::GetTextExtentPoint(hDC
, buf
, _tcslen(buf
), &width
);
1006 m_revwidth
= width
.cx
+ BLAMESPACE
;
1007 blamewidth
+= m_revwidth
;
1010 _stprintf_s(buf
, MAX_PATH
, _T("%d"), m_CommitHash
.size());
1011 ::GetTextExtentPoint(hDC
, buf
, _tcslen(buf
), &width
);
1012 m_linewidth
= width
.cx
+ BLAMESPACE
;
1013 blamewidth
+= m_revwidth
;
1018 _stprintf_s(buf
, MAX_PATH
, _T("%30s"), _T("31.08.2001 06:24:14"));
1019 ::GetTextExtentPoint32(hDC
, buf
, _tcslen(buf
), &width
);
1020 m_datewidth
= width
.cx
+ BLAMESPACE
;
1021 blamewidth
+= m_datewidth
;
1025 SIZE maxwidth
= {0};
1027 for (int i
=0;i
<this->m_Authors
.size();i
++)
1028 //for (std::vector<CString>::iterator I = authors.begin(); I != authors.end(); ++I)
1030 ::GetTextExtentPoint32(hDC
,m_Authors
[i
] , m_Authors
[i
].GetLength(), &width
);
1031 if (width
.cx
> maxwidth
.cx
)
1034 m_authorwidth
= maxwidth
.cx
+ BLAMESPACE
;
1035 blamewidth
+= m_authorwidth
;
1040 SIZE maxwidth
= {0};
1041 for (std::vector
<CString
>::iterator I
= paths
.begin(); I
!= paths
.end(); ++I
)
1043 ::GetTextExtentPoint32(hDC
, I
->c_str(), I
->size(), &width
);
1044 if (width
.cx
> maxwidth
.cx
)
1047 m_pathwidth
= maxwidth
.cx
+ BLAMESPACE
;
1048 blamewidth
+= m_pathwidth
;
1051 ::SelectObject(hDC
, oldfont
);
1052 POINT pt
= {blamewidth
, 0};
1053 LPtoDP(hDC
, &pt
, 1);
1054 m_blamewidth
= pt
.x
;
1055 //::ReleaseDC(wBlame, hDC);
1057 //return m_blamewidth;
1062 void CTortoiseGitBlameView::CreateFont()
1068 HDC hDC
= ::GetDC(wBlame
);
1069 lf
.lfHeight
= -MulDiv((DWORD
)CRegStdWORD(_T("Software\\TortoiseGit\\BlameFontSize"), 10), GetDeviceCaps(hDC
, LOGPIXELSY
), 72);
1070 lf
.lfCharSet
= DEFAULT_CHARSET
;
1071 CRegStdString fontname
= CRegStdString(_T("Software\\TortoiseGit\\BlameFontName"), _T("Courier New"));
1072 _tcscpy_s(lf
.lfFaceName
, 32, ((stdstring
)fontname
).c_str());
1073 m_font
= ::CreateFontIndirect(&lf
);
1076 m_italicfont
= ::CreateFontIndirect(&lf
);
1078 ::ReleaseDC(wBlame
, hDC
);
1080 //m_TextView.SetFont(lf.lfFaceName,((DWORD)CRegStdWORD(_T("Software\\TortoiseGit\\BlameFontSize"), 10)));
1083 void CTortoiseGitBlameView::DrawBlame(HDC hDC
)
1091 HFONT oldfont
= NULL
;
1092 LONG_PTR line
= SendEditor(SCI_GETFIRSTVISIBLELINE
);
1093 LONG_PTR linesonscreen
= SendEditor(SCI_LINESONSCREEN
);
1094 LONG_PTR height
= SendEditor(SCI_TEXTHEIGHT
);
1096 TCHAR buf
[MAX_PATH
];
1099 //::GetClientRect(this->m_hWnd, &rc);
1100 for (LRESULT i
=line
; i
<(line
+linesonscreen
); ++i
)
1103 if (i
< (int)m_CommitHash
.size())
1105 // if (mergelines[i])
1106 // oldfont = (HFONT)::SelectObject(hDC, m_italicfont);
1108 oldfont
= (HFONT
)::SelectObject(hDC
, m_font
);
1109 ::SetBkColor(hDC
, m_windowcolor
);
1110 ::SetTextColor(hDC
, m_textcolor
);
1111 if (m_CommitHash
[i
].GetLength()>0)
1113 //if (m_CommitHash[i].Compare(m_MouseHash)==0)
1114 // ::SetBkColor(hDC, m_mouseauthorcolor);
1115 if (m_CommitHash
[i
].Compare(m_SelectedHash
)==0)
1117 ::SetBkColor(hDC
, m_selectedauthorcolor
);
1118 ::SetTextColor(hDC
, m_texthighlightcolor
);
1123 if(m_MouseLine
== i
)
1124 ::SetBkColor(hDC
, m_mouserevcolor
);
1126 //if ((revs[i] == m_mouserev)&&(!sel))
1127 // ::SetBkColor(hDC, m_mouserevcolor);
1128 //if (revs[i] == m_selectedrev)
1130 // ::SetBkColor(hDC, m_selectedrevcolor);
1131 // ::SetTextColor(hDC, m_texthighlightcolor);
1135 str
.Format(_T("%d"),m_ID
[i
]);
1137 //_stprintf_s(buf, MAX_PATH, _T("%8ld "), revs[i]);
1139 rc
.left
=LOCATOR_WIDTH
;
1141 rc
.right
= rc
.left
+ m_blamewidth
;
1142 ::ExtTextOut(hDC
, LOCATOR_WIDTH
, Y
, ETO_CLIPPED
, &rc
, str
, str
.GetLength(), 0);
1143 int Left
= m_revwidth
;
1147 rc
.right
= rc
.left
+ Left
+ m_authorwidth
;
1148 //_stprintf_s(buf, MAX_PATH, _T("%-30s "), authors[i].c_str());
1149 ::ExtTextOut(hDC
, Left
, Y
, ETO_CLIPPED
, &rc
, m_Authors
[i
], m_Authors
[i
].GetLength(), 0);
1150 Left
+= m_authorwidth
;
1155 rc
.right
= rc
.left
+ Left
+ m_datewidth
;
1156 _stprintf_s(buf
, MAX_PATH
, _T("%30s "), dates
[i
].c_str());
1157 ::ExtTextOut(hDC
, Left
, Y
, ETO_CLIPPED
, &rc
, buf
, _tcslen(buf
), 0);
1158 Left
+= m_datewidth
;
1165 rc
.right
= rc
.left
+ Left
+ m_pathwidth
;
1166 _stprintf_s(buf
, MAX_PATH
, _T("%-60s "), paths
[i
].c_str());
1167 ::ExtTextOut(hDC
, Left
, Y
, ETO_CLIPPED
, &rc
, buf
, _tcslen(buf
), 0);
1168 Left
+= m_authorwidth
;
1171 if ((i
==m_SelectedLine
)&&(m_pFindDialog
))
1174 brush
.lbColor
= m_textcolor
;
1176 brush
.lbStyle
= BS_SOLID
;
1177 HPEN pen
= ExtCreatePen(PS_SOLID
| PS_GEOMETRIC
, 2, &brush
, 0, NULL
);
1178 HGDIOBJ hPenOld
= SelectObject(hDC
, pen
);
1181 rc2
.bottom
= Y
+ height
;
1182 ::MoveToEx(hDC
, rc2
.left
, rc2
.top
, NULL
);
1183 ::LineTo(hDC
, rc2
.right
, rc2
.top
);
1184 ::LineTo(hDC
, rc2
.right
, rc2
.bottom
);
1185 ::LineTo(hDC
, rc2
.left
, rc2
.bottom
);
1186 ::LineTo(hDC
, rc2
.left
, rc2
.top
);
1187 SelectObject(hDC
, hPenOld
);
1191 ::SelectObject(hDC
, oldfont
);
1195 ::SetBkColor(hDC
, m_windowcolor
);
1196 for (int j
=0; j
< MAX_PATH
; ++j
)
1198 ::ExtTextOut(hDC
, 0, Y
, ETO_CLIPPED
, &rc
, buf
, MAX_PATH
-1, 0);
1204 void CTortoiseGitBlameView::DrawHeader(HDC hDC
)
1211 HFONT oldfont
= (HFONT
)::SelectObject(hDC
, GetStockObject(DEFAULT_GUI_FONT
));
1212 ::GetClientRect(wHeader
, &rc
);
1214 ::SetBkColor(hDC
, ::GetSysColor(COLOR_BTNFACE
));
1216 TCHAR szText
[MAX_LOADSTRING
];
1217 LoadString(app
.hResource
, IDS_HEADER_REVISION
, szText
, MAX_LOADSTRING
);
1218 ::ExtTextOut(hDC
, LOCATOR_WIDTH
, 0, ETO_CLIPPED
, &rc
, szText
, _tcslen(szText
), 0);
1219 int Left
= m_revwidth
+LOCATOR_WIDTH
;
1222 LoadString(app
.hResource
, IDS_HEADER_DATE
, szText
, MAX_LOADSTRING
);
1223 ::ExtTextOut(hDC
, Left
, 0, ETO_CLIPPED
, &rc
, szText
, _tcslen(szText
), 0);
1224 Left
+= m_datewidth
;
1228 LoadString(app
.hResource
, IDS_HEADER_AUTHOR
, szText
, MAX_LOADSTRING
);
1229 ::ExtTextOut(hDC
, Left
, 0, ETO_CLIPPED
, &rc
, szText
, _tcslen(szText
), 0);
1230 Left
+= m_authorwidth
;
1234 LoadString(app
.hResource
, IDS_HEADER_PATH
, szText
, MAX_LOADSTRING
);
1235 ::ExtTextOut(hDC
, Left
, 0, ETO_CLIPPED
, &rc
, szText
, _tcslen(szText
), 0);
1236 Left
+= m_pathwidth
;
1238 LoadString(app
.hResource
, IDS_HEADER_LINE
, szText
, MAX_LOADSTRING
);
1239 ::ExtTextOut(hDC
, Left
, 0, ETO_CLIPPED
, &rc
, szText
, _tcslen(szText
), 0);
1241 ::SelectObject(hDC
, oldfont
);
1245 void CTortoiseGitBlameView::DrawLocatorBar(HDC hDC
)
1250 LONG_PTR line
= SendEditor(SCI_GETFIRSTVISIBLELINE
);
1251 LONG_PTR linesonscreen
= SendEditor(SCI_LINESONSCREEN
);
1253 COLORREF blackColor
= GetSysColor(COLOR_WINDOWTEXT
);
1256 //::GetClientRect(wLocator, &rc);
1257 this->GetClientRect(&rc
);
1259 rc
.right
=LOCATOR_WIDTH
;
1262 LONG height
= rc
.bottom
-rc
.top
;
1263 LONG currentLine
= 0;
1265 // draw the colored bar
1266 for (std::vector
<LONG
>::const_iterator it
= m_ID
.begin(); it
!= m_ID
.end(); ++it
)
1269 // get the line color
1270 COLORREF cr
= InterColor(DWORD(m_regOldLinesColor
), DWORD(m_regNewLinesColor
), (*it
- m_lowestrev
)*100/((m_highestrev
-m_lowestrev
)+1));
1271 if ((currentLine
> line
)&&(currentLine
<= (line
+ linesonscreen
)))
1273 cr
= InterColor(cr
, blackColor
, 10);
1275 SetBkColor(hDC
, cr
);
1277 lineRect
.bottom
= (currentLine
* height
/ m_ID
.size());
1278 ::ExtTextOut(hDC
, 0, 0, ETO_OPAQUE
, &lineRect
, NULL
, 0, NULL
);
1279 Y
= lineRect
.bottom
;
1284 // now draw two lines indicating the scroll position of the source view
1285 SetBkColor(hDC
, blackColor
);
1286 lineRect
.top
= line
* height
/ m_ID
.size();
1287 lineRect
.bottom
= lineRect
.top
+1;
1288 ::ExtTextOut(hDC
, 0, 0, ETO_OPAQUE
, &lineRect
, NULL
, 0, NULL
);
1289 lineRect
.top
= (line
+ linesonscreen
) * height
/ m_ID
.size();
1290 lineRect
.bottom
= lineRect
.top
+1;
1291 ::ExtTextOut(hDC
, 0, 0, ETO_OPAQUE
, &lineRect
, NULL
, 0, NULL
);
1296 void CTortoiseGitBlameView::StringExpand(LPSTR str
)
1301 cPos
= strchr(cPos
, '\n');
1304 memmove(cPos
+1, cPos
, strlen(cPos
)*sizeof(char));
1309 } while (cPos
!= NULL
);
1311 void CTortoiseGitBlameView::StringExpand(LPWSTR str
)
1313 wchar_t * cPos
= str
;
1316 cPos
= wcschr(cPos
, '\n');
1319 memmove(cPos
+1, cPos
, wcslen(cPos
)*sizeof(wchar_t));
1324 } while (cPos
!= NULL
);
1327 // Forward declarations of functions included in this code module:
1328 ATOM
MyRegisterClass(HINSTANCE hResource
);
1329 ATOM
MyRegisterBlameClass(HINSTANCE hResource
);
1330 ATOM
MyRegisterHeaderClass(HINSTANCE hResource
);
1331 ATOM
MyRegisterLocatorClass(HINSTANCE hResource
);
1332 BOOL
InitInstance(HINSTANCE
, int);
1333 LRESULT CALLBACK
WndProc(HWND
, UINT
, WPARAM
, LPARAM
);
1334 LRESULT CALLBACK
WndBlameProc(HWND
, UINT
, WPARAM
, LPARAM
);
1335 LRESULT CALLBACK
WndHeaderProc(HWND
, UINT
, WPARAM
, LPARAM
);
1336 LRESULT CALLBACK
WndLocatorProc(HWND
, UINT
, WPARAM
, LPARAM
);
1337 UINT uFindReplaceMsg
;
1340 int APIENTRY
_tWinMain(HINSTANCE hInstance
,
1341 HINSTANCE
/*hPrevInstance*/,
1345 app
.hInstance
= hInstance
;
1349 if (::LoadLibrary("SciLexer.DLL") == NULL
)
1352 CRegStdWORD loc
= CRegStdWORD(_T("Software\\TortoiseGit\\LanguageID"), 1033);
1356 app
.hResource
= langDLL
.Init(_T("CTortoiseGitBlameView"), langId
);
1357 if (app
.hResource
== NULL
)
1358 app
.hResource
= app
.hInstance
;
1360 // Initialize global strings
1361 LoadString(app
.hResource
, IDS_APP_TITLE
, szTitle
, MAX_LOADSTRING
);
1362 LoadString(app
.hResource
, IDC_TortoiseGitBlameView
, szWindowClass
, MAX_LOADSTRING
);
1363 LoadString(app
.hResource
, IDS_SEARCHNOTFOUND
, searchstringnotfound
, MAX_LOADSTRING
);
1364 MyRegisterClass(app
.hResource
);
1365 MyRegisterBlameClass(app
.hResource
);
1366 MyRegisterHeaderClass(app
.hResource
);
1367 MyRegisterLocatorClass(app
.hResource
);
1369 // Perform application initialization:
1370 if (!InitInstance (app
.hResource
, nCmdShow
))
1376 SecureZeroMemory(szViewtitle
, MAX_PATH
);
1377 SecureZeroMemory(szOrigPath
, MAX_PATH
);
1378 char blamefile
[MAX_PATH
] = {0};
1379 char logfile
[MAX_PATH
] = {0};
1381 CCmdLineParser
parser(lpCmdLine
);
1386 _tcscpy_s(blamefile
, MAX_PATH
, __argv
[1]);
1390 _tcscpy_s(logfile
, MAX_PATH
, __argv
[2]);
1394 _tcscpy_s(szViewtitle
, MAX_PATH
, __argv
[3]);
1395 if (parser
.HasVal(_T("revrange")))
1397 _tcscat_s(szViewtitle
, MAX_PATH
, _T(" : "));
1398 _tcscat_s(szViewtitle
, MAX_PATH
, parser
.GetVal(_T("revrange")));
1401 if ((_tcslen(blamefile
)==0) || parser
.HasKey(_T("?")) || parser
.HasKey(_T("help")))
1403 TCHAR szInfo
[MAX_LOADSTRING
];
1404 LoadString(app
.hResource
, IDS_COMMANDLINE_INFO
, szInfo
, MAX_LOADSTRING
);
1405 MessageBox(NULL
, szInfo
, _T("CTortoiseGitBlameView"), MB_ICONERROR
);
1410 if ( parser
.HasKey(_T("path")) )
1412 _tcscpy_s(szOrigPath
, MAX_PATH
, parser
.GetVal(_T("path")));
1414 app
.bIgnoreEOL
= parser
.HasKey(_T("ignoreeol"));
1415 app
.bIgnoreSpaces
= parser
.HasKey(_T("ignorespaces"));
1416 app
.bIgnoreAllSpaces
= parser
.HasKey(_T("ignoreallspaces"));
1418 app
.SendEditor(SCI_SETCODEPAGE
, GetACP());
1419 app
.OpenFile(blamefile
);
1420 if (_tcslen(logfile
)>0)
1421 app
.OpenLogFile(logfile
);
1423 if (parser
.HasKey(_T("line")))
1425 app
.GotoLine(parser
.GetLongVal(_T("line")));
1428 CheckMenuItem(GetMenu(app
.wMain
), ID_VIEW_COLORAGEOFLINES
, MF_CHECKED
|MF_BYCOMMAND
);
1431 hAccelTable
= LoadAccelerators(app
.hResource
, (LPCTSTR
)IDC_TortoiseGitBlameView
);
1437 going
= GetMessage(&msg
, NULL
, 0, 0);
1438 if (app
.currentDialog
&& going
)
1440 if (!IsDialogMessage(app
.currentDialog
, &msg
))
1442 if (TranslateAccelerator(msg
.hwnd
, hAccelTable
, &msg
) == 0)
1444 TranslateMessage(&msg
);
1445 DispatchMessage(&msg
);
1451 if (TranslateAccelerator(app
.wMain
, hAccelTable
, &msg
) == 0)
1453 TranslateMessage(&msg
);
1454 DispatchMessage(&msg
);
1462 ATOM
MyRegisterClass(HINSTANCE hResource
)
1466 wcex
.cbSize
= sizeof(WNDCLASSEX
);
1468 wcex
.style
= CS_HREDRAW
| CS_VREDRAW
;
1469 wcex
.lpfnWndProc
= (WNDPROC
)WndProc
;
1470 wcex
.cbClsExtra
= 0;
1471 wcex
.cbWndExtra
= 0;
1472 wcex
.hInstance
= hResource
;
1473 wcex
.hIcon
= LoadIcon(hResource
, (LPCTSTR
)IDI_TortoiseGitBlameView
);
1474 wcex
.hCursor
= LoadCursor(NULL
, IDC_ARROW
);
1475 wcex
.hbrBackground
= (HBRUSH
)(COLOR_WINDOW
+1);
1476 wcex
.lpszMenuName
= (LPCTSTR
)IDC_TortoiseGitBlameView
;
1477 wcex
.lpszClassName
= szWindowClass
;
1478 wcex
.hIconSm
= LoadIcon(wcex
.hInstance
, (LPCTSTR
)IDI_SMALL
);
1480 return RegisterClassEx(&wcex
);
1483 ATOM
MyRegisterBlameClass(HINSTANCE hResource
)
1487 wcex
.cbSize
= sizeof(WNDCLASSEX
);
1489 wcex
.style
= CS_HREDRAW
| CS_VREDRAW
;
1490 wcex
.lpfnWndProc
= (WNDPROC
)WndBlameProc
;
1491 wcex
.cbClsExtra
= 0;
1492 wcex
.cbWndExtra
= 0;
1493 wcex
.hInstance
= hResource
;
1494 wcex
.hIcon
= LoadIcon(hResource
, (LPCTSTR
)IDI_TortoiseGitBlameView
);
1495 wcex
.hCursor
= LoadCursor(NULL
, IDC_ARROW
);
1496 wcex
.hbrBackground
= (HBRUSH
)(COLOR_WINDOW
+1);
1497 wcex
.lpszMenuName
= 0;
1498 wcex
.lpszClassName
= _T("TortoiseGitBlameViewBlame");
1499 wcex
.hIconSm
= LoadIcon(wcex
.hInstance
, (LPCTSTR
)IDI_SMALL
);
1501 return RegisterClassEx(&wcex
);
1504 ATOM
MyRegisterHeaderClass(HINSTANCE hResource
)
1508 wcex
.cbSize
= sizeof(WNDCLASSEX
);
1510 wcex
.style
= CS_HREDRAW
| CS_VREDRAW
;
1511 wcex
.lpfnWndProc
= (WNDPROC
)WndHeaderProc
;
1512 wcex
.cbClsExtra
= 0;
1513 wcex
.cbWndExtra
= 0;
1514 wcex
.hInstance
= hResource
;
1515 wcex
.hIcon
= LoadIcon(hResource
, (LPCTSTR
)IDI_TortoiseGitBlameView
);
1516 wcex
.hCursor
= LoadCursor(NULL
, IDC_ARROW
);
1517 wcex
.hbrBackground
= (HBRUSH
)(COLOR_BTNFACE
+1);
1518 wcex
.lpszMenuName
= 0;
1519 wcex
.lpszClassName
= _T("TortoiseGitBlameViewHeader");
1520 wcex
.hIconSm
= LoadIcon(wcex
.hInstance
, (LPCTSTR
)IDI_SMALL
);
1522 return RegisterClassEx(&wcex
);
1525 ATOM
MyRegisterLocatorClass(HINSTANCE hResource
)
1529 wcex
.cbSize
= sizeof(WNDCLASSEX
);
1531 wcex
.style
= CS_HREDRAW
| CS_VREDRAW
;
1532 wcex
.lpfnWndProc
= (WNDPROC
)WndLocatorProc
;
1533 wcex
.cbClsExtra
= 0;
1534 wcex
.cbWndExtra
= 0;
1535 wcex
.hInstance
= hResource
;
1536 wcex
.hIcon
= LoadIcon(hResource
, (LPCTSTR
)IDI_TortoiseGitBlameView
);
1537 wcex
.hCursor
= LoadCursor(NULL
, IDC_ARROW
);
1538 wcex
.hbrBackground
= (HBRUSH
)(COLOR_WINDOW
+1);
1539 wcex
.lpszMenuName
= 0;
1540 wcex
.lpszClassName
= _T("TortoiseGitBlameViewLocator");
1541 wcex
.hIconSm
= LoadIcon(wcex
.hInstance
, (LPCTSTR
)IDI_SMALL
);
1543 return RegisterClassEx(&wcex
);
1546 BOOL
InitInstance(HINSTANCE hResource
, int nCmdShow
)
1548 app
.wMain
= CreateWindow(szWindowClass
, szTitle
, WS_OVERLAPPEDWINDOW
,
1549 CW_USEDEFAULT
, 0, CW_USEDEFAULT
, 0, NULL
, NULL
, hResource
, NULL
);
1556 CRegStdWORD
pos(_T("Software\\TortoiseGit\\TBlamePos"), 0);
1557 CRegStdWORD
width(_T("Software\\TortoiseGit\\TBlameSize"), 0);
1558 CRegStdWORD
state(_T("Software\\TortoiseGit\\TBlameState"), 0);
1559 if (DWORD(pos
) && DWORD(width
))
1562 rc
.left
= LOWORD(DWORD(pos
));
1563 rc
.top
= HIWORD(DWORD(pos
));
1564 rc
.right
= rc
.left
+ LOWORD(DWORD(width
));
1565 rc
.bottom
= rc
.top
+ HIWORD(DWORD(width
));
1566 HMONITOR hMon
= MonitorFromRect(&rc
, MONITOR_DEFAULTTONULL
);
1569 // only restore the window position if the monitor is valid
1570 MoveWindow(app
.wMain
, LOWORD(DWORD(pos
)), HIWORD(DWORD(pos
)),
1571 LOWORD(DWORD(width
)), HIWORD(DWORD(width
)), FALSE
);
1574 if (DWORD(state
) == SW_MAXIMIZE
)
1575 ShowWindow(app
.wMain
, SW_MAXIMIZE
);
1577 ShowWindow(app
.wMain
, nCmdShow
);
1578 UpdateWindow(app
.wMain
);
1580 //Create the tooltips
1582 INITCOMMONCONTROLSEX iccex
;
1583 app
.hwndTT
; // handle to the ToolTip control
1585 RECT rect
; // for client area coordinates
1586 iccex
.dwICC
= ICC_WIN95_CLASSES
;
1587 iccex
.dwSize
= sizeof(INITCOMMONCONTROLSEX
);
1588 InitCommonControlsEx(&iccex
);
1590 /* CREATE A TOOLTIP WINDOW */
1591 app
.hwndTT
= CreateWindowEx(WS_EX_TOPMOST
,
1594 WS_POPUP
| TTS_NOPREFIX
| TTS_ALWAYSTIP
,
1605 SetWindowPos(app
.hwndTT
,
1611 SWP_NOMOVE
| SWP_NOSIZE
| SWP_NOACTIVATE
);
1613 /* GET COORDINATES OF THE MAIN CLIENT AREA */
1614 GetClientRect (app
.wBlame
, &rect
);
1616 /* INITIALIZE MEMBERS OF THE TOOLINFO STRUCTURE */
1617 ti
.cbSize
= sizeof(TOOLINFO
);
1618 ti
.uFlags
= TTF_TRACK
| TTF_ABSOLUTE
;//TTF_SUBCLASS | TTF_PARSELINKS;
1619 ti
.hwnd
= app
.wBlame
;
1620 ti
.hinst
= app
.hResource
;
1622 ti
.lpszText
= LPSTR_TEXTCALLBACK
;
1623 // ToolTip control will cover the whole window
1624 ti
.rect
.left
= rect
.left
;
1625 ti
.rect
.top
= rect
.top
;
1626 ti
.rect
.right
= rect
.right
;
1627 ti
.rect
.bottom
= rect
.bottom
;
1629 /* SEND AN ADDTOOL MESSAGE TO THE TOOLTIP CONTROL WINDOW */
1630 SendMessage(app
.hwndTT
, TTM_ADDTOOL
, 0, (LPARAM
) (LPTOOLINFO
) &ti
);
1631 SendMessage(app
.hwndTT
, TTM_SETMAXTIPWIDTH
, 0, 600);
1632 //SendMessage(app.hwndTT, TTM_SETDELAYTIME, TTDT_AUTOPOP, MAKELONG(50000, 0));
1633 //SendMessage(app.hwndTT, TTM_SETDELAYTIME, TTDT_RESHOW, MAKELONG(1000, 0));
1635 uFindReplaceMsg
= RegisterWindowMessage(FINDMSGSTRING
);
1640 void CTortoiseGitBlameView::InitSize()
1645 ::GetClientRect(wMain
, &rc
);
1646 ::SetWindowPos(wHeader
, 0, rc
.left
, rc
.top
, rc
.right
-rc
.left
, HEADER_HEIGHT
, 0);
1647 rc
.top
+= HEADER_HEIGHT
;
1648 blamerc
.left
= rc
.left
;
1649 blamerc
.top
= rc
.top
;
1650 LONG w
= GetBlameWidth();
1651 blamerc
.right
= w
> abs(rc
.right
- rc
.left
) ? rc
.right
: w
+ rc
.left
;
1652 blamerc
.bottom
= rc
.bottom
;
1653 sourcerc
.left
= blamerc
.right
;
1654 sourcerc
.top
= rc
.top
;
1655 sourcerc
.bottom
= rc
.bottom
;
1656 sourcerc
.right
= rc
.right
;
1659 ::OffsetRect(&blamerc
, LOCATOR_WIDTH
, 0);
1660 ::OffsetRect(&sourcerc
, LOCATOR_WIDTH
, 0);
1661 sourcerc
.right
-= LOCATOR_WIDTH
;
1663 ::InvalidateRect(wMain
, NULL
, FALSE
);
1664 ::SetWindowPos(m_wEditor
, 0, sourcerc
.left
, sourcerc
.top
, sourcerc
.right
- sourcerc
.left
, sourcerc
.bottom
- sourcerc
.top
, 0);
1665 ::SetWindowPos(wBlame
, 0, blamerc
.left
, blamerc
.top
, blamerc
.right
- blamerc
.left
, blamerc
.bottom
- blamerc
.top
, 0);
1667 ::SetWindowPos(wLocator
, 0, 0, blamerc
.top
, LOCATOR_WIDTH
, blamerc
.bottom
- blamerc
.top
, SWP_SHOWWINDOW
);
1669 ::ShowWindow(wLocator
, SW_HIDE
);
1673 LRESULT CALLBACK
WndProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
1675 if (message
== uFindReplaceMsg
)
1677 LPFINDREPLACE lpfr
= (LPFINDREPLACE
)lParam
;
1679 // If the FR_DIALOGTERM flag is set,
1680 // invalidate the handle identifying the dialog box.
1681 if (lpfr
->Flags
& FR_DIALOGTERM
)
1683 app
.currentDialog
= NULL
;
1686 if (lpfr
->Flags
& FR_FINDNEXT
)
1688 app
.DoSearch(lpfr
->lpstrFindWhat
, lpfr
->Flags
);
1695 app
.m_wEditor
= ::CreateWindow(
1698 WS_CHILD
| WS_VSCROLL
| WS_HSCROLL
| WS_CLIPCHILDREN
,
1705 app
.InitialiseEditor();
1706 ::ShowWindow(app
.m_wEditor
, SW_SHOW
);
1707 ::SetFocus(app
.m_wEditor
);
1708 app
.wBlame
= ::CreateWindow(
1709 _T("TortoiseGitBlameViewBlame"),
1711 WS_CHILD
| WS_CLIPCHILDREN
,
1718 ::ShowWindow(app
.wBlame
, SW_SHOW
);
1719 app
.wHeader
= ::CreateWindow(
1720 _T("TortoiseGitBlameViewHeader"),
1722 WS_CHILD
| WS_CLIPCHILDREN
| WS_BORDER
,
1729 ::ShowWindow(app
.wHeader
, SW_SHOW
);
1730 app
.wLocator
= ::CreateWindow(
1731 _T("TortoiseGitBlameViewLocator"),
1733 WS_CHILD
| WS_CLIPCHILDREN
| WS_BORDER
,
1740 ::ShowWindow(app
.wLocator
, SW_SHOW
);
1751 app
.Command(LOWORD(wParam
));
1754 app
.Notify(reinterpret_cast<SCNotification
*>(lParam
));
1761 CRegStdWORD
pos(_T("Software\\TortoiseGit\\TBlamePos"), 0);
1762 CRegStdWORD
width(_T("Software\\TortoiseGit\\TBlameSize"), 0);
1763 CRegStdWORD
state(_T("Software\\TortoiseGit\\TBlameState"), 0);
1765 GetWindowRect(app
.wMain
, &rc
);
1766 if ((rc
.left
>= 0)&&(rc
.top
>= 0))
1768 pos
= MAKELONG(rc
.left
, rc
.top
);
1769 width
= MAKELONG(rc
.right
-rc
.left
, rc
.bottom
-rc
.top
);
1771 WINDOWPLACEMENT wp
= {0};
1772 wp
.length
= sizeof(WINDOWPLACEMENT
);
1773 GetWindowPlacement(app
.wMain
, &wp
);
1775 ::DestroyWindow(app
.m_wEditor
);
1776 ::PostQuitMessage(0);
1780 ::SetFocus(app
.wBlame
);
1783 return DefWindowProc(hWnd
, message
, wParam
, lParam
);
1788 LRESULT CALLBACK
WndBlameProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
1791 TRACKMOUSEEVENT mevt
;
1798 hDC
= BeginPaint(app
.wBlame
, &ps
);
1800 EndPaint(app
.wBlame
, &ps
);
1803 app
.Command(LOWORD(wParam
));
1806 switch (((LPNMHDR
)lParam
)->code
)
1808 case TTN_GETDISPINFO
:
1810 LPNMHDR pNMHDR
= (LPNMHDR
)lParam
;
1811 NMTTDISPINFOA
* pTTTA
= (NMTTDISPINFOA
*)pNMHDR
;
1812 NMTTDISPINFOW
* pTTTW
= (NMTTDISPINFOW
*)pNMHDR
;
1814 DWORD ptW
= GetMessagePos();
1815 point
.x
= GET_X_LPARAM(ptW
);
1816 point
.y
= GET_Y_LPARAM(ptW
);
1817 ::ScreenToClient(app
.wBlame
, &point
);
1818 LONG_PTR line
= app
.SendEditor(SCI_GETFIRSTVISIBLELINE
);
1819 LONG_PTR height
= app
.SendEditor(SCI_TEXTHEIGHT
);
1820 line
= line
+ (point
.y
/height
);
1821 if (line
>= (LONG
)app
.revs
.size())
1825 LONG rev
= app
.revs
[line
];
1826 if (line
>= (LONG
)app
.revs
.size())
1829 SecureZeroMemory(app
.m_szTip
, sizeof(app
.m_szTip
));
1830 SecureZeroMemory(app
.m_wszTip
, sizeof(app
.m_wszTip
));
1831 std::map
<LONG
, CString
>::iterator iter
;
1832 if ((iter
= app
.logmessages
.find(rev
)) != app
.logmessages
.end())
1837 msg
+= app
.authors
[line
];
1841 if (!ShowAuthor
) msg
+= " ";
1842 msg
+= app
.dates
[line
];
1844 if (!ShowAuthor
|| !ShowDate
)
1846 msg
+= iter
->second
;
1847 // an empty tooltip string will deactivate the tooltips,
1848 // which means we must make sure that the tooltip won't
1852 if (pNMHDR
->code
== TTN_NEEDTEXTA
)
1854 lstrcpyn(app
.m_szTip
, msg
.c_str(), MAX_LOG_LENGTH
*2);
1855 app
.StringExpand(app
.m_szTip
);
1856 pTTTA
->lpszText
= app
.m_szTip
;
1860 pTTTW
->lpszText
= app
.m_wszTip
;
1861 ::MultiByteToWideChar( CP_ACP
, 0, msg
.c_str(), min(msg
.size(), MAX_LOG_LENGTH
*2), app
.m_wszTip
, MAX_LOG_LENGTH
*2);
1862 app
.StringExpand(app
.m_wszTip
);
1874 app
.m_mouserev
= -2;
1875 app
.m_mouseauthor
.clear();
1876 app
.ttVisible
= FALSE
;
1877 SendMessage(app
.hwndTT
, TTM_TRACKACTIVATE
, FALSE
, 0);
1878 ::InvalidateRect(app
.wBlame
, NULL
, FALSE
);
1882 mevt
.cbSize
= sizeof(TRACKMOUSEEVENT
);
1883 mevt
.dwFlags
= TME_LEAVE
;
1884 mevt
.dwHoverTime
= HOVER_DEFAULT
;
1885 mevt
.hwndTrack
= app
.wBlame
;
1886 ::TrackMouseEvent(&mevt
);
1887 POINT pt
= {((int)(short)LOWORD(lParam
)), ((int)(short)HIWORD(lParam
))};
1888 ClientToScreen(app
.wBlame
, &pt
);
1891 SendMessage(app
.hwndTT
, TTM_TRACKPOSITION
, 0, MAKELONG(pt
.x
, pt
.y
));
1895 ti
.cbSize
= sizeof(TOOLINFO
);
1896 ti
.hwnd
= app
.wBlame
;
1898 SendMessage(app
.hwndTT
, TTM_TRACKACTIVATE
, TRUE
, (LPARAM
)&ti
);
1900 int y
= ((int)(short)HIWORD(lParam
));
1901 LONG_PTR line
= app
.SendEditor(SCI_GETFIRSTVISIBLELINE
);
1902 LONG_PTR height
= app
.SendEditor(SCI_TEXTHEIGHT
);
1903 line
= line
+ (y
/height
);
1904 app
.ttVisible
= (line
< (LONG
)app
.revs
.size());
1905 if ( app
.ttVisible
)
1907 if (app
.authors
[line
].compare(app
.m_mouseauthor
) != 0)
1909 app
.m_mouseauthor
= app
.authors
[line
];
1911 if (app
.revs
[line
] != app
.m_mouserev
)
1913 app
.m_mouserev
= app
.revs
[line
];
1914 ::InvalidateRect(app
.wBlame
, NULL
, FALSE
);
1915 SendMessage(app
.hwndTT
, TTM_UPDATE
, 0, 0);
1920 case WM_RBUTTONDOWN
:
1922 case WM_LBUTTONDOWN
:
1926 ::SetFocus(app
.wBlame
);
1927 app
.SendEditor(SCI_GRABFOCUS
);
1929 case WM_CONTEXTMENU
:
1931 if (app
.m_selectedrev
<= 0)
1933 int xPos
= GET_X_LPARAM(lParam
);
1934 int yPos
= GET_Y_LPARAM(lParam
);
1935 if ((xPos
< 0)||(yPos
< 0))
1937 // requested from keyboard, not mouse pointer
1938 // use the center of the window
1940 GetClientRect(app
.wBlame
, &rect
);
1941 xPos
= rect
.right
-rect
.left
;
1942 yPos
= rect
.bottom
-rect
.top
;
1944 HMENU hMenu
= LoadMenu(app
.hResource
, MAKEINTRESOURCE(IDR_BLAMEPOPUP
));
1945 HMENU hPopMenu
= GetSubMenu(hMenu
, 0);
1947 if ( _tcslen(szOrigPath
)==0 )
1949 // Without knowing the original path we cannot blame the previous revision
1950 // because we don't know which filename to pass to tortoiseproc.
1951 EnableMenuItem(hPopMenu
,ID_BLAME_PREVIOUS_REVISION
, MF_DISABLED
|MF_GRAYED
);
1954 TrackPopupMenu(hPopMenu
, TPM_LEFTALIGN
| TPM_RIGHTBUTTON
, xPos
, yPos
, 0, app
.wBlame
, NULL
);
1959 return DefWindowProc(hWnd
, message
, wParam
, lParam
);
1964 LRESULT CALLBACK
WndHeaderProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
1973 hDC
= BeginPaint(app
.wHeader
, &ps
);
1974 app
.DrawHeader(hDC
);
1975 EndPaint(app
.wHeader
, &ps
);
1984 return DefWindowProc(hWnd
, message
, wParam
, lParam
);
1989 LRESULT CALLBACK
WndLocatorProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
1996 hDC
= BeginPaint(app
.wLocator
, &ps
);
1997 app
.DrawLocatorBar(hDC
);
1998 EndPaint(app
.wLocator
, &ps
);
2000 case WM_LBUTTONDOWN
:
2002 if (wParam
& MK_LBUTTON
)
2005 ::GetClientRect(hWnd
, &rect
);
2006 int nLine
= HIWORD(lParam
)*app
.revs
.size()/(rect
.bottom
-rect
.top
);
2010 app
.ScrollToLine(nLine
);
2014 return DefWindowProc(hWnd
, message
, wParam
, lParam
);
2020 void CTortoiseGitBlameView::SetupLexer(CString filename
)
2024 //const char * lineptr = _tcsrchr(filename, '.');
2025 int start
=filename
.ReverseFind(_T('.'));
2028 //_tcscpy_s(line, 20, lineptr+1);
2029 //_tcslwr_s(line, 20);
2030 CString ext
=filename
.Right(filename
.GetLength()-start
-1);
2031 line
=ext
.GetBuffer();
2033 if ((_tcscmp(line
, _T("py"))==0)||
2034 (_tcscmp(line
, _T("pyw"))==0)||
2035 (_tcscmp(line
, _T("pyw"))==0))
2037 SendEditor(SCI_SETLEXER
, SCLEX_PYTHON
);
2038 SendEditor(SCI_SETKEYWORDS
, 0, (LPARAM
)(m_TextView
.StringForControl(_T("and assert break class continue def del elif \
2039 else except exec finally for from global if import in is lambda None \
2040 not or pass print raise return try while yield")).GetBuffer()));
2041 SetAStyle(SCE_P_DEFAULT
, black
);
2042 SetAStyle(SCE_P_COMMENTLINE
, darkGreen
);
2043 SetAStyle(SCE_P_NUMBER
, RGB(0, 0x80, 0x80));
2044 SetAStyle(SCE_P_STRING
, RGB(0, 0, 0x80));
2045 SetAStyle(SCE_P_CHARACTER
, RGB(0, 0, 0x80));
2046 SetAStyle(SCE_P_WORD
, RGB(0x80, 0, 0x80));
2047 SetAStyle(SCE_P_TRIPLE
, black
);
2048 SetAStyle(SCE_P_TRIPLEDOUBLE
, black
);
2049 SetAStyle(SCE_P_CLASSNAME
, darkBlue
);
2050 SetAStyle(SCE_P_DEFNAME
, darkBlue
);
2051 SetAStyle(SCE_P_OPERATOR
, darkBlue
);
2052 SetAStyle(SCE_P_IDENTIFIER
, darkBlue
);
2053 SetAStyle(SCE_P_COMMENTBLOCK
, darkGreen
);
2054 SetAStyle(SCE_P_STRINGEOL
, red
);
2056 if ((_tcscmp(line
, _T("c"))==0)||
2057 (_tcscmp(line
, _T("cc"))==0)||
2058 (_tcscmp(line
, _T("cpp"))==0)||
2059 (_tcscmp(line
, _T("cxx"))==0)||
2060 (_tcscmp(line
, _T("h"))==0)||
2061 (_tcscmp(line
, _T("hh"))==0)||
2062 (_tcscmp(line
, _T("hpp"))==0)||
2063 (_tcscmp(line
, _T("hxx"))==0)||
2064 (_tcscmp(line
, _T("dlg"))==0)||
2065 (_tcscmp(line
, _T("mak"))==0))
2067 SendEditor(SCI_SETLEXER
, SCLEX_CPP
);
2068 SendEditor(SCI_SETKEYWORDS
, 0, (LPARAM
)(m_TextView
.StringForControl(_T("and and_eq asm auto bitand bitor bool break \
2069 case catch char class compl const const_cast continue \
2070 default delete do double dynamic_cast else enum explicit export extern false float for \
2071 friend goto if inline int long mutable namespace new not not_eq \
2072 operator or or_eq private protected public \
2073 register reinterpret_cast return short signed sizeof static static_cast struct switch \
2074 template this throw true try typedef typeid typename union unsigned using \
2075 virtual void volatile wchar_t while xor xor_eq")).GetBuffer()));
2076 SendEditor(SCI_SETKEYWORDS
, 3, (LPARAM
)(m_TextView
.StringForControl(_T("a addindex addtogroup anchor arg attention \
2077 author b brief bug c class code date def defgroup deprecated dontinclude \
2078 e em endcode endhtmlonly endif endlatexonly endlink endverbatim enum example exception \
2079 f$ f[ f] file fn hideinitializer htmlinclude htmlonly \
2080 if image include ingroup internal invariant interface latexonly li line link \
2081 mainpage name namespace nosubgrouping note overload \
2082 p page par param post pre ref relates remarks return retval \
2083 sa section see showinitializer since skip skipline struct subsection \
2084 test throw todo typedef union until \
2085 var verbatim verbinclude version warning weakgroup $ @ \\ & < > # { }")).GetBuffer()));
2088 if (_tcscmp(line
, _T("cs"))==0)
2090 SendEditor(SCI_SETLEXER
, SCLEX_CPP
);
2091 SendEditor(SCI_SETKEYWORDS
, 0, (LPARAM
)(m_TextView
.StringForControl(_T("abstract as base bool break byte case catch char checked class \
2092 const continue decimal default delegate do double else enum \
2093 event explicit extern false finally fixed float for foreach goto if \
2094 implicit in int interface internal is lock long namespace new null \
2095 object operator out override params private protected public \
2096 readonly ref return sbyte sealed short sizeof stackalloc static \
2097 string struct switch this throw true try typeof uint ulong \
2098 unchecked unsafe ushort using virtual void while")).GetBuffer()));
2101 if ((_tcscmp(line
, _T("rc"))==0)||
2102 (_tcscmp(line
, _T("rc2"))==0))
2104 SendEditor(SCI_SETLEXER
, SCLEX_CPP
);
2105 SendEditor(SCI_SETKEYWORDS
, 0, (LPARAM
)(m_TextView
.StringForControl(_T("ACCELERATORS ALT AUTO3STATE AUTOCHECKBOX AUTORADIOBUTTON \
2106 BEGIN BITMAP BLOCK BUTTON CAPTION CHARACTERISTICS CHECKBOX CLASS \
2107 COMBOBOX CONTROL CTEXT CURSOR DEFPUSHBUTTON DIALOG DIALOGEX DISCARDABLE \
2108 EDITTEXT END EXSTYLE FONT GROUPBOX ICON LANGUAGE LISTBOX LTEXT \
2109 MENU MENUEX MENUITEM MESSAGETABLE POPUP \
2110 PUSHBUTTON RADIOBUTTON RCDATA RTEXT SCROLLBAR SEPARATOR SHIFT STATE3 \
2111 STRINGTABLE STYLE TEXTINCLUDE VALUE VERSION VERSIONINFO VIRTKEY")).GetBuffer()));
2114 if ((_tcscmp(line
, _T("idl"))==0)||
2115 (_tcscmp(line
, _T("odl"))==0))
2117 SendEditor(SCI_SETLEXER
, SCLEX_CPP
);
2118 SendEditor(SCI_SETKEYWORDS
, 0, (LPARAM
)(m_TextView
.StringForControl(_T("aggregatable allocate appobject arrays async async_uuid \
2120 bindable boolean broadcast byte byte_count \
2121 call_as callback char coclass code comm_status \
2122 const context_handle context_handle_noserialize \
2123 context_handle_serialize control cpp_quote custom \
2124 decode default defaultbind defaultcollelem \
2125 defaultvalue defaultvtable dispinterface displaybind dllname \
2127 enable_allocate encode endpoint entry enum error_status_t \
2129 fault_status first_is float \
2130 handle_t heap helpcontext helpfile helpstring \
2131 helpstringcontext helpstringdll hidden hyper \
2132 id idempotent ignore iid_as iid_is immediatebind implicit_handle \
2133 import importlib in include in_line int __int64 __int3264 interface \
2134 last_is lcid length_is library licensed local long \
2135 max_is maybe message methods midl_pragma \
2136 midl_user_allocate midl_user_free min_is module ms_union \
2137 ncacn_at_dsp ncacn_dnet_nsp ncacn_http ncacn_ip_tcp \
2138 ncacn_nb_ipx ncacn_nb_nb ncacn_nb_tcp ncacn_np \
2139 ncacn_spx ncacn_vns_spp ncadg_ip_udp ncadg_ipx ncadg_mq \
2140 ncalrpc nocode nonbrowsable noncreatable nonextensible notify \
2141 object odl oleautomation optimize optional out out_of_line \
2142 pipe pointer_default pragma properties propget propput propputref \
2144 range readonly ref represent_as requestedit restricted retval \
2145 shape short signed size_is small source strict_context_handle \
2146 string struct switch switch_is switch_type \
2147 transmit_as typedef \
2148 uidefault union unique unsigned user_marshal usesgetlasterror uuid \
2149 v1_enum vararg version void wchar_t wire_marshal")).GetBuffer()));
2152 if (_tcscmp(line
, _T("java"))==0)
2154 SendEditor(SCI_SETLEXER
, SCLEX_CPP
);
2155 SendEditor(SCI_SETKEYWORDS
, 0, (LPARAM
)(m_TextView
.StringForControl(_T("abstract assert boolean break byte case catch char class \
2156 const continue default do double else extends final finally float for future \
2157 generic goto if implements import inner instanceof int interface long \
2158 native new null outer package private protected public rest \
2159 return short static super switch synchronized this throw throws \
2160 transient try var void volatile while")).GetBuffer()));
2163 if (_tcscmp(line
, _T("js"))==0)
2165 SendEditor(SCI_SETLEXER
, SCLEX_CPP
);
2166 SendEditor(SCI_SETKEYWORDS
, 0, (LPARAM
)(m_TextView
.StringForControl(_T("abstract boolean break byte case catch char class \
2167 const continue debugger default delete do double else enum export extends \
2168 final finally float for function goto if implements import in instanceof \
2169 int interface long native new package private protected public \
2170 return short static super switch synchronized this throw throws \
2171 transient try typeof var void volatile while with")).GetBuffer()));
2174 if ((_tcscmp(line
, _T("pas"))==0)||
2175 (_tcscmp(line
, _T("dpr"))==0)||
2176 (_tcscmp(line
, _T("pp"))==0))
2178 SendEditor(SCI_SETLEXER
, SCLEX_PASCAL
);
2179 SendEditor(SCI_SETKEYWORDS
, 0, (LPARAM
)(m_TextView
.StringForControl(_T("and array as begin case class const constructor \
2180 destructor div do downto else end except file finally \
2181 for function goto if implementation in inherited \
2182 interface is mod not object of on or packed \
2183 procedure program property raise record repeat \
2184 set shl shr then threadvar to try type unit \
2185 until uses var while with xor")).GetBuffer()));
2188 if ((_tcscmp(line
, _T("as"))==0)||
2189 (_tcscmp(line
, _T("asc"))==0)||
2190 (_tcscmp(line
, _T("jsfl"))==0))
2192 SendEditor(SCI_SETLEXER
, SCLEX_CPP
);
2193 SendEditor(SCI_SETKEYWORDS
, 0, (LPARAM
)(m_TextView
.StringForControl(_T("add and break case catch class continue default delete do \
2194 dynamic else eq extends false finally for function ge get gt if implements import in \
2195 instanceof interface intrinsic le lt ne new not null or private public return \
2196 set static super switch this throw true try typeof undefined var void while with")).GetBuffer()));
2197 SendEditor(SCI_SETKEYWORDS
, 1, (LPARAM
)(m_TextView
.StringForControl(_T("Array Arguments Accessibility Boolean Button Camera Color \
2198 ContextMenu ContextMenuItem Date Error Function Key LoadVars LocalConnection Math \
2199 Microphone Mouse MovieClip MovieClipLoader NetConnection NetStream Number Object \
2200 PrintJob Selection SharedObject Sound Stage String StyleSheet System TextField \
2201 TextFormat TextSnapshot Video Void XML XMLNode XMLSocket \
2202 _accProps _focusrect _global _highquality _parent _quality _root _soundbuftime \
2203 arguments asfunction call capabilities chr clearInterval duplicateMovieClip \
2204 escape eval fscommand getProperty getTimer getURL getVersion gotoAndPlay gotoAndStop \
2205 ifFrameLoaded Infinity -Infinity int isFinite isNaN length loadMovie loadMovieNum \
2206 loadVariables loadVariablesNum maxscroll mbchr mblength mbord mbsubstring MMExecute \
2207 NaN newline nextFrame nextScene on onClipEvent onUpdate ord parseFloat parseInt play \
2208 prevFrame prevScene print printAsBitmap printAsBitmapNum printNum random removeMovieClip \
2209 scroll set setInterval setProperty startDrag stop stopAllSounds stopDrag substring \
2210 targetPath tellTarget toggleHighQuality trace unescape unloadMovie unLoadMovieNum updateAfterEvent")).GetBuffer()));
2213 if ((_tcscmp(line
, _T("html"))==0)||
2214 (_tcscmp(line
, _T("htm"))==0)||
2215 (_tcscmp(line
, _T("shtml"))==0)||
2216 (_tcscmp(line
, _T("htt"))==0)||
2217 (_tcscmp(line
, _T("xml"))==0)||
2218 (_tcscmp(line
, _T("asp"))==0)||
2219 (_tcscmp(line
, _T("xsl"))==0)||
2220 (_tcscmp(line
, _T("php"))==0)||
2221 (_tcscmp(line
, _T("xhtml"))==0)||
2222 (_tcscmp(line
, _T("phtml"))==0)||
2223 (_tcscmp(line
, _T("cfm"))==0)||
2224 (_tcscmp(line
, _T("tpl"))==0)||
2225 (_tcscmp(line
, _T("dtd"))==0)||
2226 (_tcscmp(line
, _T("hta"))==0)||
2227 (_tcscmp(line
, _T("htd"))==0)||
2228 (_tcscmp(line
, _T("wxs"))==0))
2230 SendEditor(SCI_SETLEXER
, SCLEX_HTML
);
2231 SendEditor(SCI_SETSTYLEBITS
, 7);
2232 SendEditor(SCI_SETKEYWORDS
, 0, (LPARAM
)(m_TextView
.StringForControl(_T("a abbr acronym address applet area b base basefont \
2233 bdo big blockquote body br button caption center \
2234 cite code col colgroup dd del dfn dir div dl dt em \
2235 fieldset font form frame frameset h1 h2 h3 h4 h5 h6 \
2236 head hr html i iframe img input ins isindex kbd label \
2237 legend li link map menu meta noframes noscript \
2238 object ol optgroup option p param pre q s samp \
2239 script select small span strike strong style sub sup \
2240 table tbody td textarea tfoot th thead title tr tt u ul \
2241 var xml xmlns abbr accept-charset accept accesskey action align alink \
2242 alt archive axis background bgcolor border \
2243 cellpadding cellspacing char charoff charset checked cite \
2244 class classid clear codebase codetype color cols colspan \
2245 compact content coords \
2246 data datafld dataformatas datapagesize datasrc datetime \
2247 declare defer dir disabled enctype event \
2248 face for frame frameborder \
2249 headers height href hreflang hspace http-equiv \
2250 id ismap label lang language leftmargin link longdesc \
2251 marginwidth marginheight maxlength media method multiple \
2252 name nohref noresize noshade nowrap \
2253 object onblur onchange onclick ondblclick onfocus \
2254 onkeydown onkeypress onkeyup onload onmousedown \
2255 onmousemove onmouseover onmouseout onmouseup \
2256 onreset onselect onsubmit onunload \
2257 profile prompt readonly rel rev rows rowspan rules \
2258 scheme scope selected shape size span src standby start style \
2259 summary tabindex target text title topmargin type usemap \
2260 valign value valuetype version vlink vspace width \
2261 text password checkbox radio submit reset \
2262 file hidden image")).GetBuffer()));
2263 SendEditor(SCI_SETKEYWORDS
, 1, (LPARAM
)(m_TextView
.StringForControl(_T("assign audio block break catch choice clear disconnect else elseif \
2264 emphasis enumerate error exit field filled form goto grammar help \
2265 if initial link log menu meta noinput nomatch object option p paragraph \
2266 param phoneme prompt property prosody record reprompt return s say-as \
2267 script sentence subdialog submit throw transfer value var voice vxml")).GetBuffer()));
2268 SendEditor(SCI_SETKEYWORDS
, 2, (LPARAM
)(m_TextView
.StringForControl(_T("accept age alphabet anchor application base beep bridge category charset \
2269 classid cond connecttimeout content contour count dest destexpr dtmf dtmfterm \
2270 duration enctype event eventexpr expr expritem fetchtimeout finalsilence \
2271 gender http-equiv id level maxage maxstale maxtime message messageexpr \
2272 method mime modal mode name namelist next nextitem ph pitch range rate \
2273 scope size sizeexpr skiplist slot src srcexpr sub time timeexpr timeout \
2274 transferaudio type value variant version volume xml:lang")).GetBuffer()));
2275 SendEditor(SCI_SETKEYWORDS
, 3, (LPARAM
)(m_TextView
.StringForControl(_T("and assert break class continue def del elif \
2276 else except exec finally for from global if import in is lambda None \
2277 not or pass print raise return try while yield")).GetBuffer()));
2278 SendEditor(SCI_SETKEYWORDS
, 4, (LPARAM
)(m_TextView
.StringForControl(_T("and argv as argc break case cfunction class continue declare default do \
2279 die echo else elseif empty enddeclare endfor endforeach endif endswitch \
2280 endwhile e_all e_parse e_error e_warning eval exit extends false for \
2281 foreach function global http_cookie_vars http_get_vars http_post_vars \
2282 http_post_files http_env_vars http_server_vars if include include_once \
2283 list new not null old_function or parent php_os php_self php_version \
2284 print require require_once return static switch stdclass this true var \
2285 xor virtual while __file__ __line__ __sleep __wakeup")).GetBuffer()));
2287 SetAStyle(SCE_H_TAG
, darkBlue
);
2288 SetAStyle(SCE_H_TAGUNKNOWN
, red
);
2289 SetAStyle(SCE_H_ATTRIBUTE
, darkBlue
);
2290 SetAStyle(SCE_H_ATTRIBUTEUNKNOWN
, red
);
2291 SetAStyle(SCE_H_NUMBER
, RGB(0x80,0,0x80));
2292 SetAStyle(SCE_H_DOUBLESTRING
, RGB(0,0x80,0));
2293 SetAStyle(SCE_H_SINGLESTRING
, RGB(0,0x80,0));
2294 SetAStyle(SCE_H_OTHER
, RGB(0x80,0,0x80));
2295 SetAStyle(SCE_H_COMMENT
, RGB(0x80,0x80,0));
2296 SetAStyle(SCE_H_ENTITY
, RGB(0x80,0,0x80));
2298 SetAStyle(SCE_H_TAGEND
, darkBlue
);
2299 SetAStyle(SCE_H_XMLSTART
, darkBlue
); // <?
2300 SetAStyle(SCE_H_QUESTION
, darkBlue
); // <?
2301 SetAStyle(SCE_H_XMLEND
, darkBlue
); // ?>
2302 SetAStyle(SCE_H_SCRIPT
, darkBlue
); // <script
2303 SetAStyle(SCE_H_ASP
, RGB(0x4F, 0x4F, 0), RGB(0xFF, 0xFF, 0)); // <% ... %>
2304 SetAStyle(SCE_H_ASPAT
, RGB(0x4F, 0x4F, 0), RGB(0xFF, 0xFF, 0)); // <%@ ... %>
2306 SetAStyle(SCE_HB_DEFAULT
, black
);
2307 SetAStyle(SCE_HB_COMMENTLINE
, darkGreen
);
2308 SetAStyle(SCE_HB_NUMBER
, RGB(0,0x80,0x80));
2309 SetAStyle(SCE_HB_WORD
, darkBlue
);
2310 SendEditor(SCI_STYLESETBOLD
, SCE_HB_WORD
, 1);
2311 SetAStyle(SCE_HB_STRING
, RGB(0x80,0,0x80));
2312 SetAStyle(SCE_HB_IDENTIFIER
, black
);
2314 // This light blue is found in the windows system palette so is safe to use even in 256 colour modes.
2315 // Show the whole section of VBScript with light blue background
2316 for (int bstyle
=SCE_HB_DEFAULT
; bstyle
<=SCE_HB_STRINGEOL
; bstyle
++) {
2317 SendEditor(SCI_STYLESETFONT
, bstyle
,
2318 reinterpret_cast<LPARAM
>(m_TextView
.StringForControl(_T("Lucida Console")).GetBuffer()));
2319 SendEditor(SCI_STYLESETBACK
, bstyle
, lightBlue
);
2320 // This call extends the backround colour of the last style on the line to the edge of the window
2321 SendEditor(SCI_STYLESETEOLFILLED
, bstyle
, 1);
2323 SendEditor(SCI_STYLESETBACK
, SCE_HB_STRINGEOL
, RGB(0x7F,0x7F,0xFF));
2324 SendEditor(SCI_STYLESETFONT
, SCE_HB_COMMENTLINE
,
2325 reinterpret_cast<LPARAM
>(m_TextView
.StringForControl(_T("Lucida Console")).GetBuffer()));
2327 SetAStyle(SCE_HBA_DEFAULT
, black
);
2328 SetAStyle(SCE_HBA_COMMENTLINE
, darkGreen
);
2329 SetAStyle(SCE_HBA_NUMBER
, RGB(0,0x80,0x80));
2330 SetAStyle(SCE_HBA_WORD
, darkBlue
);
2331 SendEditor(SCI_STYLESETBOLD
, SCE_HBA_WORD
, 1);
2332 SetAStyle(SCE_HBA_STRING
, RGB(0x80,0,0x80));
2333 SetAStyle(SCE_HBA_IDENTIFIER
, black
);
2335 // Show the whole section of ASP VBScript with bright yellow background
2336 for (int bastyle
=SCE_HBA_DEFAULT
; bastyle
<=SCE_HBA_STRINGEOL
; bastyle
++) {
2337 SendEditor(SCI_STYLESETFONT
, bastyle
,
2338 reinterpret_cast<LPARAM
>(m_TextView
.StringForControl(_T("Lucida Console")).GetBuffer()));
2339 SendEditor(SCI_STYLESETBACK
, bastyle
, RGB(0xFF, 0xFF, 0));
2340 // This call extends the backround colour of the last style on the line to the edge of the window
2341 SendEditor(SCI_STYLESETEOLFILLED
, bastyle
, 1);
2343 SendEditor(SCI_STYLESETBACK
, SCE_HBA_STRINGEOL
, RGB(0xCF,0xCF,0x7F));
2344 SendEditor(SCI_STYLESETFONT
, SCE_HBA_COMMENTLINE
,
2345 reinterpret_cast<LPARAM
>(m_TextView
.StringForControl(_T("Lucida Console")).GetBuffer()));
2347 // If there is no need to support embedded Javascript, the following code can be dropped.
2348 // Javascript will still be correctly processed but will be displayed in just the default style.
2350 SetAStyle(SCE_HJ_START
, RGB(0x80,0x80,0));
2351 SetAStyle(SCE_HJ_DEFAULT
, black
);
2352 SetAStyle(SCE_HJ_COMMENT
, darkGreen
);
2353 SetAStyle(SCE_HJ_COMMENTLINE
, darkGreen
);
2354 SetAStyle(SCE_HJ_COMMENTDOC
, darkGreen
);
2355 SetAStyle(SCE_HJ_NUMBER
, RGB(0,0x80,0x80));
2356 SetAStyle(SCE_HJ_WORD
, black
);
2357 SetAStyle(SCE_HJ_KEYWORD
, darkBlue
);
2358 SetAStyle(SCE_HJ_DOUBLESTRING
, RGB(0x80,0,0x80));
2359 SetAStyle(SCE_HJ_SINGLESTRING
, RGB(0x80,0,0x80));
2360 SetAStyle(SCE_HJ_SYMBOLS
, black
);
2362 SetAStyle(SCE_HJA_START
, RGB(0x80,0x80,0));
2363 SetAStyle(SCE_HJA_DEFAULT
, black
);
2364 SetAStyle(SCE_HJA_COMMENT
, darkGreen
);
2365 SetAStyle(SCE_HJA_COMMENTLINE
, darkGreen
);
2366 SetAStyle(SCE_HJA_COMMENTDOC
, darkGreen
);
2367 SetAStyle(SCE_HJA_NUMBER
, RGB(0,0x80,0x80));
2368 SetAStyle(SCE_HJA_WORD
, black
);
2369 SetAStyle(SCE_HJA_KEYWORD
, darkBlue
);
2370 SetAStyle(SCE_HJA_DOUBLESTRING
, RGB(0x80,0,0x80));
2371 SetAStyle(SCE_HJA_SINGLESTRING
, RGB(0x80,0,0x80));
2372 SetAStyle(SCE_HJA_SYMBOLS
, black
);
2374 SetAStyle(SCE_HPHP_DEFAULT
, black
);
2375 SetAStyle(SCE_HPHP_HSTRING
, RGB(0x80,0,0x80));
2376 SetAStyle(SCE_HPHP_SIMPLESTRING
, RGB(0x80,0,0x80));
2377 SetAStyle(SCE_HPHP_WORD
, darkBlue
);
2378 SetAStyle(SCE_HPHP_NUMBER
, RGB(0,0x80,0x80));
2379 SetAStyle(SCE_HPHP_VARIABLE
, red
);
2380 SetAStyle(SCE_HPHP_HSTRING_VARIABLE
, red
);
2381 SetAStyle(SCE_HPHP_COMPLEX_VARIABLE
, red
);
2382 SetAStyle(SCE_HPHP_COMMENT
, darkGreen
);
2383 SetAStyle(SCE_HPHP_COMMENTLINE
, darkGreen
);
2384 SetAStyle(SCE_HPHP_OPERATOR
, darkBlue
);
2386 // Show the whole section of Javascript with off white background
2387 for (int jstyle
=SCE_HJ_DEFAULT
; jstyle
<=SCE_HJ_SYMBOLS
; jstyle
++) {
2388 SendEditor(SCI_STYLESETFONT
, jstyle
,
2389 reinterpret_cast<LPARAM
>(m_TextView
.StringForControl(_T("Lucida Console")).GetBuffer()));
2390 SendEditor(SCI_STYLESETBACK
, jstyle
, offWhite
);
2391 SendEditor(SCI_STYLESETEOLFILLED
, jstyle
, 1);
2393 SendEditor(SCI_STYLESETBACK
, SCE_HJ_STRINGEOL
, RGB(0xDF, 0xDF, 0x7F));
2394 SendEditor(SCI_STYLESETEOLFILLED
, SCE_HJ_STRINGEOL
, 1);
2396 // Show the whole section of Javascript with brown background
2397 for (int jastyle
=SCE_HJA_DEFAULT
; jastyle
<=SCE_HJA_SYMBOLS
; jastyle
++) {
2398 SendEditor(SCI_STYLESETFONT
, jastyle
,
2399 reinterpret_cast<LPARAM
>(m_TextView
.StringForControl(_T("Lucida Console")).GetBuffer()));
2400 SendEditor(SCI_STYLESETBACK
, jastyle
, RGB(0xDF, 0xDF, 0x7F));
2401 SendEditor(SCI_STYLESETEOLFILLED
, jastyle
, 1);
2403 SendEditor(SCI_STYLESETBACK
, SCE_HJA_STRINGEOL
, RGB(0x0,0xAF,0x5F));
2404 SendEditor(SCI_STYLESETEOLFILLED
, SCE_HJA_STRINGEOL
, 1);
2409 SendEditor(SCI_SETLEXER
, SCLEX_CPP
);
2412 SendEditor(SCI_COLOURISE
, 0, -1);
2416 void CTortoiseGitBlameView::SetupCppLexer()
2418 SetAStyle(SCE_C_DEFAULT
, RGB(0, 0, 0));
2419 SetAStyle(SCE_C_COMMENT
, RGB(0, 0x80, 0));
2420 SetAStyle(SCE_C_COMMENTLINE
, RGB(0, 0x80, 0));
2421 SetAStyle(SCE_C_COMMENTDOC
, RGB(0, 0x80, 0));
2422 SetAStyle(SCE_C_COMMENTLINEDOC
, RGB(0, 0x80, 0));
2423 SetAStyle(SCE_C_COMMENTDOCKEYWORD
, RGB(0, 0x80, 0));
2424 SetAStyle(SCE_C_COMMENTDOCKEYWORDERROR
, RGB(0, 0x80, 0));
2425 SetAStyle(SCE_C_NUMBER
, RGB(0, 0x80, 0x80));
2426 SetAStyle(SCE_C_WORD
, RGB(0, 0, 0x80));
2427 SendEditor(SCE_C_WORD
, 1);
2428 SetAStyle(SCE_C_STRING
, RGB(0x80, 0, 0x80));
2429 SetAStyle(SCE_C_IDENTIFIER
, RGB(0, 0, 0));
2430 SetAStyle(SCE_C_PREPROCESSOR
, RGB(0x80, 0, 0));
2431 SetAStyle(SCE_C_OPERATOR
, RGB(0x80, 0x80, 0));
2435 void CTortoiseGitBlameView::UpdateInfo()
2437 CString
&data
= GetDocument()->m_BlameData
;
2441 CLogDataVector
* pRevs
= GetLogData();
2443 this->m_CommitHash
.clear();
2444 this->m_Authors
.clear();
2450 SendEditor(SCI_SETREADONLY
, FALSE
);
2451 SendEditor(SCI_CLEARALL
);
2452 SendEditor(EM_EMPTYUNDOBUFFER
);
2453 SendEditor(SCI_SETSAVEPOINT
);
2454 SendEditor(SCI_CANCEL
);
2455 SendEditor(SCI_SETUNDOCOLLECTION
, 0);
2459 one
=data
.Tokenize(_T("\n"),pos
);
2462 m_CommitHash
.push_back(one
.Left(40));
2464 start
=one
.Find(_T(')'),40);
2467 line
=one
.Right(one
.GetLength()-start
-2);
2468 this->m_TextView
.InsertText(line
,true);
2470 int id
=pRevs
->m_HashMap
[one
.Left(40)];
2471 if(id
>=0 && id
<GetLogData()->size())
2473 m_ID
.push_back(pRevs
->size()-id
);
2474 m_Authors
.push_back(pRevs
->at(id
).m_AuthorName
);
2481 SetupLexer(GetDocument()->m_CurrentFileName
);
2483 SendEditor(SCI_SETUNDOCOLLECTION
, 1);
2484 SendEditor(EM_EMPTYUNDOBUFFER
);
2485 SendEditor(SCI_SETSAVEPOINT
);
2486 SendEditor(SCI_GOTOPOS
, 0);
2487 SendEditor(SCI_SETSCROLLWIDTHTRACKING
, TRUE
);
2488 SendEditor(SCI_SETREADONLY
, TRUE
);
2491 m_highestrev
=this->GetLogData()->size();
2495 this->GetClientRect(rect
);
2496 //this->m_TextView.GetWindowRect(rect);
2497 //this->m_TextView.ScreenToClient(rect);
2498 rect
.left
=this->m_blamewidth
;
2499 this->m_TextView
.MoveWindow(rect
);
2504 CGitBlameLogList
* CTortoiseGitBlameView::GetLogList()
2506 return &(GetDocument()->GetMainFrame()->m_wndOutput
.m_LogList
);
2510 CLogDataVector
* CTortoiseGitBlameView::GetLogData()
2512 return &(GetDocument()->GetMainFrame()->m_wndOutput
.m_LogList
.m_logEntries
);
2515 void CTortoiseGitBlameView::OnSciPainted(NMHDR
*,LRESULT
*)
2520 void CTortoiseGitBlameView::OnLButtonDown(UINT nFlags
,CPoint point
)
2523 LONG_PTR line
= SendEditor(SCI_GETFIRSTVISIBLELINE
);
2524 LONG_PTR height
= SendEditor(SCI_TEXTHEIGHT
);
2525 line
= line
+ (point
.y
/height
);
2527 if (line
< (LONG
)m_CommitHash
.size())
2529 SetSelectedLine(line
);
2530 if (m_CommitHash
[line
] != m_SelectedHash
)
2532 m_SelectedHash
= m_CommitHash
[line
];
2533 // app.m_selectedorigrev = app.origrevs[line];
2534 // app.m_selectedauthor = app.authors[line];
2535 // app.m_selecteddate = app.dates[line];
2538 this->GetLogList()->SetItemState(this->GetLogList()->GetItemCount()-m_ID
[line
],
2543 pRev
=&this->GetLogData()->at(this->GetLogList()->GetItemCount()-m_ID
[line
]);
2544 this->GetDocument()->GetMainFrame()->m_wndProperties
.UpdateProperties(pRev
);
2548 m_SelectedHash
.Empty();
2549 // app.m_selecteddate.clear();
2550 // app.m_selectedrev = -2;
2551 // app.m_selectedorigrev = -2;
2553 //::InvalidateRect( NULL, FALSE);
2555 this->m_TextView
.Invalidate();
2560 SetSelectedLine(-1);
2563 CView::OnLButtonDown(nFlags
,point
);
2566 void CTortoiseGitBlameView::OnSciGetBkColor(NMHDR
* hdr
, LRESULT
* result
)
2569 SCNotification
*notification
=reinterpret_cast<SCNotification
*>(hdr
);
2571 if ((m_colorage
)&&(notification
->line
< (int)m_CommitHash
.size()))
2573 if(m_CommitHash
[notification
->line
] == this->m_SelectedHash
)
2574 notification
->lParam
= m_selectedauthorcolor
;
2576 notification
->lParam
= InterColor(DWORD(m_regOldLinesColor
), DWORD(m_regNewLinesColor
), (m_ID
[notification
->line
]-m_lowestrev
)*100/((m_highestrev
-m_lowestrev
)+1));
2581 void CTortoiseGitBlameView::FocusOn(GitRev
*pRev
)
2583 m_SelectedHash
= pRev
->m_CommitHash
;
2586 //pRev=&this->GetLogData()->at(this->GetLogList()->GetItemCount()-m_ID[line]);
2587 this->GetDocument()->GetMainFrame()->m_wndProperties
.UpdateProperties(pRev
);
2590 this->m_TextView
.Invalidate();
2594 void CTortoiseGitBlameView::OnMouseHover(UINT nFlags
, CPoint point
)
2597 LONG_PTR line
= SendEditor(SCI_GETFIRSTVISIBLELINE
);
2598 LONG_PTR height
= SendEditor(SCI_TEXTHEIGHT
);
2599 line
= line
+ (point
.y
/height
);
2601 if (line
< (LONG
)m_CommitHash
.size())
2603 if (line
!= m_MouseLine
)
2605 m_MouseLine
= line
;//m_CommitHash[line];
2606 // app.m_selectedorigrev = app.origrevs[line];
2607 // app.m_selectedauthor = app.authors[line];
2608 // app.m_selecteddate = app.dates[line];
2612 pRev
=&this->GetLogData()->at(this->GetLogList()->GetItemCount()-m_ID
[line
]);
2613 //this->GetDocument()->GetMainFrame()->m_wndProperties.UpdateProperties(pRev);
2614 this->ClientToScreen(&point
);
2616 //if(m_ToolTip.GetTool(this, bi))
2618 // bi.sBalloonTip=pRev->m_CommitHash;
2620 str
.Format(_T("%s\n<b>%s</b>\n%s\n%s"),pRev
->m_CommitHash
,
2622 pRev
->m_AuthorDate
.Format(_T("%Y-%m-%d %H:%M")),
2624 m_ToolTip
.AddTool(this,str
);
2625 m_ToolTip
.DisplayToolTip(&point
);
2629 this->ScreenToClient(&point
);
2630 rect
.left
=LOCATOR_WIDTH
;
2631 rect
.right
=this->m_blamewidth
+rect
.left
;
2632 rect
.top
=point
.y
-height
;
2633 rect
.bottom
=point
.y
+height
;
2634 this->InvalidateRect(rect
);
2640 // app.m_selecteddate.clear();
2641 // app.m_selectedrev = -2;
2642 // app.m_selectedorigrev = -2;
2644 //::InvalidateRect( NULL, FALSE);
2645 //this->Invalidate();
2648 // const CString str=_T("this is a <b>Message Balloon</b>\n<hr=100%>\n<ct=0x0000FF>Warning! Warning!</ct>\nSomething unexpected happened");
2649 //CBalloon::ShowBalloon(NULL, point,
2651 // FALSE, (HICON)IDI_EXCLAMATION,
2652 // (UINT)CBalloon ::BALLOON_RIGHT_TOP, (UINT)CBalloon ::BALLOON_EFFECT_SOLID,(COLORREF)NULL, (COLORREF)NULL, (COLORREF)NULL);
2655 void CTortoiseGitBlameView::OnMouseMove(UINT nFlags
, CPoint point
)
2657 TRACKMOUSEEVENT tme
;
2658 tme
.cbSize
=sizeof(TRACKMOUSEEVENT
);
2659 tme
.dwFlags
=TME_HOVER
|TME_LEAVE
;
2660 tme
.hwndTrack
=this->m_hWnd
;
2662 TrackMouseEvent(&tme
);
2666 BOOL
CTortoiseGitBlameView::PreTranslateMessage(MSG
* pMsg
)
2668 m_ToolTip
.RelayEvent(pMsg
);
2669 return CView::PreTranslateMessage(pMsg
);
2672 void CTortoiseGitBlameView::OnEditFind()
2674 m_pFindDialog
=new CFindReplaceDialog();
2676 m_pFindDialog
->Create(TRUE
,_T(""),NULL
,FR_DOWN
,this);
2679 void CTortoiseGitBlameView::OnEditGoto()
2682 if(dlg
.DoModal()==IDOK
)
2684 this->GotoLine(dlg
.m_LineNumber
);
2688 LRESULT
CTortoiseGitBlameView::OnFindDialogMessage(WPARAM wParam
, LPARAM lParam
)//Õâ¸öÒ²ÊÇÕÒÄǸö³ÌÐò¸ÄµÄ£¬Ö»²»¹ý»»³ÉÁË×Ô¼ºµÄÀà
2690 ASSERT(m_pFindDialog
!= NULL
);
2692 // If the FR_DIALOGTERM flag is set,
2693 // invalidate the handle identifying the dialog box.
2694 if (m_pFindDialog
->IsTerminating())
2696 m_pFindDialog
= NULL
;
2700 // If the FR_FINDNEXT flag is set,
2701 // call the application-defined search routine
2702 // to search for the requested string.
2703 if(m_pFindDialog
->FindNext())
2705 //read data from dialog
2706 CString FindName
= m_pFindDialog
->GetFindString();
2707 bool bMatchCase
= m_pFindDialog
->MatchCase() == TRUE
;
2708 bool bMatchWholeWord
= m_pFindDialog
->MatchWholeWord() == TRUE
;
2709 bool bSearchDown
= m_pFindDialog
->SearchDown() == TRUE
;
2711 DoSearch(FindName
,m_pFindDialog
->m_fr
.Flags
);
2712 //with given name do search
2713 // *FindWhatYouNeed(FindName, bMatchCase, bMatchWholeWord, bSearchDown);