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"
30 #include "TortoiseGitBlameAppUtils.h"
36 UINT
CTortoiseGitBlameView::m_FindDialogMessage
;
38 // CTortoiseGitBlameView
39 IMPLEMENT_DYNAMIC(CSciEditBlame
,CSciEdit
)
41 IMPLEMENT_DYNCREATE(CTortoiseGitBlameView
, CView
)
43 BEGIN_MESSAGE_MAP(CTortoiseGitBlameView
, CView
)
44 // Standard printing commands
45 ON_COMMAND(ID_FILE_PRINT
, &CView::OnFilePrint
)
46 ON_COMMAND(ID_FILE_PRINT_DIRECT
, &CView::OnFilePrint
)
47 ON_COMMAND(ID_FILE_PRINT_PREVIEW
, &CTortoiseGitBlameView::OnFilePrintPreview
)
48 ON_COMMAND(ID_EDIT_FIND
,OnEditFind
)
49 ON_COMMAND(ID_EDIT_GOTO
,OnEditGoto
)
50 ON_COMMAND(ID_EDIT_COPY
,CopySelectedLogToClipboard
)
51 ON_COMMAND(ID_VIEW_NEXT
,OnViewNext
)
52 ON_COMMAND(ID_VIEW_PREV
,OnViewPrev
)
60 ON_NOTIFY(SCN_PAINTED
,0,OnSciPainted
)
61 ON_NOTIFY(SCN_GETBKCOLOR
,0,OnSciGetBkColor
)
62 ON_REGISTERED_MESSAGE(m_FindDialogMessage
, OnFindDialogMessage
)
66 // CTortoiseGitBlameView construction/destruction
68 CTortoiseGitBlameView::CTortoiseGitBlameView()
70 // TODO: add construction code here
87 m_windowcolor
= ::GetSysColor(COLOR_WINDOW
);
88 m_textcolor
= ::GetSysColor(COLOR_WINDOWTEXT
);
89 m_texthighlightcolor
= ::GetSysColor(COLOR_HIGHLIGHTTEXT
);
90 m_mouserevcolor
= InterColor(m_windowcolor
, m_textcolor
, 20);
91 m_mouseauthorcolor
= InterColor(m_windowcolor
, m_textcolor
, 10);
92 m_selectedrevcolor
= ::GetSysColor(COLOR_HIGHLIGHT
);
93 m_selectedauthorcolor
= InterColor(m_selectedrevcolor
, m_texthighlightcolor
, 35);
97 m_selectedorigrev
= -1;
100 m_directFunction
= 0;
102 m_lowestrev
= LONG_MAX
;
111 m_FindDialogMessage
= ::RegisterWindowMessage(FINDMSGSTRING
);
112 m_pFindDialog
= NULL
;
113 // get short/long datetime setting from registry
114 DWORD RegUseShortDateFormat
= CRegDWORD(_T("Software\\TortoiseGit\\LogDateFormat"), TRUE
);
115 if ( RegUseShortDateFormat
)
117 m_DateFormat
= DATE_SHORTDATE
;
121 m_DateFormat
= DATE_LONGDATE
;
125 CTortoiseGitBlameView::~CTortoiseGitBlameView()
128 DeleteObject(m_font
);
130 DeleteObject(m_italicfont
);
134 int CTortoiseGitBlameView::OnCreate(LPCREATESTRUCT lpcs
)
138 this->GetWindowRect(&rect1
);
139 rect
.left
=m_blamewidth
+LOCATOR_WIDTH
;
140 rect
.right
=rect
.Width();
142 rect
.bottom
=rect
.Height();
143 BOOL b
=m_TextView
.Create(_T("Scintilla"),_T("source"),0,rect
,this,0,0);
145 m_TextView
.ShowWindow( SW_SHOW
);
146 //m_TextView.InsertText(_T("Abdadfasdf"));
147 m_wEditor
= m_TextView
.m_hWnd
;
150 m_ToolTip
.Create(this->GetParent());
151 m_ToolTip
.AddTool(this,_T("Test"));
153 ::AfxGetApp()->GetMainWnd();
154 return CView::OnCreate(lpcs
);
158 void CTortoiseGitBlameView::OnSize(UINT nType
,int cx
, int cy
)
162 rect
.left
=m_blamewidth
;
167 m_TextView
.MoveWindow(&rect
);
170 BOOL
CTortoiseGitBlameView::PreCreateWindow(CREATESTRUCT
& cs
)
172 // TODO: Modify the Window class or styles here by modifying
173 // the CREATESTRUCT cs
175 return CView::PreCreateWindow(cs
);
178 // CTortoiseGitBlameView drawing
180 void CTortoiseGitBlameView::OnDraw(CDC
* /*pDC*/)
182 CTortoiseGitBlameDoc
* pDoc
= GetDocument();
187 DrawBlame(this->GetDC()->m_hDC
);
188 DrawLocatorBar(this->GetDC()->m_hDC
);
189 // TODO: add draw code for native data here
193 // CTortoiseGitBlameView printing
196 void CTortoiseGitBlameView::OnFilePrintPreview()
198 AFXPrintPreview(this);
201 BOOL
CTortoiseGitBlameView::OnPreparePrinting(CPrintInfo
* pInfo
)
203 // default preparation
204 return DoPreparePrinting(pInfo
);
207 void CTortoiseGitBlameView::OnBeginPrinting(CDC
* /*pDC*/, CPrintInfo
* /*pInfo*/)
209 // TODO: add extra initialization before printing
212 void CTortoiseGitBlameView::OnEndPrinting(CDC
* /*pDC*/, CPrintInfo
* /*pInfo*/)
214 // TODO: add cleanup after printing
217 void CTortoiseGitBlameView::OnRButtonUp(UINT nFlags
, CPoint point
)
219 ClientToScreen(&point
);
220 OnContextMenu(this, point
);
223 void CTortoiseGitBlameView::OnContextMenu(CWnd
* pWnd
, CPoint point
)
225 theApp
.GetContextMenuManager()->ShowPopupMenu(IDR_POPUP_EDIT
, point
.x
, point
.y
, this, TRUE
);
229 // CTortoiseGitBlameView diagnostics
232 void CTortoiseGitBlameView::AssertValid() const
234 CView::AssertValid();
237 void CTortoiseGitBlameView::Dump(CDumpContext
& dc
) const
242 CTortoiseGitBlameDoc
* CTortoiseGitBlameView::GetDocument() const // non-debug version is inline
244 ASSERT(m_pDocument
->IsKindOf(RUNTIME_CLASS(CTortoiseGitBlameDoc
)));
245 return (CTortoiseGitBlameDoc
*)m_pDocument
;
250 // CTortoiseGitBlameView message handlers
251 CString
CTortoiseGitBlameView::GetAppDirectory()
255 DWORD bufferlen
= MAX_PATH
; // MAX_PATH is not the limit here!
258 bufferlen
+= MAX_PATH
; // MAX_PATH is not the limit here!
259 TCHAR
* pBuf
= new TCHAR
[bufferlen
];
260 len
= GetModuleFileName(NULL
, pBuf
, bufferlen
);
261 path
= CString(pBuf
, len
);
263 } while(len
== bufferlen
);
265 path
= path
.Left(path
.ReverseFind(_T('\\')));
266 //path = path.substr(0, path.rfind('\\') + 1);
271 // Return a color which is interpolated between c1 and c2.
272 // Slider controls the relative proportions as a percentage:
273 // Slider = 0 represents pure c1
274 // Slider = 50 represents equal mixture
275 // Slider = 100 represents pure c2
276 COLORREF
CTortoiseGitBlameView::InterColor(COLORREF c1
, COLORREF c2
, int Slider
)
280 // Limit Slider to 0..100% range
286 // The color components have to be treated individually.
287 r
= (GetRValue(c2
) * Slider
+ GetRValue(c1
) * (100 - Slider
)) / 100;
288 g
= (GetGValue(c2
) * Slider
+ GetGValue(c1
) * (100 - Slider
)) / 100;
289 b
= (GetBValue(c2
) * Slider
+ GetBValue(c1
) * (100 - Slider
)) / 100;
294 LRESULT
CTortoiseGitBlameView::SendEditor(UINT Msg
, WPARAM wParam
, LPARAM lParam
)
296 if (m_directFunction
)
298 return ((SciFnDirect
) m_directFunction
)(m_directPointer
, Msg
, wParam
, lParam
);
300 return ::SendMessage(m_wEditor
, Msg
, wParam
, lParam
);
303 void CTortoiseGitBlameView::GetRange(int start
, int end
, char *text
)
307 tr
.chrg
.cpMin
= start
;
311 SendMessage(m_wEditor
, EM_GETTEXTRANGE
, 0, reinterpret_cast<LPARAM
>(&tr
));
315 void CTortoiseGitBlameView::SetTitle()
318 char title
[MAX_PATH
+ 100];
319 strcpy_s(title
, MAX_PATH
+ 100, szTitle
);
320 strcat_s(title
, MAX_PATH
+ 100, " - ");
321 strcat_s(title
, MAX_PATH
+ 100, szViewtitle
);
322 ::SetWindowText(wMain
, title
);
326 BOOL
CTortoiseGitBlameView::OpenLogFile(const char *fileName
)
329 char logmsgbuf
[10000+1];
331 fopen_s(&File
, fileName
, "rb");
341 wchar_t wbuf
[MAX_LOG_LENGTH
+6];
344 len
= fread(&rev
, sizeof(LONG
), 1, File
);
351 len
= fread(&slength
, sizeof(int), 1, File
);
358 if (slength
> MAX_LOG_LENGTH
)
360 reallength
= slength
;
361 slength
= MAX_LOG_LENGTH
;
365 len
= fread(logmsgbuf
, sizeof(char), slength
, File
);
366 if (len
< (size_t)slength
)
372 msg
= CString(logmsgbuf
, slength
);
375 fseek(File
, reallength
-MAX_LOG_LENGTH
, SEEK_CUR
);
376 msg
= msg
+ _T("\n...");
378 int len2
= ::MultiByteToWideChar(CP_UTF8
, NULL
, msg
.c_str(), min(msg
.size(), MAX_LOG_LENGTH
+5), wbuf
, MAX_LOG_LENGTH
+5);
380 len2
= ::WideCharToMultiByte(CP_ACP
, NULL
, wbuf
, len2
, logmsgbuf
, MAX_LOG_LENGTH
+5, NULL
, NULL
);
382 msg
= CString(logmsgbuf
);
383 logmessages
[rev
] = msg
;
389 BOOL
CTortoiseGitBlameView::OpenFile(const char *fileName
)
392 SendEditor(SCI_SETREADONLY
, FALSE
);
393 SendEditor(SCI_CLEARALL
);
394 SendEditor(EM_EMPTYUNDOBUFFER
);
396 SendEditor(SCI_SETSAVEPOINT
);
397 SendEditor(SCI_CANCEL
);
398 SendEditor(SCI_SETUNDOCOLLECTION
, 0);
399 ::ShowWindow(m_wEditor
, SW_HIDE
);
407 char * lineptr
= NULL
;
408 char * trimptr
= NULL
;
409 //ignore the first two lines, they're of no interest to us
410 File
.getline(line
, sizeof(line
)/sizeof(char));
411 File
.getline(line
, sizeof(line
)/sizeof(char));
412 m_lowestrev
= LONG_MAX
;
417 File
.getline(line
, sizeof(line
)/sizeof(TCHAR
));
418 if (File
.gcount()>139)
420 mergelines
.push_back((line
[0] != ' '));
422 long rev
= _ttol(lineptr
);
424 m_lowestrev
= min(m_lowestrev
, rev
);
425 m_highestrev
= max(m_highestrev
, rev
);
427 rev
= _ttol(lineptr
);
428 origrevs
.push_back(rev
);
430 dates
.push_back(CString(lineptr
, 30));
432 // unfortunately, the 'path' entry can be longer than the 60 chars
433 // we made the column. We therefore have to step through the path
434 // string until we find a space
438 // TODO: how can we deal with the situation where the path has
439 // a space in it, but the space is after the 60 chars reserved
441 // The only way to deal with that would be to use a custom
442 // binary format for the blame file.
444 trimptr
= _tcschr(trimptr
, ' ');
445 } while ((trimptr
)&&(trimptr
+1 < lineptr
+61));
450 paths
.push_back(CString(lineptr
));
451 if (trimptr
+1 < lineptr
+61)
454 lineptr
= (trimptr
+1);
455 trimptr
= lineptr
+30;
456 while ((*trimptr
== ' ')&&(trimptr
> lineptr
))
459 authors
.push_back(CString(lineptr
));
461 // in case we find an UTF8 BOM at the beginning of the line, we remove it
462 if (((unsigned char)lineptr
[0] == 0xEF)&&((unsigned char)lineptr
[1] == 0xBB)&&((unsigned char)lineptr
[2] == 0xBF))
466 if (((unsigned char)lineptr
[0] == 0xBB)&&((unsigned char)lineptr
[1] == 0xEF)&&((unsigned char)lineptr
[2] == 0xBF))
470 // check each line for illegal utf8 sequences. If one is found, we treat
471 // the file as ASCII, otherwise we assume an UTF8 file.
472 char * utf8CheckBuf
= lineptr
;
473 while ((bUTF8
)&&(*utf8CheckBuf
))
475 if ((*utf8CheckBuf
== 0xC0)||(*utf8CheckBuf
== 0xC1)||(*utf8CheckBuf
>= 0xF5))
480 if ((*utf8CheckBuf
& 0xE0)==0xC0)
483 if (*utf8CheckBuf
== 0)
485 if ((*utf8CheckBuf
& 0xC0)!=0x80)
491 if ((*utf8CheckBuf
& 0xF0)==0xE0)
494 if (*utf8CheckBuf
== 0)
496 if ((*utf8CheckBuf
& 0xC0)!=0x80)
502 if (*utf8CheckBuf
== 0)
504 if ((*utf8CheckBuf
& 0xC0)!=0x80)
510 if ((*utf8CheckBuf
& 0xF8)==0xF0)
513 if (*utf8CheckBuf
== 0)
515 if ((*utf8CheckBuf
& 0xC0)!=0x80)
521 if (*utf8CheckBuf
== 0)
523 if ((*utf8CheckBuf
& 0xC0)!=0x80)
529 if (*utf8CheckBuf
== 0)
531 if ((*utf8CheckBuf
& 0xC0)!=0x80)
540 SendEditor(SCI_ADDTEXT
, _tcslen(lineptr
), reinterpret_cast<LPARAM
>(static_cast<char *>(lineptr
)));
541 SendEditor(SCI_ADDTEXT
, 2, (LPARAM
)_T("\r\n"));
543 } while (File
.gcount() > 0);
546 SendEditor(SCI_SETCODEPAGE
, SC_CP_UTF8
);
548 SendEditor(SCI_SETUNDOCOLLECTION
, 1);
549 ::SetFocus(m_wEditor
);
550 SendEditor(EM_EMPTYUNDOBUFFER
);
551 SendEditor(SCI_SETSAVEPOINT
);
552 SendEditor(SCI_GOTOPOS
, 0);
553 SendEditor(SCI_SETSCROLLWIDTHTRACKING
, TRUE
);
554 SendEditor(SCI_SETREADONLY
, TRUE
);
556 //check which lexer to use, depending on the filetype
557 SetupLexer(fileName
);
558 ::ShowWindow(m_wEditor
, SW_SHOW
);
560 ::InvalidateRect(wMain
, NULL
, TRUE
);
562 GetWindowRect(wMain
, &rc
);
563 SetWindowPos(wMain
, 0, rc
.left
, rc
.top
, rc
.right
-rc
.left
-1, rc
.bottom
- rc
.top
, 0);
568 void CTortoiseGitBlameView::SetAStyle(int style
, COLORREF fore
, COLORREF back
, int size
, CString
*face
)
570 SendEditor(SCI_STYLESETFORE
, style
, fore
);
571 SendEditor(SCI_STYLESETBACK
, style
, back
);
573 SendEditor(SCI_STYLESETSIZE
, style
, size
);
575 SendEditor(SCI_STYLESETFONT
, style
, reinterpret_cast<LPARAM
>(this->m_TextView
.StringForControl(*face
).GetBuffer()));
578 void CTortoiseGitBlameView::InitialiseEditor()
581 m_directFunction
= ::SendMessage(m_wEditor
, SCI_GETDIRECTFUNCTION
, 0, 0);
582 m_directPointer
= ::SendMessage(m_wEditor
, SCI_GETDIRECTPOINTER
, 0, 0);
583 // Set up the global default style. These attributes are used wherever no explicit choices are made.
584 SetAStyle(STYLE_DEFAULT
,
587 (DWORD
)CRegStdWORD(_T("Software\\TortoiseGit\\BlameFontSize"), 10),
588 &CString(((stdstring
)CRegStdString(_T("Software\\TortoiseGit\\BlameFontName"), _T("Courier New"))).c_str())
590 SendEditor(SCI_SETTABWIDTH
, (DWORD
)CRegStdWORD(_T("Software\\TortoiseGit\\BlameTabSize"), 4));
591 SendEditor(SCI_SETREADONLY
, TRUE
);
592 LRESULT pix
= SendEditor(SCI_TEXTWIDTH
, STYLE_LINENUMBER
, (LPARAM
)this->m_TextView
.StringForControl(_T("_99999")).GetBuffer());
594 SendEditor(SCI_SETMARGINWIDTHN
, 0, pix
);
596 SendEditor(SCI_SETMARGINWIDTHN
, 0);
597 SendEditor(SCI_SETMARGINWIDTHN
, 1);
598 SendEditor(SCI_SETMARGINWIDTHN
, 2);
599 //Set the default windows colors for edit controls
600 SendEditor(SCI_STYLESETFORE
, STYLE_DEFAULT
, ::GetSysColor(COLOR_WINDOWTEXT
));
601 SendEditor(SCI_STYLESETBACK
, STYLE_DEFAULT
, ::GetSysColor(COLOR_WINDOW
));
602 SendEditor(SCI_SETSELFORE
, TRUE
, ::GetSysColor(COLOR_HIGHLIGHTTEXT
));
603 SendEditor(SCI_SETSELBACK
, TRUE
, ::GetSysColor(COLOR_HIGHLIGHT
));
604 SendEditor(SCI_SETCARETFORE
, ::GetSysColor(COLOR_WINDOWTEXT
));
605 m_regOldLinesColor
= CRegStdWORD(_T("Software\\TortoiseGit\\BlameOldColor"), RGB(230, 230, 255));
606 m_regNewLinesColor
= CRegStdWORD(_T("Software\\TortoiseGit\\BlameNewColor"), RGB(255, 230, 230));
608 this->m_TextView
.Call(SCI_SETWRAPMODE
, SC_WRAP_NONE
);
612 void CTortoiseGitBlameView::StartSearch()
617 // Initialize FINDREPLACE
618 if (fr
.Flags
& FR_MATCHCASE
)
620 SecureZeroMemory(&fr
, sizeof(fr
));
621 fr
.lStructSize
= sizeof(fr
);
622 fr
.hwndOwner
= wMain
;
623 fr
.lpstrFindWhat
= szFindWhat
;
624 fr
.wFindWhatLen
= 80;
625 fr
.Flags
= FR_HIDEUPDOWN
| FR_HIDEWHOLEWORD
;
626 fr
.Flags
|= bCase
? FR_MATCHCASE
: 0;
628 currentDialog
= FindText(&fr
);
631 bool CTortoiseGitBlameView::DoSearch(CString what
, DWORD flags
)
635 int pos
= SendEditor(SCI_GETCURRENTPOS
);
636 int line
= SendEditor(SCI_LINEFROMPOSITION
, pos
);
638 bool bCaseSensitive
= !!(flags
& FR_MATCHCASE
);
640 //strcpy_s(szWhat, sizeof(szWhat), what);
644 what
=what
.MakeLower();
647 //CString sWhat = CString(szWhat);
654 int bufsize
= SendEditor(SCI_GETLINE
, i
);
655 char * linebuf
= new char[bufsize
+1];
656 SecureZeroMemory(linebuf
, bufsize
+1);
657 SendEditor(SCI_GETLINE
, i
, (LPARAM
)linebuf
);
658 CString oneline
=this->m_TextView
.StringFromControl(linebuf
);
661 oneline
=oneline
.MakeLower();
663 //_stprintf_s(buf, 20, _T("%ld"), revs[i]);
664 if (this->m_Authors
[i
].Find(what
)>=0)
666 else if ((!bCaseSensitive
)&&(this->m_Authors
[i
].MakeLower().Find(what
)>=0))
668 else if (oneline
.Find(what
) >=0)
674 if(i
>=(signed int)m_CommitHash
.size())
676 }while(i
!=line
&&(!bFound
));
681 int selstart
= SendEditor(SCI_GETCURRENTPOS
);
682 int selend
= SendEditor(SCI_POSITIONFROMLINE
, i
);
683 SendEditor(SCI_SETSELECTIONSTART
, selstart
);
684 SendEditor(SCI_SETSELECTIONEND
, selend
);
685 m_SelectedLine
= i
-1;
689 ::MessageBox(wMain
, what
+_T(" not found"), _T("CTortoiseGitBlameView"), MB_ICONINFORMATION
);
695 bool CTortoiseGitBlameView::GotoLine(long line
)
700 if ((unsigned long)line
>= m_CommitHash
.size())
702 line
= m_CommitHash
.size()-1;
705 int nCurrentPos
= SendEditor(SCI_GETCURRENTPOS
);
706 int nCurrentLine
= SendEditor(SCI_LINEFROMPOSITION
,nCurrentPos
);
707 int nFirstVisibleLine
= SendEditor(SCI_GETFIRSTVISIBLELINE
);
708 int nLinesOnScreen
= SendEditor(SCI_LINESONSCREEN
);
710 if ( line
>=nFirstVisibleLine
&& line
<=nFirstVisibleLine
+nLinesOnScreen
)
713 SendEditor(SCI_GOTOLINE
, line
);
717 // Place the requested line one third from the top
718 if ( line
> nCurrentLine
)
720 SendEditor(SCI_GOTOLINE
, (WPARAM
)(line
+(int)nLinesOnScreen
*(2/3.0)));
724 SendEditor(SCI_GOTOLINE
, (WPARAM
)(line
-(int)nLinesOnScreen
*(1/3.0)));
728 // Highlight the line
729 int nPosStart
= SendEditor(SCI_POSITIONFROMLINE
,line
);
730 int nPosEnd
= SendEditor(SCI_GETLINEENDPOSITION
,line
);
731 SendEditor(SCI_SETSEL
,nPosEnd
,nPosStart
);
736 bool CTortoiseGitBlameView::ScrollToLine(long line
)
741 int nCurrentLine
= SendEditor(SCI_GETFIRSTVISIBLELINE
);
743 int scrolldelta
= line
- nCurrentLine
;
744 SendEditor(SCI_LINESCROLL
, 0, scrolldelta
);
749 void CTortoiseGitBlameView::CopySelectedLogToClipboard()
751 this->GetLogList()->CopySelectionToClipBoard(FALSE
);
754 void CTortoiseGitBlameView::BlamePreviousRevision()
757 LONG nRevisionTo
= m_selectedorigrev
- 1;
763 // We now determine the smallest revision number in the blame file (but ignore "-1")
764 // We do this for two reasons:
765 // 1. we respect the "From revision" which the user entered
766 // 2. we speed up the call of "svn blame" because previous smaller revision numbers don't have any effect on the result
767 LONG nSmallestRevision
= -1;
768 for (LONG line
=0;line
<(LONG
)app
.revs
.size();line
++)
770 const LONG nRevision
= app
.revs
[line
];
773 if ( nSmallestRevision
< 1 )
775 nSmallestRevision
= nRevision
;
779 nSmallestRevision
= min(nSmallestRevision
,nRevision
);
784 char bufStartRev
[20];
785 _stprintf_s(bufStartRev
, 20, _T("%d"), nSmallestRevision
);
788 _stprintf_s(bufEndRev
, 20, _T("%d"), nRevisionTo
);
791 _stprintf_s(bufLine
, 20, _T("%d"), m_SelectedLine
+1); //using the current line is a good guess.
794 PROCESS_INFORMATION process
;
795 memset(&startup
, 0, sizeof(startup
));
796 startup
.cb
= sizeof(startup
);
797 memset(&process
, 0, sizeof(process
));
798 stdstring tortoiseProcPath
= GetAppDirectory() + _T("TortoiseProc.exe");
799 stdstring svnCmd
= _T(" /command:blame ");
800 svnCmd
+= _T(" /path:\"");
801 svnCmd
+= szOrigPath
;
803 svnCmd
+= _T(" /startrev:");
804 svnCmd
+= bufStartRev
;
805 svnCmd
+= _T(" /endrev:");
807 svnCmd
+= _T(" /line:");
810 svnCmd
+= _T(" /ignoreeol");
812 svnCmd
+= _T(" /ignorespaces");
813 if (bIgnoreAllSpaces
)
814 svnCmd
+= _T(" /ignoreallspaces");
815 if (CreateProcess(tortoiseProcPath
.c_str(), const_cast<TCHAR
*>(svnCmd
.c_str()), NULL
, NULL
, FALSE
, 0, 0, 0, &startup
, &process
))
817 CloseHandle(process
.hThread
);
818 CloseHandle(process
.hProcess
);
823 void CTortoiseGitBlameView::DiffPreviousRevision()
826 LONG nRevisionTo
= m_selectedorigrev
;
832 LONG nRevisionFrom
= nRevisionTo
-1;
834 char bufStartRev
[20];
835 _stprintf_s(bufStartRev
, 20, _T("%d"), nRevisionFrom
);
838 _stprintf_s(bufEndRev
, 20, _T("%d"), nRevisionTo
);
841 PROCESS_INFORMATION process
;
842 memset(&startup
, 0, sizeof(startup
));
843 startup
.cb
= sizeof(startup
);
844 memset(&process
, 0, sizeof(process
));
845 stdstring tortoiseProcPath
= GetAppDirectory() + _T("TortoiseProc.exe");
846 stdstring svnCmd
= _T(" /command:diff ");
847 svnCmd
+= _T(" /path:\"");
848 svnCmd
+= szOrigPath
;
850 svnCmd
+= _T(" /startrev:");
851 svnCmd
+= bufStartRev
;
852 svnCmd
+= _T(" /endrev:");
854 if (CreateProcess(tortoiseProcPath
.c_str(), const_cast<TCHAR
*>(svnCmd
.c_str()), NULL
, NULL
, FALSE
, 0, 0, 0, &startup
, &process
))
856 CloseHandle(process
.hThread
);
857 CloseHandle(process
.hProcess
);
862 void CTortoiseGitBlameView::ShowLog()
866 _stprintf_s(bufRev
, 20, _T("%d"), m_selectedorigrev
);
869 PROCESS_INFORMATION process
;
870 memset(&startup
, 0, sizeof(startup
));
871 startup
.cb
= sizeof(startup
);
872 memset(&process
, 0, sizeof(process
));
873 stdstring tortoiseProcPath
= GetAppDirectory() + _T("TortoiseProc.exe");
874 stdstring svnCmd
= _T(" /command:log ");
875 svnCmd
+= _T(" /path:\"");
876 svnCmd
+= szOrigPath
;
878 svnCmd
+= _T(" /startrev:");
880 svnCmd
+= _T(" /pegrev:");
882 if (CreateProcess(tortoiseProcPath
.c_str(), const_cast<TCHAR
*>(svnCmd
.c_str()), NULL
, NULL
, FALSE
, 0, 0, 0, &startup
, &process
))
884 CloseHandle(process
.hThread
);
885 CloseHandle(process
.hProcess
);
890 void CTortoiseGitBlameView::Notify(SCNotification
*notification
)
892 switch (notification
->nmhdr
.code
)
894 case SCN_SAVEPOINTREACHED
:
897 case SCN_SAVEPOINTLEFT
:
900 // InvalidateRect(wBlame, NULL, FALSE);
901 // InvalidateRect(wLocator, NULL, FALSE);
904 // if ((m_colorage)&&(notification->line < (int)revs.size()))
906 // notification->lParam = InterColor(DWORD(m_regOldLinesColor), DWORD(m_regNewLinesColor), (revs[notification->line]-m_lowestrev)*100/((m_highestrev-m_lowestrev)+1));
912 void CTortoiseGitBlameView::Command(int id
)
918 // ::PostQuitMessage(0);
923 case ID_COPYTOCLIPBOARD
:
924 CopySelectedLogToClipboard();
926 case ID_BLAME_PREVIOUS_REVISION
:
927 BlamePreviousRevision();
929 case ID_DIFF_PREVIOUS_REVISION
:
930 DiffPreviousRevision();
935 case ID_EDIT_GOTOLINE
:
938 case ID_VIEW_COLORAGEOFLINES
:
940 m_colorage
= !m_colorage
;
941 HMENU hMenu
= GetMenu(wMain
);
942 UINT uCheck
= MF_BYCOMMAND
;
943 uCheck
|= m_colorage
? MF_CHECKED
: MF_UNCHECKED
;
944 CheckMenuItem(hMenu
, ID_VIEW_COLORAGEOFLINES
, uCheck
);
949 case ID_VIEW_MERGEPATH
:
951 ShowPath
= !ShowPath
;
952 HMENU hMenu
= GetMenu(wMain
);
953 UINT uCheck
= MF_BYCOMMAND
;
954 uCheck
|= ShowPath
? MF_CHECKED
: MF_UNCHECKED
;
955 CheckMenuItem(hMenu
, ID_VIEW_MERGEPATH
, uCheck
);
966 LONG
CTortoiseGitBlameView::GetBlameWidth()
971 HDC hDC
= this->GetDC()->m_hDC
;
972 HFONT oldfont
= (HFONT
)::SelectObject(hDC
, m_font
);
977 for (unsigned int i
=0;i
<this->m_ID
.size();i
++)
982 _stprintf_s(buf
, MAX_PATH
, _T("%d."), maxnum
);
983 ::GetTextExtentPoint(hDC
, buf
, _tcslen(buf
), &width
);
984 m_revwidth
= width
.cx
+ BLAMESPACE
;
985 blamewidth
+= m_revwidth
;
988 _stprintf_s(buf
, MAX_PATH
, _T("%d"), m_CommitHash
.size());
989 ::GetTextExtentPoint(hDC
, buf
, _tcslen(buf
), &width
);
990 m_linewidth
= width
.cx
+ BLAMESPACE
;
991 blamewidth
+= m_revwidth
;
996 _stprintf_s(buf
, MAX_PATH
, _T("%30s"), _T("31.08.2001 06:24:14"));
997 ::GetTextExtentPoint32(hDC
, buf
, _tcslen(buf
), &width
);
998 m_datewidth
= width
.cx
+ BLAMESPACE
;
999 blamewidth
+= m_datewidth
;
1003 SIZE maxwidth
= {0};
1005 for (unsigned int i
=0;i
<this->m_Authors
.size();i
++)
1006 //for (std::vector<CString>::iterator I = authors.begin(); I != authors.end(); ++I)
1008 ::GetTextExtentPoint32(hDC
,m_Authors
[i
] , m_Authors
[i
].GetLength(), &width
);
1009 if (width
.cx
> maxwidth
.cx
)
1012 m_authorwidth
= maxwidth
.cx
+ BLAMESPACE
;
1013 blamewidth
+= m_authorwidth
;
1018 SIZE maxwidth
= {0};
1019 for (std::vector
<CString
>::iterator I
= paths
.begin(); I
!= paths
.end(); ++I
)
1021 ::GetTextExtentPoint32(hDC
, I
->c_str(), I
->size(), &width
);
1022 if (width
.cx
> maxwidth
.cx
)
1025 m_pathwidth
= maxwidth
.cx
+ BLAMESPACE
;
1026 blamewidth
+= m_pathwidth
;
1029 ::SelectObject(hDC
, oldfont
);
1030 POINT pt
= {blamewidth
, 0};
1031 LPtoDP(hDC
, &pt
, 1);
1032 m_blamewidth
= pt
.x
;
1033 //::ReleaseDC(wBlame, hDC);
1035 //return m_blamewidth;
1040 void CTortoiseGitBlameView::CreateFont()
1046 HDC hDC
= ::GetDC(wBlame
);
1047 lf
.lfHeight
= -MulDiv((DWORD
)CRegStdWORD(_T("Software\\TortoiseGit\\BlameFontSize"), 10), GetDeviceCaps(hDC
, LOGPIXELSY
), 72);
1048 lf
.lfCharSet
= DEFAULT_CHARSET
;
1049 CRegStdString fontname
= CRegStdString(_T("Software\\TortoiseGit\\BlameFontName"), _T("Courier New"));
1050 _tcscpy_s(lf
.lfFaceName
, 32, ((stdstring
)fontname
).c_str());
1051 m_font
= ::CreateFontIndirect(&lf
);
1054 m_italicfont
= ::CreateFontIndirect(&lf
);
1056 ::ReleaseDC(wBlame
, hDC
);
1058 //m_TextView.SetFont(lf.lfFaceName,((DWORD)CRegStdWORD(_T("Software\\TortoiseGit\\BlameFontSize"), 10)));
1061 void CTortoiseGitBlameView::DrawBlame(HDC hDC
)
1069 HFONT oldfont
= NULL
;
1070 LONG_PTR line
= SendEditor(SCI_GETFIRSTVISIBLELINE
);
1071 LONG_PTR linesonscreen
= SendEditor(SCI_LINESONSCREEN
);
1072 LONG_PTR height
= SendEditor(SCI_TEXTHEIGHT
);
1074 TCHAR buf
[MAX_PATH
];
1077 //::GetClientRect(this->m_hWnd, &rc);
1078 for (LRESULT i
=line
; i
<(line
+linesonscreen
); ++i
)
1081 if (i
< (int)m_CommitHash
.size())
1083 // if (mergelines[i])
1084 // oldfont = (HFONT)::SelectObject(hDC, m_italicfont);
1086 oldfont
= (HFONT
)::SelectObject(hDC
, m_font
);
1087 ::SetBkColor(hDC
, m_windowcolor
);
1088 ::SetTextColor(hDC
, m_textcolor
);
1089 if (m_CommitHash
[i
].GetLength()>0)
1091 //if (m_CommitHash[i].Compare(m_MouseHash)==0)
1092 // ::SetBkColor(hDC, m_mouseauthorcolor);
1093 if (m_CommitHash
[i
].Compare(m_SelectedHash
)==0)
1095 ::SetBkColor(hDC
, m_selectedauthorcolor
);
1096 ::SetTextColor(hDC
, m_texthighlightcolor
);
1101 if(m_MouseLine
== i
)
1102 ::SetBkColor(hDC
, m_mouserevcolor
);
1104 //if ((revs[i] == m_mouserev)&&(!sel))
1105 // ::SetBkColor(hDC, m_mouserevcolor);
1106 //if (revs[i] == m_selectedrev)
1108 // ::SetBkColor(hDC, m_selectedrevcolor);
1109 // ::SetTextColor(hDC, m_texthighlightcolor);
1114 str
.Format(_T("%d"),m_ID
[i
]);
1116 //_stprintf_s(buf, MAX_PATH, _T("%8ld "), revs[i]);
1118 rc
.left
=LOCATOR_WIDTH
;
1120 rc
.right
= rc
.left
+ m_blamewidth
;
1121 ::ExtTextOut(hDC
, LOCATOR_WIDTH
, Y
, ETO_CLIPPED
, &rc
, str
, str
.GetLength(), 0);
1122 int Left
= m_revwidth
;
1126 rc
.right
= rc
.left
+ Left
+ m_authorwidth
;
1127 //_stprintf_s(buf, MAX_PATH, _T("%-30s "), authors[i].c_str());
1128 ::ExtTextOut(hDC
, Left
, Y
, ETO_CLIPPED
, &rc
, m_Authors
[i
], m_Authors
[i
].GetLength(), 0);
1129 Left
+= m_authorwidth
;
1134 rc
.right
= rc
.left
+ Left
+ m_datewidth
;
1135 _stprintf_s(buf
, MAX_PATH
, _T("%30s "), dates
[i
].c_str());
1136 ::ExtTextOut(hDC
, Left
, Y
, ETO_CLIPPED
, &rc
, buf
, _tcslen(buf
), 0);
1137 Left
+= m_datewidth
;
1144 rc
.right
= rc
.left
+ Left
+ m_pathwidth
;
1145 _stprintf_s(buf
, MAX_PATH
, _T("%-60s "), paths
[i
].c_str());
1146 ::ExtTextOut(hDC
, Left
, Y
, ETO_CLIPPED
, &rc
, buf
, _tcslen(buf
), 0);
1147 Left
+= m_authorwidth
;
1150 if ((i
==m_SelectedLine
)&&(m_pFindDialog
))
1153 brush
.lbColor
= m_textcolor
;
1155 brush
.lbStyle
= BS_SOLID
;
1156 HPEN pen
= ExtCreatePen(PS_SOLID
| PS_GEOMETRIC
, 2, &brush
, 0, NULL
);
1157 HGDIOBJ hPenOld
= SelectObject(hDC
, pen
);
1160 rc2
.bottom
= Y
+ height
;
1161 ::MoveToEx(hDC
, rc2
.left
, rc2
.top
, NULL
);
1162 ::LineTo(hDC
, rc2
.right
, rc2
.top
);
1163 ::LineTo(hDC
, rc2
.right
, rc2
.bottom
);
1164 ::LineTo(hDC
, rc2
.left
, rc2
.bottom
);
1165 ::LineTo(hDC
, rc2
.left
, rc2
.top
);
1166 SelectObject(hDC
, hPenOld
);
1170 ::SelectObject(hDC
, oldfont
);
1174 ::SetBkColor(hDC
, m_windowcolor
);
1175 for (int j
=0; j
< MAX_PATH
; ++j
)
1177 ::ExtTextOut(hDC
, 0, Y
, ETO_CLIPPED
, &rc
, buf
, MAX_PATH
-1, 0);
1183 void CTortoiseGitBlameView::DrawHeader(HDC hDC
)
1190 HFONT oldfont
= (HFONT
)::SelectObject(hDC
, GetStockObject(DEFAULT_GUI_FONT
));
1191 ::GetClientRect(wHeader
, &rc
);
1193 ::SetBkColor(hDC
, ::GetSysColor(COLOR_BTNFACE
));
1195 TCHAR szText
[MAX_LOADSTRING
];
1196 LoadString(app
.hResource
, IDS_HEADER_REVISION
, szText
, MAX_LOADSTRING
);
1197 ::ExtTextOut(hDC
, LOCATOR_WIDTH
, 0, ETO_CLIPPED
, &rc
, szText
, _tcslen(szText
), 0);
1198 int Left
= m_revwidth
+LOCATOR_WIDTH
;
1201 LoadString(app
.hResource
, IDS_HEADER_DATE
, szText
, MAX_LOADSTRING
);
1202 ::ExtTextOut(hDC
, Left
, 0, ETO_CLIPPED
, &rc
, szText
, _tcslen(szText
), 0);
1203 Left
+= m_datewidth
;
1207 LoadString(app
.hResource
, IDS_HEADER_AUTHOR
, szText
, MAX_LOADSTRING
);
1208 ::ExtTextOut(hDC
, Left
, 0, ETO_CLIPPED
, &rc
, szText
, _tcslen(szText
), 0);
1209 Left
+= m_authorwidth
;
1213 LoadString(app
.hResource
, IDS_HEADER_PATH
, szText
, MAX_LOADSTRING
);
1214 ::ExtTextOut(hDC
, Left
, 0, ETO_CLIPPED
, &rc
, szText
, _tcslen(szText
), 0);
1215 Left
+= m_pathwidth
;
1217 LoadString(app
.hResource
, IDS_HEADER_LINE
, szText
, MAX_LOADSTRING
);
1218 ::ExtTextOut(hDC
, Left
, 0, ETO_CLIPPED
, &rc
, szText
, _tcslen(szText
), 0);
1220 ::SelectObject(hDC
, oldfont
);
1224 void CTortoiseGitBlameView::DrawLocatorBar(HDC hDC
)
1229 LONG_PTR line
= SendEditor(SCI_GETFIRSTVISIBLELINE
);
1230 LONG_PTR linesonscreen
= SendEditor(SCI_LINESONSCREEN
);
1232 COLORREF blackColor
= GetSysColor(COLOR_WINDOWTEXT
);
1235 //::GetClientRect(wLocator, &rc);
1236 this->GetClientRect(&rc
);
1238 rc
.right
=LOCATOR_WIDTH
;
1241 LONG height
= rc
.bottom
-rc
.top
;
1242 LONG currentLine
= 0;
1244 // draw the colored bar
1245 for (std::vector
<LONG
>::const_iterator it
= m_ID
.begin(); it
!= m_ID
.end(); ++it
)
1248 // get the line color
1249 COLORREF cr
= InterColor(DWORD(m_regOldLinesColor
), DWORD(m_regNewLinesColor
), (*it
- m_lowestrev
)*100/((m_highestrev
-m_lowestrev
)+1));
1250 if ((currentLine
> line
)&&(currentLine
<= (line
+ linesonscreen
)))
1252 cr
= InterColor(cr
, blackColor
, 10);
1254 SetBkColor(hDC
, cr
);
1256 lineRect
.bottom
= (currentLine
* height
/ m_ID
.size());
1257 ::ExtTextOut(hDC
, 0, 0, ETO_OPAQUE
, &lineRect
, NULL
, 0, NULL
);
1258 Y
= lineRect
.bottom
;
1263 // now draw two lines indicating the scroll position of the source view
1264 SetBkColor(hDC
, blackColor
);
1265 lineRect
.top
= line
* height
/ m_ID
.size();
1266 lineRect
.bottom
= lineRect
.top
+1;
1267 ::ExtTextOut(hDC
, 0, 0, ETO_OPAQUE
, &lineRect
, NULL
, 0, NULL
);
1268 lineRect
.top
= (line
+ linesonscreen
) * height
/ m_ID
.size();
1269 lineRect
.bottom
= lineRect
.top
+1;
1270 ::ExtTextOut(hDC
, 0, 0, ETO_OPAQUE
, &lineRect
, NULL
, 0, NULL
);
1275 void CTortoiseGitBlameView::StringExpand(LPSTR str
)
1280 cPos
= strchr(cPos
, '\n');
1283 memmove(cPos
+1, cPos
, strlen(cPos
)*sizeof(char));
1288 } while (cPos
!= NULL
);
1290 void CTortoiseGitBlameView::StringExpand(LPWSTR str
)
1292 wchar_t * cPos
= str
;
1295 cPos
= wcschr(cPos
, '\n');
1298 memmove(cPos
+1, cPos
, wcslen(cPos
)*sizeof(wchar_t));
1303 } while (cPos
!= NULL
);
1306 // Forward declarations of functions included in this code module:
1307 ATOM
MyRegisterClass(HINSTANCE hResource
);
1308 ATOM
MyRegisterBlameClass(HINSTANCE hResource
);
1309 ATOM
MyRegisterHeaderClass(HINSTANCE hResource
);
1310 ATOM
MyRegisterLocatorClass(HINSTANCE hResource
);
1311 BOOL
InitInstance(HINSTANCE
, int);
1312 LRESULT CALLBACK
WndProc(HWND
, UINT
, WPARAM
, LPARAM
);
1313 LRESULT CALLBACK
WndBlameProc(HWND
, UINT
, WPARAM
, LPARAM
);
1314 LRESULT CALLBACK
WndHeaderProc(HWND
, UINT
, WPARAM
, LPARAM
);
1315 LRESULT CALLBACK
WndLocatorProc(HWND
, UINT
, WPARAM
, LPARAM
);
1316 UINT uFindReplaceMsg
;
1319 int APIENTRY
_tWinMain(HINSTANCE hInstance
,
1320 HINSTANCE
/*hPrevInstance*/,
1324 app
.hInstance
= hInstance
;
1328 if (::LoadLibrary("SciLexer.DLL") == NULL
)
1331 CRegStdWORD loc
= CRegStdWORD(_T("Software\\TortoiseGit\\LanguageID"), 1033);
1335 app
.hResource
= langDLL
.Init(_T("CTortoiseGitBlameView"), langId
);
1336 if (app
.hResource
== NULL
)
1337 app
.hResource
= app
.hInstance
;
1339 // Initialize global strings
1340 LoadString(app
.hResource
, IDS_APP_TITLE
, szTitle
, MAX_LOADSTRING
);
1341 LoadString(app
.hResource
, IDC_TortoiseGitBlameView
, szWindowClass
, MAX_LOADSTRING
);
1342 LoadString(app
.hResource
, IDS_SEARCHNOTFOUND
, searchstringnotfound
, MAX_LOADSTRING
);
1343 MyRegisterClass(app
.hResource
);
1344 MyRegisterBlameClass(app
.hResource
);
1345 MyRegisterHeaderClass(app
.hResource
);
1346 MyRegisterLocatorClass(app
.hResource
);
1348 // Perform application initialization:
1349 if (!InitInstance (app
.hResource
, nCmdShow
))
1355 SecureZeroMemory(szViewtitle
, MAX_PATH
);
1356 SecureZeroMemory(szOrigPath
, MAX_PATH
);
1357 char blamefile
[MAX_PATH
] = {0};
1358 char logfile
[MAX_PATH
] = {0};
1360 CCmdLineParser
parser(lpCmdLine
);
1365 _tcscpy_s(blamefile
, MAX_PATH
, __argv
[1]);
1369 _tcscpy_s(logfile
, MAX_PATH
, __argv
[2]);
1373 _tcscpy_s(szViewtitle
, MAX_PATH
, __argv
[3]);
1374 if (parser
.HasVal(_T("revrange")))
1376 _tcscat_s(szViewtitle
, MAX_PATH
, _T(" : "));
1377 _tcscat_s(szViewtitle
, MAX_PATH
, parser
.GetVal(_T("revrange")));
1380 if ((_tcslen(blamefile
)==0) || parser
.HasKey(_T("?")) || parser
.HasKey(_T("help")))
1382 TCHAR szInfo
[MAX_LOADSTRING
];
1383 LoadString(app
.hResource
, IDS_COMMANDLINE_INFO
, szInfo
, MAX_LOADSTRING
);
1384 MessageBox(NULL
, szInfo
, _T("CTortoiseGitBlameView"), MB_ICONERROR
);
1389 if ( parser
.HasKey(_T("path")) )
1391 _tcscpy_s(szOrigPath
, MAX_PATH
, parser
.GetVal(_T("path")));
1393 app
.bIgnoreEOL
= parser
.HasKey(_T("ignoreeol"));
1394 app
.bIgnoreSpaces
= parser
.HasKey(_T("ignorespaces"));
1395 app
.bIgnoreAllSpaces
= parser
.HasKey(_T("ignoreallspaces"));
1397 app
.SendEditor(SCI_SETCODEPAGE
, GetACP());
1398 app
.OpenFile(blamefile
);
1399 if (_tcslen(logfile
)>0)
1400 app
.OpenLogFile(logfile
);
1402 if (parser
.HasKey(_T("line")))
1404 app
.GotoLine(parser
.GetLongVal(_T("line")));
1407 CheckMenuItem(GetMenu(app
.wMain
), ID_VIEW_COLORAGEOFLINES
, MF_CHECKED
|MF_BYCOMMAND
);
1410 hAccelTable
= LoadAccelerators(app
.hResource
, (LPCTSTR
)IDC_TortoiseGitBlameView
);
1416 going
= GetMessage(&msg
, NULL
, 0, 0);
1417 if (app
.currentDialog
&& going
)
1419 if (!IsDialogMessage(app
.currentDialog
, &msg
))
1421 if (TranslateAccelerator(msg
.hwnd
, hAccelTable
, &msg
) == 0)
1423 TranslateMessage(&msg
);
1424 DispatchMessage(&msg
);
1430 if (TranslateAccelerator(app
.wMain
, hAccelTable
, &msg
) == 0)
1432 TranslateMessage(&msg
);
1433 DispatchMessage(&msg
);
1441 ATOM
MyRegisterClass(HINSTANCE hResource
)
1445 wcex
.cbSize
= sizeof(WNDCLASSEX
);
1447 wcex
.style
= CS_HREDRAW
| CS_VREDRAW
;
1448 wcex
.lpfnWndProc
= (WNDPROC
)WndProc
;
1449 wcex
.cbClsExtra
= 0;
1450 wcex
.cbWndExtra
= 0;
1451 wcex
.hInstance
= hResource
;
1452 wcex
.hIcon
= LoadIcon(hResource
, (LPCTSTR
)IDI_TortoiseGitBlameView
);
1453 wcex
.hCursor
= LoadCursor(NULL
, IDC_ARROW
);
1454 wcex
.hbrBackground
= (HBRUSH
)(COLOR_WINDOW
+1);
1455 wcex
.lpszMenuName
= (LPCTSTR
)IDC_TortoiseGitBlameView
;
1456 wcex
.lpszClassName
= szWindowClass
;
1457 wcex
.hIconSm
= LoadIcon(wcex
.hInstance
, (LPCTSTR
)IDI_SMALL
);
1459 return RegisterClassEx(&wcex
);
1462 ATOM
MyRegisterBlameClass(HINSTANCE hResource
)
1466 wcex
.cbSize
= sizeof(WNDCLASSEX
);
1468 wcex
.style
= CS_HREDRAW
| CS_VREDRAW
;
1469 wcex
.lpfnWndProc
= (WNDPROC
)WndBlameProc
;
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
= 0;
1477 wcex
.lpszClassName
= _T("TortoiseGitBlameViewBlame");
1478 wcex
.hIconSm
= LoadIcon(wcex
.hInstance
, (LPCTSTR
)IDI_SMALL
);
1480 return RegisterClassEx(&wcex
);
1483 ATOM
MyRegisterHeaderClass(HINSTANCE hResource
)
1487 wcex
.cbSize
= sizeof(WNDCLASSEX
);
1489 wcex
.style
= CS_HREDRAW
| CS_VREDRAW
;
1490 wcex
.lpfnWndProc
= (WNDPROC
)WndHeaderProc
;
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_BTNFACE
+1);
1497 wcex
.lpszMenuName
= 0;
1498 wcex
.lpszClassName
= _T("TortoiseGitBlameViewHeader");
1499 wcex
.hIconSm
= LoadIcon(wcex
.hInstance
, (LPCTSTR
)IDI_SMALL
);
1501 return RegisterClassEx(&wcex
);
1504 ATOM
MyRegisterLocatorClass(HINSTANCE hResource
)
1508 wcex
.cbSize
= sizeof(WNDCLASSEX
);
1510 wcex
.style
= CS_HREDRAW
| CS_VREDRAW
;
1511 wcex
.lpfnWndProc
= (WNDPROC
)WndLocatorProc
;
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_WINDOW
+1);
1518 wcex
.lpszMenuName
= 0;
1519 wcex
.lpszClassName
= _T("TortoiseGitBlameViewLocator");
1520 wcex
.hIconSm
= LoadIcon(wcex
.hInstance
, (LPCTSTR
)IDI_SMALL
);
1522 return RegisterClassEx(&wcex
);
1525 BOOL
InitInstance(HINSTANCE hResource
, int nCmdShow
)
1527 app
.wMain
= CreateWindow(szWindowClass
, szTitle
, WS_OVERLAPPEDWINDOW
,
1528 CW_USEDEFAULT
, 0, CW_USEDEFAULT
, 0, NULL
, NULL
, hResource
, NULL
);
1535 CRegStdWORD
pos(_T("Software\\TortoiseGit\\TBlamePos"), 0);
1536 CRegStdWORD
width(_T("Software\\TortoiseGit\\TBlameSize"), 0);
1537 CRegStdWORD
state(_T("Software\\TortoiseGit\\TBlameState"), 0);
1538 if (DWORD(pos
) && DWORD(width
))
1541 rc
.left
= LOWORD(DWORD(pos
));
1542 rc
.top
= HIWORD(DWORD(pos
));
1543 rc
.right
= rc
.left
+ LOWORD(DWORD(width
));
1544 rc
.bottom
= rc
.top
+ HIWORD(DWORD(width
));
1545 HMONITOR hMon
= MonitorFromRect(&rc
, MONITOR_DEFAULTTONULL
);
1548 // only restore the window position if the monitor is valid
1549 MoveWindow(app
.wMain
, LOWORD(DWORD(pos
)), HIWORD(DWORD(pos
)),
1550 LOWORD(DWORD(width
)), HIWORD(DWORD(width
)), FALSE
);
1553 if (DWORD(state
) == SW_MAXIMIZE
)
1554 ShowWindow(app
.wMain
, SW_MAXIMIZE
);
1556 ShowWindow(app
.wMain
, nCmdShow
);
1557 UpdateWindow(app
.wMain
);
1559 //Create the tooltips
1561 INITCOMMONCONTROLSEX iccex
;
1562 app
.hwndTT
; // handle to the ToolTip control
1564 RECT rect
; // for client area coordinates
1565 iccex
.dwICC
= ICC_WIN95_CLASSES
;
1566 iccex
.dwSize
= sizeof(INITCOMMONCONTROLSEX
);
1567 InitCommonControlsEx(&iccex
);
1569 /* CREATE A TOOLTIP WINDOW */
1570 app
.hwndTT
= CreateWindowEx(WS_EX_TOPMOST
,
1573 WS_POPUP
| TTS_NOPREFIX
| TTS_ALWAYSTIP
,
1584 SetWindowPos(app
.hwndTT
,
1590 SWP_NOMOVE
| SWP_NOSIZE
| SWP_NOACTIVATE
);
1592 /* GET COORDINATES OF THE MAIN CLIENT AREA */
1593 GetClientRect (app
.wBlame
, &rect
);
1595 /* INITIALIZE MEMBERS OF THE TOOLINFO STRUCTURE */
1596 ti
.cbSize
= sizeof(TOOLINFO
);
1597 ti
.uFlags
= TTF_TRACK
| TTF_ABSOLUTE
;//TTF_SUBCLASS | TTF_PARSELINKS;
1598 ti
.hwnd
= app
.wBlame
;
1599 ti
.hinst
= app
.hResource
;
1601 ti
.lpszText
= LPSTR_TEXTCALLBACK
;
1602 // ToolTip control will cover the whole window
1603 ti
.rect
.left
= rect
.left
;
1604 ti
.rect
.top
= rect
.top
;
1605 ti
.rect
.right
= rect
.right
;
1606 ti
.rect
.bottom
= rect
.bottom
;
1608 /* SEND AN ADDTOOL MESSAGE TO THE TOOLTIP CONTROL WINDOW */
1609 SendMessage(app
.hwndTT
, TTM_ADDTOOL
, 0, (LPARAM
) (LPTOOLINFO
) &ti
);
1610 SendMessage(app
.hwndTT
, TTM_SETMAXTIPWIDTH
, 0, 600);
1611 //SendMessage(app.hwndTT, TTM_SETDELAYTIME, TTDT_AUTOPOP, MAKELONG(50000, 0));
1612 //SendMessage(app.hwndTT, TTM_SETDELAYTIME, TTDT_RESHOW, MAKELONG(1000, 0));
1614 uFindReplaceMsg
= RegisterWindowMessage(FINDMSGSTRING
);
1619 void CTortoiseGitBlameView::InitSize()
1624 ::GetClientRect(wMain
, &rc
);
1625 ::SetWindowPos(wHeader
, 0, rc
.left
, rc
.top
, rc
.right
-rc
.left
, HEADER_HEIGHT
, 0);
1626 rc
.top
+= HEADER_HEIGHT
;
1627 blamerc
.left
= rc
.left
;
1628 blamerc
.top
= rc
.top
;
1629 LONG w
= GetBlameWidth();
1630 blamerc
.right
= w
> abs(rc
.right
- rc
.left
) ? rc
.right
: w
+ rc
.left
;
1631 blamerc
.bottom
= rc
.bottom
;
1632 sourcerc
.left
= blamerc
.right
;
1633 sourcerc
.top
= rc
.top
;
1634 sourcerc
.bottom
= rc
.bottom
;
1635 sourcerc
.right
= rc
.right
;
1638 ::OffsetRect(&blamerc
, LOCATOR_WIDTH
, 0);
1639 ::OffsetRect(&sourcerc
, LOCATOR_WIDTH
, 0);
1640 sourcerc
.right
-= LOCATOR_WIDTH
;
1642 ::InvalidateRect(wMain
, NULL
, FALSE
);
1643 ::SetWindowPos(m_wEditor
, 0, sourcerc
.left
, sourcerc
.top
, sourcerc
.right
- sourcerc
.left
, sourcerc
.bottom
- sourcerc
.top
, 0);
1644 ::SetWindowPos(wBlame
, 0, blamerc
.left
, blamerc
.top
, blamerc
.right
- blamerc
.left
, blamerc
.bottom
- blamerc
.top
, 0);
1646 ::SetWindowPos(wLocator
, 0, 0, blamerc
.top
, LOCATOR_WIDTH
, blamerc
.bottom
- blamerc
.top
, SWP_SHOWWINDOW
);
1648 ::ShowWindow(wLocator
, SW_HIDE
);
1652 LRESULT CALLBACK
WndProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
1654 if (message
== uFindReplaceMsg
)
1656 LPFINDREPLACE lpfr
= (LPFINDREPLACE
)lParam
;
1658 // If the FR_DIALOGTERM flag is set,
1659 // invalidate the handle identifying the dialog box.
1660 if (lpfr
->Flags
& FR_DIALOGTERM
)
1662 app
.currentDialog
= NULL
;
1665 if (lpfr
->Flags
& FR_FINDNEXT
)
1667 app
.DoSearch(lpfr
->lpstrFindWhat
, lpfr
->Flags
);
1674 app
.m_wEditor
= ::CreateWindow(
1677 WS_CHILD
| WS_VSCROLL
| WS_HSCROLL
| WS_CLIPCHILDREN
,
1684 app
.InitialiseEditor();
1685 ::ShowWindow(app
.m_wEditor
, SW_SHOW
);
1686 ::SetFocus(app
.m_wEditor
);
1687 app
.wBlame
= ::CreateWindow(
1688 _T("TortoiseGitBlameViewBlame"),
1690 WS_CHILD
| WS_CLIPCHILDREN
,
1697 ::ShowWindow(app
.wBlame
, SW_SHOW
);
1698 app
.wHeader
= ::CreateWindow(
1699 _T("TortoiseGitBlameViewHeader"),
1701 WS_CHILD
| WS_CLIPCHILDREN
| WS_BORDER
,
1708 ::ShowWindow(app
.wHeader
, SW_SHOW
);
1709 app
.wLocator
= ::CreateWindow(
1710 _T("TortoiseGitBlameViewLocator"),
1712 WS_CHILD
| WS_CLIPCHILDREN
| WS_BORDER
,
1719 ::ShowWindow(app
.wLocator
, SW_SHOW
);
1730 app
.Command(LOWORD(wParam
));
1733 app
.Notify(reinterpret_cast<SCNotification
*>(lParam
));
1740 CRegStdWORD
pos(_T("Software\\TortoiseGit\\TBlamePos"), 0);
1741 CRegStdWORD
width(_T("Software\\TortoiseGit\\TBlameSize"), 0);
1742 CRegStdWORD
state(_T("Software\\TortoiseGit\\TBlameState"), 0);
1744 GetWindowRect(app
.wMain
, &rc
);
1745 if ((rc
.left
>= 0)&&(rc
.top
>= 0))
1747 pos
= MAKELONG(rc
.left
, rc
.top
);
1748 width
= MAKELONG(rc
.right
-rc
.left
, rc
.bottom
-rc
.top
);
1750 WINDOWPLACEMENT wp
= {0};
1751 wp
.length
= sizeof(WINDOWPLACEMENT
);
1752 GetWindowPlacement(app
.wMain
, &wp
);
1754 ::DestroyWindow(app
.m_wEditor
);
1755 ::PostQuitMessage(0);
1759 ::SetFocus(app
.wBlame
);
1762 return DefWindowProc(hWnd
, message
, wParam
, lParam
);
1767 LRESULT CALLBACK
WndBlameProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
1770 TRACKMOUSEEVENT mevt
;
1777 hDC
= BeginPaint(app
.wBlame
, &ps
);
1779 EndPaint(app
.wBlame
, &ps
);
1782 app
.Command(LOWORD(wParam
));
1785 switch (((LPNMHDR
)lParam
)->code
)
1787 case TTN_GETDISPINFO
:
1789 LPNMHDR pNMHDR
= (LPNMHDR
)lParam
;
1790 NMTTDISPINFOA
* pTTTA
= (NMTTDISPINFOA
*)pNMHDR
;
1791 NMTTDISPINFOW
* pTTTW
= (NMTTDISPINFOW
*)pNMHDR
;
1793 DWORD ptW
= GetMessagePos();
1794 point
.x
= GET_X_LPARAM(ptW
);
1795 point
.y
= GET_Y_LPARAM(ptW
);
1796 ::ScreenToClient(app
.wBlame
, &point
);
1797 LONG_PTR line
= app
.SendEditor(SCI_GETFIRSTVISIBLELINE
);
1798 LONG_PTR height
= app
.SendEditor(SCI_TEXTHEIGHT
);
1799 line
= line
+ (point
.y
/height
);
1800 if (line
>= (LONG
)app
.revs
.size())
1804 LONG rev
= app
.revs
[line
];
1805 if (line
>= (LONG
)app
.revs
.size())
1808 SecureZeroMemory(app
.m_szTip
, sizeof(app
.m_szTip
));
1809 SecureZeroMemory(app
.m_wszTip
, sizeof(app
.m_wszTip
));
1810 std::map
<LONG
, CString
>::iterator iter
;
1811 if ((iter
= app
.logmessages
.find(rev
)) != app
.logmessages
.end())
1816 msg
+= app
.authors
[line
];
1820 if (!ShowAuthor
) msg
+= " ";
1821 msg
+= app
.dates
[line
];
1823 if (!ShowAuthor
|| !ShowDate
)
1825 msg
+= iter
->second
;
1826 // an empty tooltip string will deactivate the tooltips,
1827 // which means we must make sure that the tooltip won't
1831 if (pNMHDR
->code
== TTN_NEEDTEXTA
)
1833 lstrcpyn(app
.m_szTip
, msg
.c_str(), MAX_LOG_LENGTH
*2);
1834 app
.StringExpand(app
.m_szTip
);
1835 pTTTA
->lpszText
= app
.m_szTip
;
1839 pTTTW
->lpszText
= app
.m_wszTip
;
1840 ::MultiByteToWideChar( CP_ACP
, 0, msg
.c_str(), min(msg
.size(), MAX_LOG_LENGTH
*2), app
.m_wszTip
, MAX_LOG_LENGTH
*2);
1841 app
.StringExpand(app
.m_wszTip
);
1853 app
.m_mouserev
= -2;
1854 app
.m_mouseauthor
.clear();
1855 app
.ttVisible
= FALSE
;
1856 SendMessage(app
.hwndTT
, TTM_TRACKACTIVATE
, FALSE
, 0);
1857 ::InvalidateRect(app
.wBlame
, NULL
, FALSE
);
1861 mevt
.cbSize
= sizeof(TRACKMOUSEEVENT
);
1862 mevt
.dwFlags
= TME_LEAVE
;
1863 mevt
.dwHoverTime
= HOVER_DEFAULT
;
1864 mevt
.hwndTrack
= app
.wBlame
;
1865 ::TrackMouseEvent(&mevt
);
1866 POINT pt
= {((int)(short)LOWORD(lParam
)), ((int)(short)HIWORD(lParam
))};
1867 ClientToScreen(app
.wBlame
, &pt
);
1870 SendMessage(app
.hwndTT
, TTM_TRACKPOSITION
, 0, MAKELONG(pt
.x
, pt
.y
));
1874 ti
.cbSize
= sizeof(TOOLINFO
);
1875 ti
.hwnd
= app
.wBlame
;
1877 SendMessage(app
.hwndTT
, TTM_TRACKACTIVATE
, TRUE
, (LPARAM
)&ti
);
1879 int y
= ((int)(short)HIWORD(lParam
));
1880 LONG_PTR line
= app
.SendEditor(SCI_GETFIRSTVISIBLELINE
);
1881 LONG_PTR height
= app
.SendEditor(SCI_TEXTHEIGHT
);
1882 line
= line
+ (y
/height
);
1883 app
.ttVisible
= (line
< (LONG
)app
.revs
.size());
1884 if ( app
.ttVisible
)
1886 if (app
.authors
[line
].compare(app
.m_mouseauthor
) != 0)
1888 app
.m_mouseauthor
= app
.authors
[line
];
1890 if (app
.revs
[line
] != app
.m_mouserev
)
1892 app
.m_mouserev
= app
.revs
[line
];
1893 ::InvalidateRect(app
.wBlame
, NULL
, FALSE
);
1894 SendMessage(app
.hwndTT
, TTM_UPDATE
, 0, 0);
1899 case WM_RBUTTONDOWN
:
1901 case WM_LBUTTONDOWN
:
1905 ::SetFocus(app
.wBlame
);
1906 app
.SendEditor(SCI_GRABFOCUS
);
1908 case WM_CONTEXTMENU
:
1910 if (app
.m_selectedrev
<= 0)
1912 int xPos
= GET_X_LPARAM(lParam
);
1913 int yPos
= GET_Y_LPARAM(lParam
);
1914 if ((xPos
< 0)||(yPos
< 0))
1916 // requested from keyboard, not mouse pointer
1917 // use the center of the window
1919 GetClientRect(app
.wBlame
, &rect
);
1920 xPos
= rect
.right
-rect
.left
;
1921 yPos
= rect
.bottom
-rect
.top
;
1923 HMENU hMenu
= LoadMenu(app
.hResource
, MAKEINTRESOURCE(IDR_BLAMEPOPUP
));
1924 HMENU hPopMenu
= GetSubMenu(hMenu
, 0);
1926 if ( _tcslen(szOrigPath
)==0 )
1928 // Without knowing the original path we cannot blame the previous revision
1929 // because we don't know which filename to pass to tortoiseproc.
1930 EnableMenuItem(hPopMenu
,ID_BLAME_PREVIOUS_REVISION
, MF_DISABLED
|MF_GRAYED
);
1933 TrackPopupMenu(hPopMenu
, TPM_LEFTALIGN
| TPM_RIGHTBUTTON
, xPos
, yPos
, 0, app
.wBlame
, NULL
);
1938 return DefWindowProc(hWnd
, message
, wParam
, lParam
);
1943 LRESULT CALLBACK
WndHeaderProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
1952 hDC
= BeginPaint(app
.wHeader
, &ps
);
1953 app
.DrawHeader(hDC
);
1954 EndPaint(app
.wHeader
, &ps
);
1963 return DefWindowProc(hWnd
, message
, wParam
, lParam
);
1968 LRESULT CALLBACK
WndLocatorProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
1975 hDC
= BeginPaint(app
.wLocator
, &ps
);
1976 app
.DrawLocatorBar(hDC
);
1977 EndPaint(app
.wLocator
, &ps
);
1979 case WM_LBUTTONDOWN
:
1981 if (wParam
& MK_LBUTTON
)
1984 ::GetClientRect(hWnd
, &rect
);
1985 int nLine
= HIWORD(lParam
)*app
.revs
.size()/(rect
.bottom
-rect
.top
);
1989 app
.ScrollToLine(nLine
);
1993 return DefWindowProc(hWnd
, message
, wParam
, lParam
);
1999 void CTortoiseGitBlameView::SetupLexer(CString filename
)
2003 //const char * lineptr = _tcsrchr(filename, '.');
2004 int start
=filename
.ReverseFind(_T('.'));
2007 //_tcscpy_s(line, 20, lineptr+1);
2008 //_tcslwr_s(line, 20);
2009 CString ext
=filename
.Right(filename
.GetLength()-start
-1);
2010 line
=ext
.GetBuffer();
2012 if ((_tcscmp(line
, _T("py"))==0)||
2013 (_tcscmp(line
, _T("pyw"))==0)||
2014 (_tcscmp(line
, _T("pyw"))==0))
2016 SendEditor(SCI_SETLEXER
, SCLEX_PYTHON
);
2017 SendEditor(SCI_SETKEYWORDS
, 0, (LPARAM
)(m_TextView
.StringForControl(_T("and assert break class continue def del elif \
2018 else except exec finally for from global if import in is lambda None \
2019 not or pass print raise return try while yield")).GetBuffer()));
2020 SetAStyle(SCE_P_DEFAULT
, black
);
2021 SetAStyle(SCE_P_COMMENTLINE
, darkGreen
);
2022 SetAStyle(SCE_P_NUMBER
, RGB(0, 0x80, 0x80));
2023 SetAStyle(SCE_P_STRING
, RGB(0, 0, 0x80));
2024 SetAStyle(SCE_P_CHARACTER
, RGB(0, 0, 0x80));
2025 SetAStyle(SCE_P_WORD
, RGB(0x80, 0, 0x80));
2026 SetAStyle(SCE_P_TRIPLE
, black
);
2027 SetAStyle(SCE_P_TRIPLEDOUBLE
, black
);
2028 SetAStyle(SCE_P_CLASSNAME
, darkBlue
);
2029 SetAStyle(SCE_P_DEFNAME
, darkBlue
);
2030 SetAStyle(SCE_P_OPERATOR
, darkBlue
);
2031 SetAStyle(SCE_P_IDENTIFIER
, darkBlue
);
2032 SetAStyle(SCE_P_COMMENTBLOCK
, darkGreen
);
2033 SetAStyle(SCE_P_STRINGEOL
, red
);
2035 if ((_tcscmp(line
, _T("c"))==0)||
2036 (_tcscmp(line
, _T("cc"))==0)||
2037 (_tcscmp(line
, _T("cpp"))==0)||
2038 (_tcscmp(line
, _T("cxx"))==0)||
2039 (_tcscmp(line
, _T("h"))==0)||
2040 (_tcscmp(line
, _T("hh"))==0)||
2041 (_tcscmp(line
, _T("hpp"))==0)||
2042 (_tcscmp(line
, _T("hxx"))==0)||
2043 (_tcscmp(line
, _T("dlg"))==0)||
2044 (_tcscmp(line
, _T("mak"))==0))
2046 SendEditor(SCI_SETLEXER
, SCLEX_CPP
);
2047 SendEditor(SCI_SETKEYWORDS
, 0, (LPARAM
)(m_TextView
.StringForControl(_T("and and_eq asm auto bitand bitor bool break \
2048 case catch char class compl const const_cast continue \
2049 default delete do double dynamic_cast else enum explicit export extern false float for \
2050 friend goto if inline int long mutable namespace new not not_eq \
2051 operator or or_eq private protected public \
2052 register reinterpret_cast return short signed sizeof static static_cast struct switch \
2053 template this throw true try typedef typeid typename union unsigned using \
2054 virtual void volatile wchar_t while xor xor_eq")).GetBuffer()));
2055 SendEditor(SCI_SETKEYWORDS
, 3, (LPARAM
)(m_TextView
.StringForControl(_T("a addindex addtogroup anchor arg attention \
2056 author b brief bug c class code date def defgroup deprecated dontinclude \
2057 e em endcode endhtmlonly endif endlatexonly endlink endverbatim enum example exception \
2058 f$ f[ f] file fn hideinitializer htmlinclude htmlonly \
2059 if image include ingroup internal invariant interface latexonly li line link \
2060 mainpage name namespace nosubgrouping note overload \
2061 p page par param post pre ref relates remarks return retval \
2062 sa section see showinitializer since skip skipline struct subsection \
2063 test throw todo typedef union until \
2064 var verbatim verbinclude version warning weakgroup $ @ \\ & < > # { }")).GetBuffer()));
2067 if (_tcscmp(line
, _T("cs"))==0)
2069 SendEditor(SCI_SETLEXER
, SCLEX_CPP
);
2070 SendEditor(SCI_SETKEYWORDS
, 0, (LPARAM
)(m_TextView
.StringForControl(_T("abstract as base bool break byte case catch char checked class \
2071 const continue decimal default delegate do double else enum \
2072 event explicit extern false finally fixed float for foreach goto if \
2073 implicit in int interface internal is lock long namespace new null \
2074 object operator out override params private protected public \
2075 readonly ref return sbyte sealed short sizeof stackalloc static \
2076 string struct switch this throw true try typeof uint ulong \
2077 unchecked unsafe ushort using virtual void while")).GetBuffer()));
2080 if ((_tcscmp(line
, _T("rc"))==0)||
2081 (_tcscmp(line
, _T("rc2"))==0))
2083 SendEditor(SCI_SETLEXER
, SCLEX_CPP
);
2084 SendEditor(SCI_SETKEYWORDS
, 0, (LPARAM
)(m_TextView
.StringForControl(_T("ACCELERATORS ALT AUTO3STATE AUTOCHECKBOX AUTORADIOBUTTON \
2085 BEGIN BITMAP BLOCK BUTTON CAPTION CHARACTERISTICS CHECKBOX CLASS \
2086 COMBOBOX CONTROL CTEXT CURSOR DEFPUSHBUTTON DIALOG DIALOGEX DISCARDABLE \
2087 EDITTEXT END EXSTYLE FONT GROUPBOX ICON LANGUAGE LISTBOX LTEXT \
2088 MENU MENUEX MENUITEM MESSAGETABLE POPUP \
2089 PUSHBUTTON RADIOBUTTON RCDATA RTEXT SCROLLBAR SEPARATOR SHIFT STATE3 \
2090 STRINGTABLE STYLE TEXTINCLUDE VALUE VERSION VERSIONINFO VIRTKEY")).GetBuffer()));
2093 if ((_tcscmp(line
, _T("idl"))==0)||
2094 (_tcscmp(line
, _T("odl"))==0))
2096 SendEditor(SCI_SETLEXER
, SCLEX_CPP
);
2097 SendEditor(SCI_SETKEYWORDS
, 0, (LPARAM
)(m_TextView
.StringForControl(_T("aggregatable allocate appobject arrays async async_uuid \
2099 bindable boolean broadcast byte byte_count \
2100 call_as callback char coclass code comm_status \
2101 const context_handle context_handle_noserialize \
2102 context_handle_serialize control cpp_quote custom \
2103 decode default defaultbind defaultcollelem \
2104 defaultvalue defaultvtable dispinterface displaybind dllname \
2106 enable_allocate encode endpoint entry enum error_status_t \
2108 fault_status first_is float \
2109 handle_t heap helpcontext helpfile helpstring \
2110 helpstringcontext helpstringdll hidden hyper \
2111 id idempotent ignore iid_as iid_is immediatebind implicit_handle \
2112 import importlib in include in_line int __int64 __int3264 interface \
2113 last_is lcid length_is library licensed local long \
2114 max_is maybe message methods midl_pragma \
2115 midl_user_allocate midl_user_free min_is module ms_union \
2116 ncacn_at_dsp ncacn_dnet_nsp ncacn_http ncacn_ip_tcp \
2117 ncacn_nb_ipx ncacn_nb_nb ncacn_nb_tcp ncacn_np \
2118 ncacn_spx ncacn_vns_spp ncadg_ip_udp ncadg_ipx ncadg_mq \
2119 ncalrpc nocode nonbrowsable noncreatable nonextensible notify \
2120 object odl oleautomation optimize optional out out_of_line \
2121 pipe pointer_default pragma properties propget propput propputref \
2123 range readonly ref represent_as requestedit restricted retval \
2124 shape short signed size_is small source strict_context_handle \
2125 string struct switch switch_is switch_type \
2126 transmit_as typedef \
2127 uidefault union unique unsigned user_marshal usesgetlasterror uuid \
2128 v1_enum vararg version void wchar_t wire_marshal")).GetBuffer()));
2131 if (_tcscmp(line
, _T("java"))==0)
2133 SendEditor(SCI_SETLEXER
, SCLEX_CPP
);
2134 SendEditor(SCI_SETKEYWORDS
, 0, (LPARAM
)(m_TextView
.StringForControl(_T("abstract assert boolean break byte case catch char class \
2135 const continue default do double else extends final finally float for future \
2136 generic goto if implements import inner instanceof int interface long \
2137 native new null outer package private protected public rest \
2138 return short static super switch synchronized this throw throws \
2139 transient try var void volatile while")).GetBuffer()));
2142 if (_tcscmp(line
, _T("js"))==0)
2144 SendEditor(SCI_SETLEXER
, SCLEX_CPP
);
2145 SendEditor(SCI_SETKEYWORDS
, 0, (LPARAM
)(m_TextView
.StringForControl(_T("abstract boolean break byte case catch char class \
2146 const continue debugger default delete do double else enum export extends \
2147 final finally float for function goto if implements import in instanceof \
2148 int interface long native new package private protected public \
2149 return short static super switch synchronized this throw throws \
2150 transient try typeof var void volatile while with")).GetBuffer()));
2153 if ((_tcscmp(line
, _T("pas"))==0)||
2154 (_tcscmp(line
, _T("dpr"))==0)||
2155 (_tcscmp(line
, _T("pp"))==0))
2157 SendEditor(SCI_SETLEXER
, SCLEX_PASCAL
);
2158 SendEditor(SCI_SETKEYWORDS
, 0, (LPARAM
)(m_TextView
.StringForControl(_T("and array as begin case class const constructor \
2159 destructor div do downto else end except file finally \
2160 for function goto if implementation in inherited \
2161 interface is mod not object of on or packed \
2162 procedure program property raise record repeat \
2163 set shl shr then threadvar to try type unit \
2164 until uses var while with xor")).GetBuffer()));
2167 if ((_tcscmp(line
, _T("as"))==0)||
2168 (_tcscmp(line
, _T("asc"))==0)||
2169 (_tcscmp(line
, _T("jsfl"))==0))
2171 SendEditor(SCI_SETLEXER
, SCLEX_CPP
);
2172 SendEditor(SCI_SETKEYWORDS
, 0, (LPARAM
)(m_TextView
.StringForControl(_T("add and break case catch class continue default delete do \
2173 dynamic else eq extends false finally for function ge get gt if implements import in \
2174 instanceof interface intrinsic le lt ne new not null or private public return \
2175 set static super switch this throw true try typeof undefined var void while with")).GetBuffer()));
2176 SendEditor(SCI_SETKEYWORDS
, 1, (LPARAM
)(m_TextView
.StringForControl(_T("Array Arguments Accessibility Boolean Button Camera Color \
2177 ContextMenu ContextMenuItem Date Error Function Key LoadVars LocalConnection Math \
2178 Microphone Mouse MovieClip MovieClipLoader NetConnection NetStream Number Object \
2179 PrintJob Selection SharedObject Sound Stage String StyleSheet System TextField \
2180 TextFormat TextSnapshot Video Void XML XMLNode XMLSocket \
2181 _accProps _focusrect _global _highquality _parent _quality _root _soundbuftime \
2182 arguments asfunction call capabilities chr clearInterval duplicateMovieClip \
2183 escape eval fscommand getProperty getTimer getURL getVersion gotoAndPlay gotoAndStop \
2184 ifFrameLoaded Infinity -Infinity int isFinite isNaN length loadMovie loadMovieNum \
2185 loadVariables loadVariablesNum maxscroll mbchr mblength mbord mbsubstring MMExecute \
2186 NaN newline nextFrame nextScene on onClipEvent onUpdate ord parseFloat parseInt play \
2187 prevFrame prevScene print printAsBitmap printAsBitmapNum printNum random removeMovieClip \
2188 scroll set setInterval setProperty startDrag stop stopAllSounds stopDrag substring \
2189 targetPath tellTarget toggleHighQuality trace unescape unloadMovie unLoadMovieNum updateAfterEvent")).GetBuffer()));
2192 if ((_tcscmp(line
, _T("html"))==0)||
2193 (_tcscmp(line
, _T("htm"))==0)||
2194 (_tcscmp(line
, _T("shtml"))==0)||
2195 (_tcscmp(line
, _T("htt"))==0)||
2196 (_tcscmp(line
, _T("xml"))==0)||
2197 (_tcscmp(line
, _T("asp"))==0)||
2198 (_tcscmp(line
, _T("xsl"))==0)||
2199 (_tcscmp(line
, _T("php"))==0)||
2200 (_tcscmp(line
, _T("xhtml"))==0)||
2201 (_tcscmp(line
, _T("phtml"))==0)||
2202 (_tcscmp(line
, _T("cfm"))==0)||
2203 (_tcscmp(line
, _T("tpl"))==0)||
2204 (_tcscmp(line
, _T("dtd"))==0)||
2205 (_tcscmp(line
, _T("hta"))==0)||
2206 (_tcscmp(line
, _T("htd"))==0)||
2207 (_tcscmp(line
, _T("wxs"))==0))
2209 SendEditor(SCI_SETLEXER
, SCLEX_HTML
);
2210 SendEditor(SCI_SETSTYLEBITS
, 7);
2211 SendEditor(SCI_SETKEYWORDS
, 0, (LPARAM
)(m_TextView
.StringForControl(_T("a abbr acronym address applet area b base basefont \
2212 bdo big blockquote body br button caption center \
2213 cite code col colgroup dd del dfn dir div dl dt em \
2214 fieldset font form frame frameset h1 h2 h3 h4 h5 h6 \
2215 head hr html i iframe img input ins isindex kbd label \
2216 legend li link map menu meta noframes noscript \
2217 object ol optgroup option p param pre q s samp \
2218 script select small span strike strong style sub sup \
2219 table tbody td textarea tfoot th thead title tr tt u ul \
2220 var xml xmlns abbr accept-charset accept accesskey action align alink \
2221 alt archive axis background bgcolor border \
2222 cellpadding cellspacing char charoff charset checked cite \
2223 class classid clear codebase codetype color cols colspan \
2224 compact content coords \
2225 data datafld dataformatas datapagesize datasrc datetime \
2226 declare defer dir disabled enctype event \
2227 face for frame frameborder \
2228 headers height href hreflang hspace http-equiv \
2229 id ismap label lang language leftmargin link longdesc \
2230 marginwidth marginheight maxlength media method multiple \
2231 name nohref noresize noshade nowrap \
2232 object onblur onchange onclick ondblclick onfocus \
2233 onkeydown onkeypress onkeyup onload onmousedown \
2234 onmousemove onmouseover onmouseout onmouseup \
2235 onreset onselect onsubmit onunload \
2236 profile prompt readonly rel rev rows rowspan rules \
2237 scheme scope selected shape size span src standby start style \
2238 summary tabindex target text title topmargin type usemap \
2239 valign value valuetype version vlink vspace width \
2240 text password checkbox radio submit reset \
2241 file hidden image")).GetBuffer()));
2242 SendEditor(SCI_SETKEYWORDS
, 1, (LPARAM
)(m_TextView
.StringForControl(_T("assign audio block break catch choice clear disconnect else elseif \
2243 emphasis enumerate error exit field filled form goto grammar help \
2244 if initial link log menu meta noinput nomatch object option p paragraph \
2245 param phoneme prompt property prosody record reprompt return s say-as \
2246 script sentence subdialog submit throw transfer value var voice vxml")).GetBuffer()));
2247 SendEditor(SCI_SETKEYWORDS
, 2, (LPARAM
)(m_TextView
.StringForControl(_T("accept age alphabet anchor application base beep bridge category charset \
2248 classid cond connecttimeout content contour count dest destexpr dtmf dtmfterm \
2249 duration enctype event eventexpr expr expritem fetchtimeout finalsilence \
2250 gender http-equiv id level maxage maxstale maxtime message messageexpr \
2251 method mime modal mode name namelist next nextitem ph pitch range rate \
2252 scope size sizeexpr skiplist slot src srcexpr sub time timeexpr timeout \
2253 transferaudio type value variant version volume xml:lang")).GetBuffer()));
2254 SendEditor(SCI_SETKEYWORDS
, 3, (LPARAM
)(m_TextView
.StringForControl(_T("and assert break class continue def del elif \
2255 else except exec finally for from global if import in is lambda None \
2256 not or pass print raise return try while yield")).GetBuffer()));
2257 SendEditor(SCI_SETKEYWORDS
, 4, (LPARAM
)(m_TextView
.StringForControl(_T("and argv as argc break case cfunction class continue declare default do \
2258 die echo else elseif empty enddeclare endfor endforeach endif endswitch \
2259 endwhile e_all e_parse e_error e_warning eval exit extends false for \
2260 foreach function global http_cookie_vars http_get_vars http_post_vars \
2261 http_post_files http_env_vars http_server_vars if include include_once \
2262 list new not null old_function or parent php_os php_self php_version \
2263 print require require_once return static switch stdclass this true var \
2264 xor virtual while __file__ __line__ __sleep __wakeup")).GetBuffer()));
2266 SetAStyle(SCE_H_TAG
, darkBlue
);
2267 SetAStyle(SCE_H_TAGUNKNOWN
, red
);
2268 SetAStyle(SCE_H_ATTRIBUTE
, darkBlue
);
2269 SetAStyle(SCE_H_ATTRIBUTEUNKNOWN
, red
);
2270 SetAStyle(SCE_H_NUMBER
, RGB(0x80,0,0x80));
2271 SetAStyle(SCE_H_DOUBLESTRING
, RGB(0,0x80,0));
2272 SetAStyle(SCE_H_SINGLESTRING
, RGB(0,0x80,0));
2273 SetAStyle(SCE_H_OTHER
, RGB(0x80,0,0x80));
2274 SetAStyle(SCE_H_COMMENT
, RGB(0x80,0x80,0));
2275 SetAStyle(SCE_H_ENTITY
, RGB(0x80,0,0x80));
2277 SetAStyle(SCE_H_TAGEND
, darkBlue
);
2278 SetAStyle(SCE_H_XMLSTART
, darkBlue
); // <?
2279 SetAStyle(SCE_H_QUESTION
, darkBlue
); // <?
2280 SetAStyle(SCE_H_XMLEND
, darkBlue
); // ?>
2281 SetAStyle(SCE_H_SCRIPT
, darkBlue
); // <script
2282 SetAStyle(SCE_H_ASP
, RGB(0x4F, 0x4F, 0), RGB(0xFF, 0xFF, 0)); // <% ... %>
2283 SetAStyle(SCE_H_ASPAT
, RGB(0x4F, 0x4F, 0), RGB(0xFF, 0xFF, 0)); // <%@ ... %>
2285 SetAStyle(SCE_HB_DEFAULT
, black
);
2286 SetAStyle(SCE_HB_COMMENTLINE
, darkGreen
);
2287 SetAStyle(SCE_HB_NUMBER
, RGB(0,0x80,0x80));
2288 SetAStyle(SCE_HB_WORD
, darkBlue
);
2289 SendEditor(SCI_STYLESETBOLD
, SCE_HB_WORD
, 1);
2290 SetAStyle(SCE_HB_STRING
, RGB(0x80,0,0x80));
2291 SetAStyle(SCE_HB_IDENTIFIER
, black
);
2293 // This light blue is found in the windows system palette so is safe to use even in 256 colour modes.
2294 // Show the whole section of VBScript with light blue background
2295 for (int bstyle
=SCE_HB_DEFAULT
; bstyle
<=SCE_HB_STRINGEOL
; bstyle
++) {
2296 SendEditor(SCI_STYLESETFONT
, bstyle
,
2297 reinterpret_cast<LPARAM
>(m_TextView
.StringForControl(_T("Lucida Console")).GetBuffer()));
2298 SendEditor(SCI_STYLESETBACK
, bstyle
, lightBlue
);
2299 // This call extends the backround colour of the last style on the line to the edge of the window
2300 SendEditor(SCI_STYLESETEOLFILLED
, bstyle
, 1);
2302 SendEditor(SCI_STYLESETBACK
, SCE_HB_STRINGEOL
, RGB(0x7F,0x7F,0xFF));
2303 SendEditor(SCI_STYLESETFONT
, SCE_HB_COMMENTLINE
,
2304 reinterpret_cast<LPARAM
>(m_TextView
.StringForControl(_T("Lucida Console")).GetBuffer()));
2306 SetAStyle(SCE_HBA_DEFAULT
, black
);
2307 SetAStyle(SCE_HBA_COMMENTLINE
, darkGreen
);
2308 SetAStyle(SCE_HBA_NUMBER
, RGB(0,0x80,0x80));
2309 SetAStyle(SCE_HBA_WORD
, darkBlue
);
2310 SendEditor(SCI_STYLESETBOLD
, SCE_HBA_WORD
, 1);
2311 SetAStyle(SCE_HBA_STRING
, RGB(0x80,0,0x80));
2312 SetAStyle(SCE_HBA_IDENTIFIER
, black
);
2314 // Show the whole section of ASP VBScript with bright yellow background
2315 for (int bastyle
=SCE_HBA_DEFAULT
; bastyle
<=SCE_HBA_STRINGEOL
; bastyle
++) {
2316 SendEditor(SCI_STYLESETFONT
, bastyle
,
2317 reinterpret_cast<LPARAM
>(m_TextView
.StringForControl(_T("Lucida Console")).GetBuffer()));
2318 SendEditor(SCI_STYLESETBACK
, bastyle
, RGB(0xFF, 0xFF, 0));
2319 // This call extends the backround colour of the last style on the line to the edge of the window
2320 SendEditor(SCI_STYLESETEOLFILLED
, bastyle
, 1);
2322 SendEditor(SCI_STYLESETBACK
, SCE_HBA_STRINGEOL
, RGB(0xCF,0xCF,0x7F));
2323 SendEditor(SCI_STYLESETFONT
, SCE_HBA_COMMENTLINE
,
2324 reinterpret_cast<LPARAM
>(m_TextView
.StringForControl(_T("Lucida Console")).GetBuffer()));
2326 // If there is no need to support embedded Javascript, the following code can be dropped.
2327 // Javascript will still be correctly processed but will be displayed in just the default style.
2329 SetAStyle(SCE_HJ_START
, RGB(0x80,0x80,0));
2330 SetAStyle(SCE_HJ_DEFAULT
, black
);
2331 SetAStyle(SCE_HJ_COMMENT
, darkGreen
);
2332 SetAStyle(SCE_HJ_COMMENTLINE
, darkGreen
);
2333 SetAStyle(SCE_HJ_COMMENTDOC
, darkGreen
);
2334 SetAStyle(SCE_HJ_NUMBER
, RGB(0,0x80,0x80));
2335 SetAStyle(SCE_HJ_WORD
, black
);
2336 SetAStyle(SCE_HJ_KEYWORD
, darkBlue
);
2337 SetAStyle(SCE_HJ_DOUBLESTRING
, RGB(0x80,0,0x80));
2338 SetAStyle(SCE_HJ_SINGLESTRING
, RGB(0x80,0,0x80));
2339 SetAStyle(SCE_HJ_SYMBOLS
, black
);
2341 SetAStyle(SCE_HJA_START
, RGB(0x80,0x80,0));
2342 SetAStyle(SCE_HJA_DEFAULT
, black
);
2343 SetAStyle(SCE_HJA_COMMENT
, darkGreen
);
2344 SetAStyle(SCE_HJA_COMMENTLINE
, darkGreen
);
2345 SetAStyle(SCE_HJA_COMMENTDOC
, darkGreen
);
2346 SetAStyle(SCE_HJA_NUMBER
, RGB(0,0x80,0x80));
2347 SetAStyle(SCE_HJA_WORD
, black
);
2348 SetAStyle(SCE_HJA_KEYWORD
, darkBlue
);
2349 SetAStyle(SCE_HJA_DOUBLESTRING
, RGB(0x80,0,0x80));
2350 SetAStyle(SCE_HJA_SINGLESTRING
, RGB(0x80,0,0x80));
2351 SetAStyle(SCE_HJA_SYMBOLS
, black
);
2353 SetAStyle(SCE_HPHP_DEFAULT
, black
);
2354 SetAStyle(SCE_HPHP_HSTRING
, RGB(0x80,0,0x80));
2355 SetAStyle(SCE_HPHP_SIMPLESTRING
, RGB(0x80,0,0x80));
2356 SetAStyle(SCE_HPHP_WORD
, darkBlue
);
2357 SetAStyle(SCE_HPHP_NUMBER
, RGB(0,0x80,0x80));
2358 SetAStyle(SCE_HPHP_VARIABLE
, red
);
2359 SetAStyle(SCE_HPHP_HSTRING_VARIABLE
, red
);
2360 SetAStyle(SCE_HPHP_COMPLEX_VARIABLE
, red
);
2361 SetAStyle(SCE_HPHP_COMMENT
, darkGreen
);
2362 SetAStyle(SCE_HPHP_COMMENTLINE
, darkGreen
);
2363 SetAStyle(SCE_HPHP_OPERATOR
, darkBlue
);
2365 // Show the whole section of Javascript with off white background
2366 for (int jstyle
=SCE_HJ_DEFAULT
; jstyle
<=SCE_HJ_SYMBOLS
; jstyle
++) {
2367 SendEditor(SCI_STYLESETFONT
, jstyle
,
2368 reinterpret_cast<LPARAM
>(m_TextView
.StringForControl(_T("Lucida Console")).GetBuffer()));
2369 SendEditor(SCI_STYLESETBACK
, jstyle
, offWhite
);
2370 SendEditor(SCI_STYLESETEOLFILLED
, jstyle
, 1);
2372 SendEditor(SCI_STYLESETBACK
, SCE_HJ_STRINGEOL
, RGB(0xDF, 0xDF, 0x7F));
2373 SendEditor(SCI_STYLESETEOLFILLED
, SCE_HJ_STRINGEOL
, 1);
2375 // Show the whole section of Javascript with brown background
2376 for (int jastyle
=SCE_HJA_DEFAULT
; jastyle
<=SCE_HJA_SYMBOLS
; jastyle
++) {
2377 SendEditor(SCI_STYLESETFONT
, jastyle
,
2378 reinterpret_cast<LPARAM
>(m_TextView
.StringForControl(_T("Lucida Console")).GetBuffer()));
2379 SendEditor(SCI_STYLESETBACK
, jastyle
, RGB(0xDF, 0xDF, 0x7F));
2380 SendEditor(SCI_STYLESETEOLFILLED
, jastyle
, 1);
2382 SendEditor(SCI_STYLESETBACK
, SCE_HJA_STRINGEOL
, RGB(0x0,0xAF,0x5F));
2383 SendEditor(SCI_STYLESETEOLFILLED
, SCE_HJA_STRINGEOL
, 1);
2388 SendEditor(SCI_SETLEXER
, SCLEX_CPP
);
2391 SendEditor(SCI_COLOURISE
, 0, -1);
2395 void CTortoiseGitBlameView::SetupCppLexer()
2397 SetAStyle(SCE_C_DEFAULT
, RGB(0, 0, 0));
2398 SetAStyle(SCE_C_COMMENT
, RGB(0, 0x80, 0));
2399 SetAStyle(SCE_C_COMMENTLINE
, RGB(0, 0x80, 0));
2400 SetAStyle(SCE_C_COMMENTDOC
, RGB(0, 0x80, 0));
2401 SetAStyle(SCE_C_COMMENTLINEDOC
, RGB(0, 0x80, 0));
2402 SetAStyle(SCE_C_COMMENTDOCKEYWORD
, RGB(0, 0x80, 0));
2403 SetAStyle(SCE_C_COMMENTDOCKEYWORDERROR
, RGB(0, 0x80, 0));
2404 SetAStyle(SCE_C_NUMBER
, RGB(0, 0x80, 0x80));
2405 SetAStyle(SCE_C_WORD
, RGB(0, 0, 0x80));
2406 SendEditor(SCE_C_WORD
, 1);
2407 SetAStyle(SCE_C_STRING
, RGB(0x80, 0, 0x80));
2408 SetAStyle(SCE_C_IDENTIFIER
, RGB(0, 0, 0));
2409 SetAStyle(SCE_C_PREPROCESSOR
, RGB(0x80, 0, 0));
2410 SetAStyle(SCE_C_OPERATOR
, RGB(0x80, 0x80, 0));
2414 void CTortoiseGitBlameView::UpdateInfo()
2416 CString
&data
= GetDocument()->m_BlameData
;
2422 CLogDataVector
* pRevs
= GetLogData();
2424 this->m_CommitHash
.clear();
2425 this->m_Authors
.clear();
2431 SendEditor(SCI_SETREADONLY
, FALSE
);
2432 SendEditor(SCI_CLEARALL
);
2433 SendEditor(EM_EMPTYUNDOBUFFER
);
2434 SendEditor(SCI_SETSAVEPOINT
);
2435 SendEditor(SCI_CANCEL
);
2436 SendEditor(SCI_SETUNDOCOLLECTION
, 0);
2440 one
=data
.Tokenize(_T("\n"),pos
);
2442 if(one
.GetLength()>1 && one
[0] == _T('^'))
2447 m_CommitHash
.push_back(one
.Left(40));
2449 start
=one
.Find(_T(')'),40);
2452 line
=one
.Right(one
.GetLength()-start
-2);
2453 this->m_TextView
.InsertText(line
,true);
2456 if(pRevs
->m_HashMap
.find(one
.Left(40))!=pRevs
->m_HashMap
.end())
2458 id
=pRevs
->m_HashMap
[one
.Left(40)];
2463 if(this->m_NoListCommit
.find(one
.Left(40)) == m_NoListCommit
.end() )
2465 g_Git
.GetLog(vector
,one
.Left(40),NULL
,1);
2466 this->m_NoListCommit
[one
.Left(40)].ParserFromLog(vector
);
2471 if(id
>=0 && id
<(int)GetLogData()->size())
2473 m_ID
.push_back(pRevs
->size()-id
);
2474 m_Authors
.push_back(pRevs
->GetGitRevAt(id
).m_AuthorName
);
2478 m_Authors
.push_back(one
.Left(6));
2482 SetupLexer(GetDocument()->m_CurrentFileName
);
2484 SendEditor(SCI_SETUNDOCOLLECTION
, 1);
2485 SendEditor(EM_EMPTYUNDOBUFFER
);
2486 SendEditor(SCI_SETSAVEPOINT
);
2487 SendEditor(SCI_GOTOPOS
, 0);
2488 SendEditor(SCI_SETSCROLLWIDTHTRACKING
, TRUE
);
2489 SendEditor(SCI_SETREADONLY
, TRUE
);
2492 m_highestrev
=this->GetLogData()->size()+m_NoListCommit
.size();
2496 this->GetClientRect(rect
);
2497 //this->m_TextView.GetWindowRect(rect);
2498 //this->m_TextView.ScreenToClient(rect);
2499 rect
.left
=this->m_blamewidth
;
2500 this->m_TextView
.MoveWindow(rect
);
2505 CGitBlameLogList
* CTortoiseGitBlameView::GetLogList()
2507 return &(GetDocument()->GetMainFrame()->m_wndOutput
.m_LogList
);
2511 CLogDataVector
* CTortoiseGitBlameView::GetLogData()
2513 return &(GetDocument()->GetMainFrame()->m_wndOutput
.m_LogList
.m_logEntries
);
2516 void CTortoiseGitBlameView::OnSciPainted(NMHDR
*,LRESULT
*)
2521 void CTortoiseGitBlameView::OnLButtonDown(UINT nFlags
,CPoint point
)
2524 LONG_PTR line
= SendEditor(SCI_GETFIRSTVISIBLELINE
);
2525 LONG_PTR height
= SendEditor(SCI_TEXTHEIGHT
);
2526 line
= line
+ (point
.y
/height
);
2528 if (line
< (LONG
)m_CommitHash
.size())
2530 SetSelectedLine(line
);
2531 if (m_CommitHash
[line
] != m_SelectedHash
)
2533 m_SelectedHash
= m_CommitHash
[line
];
2537 this->GetLogList()->SetItemState(this->GetLogList()->GetItemCount()-m_ID
[line
],
2542 pRev
=&this->GetLogData()->GetGitRevAt(this->GetLogList()->GetItemCount()-m_ID
[line
]);
2543 this->GetDocument()->GetMainFrame()->m_wndProperties
.UpdateProperties(pRev
);
2546 this->GetDocument()->GetMainFrame()->m_wndProperties
.UpdateProperties(&m_NoListCommit
[m_CommitHash
[line
]]);
2551 m_SelectedHash
.Empty();
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
);
2592 for(i
=0;i
<m_CommitHash
.size();i
++)
2594 if( pRev
->m_CommitHash
.ToString() == m_CommitHash
[i
] )
2598 this->m_TextView
.Invalidate();
2602 void CTortoiseGitBlameView::OnMouseHover(UINT nFlags
, CPoint point
)
2605 LONG_PTR line
= SendEditor(SCI_GETFIRSTVISIBLELINE
);
2606 LONG_PTR height
= SendEditor(SCI_TEXTHEIGHT
);
2607 line
= line
+ (point
.y
/height
);
2609 if (line
< (LONG
)m_CommitHash
.size())
2611 if (line
!= m_MouseLine
)
2613 m_MouseLine
= line
;//m_CommitHash[line];
2617 pRev
=&this->m_NoListCommit
[m_CommitHash
[line
]];
2621 pRev
=&this->GetLogData()->GetGitRevAt(this->GetLogList()->GetItemCount()-m_ID
[line
]);
2624 this->ClientToScreen(&point
);
2627 str
.Format(_T("%s\n<b>%s</b>\n%s %s\n%s"),pRev
->m_CommitHash
,
2630 CAppUtils::FormatDateAndTime( pRev
->m_AuthorDate
, m_DateFormat
),
2632 m_ToolTip
.AddTool(this,str
);
2633 m_ToolTip
.DisplayToolTip(&point
);
2636 this->ScreenToClient(&point
);
2637 rect
.left
=LOCATOR_WIDTH
;
2638 rect
.right
=this->m_blamewidth
+rect
.left
;
2639 rect
.top
=point
.y
-height
;
2640 rect
.bottom
=point
.y
+height
;
2641 this->InvalidateRect(rect
);
2651 void CTortoiseGitBlameView::OnMouseMove(UINT nFlags
, CPoint point
)
2653 TRACKMOUSEEVENT tme
;
2654 tme
.cbSize
=sizeof(TRACKMOUSEEVENT
);
2655 tme
.dwFlags
=TME_HOVER
|TME_LEAVE
;
2656 tme
.hwndTrack
=this->m_hWnd
;
2658 TrackMouseEvent(&tme
);
2662 BOOL
CTortoiseGitBlameView::PreTranslateMessage(MSG
* pMsg
)
2664 m_ToolTip
.RelayEvent(pMsg
);
2665 return CView::PreTranslateMessage(pMsg
);
2668 void CTortoiseGitBlameView::OnEditFind()
2670 m_pFindDialog
=new CFindReplaceDialog();
2672 m_pFindDialog
->Create(TRUE
,_T(""),NULL
,FR_DOWN
,this);
2675 void CTortoiseGitBlameView::OnEditGoto()
2678 if(dlg
.DoModal()==IDOK
)
2680 this->GotoLine(dlg
.m_LineNumber
);
2684 LRESULT
CTortoiseGitBlameView::OnFindDialogMessage(WPARAM wParam
, LPARAM lParam
)//Õâ¸öÒ²ÊÇÕÒÄǸö³ÌÐò¸ÄµÄ£¬Ö»²»¹ý»»³ÉÁË×Ô¼ºµÄÀà
2686 ASSERT(m_pFindDialog
!= NULL
);
2688 // If the FR_DIALOGTERM flag is set,
2689 // invalidate the handle identifying the dialog box.
2690 if (m_pFindDialog
->IsTerminating())
2692 m_pFindDialog
= NULL
;
2696 // If the FR_FINDNEXT flag is set,
2697 // call the application-defined search routine
2698 // to search for the requested string.
2699 if(m_pFindDialog
->FindNext())
2701 //read data from dialog
2702 CString FindName
= m_pFindDialog
->GetFindString();
2703 bool bMatchCase
= m_pFindDialog
->MatchCase() == TRUE
;
2704 bool bMatchWholeWord
= m_pFindDialog
->MatchWholeWord() == TRUE
;
2705 bool bSearchDown
= m_pFindDialog
->SearchDown() == TRUE
;
2707 DoSearch(FindName
,m_pFindDialog
->m_fr
.Flags
);
2708 //with given name do search
2709 // *FindWhatYouNeed(FindName, bMatchCase, bMatchWholeWord, bSearchDown);
2715 void CTortoiseGitBlameView::OnViewNext()
2717 FindNextLine(this->m_SelectedHash
,false);
2719 void CTortoiseGitBlameView::OnViewPrev()
2721 FindNextLine(this->m_SelectedHash
,true);
2724 int CTortoiseGitBlameView::FindNextLine(CString CommitHash
,bool bUpOrDown
)
2726 LONG_PTR line
= SendEditor(SCI_GETFIRSTVISIBLELINE
);
2727 LONG_PTR startline
=line
;
2728 bool findNoMatch
=false;
2729 while(line
>=0 && line
<m_CommitHash
.size())
2731 if(m_CommitHash
[line
]!=CommitHash
)
2736 if(m_CommitHash
[line
] == CommitHash
&& findNoMatch
)
2738 if( line
== startline
+2 )
2746 line
=FindFirstLine(CommitHash
,line
);
2748 SendEditor(SCI_LINESCROLL
,0,line
-startline
-2);