1 // TortoiseGitBlame - a Viewer for Git Blames
3 // Copyright (C) 2008-2015 - TortoiseGit
4 // Copyright (C) 2010-2013 Sven Strickroth <email@cs-ware.de>
5 // Copyright (C) 2003-2008, 2014 - TortoiseSVN
7 // Copyright (C)2003 Don HO <donho@altern.org>
9 // This program is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU General Public License
11 // as published by the Free Software Foundation; either version 2
12 // of the License, or (at your option) any later version.
14 // This program is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 // GNU General Public License for more details.
19 // You should have received a copy of the GNU General Public License
20 // along with this program; if not, write to the Free Software Foundation,
21 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 // CTortoiseGitBlameView.cpp : implementation of the CTortoiseGitBlameView class
27 #include "TortoiseGitBlame.h"
28 #include "CommonAppUtils.h"
29 #include "TortoiseGitBlameDoc.h"
30 #include "TortoiseGitBlameView.h"
32 #include "EditGotoDlg.h"
33 #include "LoglistUtils.h"
34 #include "FileTextLines.h"
35 #include "UnicodeUtils.h"
36 #include "MenuEncode.h"
39 #include "StringUtils.h"
40 #include "BlameIndexColors.h"
41 #include "BlameDetectMovedOrCopiedLines.h"
49 UINT
CTortoiseGitBlameView::m_FindDialogMessage
;
51 // CTortoiseGitBlameView
52 IMPLEMENT_DYNAMIC(CSciEditBlame
,CSciEdit
)
54 IMPLEMENT_DYNCREATE(CTortoiseGitBlameView
, CView
)
56 BEGIN_MESSAGE_MAP(CTortoiseGitBlameView
, CView
)
57 // Standard printing commands
58 ON_COMMAND(ID_FILE_PRINT
, &CView::OnFilePrint
)
59 ON_COMMAND(ID_FILE_PRINT_DIRECT
, &CView::OnFilePrint
)
60 ON_COMMAND(ID_FILE_PRINT_PREVIEW
, &CTortoiseGitBlameView::OnFilePrintPreview
)
61 ON_COMMAND(ID_EDIT_FIND
,OnEditFind
)
62 ON_COMMAND(ID_EDIT_GOTO
,OnEditGoto
)
63 ON_COMMAND(ID_EDIT_COPY
, CopyToClipboard
)
64 ON_UPDATE_COMMAND_UI(ID_EDIT_COPY
, OnUpdateViewCopyToClipboard
)
65 ON_COMMAND(ID_VIEW_NEXT
,OnViewNext
)
66 ON_COMMAND(ID_VIEW_PREV
,OnViewPrev
)
67 ON_COMMAND(ID_FIND_NEXT
, OnFindNext
)
68 ON_COMMAND(ID_FIND_PREV
, OnFindPrev
)
69 ON_COMMAND(ID_VIEW_SHOWAUTHOR
, OnViewToggleAuthor
)
70 ON_UPDATE_COMMAND_UI(ID_VIEW_SHOWAUTHOR
, OnUpdateViewToggleAuthor
)
71 ON_COMMAND(ID_VIEW_SHOWDATE
, OnViewToggleDate
)
72 ON_UPDATE_COMMAND_UI(ID_VIEW_SHOWDATE
, OnUpdateViewToggleDate
)
73 ON_COMMAND(ID_VIEW_SHOWFILENAME
, OnViewToggleShowFilename
)
74 ON_UPDATE_COMMAND_UI(ID_VIEW_SHOWFILENAME
, OnUpdateViewToggleShowFilename
)
75 ON_COMMAND(ID_VIEW_SHOWORIGINALLINENUMBER
, OnViewToggleShowOriginalLineNumber
)
76 ON_UPDATE_COMMAND_UI(ID_VIEW_SHOWORIGINALLINENUMBER
, OnUpdateViewToggleShowOriginalLineNumber
)
77 ON_COMMAND(ID_VIEW_DETECT_MOVED_OR_COPIED_LINES_DISABLED
, OnViewDetectMovedOrCopiedLinesToggleDisabled
)
78 ON_UPDATE_COMMAND_UI(ID_VIEW_DETECT_MOVED_OR_COPIED_LINES_DISABLED
, OnUpdateViewDetectMovedOrCopiedLinesToggleDisabled
)
79 ON_COMMAND(ID_VIEW_DETECT_MOVED_OR_COPIED_LINES_WITHIN_FILE
, OnViewDetectMovedOrCopiedLinesToggleWithinFile
)
80 ON_UPDATE_COMMAND_UI(ID_VIEW_DETECT_MOVED_OR_COPIED_LINES_WITHIN_FILE
, OnUpdateViewDetectMovedOrCopiedLinesToggleWithinFile
)
81 ON_COMMAND(ID_VIEW_DETECT_MOVED_OR_COPIED_LINES_FROM_MODIFIED_FILES
, OnViewDetectMovedOrCopiedLinesToggleFromModifiedFiles
)
82 ON_UPDATE_COMMAND_UI(ID_VIEW_DETECT_MOVED_OR_COPIED_LINES_FROM_MODIFIED_FILES
, OnUpdateViewDetectMovedOrCopiedLinesToggleFromModifiedFiles
)
83 ON_COMMAND(ID_VIEW_DETECT_MOVED_OR_COPIED_LINES_FROM_EXISTING_FILES_AT_FILE_CREATION
, OnViewDetectMovedOrCopiedLinesToggleFromExistingFilesAtFileCreation
)
84 ON_UPDATE_COMMAND_UI(ID_VIEW_DETECT_MOVED_OR_COPIED_LINES_FROM_EXISTING_FILES_AT_FILE_CREATION
, OnUpdateViewDetectMovedOrCopiedLinesToggleFromExistingFilesAtFileCreation
)
85 ON_COMMAND(ID_VIEW_DETECT_MOVED_OR_COPIED_LINES_FROM_EXISTING_FILES
, OnViewDetectMovedOrCopiedLinesToggleFromExistingFiles
)
86 ON_UPDATE_COMMAND_UI(ID_VIEW_DETECT_MOVED_OR_COPIED_LINES_FROM_EXISTING_FILES
, OnUpdateViewDetectMovedOrCopiedLinesToggleFromExistingFiles
)
87 ON_COMMAND(ID_VIEW_IGNORE_WHITESPACE
, OnViewToggleIgnoreWhitespace
)
88 ON_UPDATE_COMMAND_UI(ID_VIEW_IGNORE_WHITESPACE
, OnUpdateViewToggleIgnoreWhitespace
)
89 ON_COMMAND(ID_VIEW_SHOWCOMPLETELOG
, OnViewToggleShowCompleteLog
)
90 ON_UPDATE_COMMAND_UI(ID_VIEW_SHOWCOMPLETELOG
, OnUpdateViewToggleShowCompleteLog
)
91 ON_COMMAND(ID_VIEW_FOLLOWRENAMES
, OnViewToggleFollowRenames
)
92 ON_UPDATE_COMMAND_UI(ID_VIEW_FOLLOWRENAMES
, OnUpdateViewToggleFollowRenames
)
93 ON_COMMAND(ID_VIEW_COLORBYAGE
, OnViewToggleColorByAge
)
94 ON_UPDATE_COMMAND_UI(ID_VIEW_COLORBYAGE
, OnUpdateViewToggleColorByAge
)
95 ON_COMMAND(ID_VIEW_ENABLELEXER
, OnViewToggleLexer
)
96 ON_UPDATE_COMMAND_UI(ID_VIEW_ENABLELEXER
, OnUpdateViewToggleLexer
)
97 ON_COMMAND_RANGE(IDM_FORMAT_ENCODE
, IDM_FORMAT_ENCODE_END
, OnChangeEncode
)
106 ON_NOTIFY(SCN_PAINTED
, IDC_SCINTILLA
, OnSciPainted
)
107 ON_NOTIFY(SCN_GETBKCOLOR
, IDC_SCINTILLA
, OnSciGetBkColor
)
108 ON_REGISTERED_MESSAGE(m_FindDialogMessage
, OnFindDialogMessage
)
112 // CTortoiseGitBlameView construction/destruction
114 CTortoiseGitBlameView::CTortoiseGitBlameView()
119 , bIgnoreSpaces(false)
120 , bIgnoreAllSpaces(false)
122 , m_bMatchCase(false)
137 m_originalLineNumberWidth
= 0;
140 m_windowcolor
= ::GetSysColor(COLOR_WINDOW
);
141 m_textcolor
= ::GetSysColor(COLOR_WINDOWTEXT
);
142 m_texthighlightcolor
= ::GetSysColor(COLOR_HIGHLIGHTTEXT
);
143 m_mouserevcolor
= InterColor(m_windowcolor
, m_textcolor
, 20);
144 m_mouseauthorcolor
= InterColor(m_windowcolor
, m_textcolor
, 10);
145 m_selectedrevcolor
= ::GetSysColor(COLOR_HIGHLIGHT
);
146 m_selectedauthorcolor
= InterColor(m_selectedrevcolor
, m_texthighlightcolor
, 35);
150 HIGHCONTRAST highContrast
= { 0 };
151 highContrast
.cbSize
= sizeof(HIGHCONTRAST
);
152 BOOL highContrastModeEnabled
= SystemParametersInfo(SPI_GETHIGHCONTRAST
, 0, &highContrast
, 0) == TRUE
&& (highContrast
.dwFlags
& HCF_HIGHCONTRASTON
);
153 m_colorage
= !!theApp
.GetInt(_T("ColorAge"), !highContrastModeEnabled
);
154 m_bLexer
= !!theApp
.GetInt(_T("EnableLexer"), !highContrastModeEnabled
);
158 m_bShowAuthor
= (theApp
.GetInt(_T("ShowAuthor"), 1) == 1);
159 m_bShowDate
= (theApp
.GetInt(_T("ShowDate"), 0) == 1);
160 m_bShowFilename
= (theApp
.GetInt(_T("ShowFilename"), 0) == 1);
161 m_bShowOriginalLineNumber
= (theApp
.GetInt(_T("ShowOriginalLineNumber"), 0) == 1);
162 m_dwDetectMovedOrCopiedLines
= theApp
.GetInt(_T("DetectMovedOrCopiedLines"), 0);
163 m_bIgnoreWhitespace
= (theApp
.GetInt(_T("IgnoreWhitespace"), 0) == 1);
164 m_bShowCompleteLog
= (theApp
.GetInt(_T("ShowCompleteLog"), 1) == 1);
165 m_bFollowRenames
= (theApp
.GetInt(_T("FollowRenames"), 0) == 1);
166 m_bBlameOuputContainsOtherFilenames
= FALSE
;
168 m_FindDialogMessage
= ::RegisterWindowMessage(FINDMSGSTRING
);
169 m_pFindDialog
= NULL
;
170 // get short/long datetime setting from registry
171 DWORD RegUseShortDateFormat
= CRegDWORD(_T("Software\\TortoiseGit\\LogDateFormat"), TRUE
);
172 if ( RegUseShortDateFormat
)
174 m_DateFormat
= DATE_SHORTDATE
;
178 m_DateFormat
= DATE_LONGDATE
;
180 // get relative time display setting from registry
181 DWORD regRelativeTimes
= CRegDWORD(_T("Software\\TortoiseGit\\RelativeTimes"), FALSE
);
182 m_bRelativeTimes
= (regRelativeTimes
!= 0);
184 m_sRev
.LoadString(IDS_LOG_REVISION
);
185 m_sFileName
.LoadString(IDS_FILENAME
);
186 m_sAuthor
.LoadString(IDS_LOG_AUTHOR
);
187 m_sDate
.LoadString(IDS_LOG_DATE
);
188 m_sMessage
.LoadString(IDS_LOG_MESSAGE
);
190 #ifdef USE_TEMPFILENAME
195 CTortoiseGitBlameView::~CTortoiseGitBlameView()
198 DeleteObject(m_font
);
200 DeleteObject(m_italicfont
);
202 #ifdef USE_TEMPFILENAME
216 static EncodingUnit encodings
[] = {
217 {1250, "windows-1250"}, //IDM_FORMAT_WIN_1250
218 {1251, "windows-1251"}, //IDM_FORMAT_WIN_1251
219 {1252, "windows-1252"}, //IDM_FORMAT_WIN_1252
220 {1253, "windows-1253"}, //IDM_FORMAT_WIN_1253
221 {1254, "windows-1254"}, //IDM_FORMAT_WIN_1254
222 {1255, "windows-1255"}, //IDM_FORMAT_WIN_1255
223 {1256, "windows-1256"}, //IDM_FORMAT_WIN_1256
224 {1257, "windows-1257"}, //IDM_FORMAT_WIN_1257
225 {1258, "windows-1258"}, //IDM_FORMAT_WIN_1258
226 {28591, "latin1 ISO_8859-1 ISO-8859-1 CP819 IBM819 csISOLatin1 iso-ir-100 l1"}, //IDM_FORMAT_ISO_8859_1
227 {28592, "latin2 ISO_8859-2 ISO-8859-2 csISOLatin2 iso-ir-101 l2"}, //IDM_FORMAT_ISO_8859_2
228 {28593, "latin3 ISO_8859-3 ISO-8859-3 csISOLatin3 iso-ir-109 l3"}, //IDM_FORMAT_ISO_8859_3
229 {28594, "latin4 ISO_8859-4 ISO-8859-4 csISOLatin4 iso-ir-110 l4"}, //IDM_FORMAT_ISO_8859_4
230 {28595, "cyrillic ISO_8859-5 ISO-8859-5 csISOLatinCyrillic iso-ir-144"}, //IDM_FORMAT_ISO_8859_5
231 {28596, "arabic ISO_8859-6 ISO-8859-6 csISOLatinArabic iso-ir-127 ASMO-708 ECMA-114"}, //IDM_FORMAT_ISO_8859_6
232 {28597, "greek ISO_8859-7 ISO-8859-7 csISOLatinGreek greek8 iso-ir-126 ELOT_928 ECMA-118"}, //IDM_FORMAT_ISO_8859_7
233 {28598, "hebrew ISO_8859-8 ISO-8859-8 csISOLatinHebrew iso-ir-138"}, //IDM_FORMAT_ISO_8859_8
234 {28599, "latin5 ISO_8859-9 ISO-8859-9 csISOLatin5 iso-ir-148 l5"}, //IDM_FORMAT_ISO_8859_9
235 {28600, "latin6 ISO_8859-10 ISO-8859-10 csISOLatin6 iso-ir-157 l6"}, //IDM_FORMAT_ISO_8859_10
236 {28601, "ISO_8859-11 ISO-8859-11"}, //IDM_FORMAT_ISO_8859_11
237 {28603, "ISO_8859-13 ISO-8859-13"}, //IDM_FORMAT_ISO_8859_13
238 {28604, "iso-celtic latin8 ISO_8859-14 ISO-8859-14 18 iso-ir-199"}, //IDM_FORMAT_ISO_8859_14
239 {28605, "Latin-9 ISO_8859-15 ISO-8859-15"}, //IDM_FORMAT_ISO_8859_15
240 {28606, "latin10 ISO_8859-16 ISO-8859-16 110 iso-ir-226"}, //IDM_FORMAT_ISO_8859_16
241 {437, "IBM437 cp437 437 csPC8CodePage437"}, //IDM_FORMAT_DOS_437
242 {720, "IBM720 cp720 oem720 720"}, //IDM_FORMAT_DOS_720
243 {737, "IBM737 cp737 oem737 737"}, //IDM_FORMAT_DOS_737
244 {775, "IBM775 cp775 oem775 775"}, //IDM_FORMAT_DOS_775
245 {850, "IBM850 cp850 oem850 850"}, //IDM_FORMAT_DOS_850
246 {852, "IBM852 cp852 oem852 852"}, //IDM_FORMAT_DOS_852
247 {855, "IBM855 cp855 oem855 855 csIBM855"}, //IDM_FORMAT_DOS_855
248 {857, "IBM857 cp857 oem857 857"}, //IDM_FORMAT_DOS_857
249 {858, "IBM858 cp858 oem858 858"}, //IDM_FORMAT_DOS_858
250 {860, "IBM860 cp860 oem860 860"}, //IDM_FORMAT_DOS_860
251 {861, "IBM861 cp861 oem861 861"}, //IDM_FORMAT_DOS_861
252 {862, "IBM862 cp862 oem862 862"}, //IDM_FORMAT_DOS_862
253 {863, "IBM863 cp863 oem863 863"}, //IDM_FORMAT_DOS_863
254 {865, "IBM865 cp865 oem865 865"}, //IDM_FORMAT_DOS_865
255 {866, "IBM866 cp866 oem866 866"}, //IDM_FORMAT_DOS_866
256 {869, "IBM869 cp869 oem869 869"}, //IDM_FORMAT_DOS_869
257 {950, "big5 csBig5"}, //IDM_FORMAT_BIG5
258 {936, "gb2312 gbk csGB2312"}, //IDM_FORMAT_GB2312
259 {932, "Shift_JIS MS_Kanji csShiftJIS csWindows31J"}, //IDM_FORMAT_SHIFT_JIS
260 {949, "windows-949 korean"}, //IDM_FORMAT_KOREAN_WIN
261 {51949, "euc-kr csEUCKR"}, //IDM_FORMAT_EUC_KR
262 {874, "tis-620"}, //IDM_FORMAT_TIS_620
263 {10007, "x-mac-cyrillic xmaccyrillic"}, //IDM_FORMAT_MAC_CYRILLIC
264 {21866, "koi8_u"}, //IDM_FORMAT_KOI8U_CYRILLIC
265 {20866, "koi8_r csKOI8R"}, //IDM_FORMAT_KOI8R_CYRILLIC
266 {65001, "UTF-8"}, //IDM_FORMAT_UTF8
267 {1200, "UTF-16 LE"}, //IDM_FORMAT_UTF16LE
268 {1201, "UTF-16 BE"}, //IDM_FORMAT_UTF16BE
270 void CTortoiseGitBlameView::OnChangeEncode(UINT nId
)
272 if(nId
>= IDM_FORMAT_ENCODE
&& nId
<= IDM_FORMAT_ENCODE_END
)
273 this->UpdateInfo(encodings
[nId
- IDM_FORMAT_ENCODE
].id
);
275 int CTortoiseGitBlameView::OnCreate(LPCREATESTRUCT lpcs
)
279 this->GetWindowRect(&rect1
);
280 rect
.left
=m_blamewidth
+LOCATOR_WIDTH
;
281 rect
.right
=rect
.Width();
283 rect
.bottom
=rect
.Height();
284 if (!m_TextView
.Create(_T("Scintilla"), _T("source"), 0, rect
, this, IDC_SCINTILLA
, 0))
286 TRACE0("Failed to create view\n");
287 return -1; // fail to create
289 m_TextView
.Init(0,FALSE
);
290 m_TextView
.ShowWindow( SW_SHOW
);
292 SendEditor(SCI_SETREADONLY
, TRUE
);
293 m_ToolTip
.Create(this->GetParent());
295 ::AfxGetApp()->GetMainWnd();
296 return CView::OnCreate(lpcs
);
300 void CTortoiseGitBlameView::OnSize(UINT
/*nType*/, int cx
, int cy
)
304 rect
.left
=m_blamewidth
;
309 m_TextView
.MoveWindow(&rect
);
312 BOOL
CTortoiseGitBlameView::PreCreateWindow(CREATESTRUCT
& cs
)
314 return CView::PreCreateWindow(cs
);
317 // CTortoiseGitBlameView drawing
319 void CTortoiseGitBlameView::OnDraw(CDC
* /*pDC*/)
321 CTortoiseGitBlameDoc
* pDoc
= GetDocument();
326 DrawBlame(this->GetDC()->m_hDC
);
327 DrawLocatorBar(this->GetDC()->m_hDC
);
328 // TODO: add draw code for native data here
332 // CTortoiseGitBlameView printing
335 void CTortoiseGitBlameView::OnFilePrintPreview()
337 AFXPrintPreview(this);
340 BOOL
CTortoiseGitBlameView::OnPreparePrinting(CPrintInfo
* pInfo
)
342 // default preparation
343 return DoPreparePrinting(pInfo
);
346 void CTortoiseGitBlameView::OnBeginPrinting(CDC
* /*pDC*/, CPrintInfo
* /*pInfo*/)
348 // TODO: add extra initialization before printing
351 void CTortoiseGitBlameView::OnEndPrinting(CDC
* /*pDC*/, CPrintInfo
* /*pInfo*/)
353 // TODO: add cleanup after printing
356 void CTortoiseGitBlameView::OnRButtonUp(UINT
/*nFlags*/, CPoint point
)
358 int line
= (int)SendEditor(SCI_GETFIRSTVISIBLELINE
);
359 int height
= (int)SendEditor(SCI_TEXTHEIGHT
);
360 line
= line
+ (int)(point
.y
/ height
);
361 if (m_data
.IsValidLine(line
))
364 ClientToScreen(&point
);
366 CGitHash hash
= m_data
.GetHash(line
);
367 CString hashStr
= hash
.ToString();
369 GitRevLoglist
* pRev
= nullptr;
370 int logIndex
= m_lineToLogIndex
[line
];
372 pRev
= &GetLogData()->GetGitRevAt(logIndex
);
375 pRev
= m_data
.GetRev(line
, GetLogData()->m_pLogCache
->m_HashMap
);
376 if (pRev
&& pRev
->m_ParentHash
.empty())
378 if (pRev
->GetParentFromHash(pRev
->m_CommitHash
))
379 MessageBox(pRev
->GetLastErr(), _T("TortoiseGit"), MB_ICONERROR
);
387 CIconMenu blamemenu
, diffmenu
;
389 if (!popup
.CreatePopupMenu())
392 // Now find the relevant parent commits, they must contain the file which is blamed to be the source of the selected line,
393 // otherwise there is no previous file to compare to (only another previous revision).
395 GIT_REV_LIST parentHashWithFile
;
396 std::vector
<CString
> parentFilename
;
399 CTGitPath
path(m_data
.GetFilename(line
));
400 const CTGitPathList
& files
= pRev
->GetFiles(NULL
);
401 for (int j
= 0, j_size
= files
.GetCount(); j
< j_size
; ++j
)
403 const CTGitPath
&file
= files
[j
];
404 if (file
.IsEquivalentTo(path
))
406 if (!(file
.m_ParentNo
& MERGE_MASK
))
408 int action
= file
.m_Action
;
409 // ignore (action & CTGitPath::LOGACTIONS_ADDED), as then there is nothing to blame/diff
410 // ignore (action & CTGitPath::LOGACTIONS_DELETED), should never happen as the file must exist
411 if (action
& (CTGitPath::LOGACTIONS_MODIFIED
| CTGitPath::LOGACTIONS_REPLACED
))
413 int parentNo
= file
.m_ParentNo
& PARENT_MASK
;
414 if (parentNo
>= 0 && (size_t)parentNo
< pRev
->m_ParentHash
.size())
416 parentHashWithFile
.push_back(pRev
->m_ParentHash
[parentNo
]);
417 parentFilename
.push_back((action
& CTGitPath::LOGACTIONS_REPLACED
) ? file
.GetGitOldPathString() : file
.GetGitPathString());
424 catch (const char* msg
)
426 MessageBox(_T("Could not get files of parents.\nlibgit reports:\n") + CString(msg
), _T("TortoiseGit"), MB_ICONERROR
);
430 if (!parentHashWithFile
.empty())
432 if (parentHashWithFile
.size() == 1)
434 popup
.AppendMenuIcon(ID_BLAMEPREVIOUS
, IDS_BLAME_POPUP_BLAME
, IDI_BLAME_POPUP_BLAME
);
438 blamemenu
.CreatePopupMenu();
439 popup
.AppendMenuIcon(ID_BLAMEPREVIOUS
, IDS_BLAME_POPUP_BLAME
, IDI_BLAME_POPUP_BLAME
, blamemenu
.m_hMenu
);
441 for (size_t i
= 0; i
< parentHashWithFile
.size(); ++i
)
444 str
.Format(IDS_PARENT
, i
+ 1);
445 blamemenu
.AppendMenuIcon(ID_BLAMEPREVIOUS
+ ((i
+ 1) << 16), str
);
450 // compare with previous
451 if (!parentHashWithFile
.empty())
453 if (parentHashWithFile
.size() == 1)
455 popup
.AppendMenuIcon(ID_COMPAREWITHPREVIOUS
, IDS_BLAME_POPUP_COMPARE
, IDI_BLAME_POPUP_COMPARE
);
456 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE
))
457 popup
.SetDefaultItem(ID_COMPAREWITHPREVIOUS
, FALSE
);
461 diffmenu
.CreatePopupMenu();
462 popup
.AppendMenuIcon(ID_COMPAREWITHPREVIOUS
, IDS_BLAME_POPUP_COMPARE
, IDI_BLAME_POPUP_COMPARE
, diffmenu
.m_hMenu
);
463 for (size_t i
= 0; i
< parentHashWithFile
.size(); ++i
)
466 str
.Format(IDS_BLAME_POPUP_PARENT
, i
+ 1);
467 diffmenu
.AppendMenuIcon((UINT
)(ID_COMPAREWITHPREVIOUS
+ ((i
+ 1) << 16)),str
);
468 if (i
== 0 && CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE
))
470 popup
.SetDefaultItem(ID_COMPAREWITHPREVIOUS
, FALSE
);
471 diffmenu
.SetDefaultItem((UINT
)(ID_COMPAREWITHPREVIOUS
+ ((i
+ 1) << 16)), FALSE
);
477 popup
.AppendMenuIcon(ID_SHOWLOG
, IDS_BLAME_POPUP_LOG
, IDI_BLAME_POPUP_LOG
);
478 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
479 popup
.AppendMenuIcon(ID_COPYHASHTOCLIPBOARD
, IDS_BLAME_POPUP_COPYHASHTOCLIPBOARD
, IDI_BLAME_POPUP_COPY
);
480 popup
.AppendMenuIcon(ID_COPYLOGTOCLIPBOARD
, IDS_BLAME_POPUP_COPYLOGTOCLIPBOARD
, IDI_BLAME_POPUP_COPY
);
482 int cmd
= popup
.TrackPopupMenu(TPM_RETURNCMD
| TPM_LEFTALIGN
| TPM_NONOTIFY
, point
.x
, point
.y
, this, 0);
483 this->ContextMenuAction(cmd
, pRev
, parentHashWithFile
, parentFilename
);
487 void CTortoiseGitBlameView::ContextMenuAction(int cmd
, GitRev
*pRev
, GIT_REV_LIST
& parentHashWithFile
, const std::vector
<CString
>& parentFilename
)
489 switch (cmd
& 0xFFFF)
491 case ID_BLAMEPREVIOUS
:
493 int index
= (cmd
>>16) & 0xFFFF;
497 CString path
= ResolveCommitFile(parentFilename
[index
]);
498 CString endrev
= parentHashWithFile
[index
].ToString();
499 int line
= m_data
.GetOriginalLineNumber(m_MouseLine
);
501 lineNumber
.Format(_T("%d"), line
);
503 CString procCmd
= _T("/path:\"") + path
+ _T("\" ");
504 procCmd
+= _T(" /command:blame");
505 procCmd
+= _T(" /endrev:") + endrev
;
506 procCmd
+= _T(" /line:") + lineNumber
;
508 CCommonAppUtils::RunTortoiseGitProc(procCmd
);
512 case ID_COMPAREWITHPREVIOUS
:
514 int index
= (cmd
>> 16) & 0xFFFF;
518 CString path
= ResolveCommitFile(parentFilename
[index
]);
519 CString startrev
= pRev
->m_CommitHash
.ToString();
520 CString endrev
= parentHashWithFile
[index
].ToString();
522 CString procCmd
= _T("/path:\"") + path
+ _T("\" ");
523 procCmd
+= _T(" /command:diff");
524 procCmd
+= _T(" /startrev:") + startrev
;
525 procCmd
+= _T(" /endrev:") + endrev
;
527 CCommonAppUtils::RunTortoiseGitProc(procCmd
);
533 CString path
= ResolveCommitFile(m_MouseLine
);
534 CString rev
= m_data
.GetHash(m_MouseLine
).ToString();
536 CString procCmd
= _T("/path:\"") + path
+ _T("\" ");
537 procCmd
+= _T(" /command:log");
538 procCmd
+= _T(" /rev:") + rev
;
539 procCmd
+= _T(" /endrev:") + rev
;
541 CCommonAppUtils::RunTortoiseGitProc(procCmd
);
545 case ID_COPYHASHTOCLIPBOARD
:
546 this->GetLogList()->CopySelectionToClipBoard(CGitLogListBase::ID_COPY_HASH
);
549 case ID_COPYLOGTOCLIPBOARD
:
550 this->GetLogList()->CopySelectionToClipBoard();
555 // CTortoiseGitBlameView diagnostics
558 void CTortoiseGitBlameView::AssertValid() const
560 CView::AssertValid();
563 void CTortoiseGitBlameView::Dump(CDumpContext
& dc
) const
568 CTortoiseGitBlameDoc
* CTortoiseGitBlameView::GetDocument() const // non-debug version is inline
570 ASSERT(m_pDocument
->IsKindOf(RUNTIME_CLASS(CTortoiseGitBlameDoc
)));
571 return (CTortoiseGitBlameDoc
*)m_pDocument
;
576 // CTortoiseGitBlameView message handlers
577 CString
CTortoiseGitBlameView::GetAppDirectory()
581 DWORD bufferlen
= MAX_PATH
; // MAX_PATH is not the limit here!
584 bufferlen
+= MAX_PATH
; // MAX_PATH is not the limit here!
585 std::unique_ptr
<TCHAR
[]> pBuf(new TCHAR
[bufferlen
]);
586 len
= GetModuleFileName(NULL
, pBuf
.get(), bufferlen
);
587 path
= CString(pBuf
.get(), len
);
588 } while(len
== bufferlen
);
590 path
= path
.Left(path
.ReverseFind(_T('\\')));
591 //path = path.substr(0, path.rfind('\\') + 1);
596 // Return a color which is interpolated between c1 and c2.
597 // Slider controls the relative proportions as a percentage:
598 // Slider = 0 represents pure c1
599 // Slider = 50 represents equal mixture
600 // Slider = 100 represents pure c2
601 COLORREF
CTortoiseGitBlameView::InterColor(COLORREF c1
, COLORREF c2
, int Slider
)
605 // Limit Slider to 0..100% range
611 // The color components have to be treated individually.
612 r
= (GetRValue(c2
) * Slider
+ GetRValue(c1
) * (100 - Slider
)) / 100;
613 g
= (GetGValue(c2
) * Slider
+ GetGValue(c1
) * (100 - Slider
)) / 100;
614 b
= (GetBValue(c2
) * Slider
+ GetBValue(c1
) * (100 - Slider
)) / 100;
619 LRESULT
CTortoiseGitBlameView::SendEditor(UINT Msg
, WPARAM wParam
, LPARAM lParam
)
621 return m_TextView
.Call(Msg
, wParam
, lParam
);
624 void CTortoiseGitBlameView::SetAStyle(int style
, COLORREF fore
, COLORREF back
, int size
, const char *face
)
626 if (fore
== back
&& fore
== m_windowcolor
)
628 m_TextView
.SetAStyle(style
, fore
, back
, size
, face
);
631 void CTortoiseGitBlameView::InitialiseEditor()
633 SendEditor(SCI_STYLERESETDEFAULT
);
634 // Set up the global default style. These attributes are used wherever no explicit choices are made.
635 std::string fontName
= CUnicodeUtils::StdGetUTF8((stdstring
)CRegStdString(_T("Software\\TortoiseGit\\BlameFontName"), _T("Courier New")));
636 SetAStyle(STYLE_DEFAULT
,
637 ::GetSysColor(COLOR_WINDOWTEXT
),
638 ::GetSysColor(COLOR_WINDOW
),
639 (DWORD
)CRegStdDWORD(_T("Software\\TortoiseGit\\BlameFontSize"), 10),
642 SendEditor(SCI_SETTABWIDTH
, (DWORD
)CRegStdDWORD(_T("Software\\TortoiseGit\\BlameTabSize"), 4));
643 SendEditor(SCI_SETREADONLY
, TRUE
);
644 LRESULT pix
= SendEditor(SCI_TEXTWIDTH
, STYLE_LINENUMBER
, (LPARAM
)this->m_TextView
.StringForControl(_T("_99999")).GetBuffer());
646 SendEditor(SCI_SETMARGINWIDTHN
, 0, pix
);
648 SendEditor(SCI_SETMARGINWIDTHN
, 0);
649 SendEditor(SCI_SETMARGINWIDTHN
, 1);
650 SendEditor(SCI_SETMARGINWIDTHN
, 2);
651 //Set the default windows colors for edit controls
652 SendEditor(SCI_SETSELFORE
, TRUE
, ::GetSysColor(COLOR_HIGHLIGHTTEXT
));
653 SendEditor(SCI_SETSELBACK
, TRUE
, ::GetSysColor(COLOR_HIGHLIGHT
));
654 SendEditor(SCI_SETCARETFORE
, ::GetSysColor(COLOR_WINDOWTEXT
));
655 m_regOldLinesColor
= CRegStdDWORD(_T("Software\\TortoiseGit\\BlameOldColor"), BLAMEOLDCOLOR
);
656 m_regNewLinesColor
= CRegStdDWORD(_T("Software\\TortoiseGit\\BlameNewColor"), BLAMENEWCOLOR
);
657 CRegStdDWORD
used2d(L
"Software\\TortoiseGit\\ScintillaDirect2D", FALSE
);
658 if (SysInfo::Instance().IsWin7OrLater() && DWORD(used2d
))
660 SendEditor(SCI_SETTECHNOLOGY
, SC_TECHNOLOGY_DIRECTWRITERETAIN
);
661 SendEditor(SCI_SETBUFFEREDDRAW
, 0);
664 SendEditor(SCI_SETWRAPMODE
, SC_WRAP_NONE
);
665 SendEditor(SCI_STYLECLEARALL
);
668 bool CTortoiseGitBlameView::DoSearch(CTortoiseGitBlameData::SearchDirection direction
)
670 int pos
= (int)SendEditor(SCI_GETCURRENTPOS
);
671 int line
= (int)SendEditor(SCI_LINEFROMPOSITION
, pos
);
673 int i
= m_data
.FindFirstLineWrapAround(direction
, m_sFindText
, line
, m_bMatchCase
);
677 int selstart
= (int)SendEditor(SCI_GETCURRENTPOS
);
678 int selend
= (int)SendEditor(SCI_POSITIONFROMLINE
, i
+ 1);
679 SendEditor(SCI_SETSELECTIONSTART
, selstart
);
680 SendEditor(SCI_SETSELECTIONEND
, selend
);
685 ::MessageBox(m_pFindDialog
&& m_pFindDialog
->GetSafeHwnd() ? m_pFindDialog
->GetSafeHwnd() : wMain
, _T("\"") + m_sFindText
+ _T("\" ") + CString(MAKEINTRESOURCE(IDS_NOTFOUND
)), _T("TortoiseGitBlame"), MB_ICONINFORMATION
);
691 void CTortoiseGitBlameView::OnFindPrev()
693 if (m_sFindText
.IsEmpty())
695 DoSearch(CTortoiseGitBlameData::SearchPrevious
);
698 void CTortoiseGitBlameView::OnFindNext()
700 if (m_sFindText
.IsEmpty())
702 DoSearch(CTortoiseGitBlameData::SearchNext
);
705 bool CTortoiseGitBlameView::GotoLine(int line
)
708 int numberOfLines
= m_data
.GetNumberOfLines();
709 if (line
< 0 || numberOfLines
== 0)
711 if (line
>= numberOfLines
)
713 line
= numberOfLines
- 1;
716 int nCurrentPos
= (int)SendEditor(SCI_GETCURRENTPOS
);
717 int nCurrentLine
= (int)SendEditor(SCI_LINEFROMPOSITION
,nCurrentPos
);
718 int nFirstVisibleLine
= (int)SendEditor(SCI_GETFIRSTVISIBLELINE
);
719 int nLinesOnScreen
= (int)SendEditor(SCI_LINESONSCREEN
);
721 if ( line
>=nFirstVisibleLine
&& line
<=nFirstVisibleLine
+nLinesOnScreen
)
724 SendEditor(SCI_GOTOLINE
, line
);
728 // Place the requested line one third from the top
729 if ( line
> nCurrentLine
)
731 SendEditor(SCI_GOTOLINE
, (WPARAM
)(line
+(int)nLinesOnScreen
*(2/3.0)));
735 SendEditor(SCI_GOTOLINE
, (WPARAM
)(line
-(int)nLinesOnScreen
*(1/3.0)));
739 // Highlight the line
740 int nPosStart
= (int)SendEditor(SCI_POSITIONFROMLINE
,line
);
741 int nPosEnd
= (int)SendEditor(SCI_GETLINEENDPOSITION
,line
);
742 SendEditor(SCI_SETSEL
,nPosEnd
,nPosStart
);
747 bool CTortoiseGitBlameView::ScrollToLine(long line
)
752 int nCurrentLine
= (int)SendEditor(SCI_GETFIRSTVISIBLELINE
);
754 int scrolldelta
= line
- nCurrentLine
;
755 SendEditor(SCI_LINESCROLL
, 0, scrolldelta
);
760 void CTortoiseGitBlameView::CopyToClipboard()
762 CWnd
* wnd
= GetFocus();
763 if (wnd
== this->GetLogList())
764 GetLogList()->CopySelectionToClipBoard();
767 if (CString(wnd
->GetRuntimeClass()->m_lpszClassName
) == _T("CMFCPropertyGridCtrl"))
769 CMFCPropertyGridCtrl
*grid
= (CMFCPropertyGridCtrl
*)wnd
;
770 if (grid
->GetCurSel() && !grid
->GetCurSel()->IsGroup())
771 CStringUtils::WriteAsciiStringToClipboard(grid
->GetCurSel()->GetValue(), GetSafeHwnd());
774 m_TextView
.Call(SCI_COPY
);
778 LONG
CTortoiseGitBlameView::GetBlameWidth()
783 HDC hDC
= this->GetDC()->m_hDC
;
784 HFONT oldfont
= (HFONT
)::SelectObject(hDC
, m_font
);
786 CString
shortHash('f', g_Git
.GetShortHASHLength() + 1);
787 ::GetTextExtentPoint32(hDC
, shortHash
, g_Git
.GetShortHASHLength() + 1, &width
);
788 m_revwidth
= width
.cx
+ BLAMESPACE
;
789 blamewidth
+= m_revwidth
;
795 int numberOfLines
= m_data
.GetNumberOfLines();
796 for (int i
= 0; i
< numberOfLines
; ++i
)
798 ::GetTextExtentPoint32(hDC
, m_data
.GetDate(i
), m_data
.GetDate(i
).GetLength(), &width
);
799 if (width
.cx
> maxwidth
.cx
)
802 m_datewidth
= maxwidth
.cx
+ BLAMESPACE
;
803 blamewidth
+= m_datewidth
;
809 int numberOfLines
= m_data
.GetNumberOfLines();
810 for (int i
= 0; i
< numberOfLines
; ++i
)
812 ::GetTextExtentPoint32(hDC
,m_data
.GetAuthor(i
) , m_data
.GetAuthor(i
).GetLength(), &width
);
813 if (width
.cx
> maxwidth
.cx
)
816 m_authorwidth
= maxwidth
.cx
+ BLAMESPACE
;
817 blamewidth
+= m_authorwidth
;
823 int numberOfLines
= m_data
.GetNumberOfLines();
824 for (int i
= 0; i
< numberOfLines
; ++i
)
826 ::GetTextExtentPoint32(hDC
, m_data
.GetFilename(i
), m_data
.GetFilename(i
).GetLength(), &width
);
827 if (width
.cx
> maxwidth
.cx
)
830 m_filenameWidth
= maxwidth
.cx
+ BLAMESPACE
;
831 blamewidth
+= m_filenameWidth
;
833 if (m_bShowOriginalLineNumber
)
837 int numberOfLines
= m_data
.GetNumberOfLines();
839 for (int i
= 0; i
< numberOfLines
; ++i
)
841 str
.Format(_T("%5d"), m_data
.GetOriginalLineNumber(i
));
842 ::GetTextExtentPoint32(hDC
, str
, str
.GetLength(), &width
);
843 if (width
.cx
> maxwidth
.cx
)
846 m_originalLineNumberWidth
= maxwidth
.cx
+ BLAMESPACE
;
847 blamewidth
+= m_originalLineNumberWidth
;
849 ::SelectObject(hDC
, oldfont
);
850 POINT pt
= {blamewidth
, 0};
853 //::ReleaseDC(wBlame, hDC);
858 void CTortoiseGitBlameView::CreateFont()
864 HDC hDC
= ::GetDC(wBlame
);
865 lf
.lfHeight
= -MulDiv((DWORD
)CRegStdDWORD(_T("Software\\TortoiseGit\\BlameFontSize"), 10), GetDeviceCaps(hDC
, LOGPIXELSY
), 72);
866 lf
.lfCharSet
= DEFAULT_CHARSET
;
867 CRegStdString fontname
= CRegStdString(_T("Software\\TortoiseGit\\BlameFontName"), _T("Courier New"));
868 _tcscpy_s(lf
.lfFaceName
, 32, ((stdstring
)fontname
).c_str());
869 m_font
= ::CreateFontIndirect(&lf
);
872 m_italicfont
= ::CreateFontIndirect(&lf
);
874 ::ReleaseDC(wBlame
, hDC
);
877 void CTortoiseGitBlameView::DrawBlame(HDC hDC
)
884 HFONT oldfont
= NULL
;
885 int line
= (int)SendEditor(SCI_GETFIRSTVISIBLELINE
);
886 int linesonscreen
= (int)SendEditor(SCI_LINESONSCREEN
);
887 int height
= (int)SendEditor(SCI_TEXTHEIGHT
);
889 TCHAR buf
[MAX_PATH
] = {0};
892 //::GetClientRect(this->m_hWnd, &rc);
893 for (int i
= line
; i
< (line
+ linesonscreen
); ++i
)
896 if (i
< m_data
.GetNumberOfLines())
898 CGitHash
hash(m_data
.GetHash(i
));
899 // if (mergelines[i])
900 // oldfont = (HFONT)::SelectObject(hDC, m_italicfont);
902 oldfont
= (HFONT
)::SelectObject(hDC
, m_font
);
903 ::SetBkColor(hDC
, m_windowcolor
);
904 ::SetTextColor(hDC
, m_textcolor
);
907 //if (m_CommitHash[i].Compare(m_MouseHash)==0)
908 // ::SetBkColor(hDC, m_mouseauthorcolor);
909 if (hash
== m_SelectedHash
)
911 ::SetBkColor(hDC
, m_selectedauthorcolor
);
912 ::SetTextColor(hDC
, m_texthighlightcolor
);
918 ::SetBkColor(hDC
, m_mouserevcolor
);
920 //if ((revs[i] == m_mouserev)&&(!sel))
921 // ::SetBkColor(hDC, m_mouserevcolor);
922 //if (revs[i] == m_selectedrev)
924 // ::SetBkColor(hDC, m_selectedrevcolor);
925 // ::SetTextColor(hDC, m_texthighlightcolor);
928 CString shortHashStr
;
929 shortHashStr
= hash
.ToString().Left(g_Git
.GetShortHASHLength());
931 //_stprintf_s(buf, MAX_PATH, _T("%8ld "), revs[i]);
933 rc
.left
=LOCATOR_WIDTH
;
934 rc
.bottom
= (LONG
)(Y
+ height
);
935 rc
.right
= rc
.left
+ m_blamewidth
;
936 ::ExtTextOut(hDC
, LOCATOR_WIDTH
, Y
, ETO_CLIPPED
, &rc
, shortHashStr
, shortHashStr
.GetLength(), 0);
937 int Left
= m_revwidth
;
941 rc
.right
= rc
.left
+ Left
+ m_authorwidth
;
942 ::ExtTextOut(hDC
, Left
, Y
, ETO_CLIPPED
, &rc
, m_data
.GetAuthor(i
), m_data
.GetAuthor(i
).GetLength(), 0);
943 Left
+= m_authorwidth
;
947 rc
.right
= rc
.left
+ Left
+ m_datewidth
;
948 ::ExtTextOut(hDC
, Left
, Y
, ETO_CLIPPED
, &rc
, m_data
.GetDate(i
), m_data
.GetDate(i
).GetLength(), 0);
953 rc
.right
= rc
.left
+ Left
+ m_filenameWidth
;
954 ::ExtTextOut(hDC
, Left
, (int)Y
, ETO_CLIPPED
, &rc
, m_data
.GetFilename(i
), m_data
.GetFilename(i
).GetLength(), 0);
955 Left
+= m_filenameWidth
;
957 if (m_bShowOriginalLineNumber
)
959 rc
.right
= rc
.left
+ Left
+ m_originalLineNumberWidth
;
961 str
.Format(_T("%5d"), m_data
.GetOriginalLineNumber(i
));
962 ::ExtTextOut(hDC
, Left
, (int)Y
, ETO_CLIPPED
, &rc
, str
, str
.GetLength(), 0);
963 Left
+= m_originalLineNumberWidth
;
965 if ((i
==m_SelectedLine
)&&(m_pFindDialog
))
968 brush
.lbColor
= m_textcolor
;
970 brush
.lbStyle
= BS_SOLID
;
971 HPEN pen
= ExtCreatePen(PS_SOLID
| PS_GEOMETRIC
, 2, &brush
, 0, NULL
);
972 HGDIOBJ hPenOld
= SelectObject(hDC
, pen
);
975 rc2
.bottom
= (LONG
)(Y
+ height
);
976 ::MoveToEx(hDC
, rc2
.left
, rc2
.top
, NULL
);
977 ::LineTo(hDC
, rc2
.right
, rc2
.top
);
978 ::LineTo(hDC
, rc2
.right
, rc2
.bottom
);
979 ::LineTo(hDC
, rc2
.left
, rc2
.bottom
);
980 ::LineTo(hDC
, rc2
.left
, rc2
.top
);
981 SelectObject(hDC
, hPenOld
);
985 ::SelectObject(hDC
, oldfont
);
989 ::SetBkColor(hDC
, m_windowcolor
);
990 for (int j
=0; j
< MAX_PATH
; ++j
)
992 ::ExtTextOut(hDC
, 0, (int)Y
, ETO_CLIPPED
, &rc
, buf
, MAX_PATH
-1, 0);
998 void CTortoiseGitBlameView::DrawLocatorBar(HDC hDC
)
1003 int line
= (int)SendEditor(SCI_GETFIRSTVISIBLELINE
);
1004 int linesonscreen
= (int)SendEditor(SCI_LINESONSCREEN
);
1006 COLORREF blackColor
= GetSysColor(COLOR_WINDOWTEXT
);
1009 //::GetClientRect(wLocator, &rc);
1010 this->GetClientRect(&rc
);
1012 rc
.right
=LOCATOR_WIDTH
;
1015 LONG height
= rc
.bottom
-rc
.top
;
1017 int numberOfLines
= m_data
.GetNumberOfLines();
1018 // draw the colored bar
1019 for (int currentLine
= 0; currentLine
<numberOfLines
; ++currentLine
)
1021 COLORREF cr
= GetLineColor(currentLine
);
1022 // get the line color
1023 if ((currentLine
>= line
)&&(currentLine
< (line
+ linesonscreen
)))
1025 cr
= InterColor(cr
, blackColor
, 10);
1027 SetBkColor(hDC
, cr
);
1028 lineRect
.top
= (LONG
)Y
;
1029 lineRect
.bottom
= ((currentLine
+ 1) * height
/ numberOfLines
);
1030 ::ExtTextOut(hDC
, 0, 0, ETO_OPAQUE
, &lineRect
, NULL
, 0, NULL
);
1031 Y
= lineRect
.bottom
;
1034 if (numberOfLines
> 0)
1036 // now draw two lines indicating the scroll position of the source view
1037 SetBkColor(hDC
, blackColor
);
1038 lineRect
.top
= (LONG
)line
* height
/ numberOfLines
;
1039 lineRect
.bottom
= lineRect
.top
+1;
1040 ::ExtTextOut(hDC
, 0, 0, ETO_OPAQUE
, &lineRect
, NULL
, 0, NULL
);
1041 lineRect
.top
= (LONG
)(line
+ linesonscreen
) * height
/ numberOfLines
;
1042 lineRect
.bottom
= lineRect
.top
+1;
1043 ::ExtTextOut(hDC
, 0, 0, ETO_OPAQUE
, &lineRect
, NULL
, 0, NULL
);
1048 void CTortoiseGitBlameView::StringExpand(LPSTR str
) const
1053 cPos
= strchr(cPos
, '\n');
1056 memmove(cPos
+1, cPos
, strlen(cPos
)*sizeof(char));
1061 } while (cPos
!= NULL
);
1063 void CTortoiseGitBlameView::StringExpand(LPWSTR str
) const
1065 wchar_t * cPos
= str
;
1068 cPos
= wcschr(cPos
, '\n');
1071 memmove(cPos
+1, cPos
, wcslen(cPos
)*sizeof(wchar_t));
1076 } while (cPos
!= NULL
);
1079 void CTortoiseGitBlameView::SetupLexer(CString filename
)
1081 int start
=filename
.ReverseFind(_T('.'));
1082 SendEditor(SCI_SETLEXER
, SCLEX_NULL
);
1087 //_tcscpy_s(line, 20, lineptr+1);
1088 //_tcslwr_s(line, 20);
1089 CString ext
=filename
.Right(filename
.GetLength()-start
-1);
1090 const TCHAR
* line
= ext
;
1092 if ((_tcscmp(line
, _T("py"))==0)||
1093 (_tcscmp(line
, _T("pyw"))==0))
1095 SendEditor(SCI_SETLEXER
, SCLEX_PYTHON
);
1096 SendEditor(SCI_SETKEYWORDS
, 0, (LPARAM
)(m_TextView
.StringForControl(_T("and assert break class continue def del elif \
1097 else except exec finally for from global if import in is lambda None \
1098 not or pass print raise return try while yield")).GetBuffer()));
1099 SetAStyle(SCE_P_DEFAULT
, black
);
1100 SetAStyle(SCE_P_COMMENTLINE
, darkGreen
);
1101 SetAStyle(SCE_P_NUMBER
, RGB(0, 0x80, 0x80));
1102 SetAStyle(SCE_P_STRING
, RGB(0, 0, 0x80));
1103 SetAStyle(SCE_P_CHARACTER
, RGB(0, 0, 0x80));
1104 SetAStyle(SCE_P_WORD
, RGB(0x80, 0, 0x80));
1105 SetAStyle(SCE_P_TRIPLE
, black
);
1106 SetAStyle(SCE_P_TRIPLEDOUBLE
, black
);
1107 SetAStyle(SCE_P_CLASSNAME
, darkBlue
);
1108 SetAStyle(SCE_P_DEFNAME
, darkBlue
);
1109 SetAStyle(SCE_P_OPERATOR
, darkBlue
);
1110 SetAStyle(SCE_P_IDENTIFIER
, darkBlue
);
1111 SetAStyle(SCE_P_COMMENTBLOCK
, darkGreen
);
1112 SetAStyle(SCE_P_STRINGEOL
, red
);
1114 if ((_tcscmp(line
, _T("c"))==0)||
1115 (_tcscmp(line
, _T("cc"))==0)||
1116 (_tcscmp(line
, _T("cpp"))==0)||
1117 (_tcscmp(line
, _T("cxx"))==0)||
1118 (_tcscmp(line
, _T("h"))==0)||
1119 (_tcscmp(line
, _T("hh"))==0)||
1120 (_tcscmp(line
, _T("hpp"))==0)||
1121 (_tcscmp(line
, _T("hxx"))==0)||
1122 (_tcscmp(line
, _T("dlg"))==0)||
1123 (_tcscmp(line
, _T("mak"))==0))
1125 SendEditor(SCI_SETLEXER
, SCLEX_CPP
);
1126 SendEditor(SCI_SETKEYWORDS
, 0, (LPARAM
)(m_TextView
.StringForControl(_T("and and_eq asm auto bitand bitor bool break \
1127 case catch char class compl const const_cast continue \
1128 default delete do double dynamic_cast else enum explicit export extern false float for \
1129 friend goto if inline int long mutable namespace new not not_eq \
1130 operator or or_eq private protected public \
1131 register reinterpret_cast return short signed sizeof static static_cast struct switch \
1132 template this throw true try typedef typeid typename union unsigned using \
1133 virtual void volatile wchar_t while xor xor_eq")).GetBuffer()));
1134 SendEditor(SCI_SETKEYWORDS
, 3, (LPARAM
)(m_TextView
.StringForControl(_T("a addindex addtogroup anchor arg attention \
1135 author b brief bug c class code date def defgroup deprecated dontinclude \
1136 e em endcode endhtmlonly endif endlatexonly endlink endverbatim enum example exception \
1137 f$ f[ f] file fn hideinitializer htmlinclude htmlonly \
1138 if image include ingroup internal invariant interface latexonly li line link \
1139 mainpage name namespace nosubgrouping note overload \
1140 p page par param post pre ref relates remarks return retval \
1141 sa section see showinitializer since skip skipline struct subsection \
1142 test throw todo typedef union until \
1143 var verbatim verbinclude version warning weakgroup $ @ \\ & < > # { }")).GetBuffer()));
1146 if (_tcscmp(line
, _T("cs"))==0)
1148 SendEditor(SCI_SETLEXER
, SCLEX_CPP
);
1149 SendEditor(SCI_SETKEYWORDS
, 0, (LPARAM
)(m_TextView
.StringForControl(_T("abstract as base bool break byte case catch char checked class \
1150 const continue decimal default delegate do double else enum \
1151 event explicit extern false finally fixed float for foreach goto if \
1152 implicit in int interface internal is lock long namespace new null \
1153 object operator out override params private protected public \
1154 readonly ref return sbyte sealed short sizeof stackalloc static \
1155 string struct switch this throw true try typeof uint ulong \
1156 unchecked unsafe ushort using virtual void while")).GetBuffer()));
1159 if ((_tcscmp(line
, _T("rc"))==0)||
1160 (_tcscmp(line
, _T("rc2"))==0))
1162 SendEditor(SCI_SETLEXER
, SCLEX_CPP
);
1163 SendEditor(SCI_SETKEYWORDS
, 0, (LPARAM
)(m_TextView
.StringForControl(_T("ACCELERATORS ALT AUTO3STATE AUTOCHECKBOX AUTORADIOBUTTON \
1164 BEGIN BITMAP BLOCK BUTTON CAPTION CHARACTERISTICS CHECKBOX CLASS \
1165 COMBOBOX CONTROL CTEXT CURSOR DEFPUSHBUTTON DIALOG DIALOGEX DISCARDABLE \
1166 EDITTEXT END EXSTYLE FONT GROUPBOX ICON LANGUAGE LISTBOX LTEXT \
1167 MENU MENUEX MENUITEM MESSAGETABLE POPUP \
1168 PUSHBUTTON RADIOBUTTON RCDATA RTEXT SCROLLBAR SEPARATOR SHIFT STATE3 \
1169 STRINGTABLE STYLE TEXTINCLUDE VALUE VERSION VERSIONINFO VIRTKEY")).GetBuffer()));
1172 if ((_tcscmp(line
, _T("idl"))==0)||
1173 (_tcscmp(line
, _T("odl"))==0))
1175 SendEditor(SCI_SETLEXER
, SCLEX_CPP
);
1176 SendEditor(SCI_SETKEYWORDS
, 0, (LPARAM
)(m_TextView
.StringForControl(_T("aggregatable allocate appobject arrays async async_uuid \
1178 bindable boolean broadcast byte byte_count \
1179 call_as callback char coclass code comm_status \
1180 const context_handle context_handle_noserialize \
1181 context_handle_serialize control cpp_quote custom \
1182 decode default defaultbind defaultcollelem \
1183 defaultvalue defaultvtable dispinterface displaybind dllname \
1185 enable_allocate encode endpoint entry enum error_status_t \
1187 fault_status first_is float \
1188 handle_t heap helpcontext helpfile helpstring \
1189 helpstringcontext helpstringdll hidden hyper \
1190 id idempotent ignore iid_as iid_is immediatebind implicit_handle \
1191 import importlib in include in_line int __int64 __int3264 interface \
1192 last_is lcid length_is library licensed local long \
1193 max_is maybe message methods midl_pragma \
1194 midl_user_allocate midl_user_free min_is module ms_union \
1195 ncacn_at_dsp ncacn_dnet_nsp ncacn_http ncacn_ip_tcp \
1196 ncacn_nb_ipx ncacn_nb_nb ncacn_nb_tcp ncacn_np \
1197 ncacn_spx ncacn_vns_spp ncadg_ip_udp ncadg_ipx ncadg_mq \
1198 ncalrpc nocode nonbrowsable noncreatable nonextensible notify \
1199 object odl oleautomation optimize optional out out_of_line \
1200 pipe pointer_default pragma properties propget propput propputref \
1202 range readonly ref represent_as requestedit restricted retval \
1203 shape short signed size_is small source strict_context_handle \
1204 string struct switch switch_is switch_type \
1205 transmit_as typedef \
1206 uidefault union unique unsigned user_marshal usesgetlasterror uuid \
1207 v1_enum vararg version void wchar_t wire_marshal")).GetBuffer()));
1210 if (_tcscmp(line
, _T("java"))==0)
1212 SendEditor(SCI_SETLEXER
, SCLEX_CPP
);
1213 SendEditor(SCI_SETKEYWORDS
, 0, (LPARAM
)(m_TextView
.StringForControl(_T("abstract assert boolean break byte case catch char class \
1214 const continue default do double else extends final finally float for future \
1215 generic goto if implements import inner instanceof int interface long \
1216 native new null outer package private protected public rest \
1217 return short static super switch synchronized this throw throws \
1218 transient try var void volatile while")).GetBuffer()));
1221 if (_tcscmp(line
, _T("js"))==0)
1223 SendEditor(SCI_SETLEXER
, SCLEX_CPP
);
1224 SendEditor(SCI_SETKEYWORDS
, 0, (LPARAM
)(m_TextView
.StringForControl(_T("abstract boolean break byte case catch char class \
1225 const continue debugger default delete do double else enum export extends \
1226 final finally float for function goto if implements import in instanceof \
1227 int interface long native new package private protected public \
1228 return short static super switch synchronized this throw throws \
1229 transient try typeof var void volatile while with")).GetBuffer()));
1232 if ((_tcscmp(line
, _T("pas"))==0)||
1233 (_tcscmp(line
, _T("dpr"))==0)||
1234 (_tcscmp(line
, _T("pp"))==0))
1236 SendEditor(SCI_SETLEXER
, SCLEX_PASCAL
);
1237 SendEditor(SCI_SETKEYWORDS
, 0, (LPARAM
)(m_TextView
.StringForControl(_T("and array as begin case class const constructor \
1238 destructor div do downto else end except file finally \
1239 for function goto if implementation in inherited \
1240 interface is mod not object of on or packed \
1241 procedure program property raise record repeat \
1242 set shl shr then threadvar to try type unit \
1243 until uses var while with xor")).GetBuffer()));
1246 if ((_tcscmp(line
, _T("as"))==0)||
1247 (_tcscmp(line
, _T("asc"))==0)||
1248 (_tcscmp(line
, _T("jsfl"))==0))
1250 SendEditor(SCI_SETLEXER
, SCLEX_CPP
);
1251 SendEditor(SCI_SETKEYWORDS
, 0, (LPARAM
)(m_TextView
.StringForControl(_T("add and break case catch class continue default delete do \
1252 dynamic else eq extends false finally for function ge get gt if implements import in \
1253 instanceof interface intrinsic le lt ne new not null or private public return \
1254 set static super switch this throw true try typeof undefined var void while with")).GetBuffer()));
1255 SendEditor(SCI_SETKEYWORDS
, 1, (LPARAM
)(m_TextView
.StringForControl(_T("Array Arguments Accessibility Boolean Button Camera Color \
1256 ContextMenu ContextMenuItem Date Error Function Key LoadVars LocalConnection Math \
1257 Microphone Mouse MovieClip MovieClipLoader NetConnection NetStream Number Object \
1258 PrintJob Selection SharedObject Sound Stage String StyleSheet System TextField \
1259 TextFormat TextSnapshot Video Void XML XMLNode XMLSocket \
1260 _accProps _focusrect _global _highquality _parent _quality _root _soundbuftime \
1261 arguments asfunction call capabilities chr clearInterval duplicateMovieClip \
1262 escape eval fscommand getProperty getTimer getURL getVersion gotoAndPlay gotoAndStop \
1263 ifFrameLoaded Infinity -Infinity int isFinite isNaN length loadMovie loadMovieNum \
1264 loadVariables loadVariablesNum maxscroll mbchr mblength mbord mbsubstring MMExecute \
1265 NaN newline nextFrame nextScene on onClipEvent onUpdate ord parseFloat parseInt play \
1266 prevFrame prevScene print printAsBitmap printAsBitmapNum printNum random removeMovieClip \
1267 scroll set setInterval setProperty startDrag stop stopAllSounds stopDrag substring \
1268 targetPath tellTarget toggleHighQuality trace unescape unloadMovie unLoadMovieNum updateAfterEvent")).GetBuffer()));
1271 if ((_tcscmp(line
, _T("html"))==0)||
1272 (_tcscmp(line
, _T("htm"))==0)||
1273 (_tcscmp(line
, _T("shtml"))==0)||
1274 (_tcscmp(line
, _T("htt"))==0)||
1275 (_tcscmp(line
, _T("xml"))==0)||
1276 (_tcscmp(line
, _T("asp"))==0)||
1277 (_tcscmp(line
, _T("xsl"))==0)||
1278 (_tcscmp(line
, _T("php"))==0)||
1279 (_tcscmp(line
, _T("xhtml"))==0)||
1280 (_tcscmp(line
, _T("phtml"))==0)||
1281 (_tcscmp(line
, _T("cfm"))==0)||
1282 (_tcscmp(line
, _T("tpl"))==0)||
1283 (_tcscmp(line
, _T("dtd"))==0)||
1284 (_tcscmp(line
, _T("hta"))==0)||
1285 (_tcscmp(line
, _T("htd"))==0)||
1286 (_tcscmp(line
, _T("wxs"))==0))
1288 SendEditor(SCI_SETLEXER
, SCLEX_HTML
);
1289 SendEditor(SCI_SETSTYLEBITS
, 7);
1290 SendEditor(SCI_SETKEYWORDS
, 0, (LPARAM
)(m_TextView
.StringForControl(_T("a abbr acronym address applet area b base basefont \
1291 bdo big blockquote body br button caption center \
1292 cite code col colgroup dd del dfn dir div dl dt em \
1293 fieldset font form frame frameset h1 h2 h3 h4 h5 h6 \
1294 head hr html i iframe img input ins isindex kbd label \
1295 legend li link map menu meta noframes noscript \
1296 object ol optgroup option p param pre q s samp \
1297 script select small span strike strong style sub sup \
1298 table tbody td textarea tfoot th thead title tr tt u ul \
1299 var xml xmlns abbr accept-charset accept accesskey action align alink \
1300 alt archive axis background bgcolor border \
1301 cellpadding cellspacing char charoff charset checked cite \
1302 class classid clear codebase codetype color cols colspan \
1303 compact content coords \
1304 data datafld dataformatas datapagesize datasrc datetime \
1305 declare defer dir disabled enctype event \
1306 face for frame frameborder \
1307 headers height href hreflang hspace http-equiv \
1308 id ismap label lang language leftmargin link longdesc \
1309 marginwidth marginheight maxlength media method multiple \
1310 name nohref noresize noshade nowrap \
1311 object onblur onchange onclick ondblclick onfocus \
1312 onkeydown onkeypress onkeyup onload onmousedown \
1313 onmousemove onmouseover onmouseout onmouseup \
1314 onreset onselect onsubmit onunload \
1315 profile prompt readonly rel rev rows rowspan rules \
1316 scheme scope selected shape size span src standby start style \
1317 summary tabindex target text title topmargin type usemap \
1318 valign value valuetype version vlink vspace width \
1319 text password checkbox radio submit reset \
1320 file hidden image")).GetBuffer()));
1321 SendEditor(SCI_SETKEYWORDS
, 1, (LPARAM
)(m_TextView
.StringForControl(_T("assign audio block break catch choice clear disconnect else elseif \
1322 emphasis enumerate error exit field filled form goto grammar help \
1323 if initial link log menu meta noinput nomatch object option p paragraph \
1324 param phoneme prompt property prosody record reprompt return s say-as \
1325 script sentence subdialog submit throw transfer value var voice vxml")).GetBuffer()));
1326 SendEditor(SCI_SETKEYWORDS
, 2, (LPARAM
)(m_TextView
.StringForControl(_T("accept age alphabet anchor application base beep bridge category charset \
1327 classid cond connecttimeout content contour count dest destexpr dtmf dtmfterm \
1328 duration enctype event eventexpr expr expritem fetchtimeout finalsilence \
1329 gender http-equiv id level maxage maxstale maxtime message messageexpr \
1330 method mime modal mode name namelist next nextitem ph pitch range rate \
1331 scope size sizeexpr skiplist slot src srcexpr sub time timeexpr timeout \
1332 transferaudio type value variant version volume xml:lang")).GetBuffer()));
1333 SendEditor(SCI_SETKEYWORDS
, 3, (LPARAM
)(m_TextView
.StringForControl(_T("and assert break class continue def del elif \
1334 else except exec finally for from global if import in is lambda None \
1335 not or pass print raise return try while yield")).GetBuffer()));
1336 SendEditor(SCI_SETKEYWORDS
, 4, (LPARAM
)(m_TextView
.StringForControl(_T("and argv as argc break case cfunction class continue declare default do \
1337 die echo else elseif empty enddeclare endfor endforeach endif endswitch \
1338 endwhile e_all e_parse e_error e_warning eval exit extends false for \
1339 foreach function global http_cookie_vars http_get_vars http_post_vars \
1340 http_post_files http_env_vars http_server_vars if include include_once \
1341 list new not null old_function or parent php_os php_self php_version \
1342 print require require_once return static switch stdclass this true var \
1343 xor virtual while __file__ __line__ __sleep __wakeup")).GetBuffer()));
1345 SetAStyle(SCE_H_TAG
, darkBlue
);
1346 SetAStyle(SCE_H_TAGUNKNOWN
, red
);
1347 SetAStyle(SCE_H_ATTRIBUTE
, darkBlue
);
1348 SetAStyle(SCE_H_ATTRIBUTEUNKNOWN
, red
);
1349 SetAStyle(SCE_H_NUMBER
, RGB(0x80,0,0x80));
1350 SetAStyle(SCE_H_DOUBLESTRING
, RGB(0,0x80,0));
1351 SetAStyle(SCE_H_SINGLESTRING
, RGB(0,0x80,0));
1352 SetAStyle(SCE_H_OTHER
, RGB(0x80,0,0x80));
1353 SetAStyle(SCE_H_COMMENT
, RGB(0x80,0x80,0));
1354 SetAStyle(SCE_H_ENTITY
, RGB(0x80,0,0x80));
1356 SetAStyle(SCE_H_TAGEND
, darkBlue
);
1357 SetAStyle(SCE_H_XMLSTART
, darkBlue
); // <?
1358 SetAStyle(SCE_H_QUESTION
, darkBlue
); // <?
1359 SetAStyle(SCE_H_XMLEND
, darkBlue
); // ?>
1360 SetAStyle(SCE_H_SCRIPT
, darkBlue
); // <script
1361 SetAStyle(SCE_H_ASP
, RGB(0x4F, 0x4F, 0), RGB(0xFF, 0xFF, 0)); // <% ... %>
1362 SetAStyle(SCE_H_ASPAT
, RGB(0x4F, 0x4F, 0), RGB(0xFF, 0xFF, 0)); // <%@ ... %>
1364 SetAStyle(SCE_HB_DEFAULT
, black
);
1365 SetAStyle(SCE_HB_COMMENTLINE
, darkGreen
);
1366 SetAStyle(SCE_HB_NUMBER
, RGB(0,0x80,0x80));
1367 SetAStyle(SCE_HB_WORD
, darkBlue
);
1368 SendEditor(SCI_STYLESETBOLD
, SCE_HB_WORD
, 1);
1369 SetAStyle(SCE_HB_STRING
, RGB(0x80,0,0x80));
1370 SetAStyle(SCE_HB_IDENTIFIER
, black
);
1372 // This light blue is found in the windows system palette so is safe to use even in 256 colour modes.
1373 // Show the whole section of VBScript with light blue background
1374 for (int bstyle
= SCE_HB_DEFAULT
; bstyle
<= SCE_HB_STRINGEOL
; ++bstyle
) {
1375 SendEditor(SCI_STYLESETFONT
, bstyle
,
1376 reinterpret_cast<LPARAM
>(m_TextView
.StringForControl(_T("Lucida Console")).GetBuffer()));
1377 SendEditor(SCI_STYLESETBACK
, bstyle
, lightBlue
);
1378 // This call extends the backround colour of the last style on the line to the edge of the window
1379 SendEditor(SCI_STYLESETEOLFILLED
, bstyle
, 1);
1381 SendEditor(SCI_STYLESETBACK
, SCE_HB_STRINGEOL
, RGB(0x7F,0x7F,0xFF));
1382 SendEditor(SCI_STYLESETFONT
, SCE_HB_COMMENTLINE
,
1383 reinterpret_cast<LPARAM
>(m_TextView
.StringForControl(_T("Lucida Console")).GetBuffer()));
1385 SetAStyle(SCE_HBA_DEFAULT
, black
);
1386 SetAStyle(SCE_HBA_COMMENTLINE
, darkGreen
);
1387 SetAStyle(SCE_HBA_NUMBER
, RGB(0,0x80,0x80));
1388 SetAStyle(SCE_HBA_WORD
, darkBlue
);
1389 SendEditor(SCI_STYLESETBOLD
, SCE_HBA_WORD
, 1);
1390 SetAStyle(SCE_HBA_STRING
, RGB(0x80,0,0x80));
1391 SetAStyle(SCE_HBA_IDENTIFIER
, black
);
1393 // Show the whole section of ASP VBScript with bright yellow background
1394 for (int bastyle
= SCE_HBA_DEFAULT
; bastyle
<= SCE_HBA_STRINGEOL
; ++bastyle
) {
1395 SendEditor(SCI_STYLESETFONT
, bastyle
,
1396 reinterpret_cast<LPARAM
>(m_TextView
.StringForControl(_T("Lucida Console")).GetBuffer()));
1397 SendEditor(SCI_STYLESETBACK
, bastyle
, RGB(0xFF, 0xFF, 0));
1398 // This call extends the backround colour of the last style on the line to the edge of the window
1399 SendEditor(SCI_STYLESETEOLFILLED
, bastyle
, 1);
1401 SendEditor(SCI_STYLESETBACK
, SCE_HBA_STRINGEOL
, RGB(0xCF,0xCF,0x7F));
1402 SendEditor(SCI_STYLESETFONT
, SCE_HBA_COMMENTLINE
,
1403 reinterpret_cast<LPARAM
>(m_TextView
.StringForControl(_T("Lucida Console")).GetBuffer()));
1405 // If there is no need to support embedded Javascript, the following code can be dropped.
1406 // Javascript will still be correctly processed but will be displayed in just the default style.
1408 SetAStyle(SCE_HJ_START
, RGB(0x80,0x80,0));
1409 SetAStyle(SCE_HJ_DEFAULT
, black
);
1410 SetAStyle(SCE_HJ_COMMENT
, darkGreen
);
1411 SetAStyle(SCE_HJ_COMMENTLINE
, darkGreen
);
1412 SetAStyle(SCE_HJ_COMMENTDOC
, darkGreen
);
1413 SetAStyle(SCE_HJ_NUMBER
, RGB(0,0x80,0x80));
1414 SetAStyle(SCE_HJ_WORD
, black
);
1415 SetAStyle(SCE_HJ_KEYWORD
, darkBlue
);
1416 SetAStyle(SCE_HJ_DOUBLESTRING
, RGB(0x80,0,0x80));
1417 SetAStyle(SCE_HJ_SINGLESTRING
, RGB(0x80,0,0x80));
1418 SetAStyle(SCE_HJ_SYMBOLS
, black
);
1420 SetAStyle(SCE_HJA_START
, RGB(0x80,0x80,0));
1421 SetAStyle(SCE_HJA_DEFAULT
, black
);
1422 SetAStyle(SCE_HJA_COMMENT
, darkGreen
);
1423 SetAStyle(SCE_HJA_COMMENTLINE
, darkGreen
);
1424 SetAStyle(SCE_HJA_COMMENTDOC
, darkGreen
);
1425 SetAStyle(SCE_HJA_NUMBER
, RGB(0,0x80,0x80));
1426 SetAStyle(SCE_HJA_WORD
, black
);
1427 SetAStyle(SCE_HJA_KEYWORD
, darkBlue
);
1428 SetAStyle(SCE_HJA_DOUBLESTRING
, RGB(0x80,0,0x80));
1429 SetAStyle(SCE_HJA_SINGLESTRING
, RGB(0x80,0,0x80));
1430 SetAStyle(SCE_HJA_SYMBOLS
, black
);
1432 SetAStyle(SCE_HPHP_DEFAULT
, black
);
1433 SetAStyle(SCE_HPHP_HSTRING
, RGB(0x80,0,0x80));
1434 SetAStyle(SCE_HPHP_SIMPLESTRING
, RGB(0x80,0,0x80));
1435 SetAStyle(SCE_HPHP_WORD
, darkBlue
);
1436 SetAStyle(SCE_HPHP_NUMBER
, RGB(0,0x80,0x80));
1437 SetAStyle(SCE_HPHP_VARIABLE
, red
);
1438 SetAStyle(SCE_HPHP_HSTRING_VARIABLE
, red
);
1439 SetAStyle(SCE_HPHP_COMPLEX_VARIABLE
, red
);
1440 SetAStyle(SCE_HPHP_COMMENT
, darkGreen
);
1441 SetAStyle(SCE_HPHP_COMMENTLINE
, darkGreen
);
1442 SetAStyle(SCE_HPHP_OPERATOR
, darkBlue
);
1444 // Show the whole section of Javascript with off white background
1445 for (int jstyle
= SCE_HJ_DEFAULT
; jstyle
<= SCE_HJ_SYMBOLS
; ++jstyle
) {
1446 SendEditor(SCI_STYLESETFONT
, jstyle
,
1447 reinterpret_cast<LPARAM
>(m_TextView
.StringForControl(_T("Lucida Console")).GetBuffer()));
1448 SendEditor(SCI_STYLESETBACK
, jstyle
, offWhite
);
1449 SendEditor(SCI_STYLESETEOLFILLED
, jstyle
, 1);
1451 SendEditor(SCI_STYLESETBACK
, SCE_HJ_STRINGEOL
, RGB(0xDF, 0xDF, 0x7F));
1452 SendEditor(SCI_STYLESETEOLFILLED
, SCE_HJ_STRINGEOL
, 1);
1454 // Show the whole section of Javascript with brown background
1455 for (int jastyle
= SCE_HJA_DEFAULT
; jastyle
<= SCE_HJA_SYMBOLS
; ++jastyle
) {
1456 SendEditor(SCI_STYLESETFONT
, jastyle
,
1457 reinterpret_cast<LPARAM
>(m_TextView
.StringForControl(_T("Lucida Console")).GetBuffer()));
1458 SendEditor(SCI_STYLESETBACK
, jastyle
, RGB(0xDF, 0xDF, 0x7F));
1459 SendEditor(SCI_STYLESETEOLFILLED
, jastyle
, 1);
1461 SendEditor(SCI_STYLESETBACK
, SCE_HJA_STRINGEOL
, RGB(0x0,0xAF,0x5F));
1462 SendEditor(SCI_STYLESETEOLFILLED
, SCE_HJA_STRINGEOL
, 1);
1467 SendEditor(SCI_SETLEXER
, SCLEX_CPP
);
1470 SendEditor(SCI_COLOURISE
, 0, -1);
1474 void CTortoiseGitBlameView::SetupCppLexer()
1476 SetAStyle(SCE_C_DEFAULT
, RGB(0, 0, 0));
1477 SetAStyle(SCE_C_COMMENT
, RGB(0, 0x80, 0));
1478 SetAStyle(SCE_C_COMMENTLINE
, RGB(0, 0x80, 0));
1479 SetAStyle(SCE_C_COMMENTDOC
, RGB(0, 0x80, 0));
1480 SetAStyle(SCE_C_COMMENTLINEDOC
, RGB(0, 0x80, 0));
1481 SetAStyle(SCE_C_COMMENTDOCKEYWORD
, RGB(0, 0x80, 0));
1482 SetAStyle(SCE_C_COMMENTDOCKEYWORDERROR
, RGB(0, 0x80, 0));
1483 SetAStyle(SCE_C_NUMBER
, RGB(0, 0x80, 0x80));
1484 SetAStyle(SCE_C_WORD
, RGB(0, 0, 0x80));
1485 SendEditor(SCE_C_WORD
, 1);
1486 SetAStyle(SCE_C_STRING
, RGB(0x80, 0, 0x80));
1487 SetAStyle(SCE_C_IDENTIFIER
, RGB(0, 0, 0));
1488 SetAStyle(SCE_C_PREPROCESSOR
, RGB(0x80, 0, 0));
1489 SetAStyle(SCE_C_OPERATOR
, RGB(0x80, 0x80, 0));
1490 SendEditor(SCI_SETPROPERTY
, (WPARAM
)"lexer.cpp.track.preprocessor", (LPARAM
)"0");
1493 int CTortoiseGitBlameView::GetEncode(unsigned char *buff
, int size
, int *bomoffset
)
1495 CFileTextLines textlines
;
1496 CFileTextLines::UnicodeType type
= textlines
.CheckUnicodeType(buff
, size
);
1498 if(type
== CFileTextLines::UTF8BOM
)
1503 if(type
== CFileTextLines::UTF8
)
1506 if(type
== CFileTextLines::UTF16_LE
)
1508 if (type
== CFileTextLines::UTF16_LEBOM
)
1514 if(type
== CFileTextLines::UTF16_BE
)
1516 if (type
== CFileTextLines::UTF16_BEBOM
)
1525 void CTortoiseGitBlameView::ParseBlame()
1527 m_data
.ParseBlameOutput(GetDocument()->m_BlameData
, GetLogData()->m_pLogCache
->m_HashMap
, m_DateFormat
, m_bRelativeTimes
);
1528 CString filename
= GetDocument()->m_GitPath
.GetGitPathString();
1529 m_bBlameOuputContainsOtherFilenames
= m_data
.ContainsOnlyFilename(filename
) ? FALSE
: TRUE
;
1532 void CTortoiseGitBlameView::MapLineToLogIndex()
1534 std::vector
<int> lineToLogIndex
;
1537 int numberOfLines
= m_data
.GetNumberOfLines();
1538 lineToLogIndex
.reserve(numberOfLines
);
1539 size_t logSize
= this->GetLogData()->size();
1540 for (int j
= 0; j
< numberOfLines
; ++j
)
1542 CGitHash
& hash
= m_data
.GetHash(j
);
1545 for (size_t i
= 0; i
< logSize
; ++i
)
1547 if (hash
== this->GetLogData()->at(i
))
1553 lineToLogIndex
.push_back(index
);
1555 this->m_lineToLogIndex
.swap(lineToLogIndex
);
1558 void CTortoiseGitBlameView::UpdateInfo(int Encode
)
1563 SendEditor(SCI_SETREADONLY
, FALSE
);
1564 SendEditor(SCI_CLEARALL
);
1565 SendEditor(EM_EMPTYUNDOBUFFER
);
1566 SendEditor(SCI_SETSAVEPOINT
);
1567 SendEditor(SCI_CANCEL
);
1568 SendEditor(SCI_SETUNDOCOLLECTION
, 0);
1570 SendEditor(SCI_SETCODEPAGE
, SC_CP_UTF8
);
1572 int encoding
= m_data
.UpdateEncoding(Encode
);
1574 int numberOfLines
= m_data
.GetNumberOfLines();
1575 if (numberOfLines
> 0)
1577 for (int i
= 0; i
< numberOfLines
- 1; ++i
)
1579 SendEditor(SCI_REPLACESEL
, 0, (LPARAM
)(LPCSTR
)m_data
.GetUtf8Line(i
));
1580 SendEditor(SCI_REPLACESEL
, 0, (LPARAM
)(LPCSTR
)"\n\0\0\0");
1583 // as it will add another line number in scintilla which has no counter part in the blame output
1584 // prevent carriage return and line feed for the last line
1585 CStringA s
= m_data
.GetUtf8Line(numberOfLines
- 1);
1586 int length
= s
.GetLength();
1587 if (length
> 0 && s
.GetAt(length
- 1) == '\r')
1588 s
.Truncate(length
- 1);
1589 SendEditor(SCI_REPLACESEL
, 0, (LPARAM
)(LPCSTR
)s
);
1597 int nIndex
= ((CMainFrame
*)::AfxGetApp()->GetMainWnd())->m_wndStatusBar
.CommandToIndex(ID_INDICATOR_ENCODING
);
1598 ((CMainFrame
*)::AfxGetApp()->GetMainWnd())->m_wndStatusBar
.GetPaneInfo(nIndex
, nID
, nStyle
, cxWidth
);
1599 CString sBarText
= L
"";
1600 for (int i
= 0; i
< _countof(encodings
); ++i
)
1602 if (encodings
[i
].id
== encoding
)
1604 sBarText
= CString(encodings
[i
].name
);
1608 //calculate the width of the text
1609 CDC
* pDC
= ((CMainFrame
*)::AfxGetApp()->GetMainWnd())->m_wndStatusBar
.GetDC();
1612 CSize size
= pDC
->GetTextExtent(sBarText
);
1613 ((CMainFrame
*)::AfxGetApp()->GetMainWnd())->m_wndStatusBar
.SetPaneInfo(nIndex
, nID
, nStyle
, size
.cx
+2);
1616 ((CMainFrame
*)::AfxGetApp()->GetMainWnd())->m_wndStatusBar
.SetPaneText(nIndex
, sBarText
);
1619 #ifdef USE_TEMPFILENAME
1627 file
.Open(this->GetDocument()->m_TempFileName
,CFile::modeRead
);
1629 m_Buffer
= new char[file
.GetLength()+4];
1630 m_Buffer
[file
.GetLength()] =0;
1631 m_Buffer
[file
.GetLength()+1] =0;
1632 m_Buffer
[file
.GetLength()+2] =0;
1633 m_Buffer
[file
.GetLength()+3] =0;
1635 file
.Read(m_Buffer
, file
.GetLength());
1638 int encoding
= GetEncode( (unsigned char *)m_Buffer
, file
.GetLength(), &bomoffset
);
1641 //SendEditor(SCI_SETCODEPAGE, encoding);
1643 //SendEditor(SCI_REPLACESEL, 0, (LPARAM)(LPCSTR)(m_Buffer + bomoffset));
1645 SetupLexer(GetDocument()->m_CurrentFileName
);
1647 SendEditor(SCI_SETUNDOCOLLECTION
, 1);
1648 SendEditor(EM_EMPTYUNDOBUFFER
);
1649 SendEditor(SCI_SETSAVEPOINT
);
1650 SendEditor(SCI_GOTOPOS
, 0);
1651 SendEditor(SCI_SETSCROLLWIDTHTRACKING
, TRUE
);
1652 SendEditor(SCI_SETREADONLY
, TRUE
);
1656 this->GetClientRect(rect
);
1657 //this->m_TextView.GetWindowRect(rect);
1658 //this->m_TextView.ScreenToClient(rect);
1659 rect
.left
=this->m_blamewidth
;
1660 this->m_TextView
.MoveWindow(rect
);
1665 CString
CTortoiseGitBlameView::ResolveCommitFile(int line
)
1667 return ResolveCommitFile(m_data
.GetFilename(line
));
1670 CString
CTortoiseGitBlameView::ResolveCommitFile(const CString
& path
)
1674 return ((CMainFrame
*)::AfxGetApp()->GetMainWnd())->GetActiveView()->GetDocument()->GetPathName();
1678 return g_Git
.CombinePath(path
);
1682 COLORREF
CTortoiseGitBlameView::GetLineColor(int line
)
1684 if (m_colorage
&& m_data
.IsValidLine(line
))
1686 int logIndex
= m_lineToLogIndex
[line
];
1689 int slider
= (int)((GetLogData()->size() - logIndex
) * 100 / (GetLogData()->size() + 1));
1690 return InterColor(DWORD(m_regOldLinesColor
), DWORD(m_regNewLinesColor
), slider
);
1693 return m_windowcolor
;
1696 CGitBlameLogList
* CTortoiseGitBlameView::GetLogList()
1698 return &(GetDocument()->GetMainFrame()->m_wndOutput
.m_LogList
);
1702 CLogDataVector
* CTortoiseGitBlameView::GetLogData()
1704 return &(GetDocument()->GetMainFrame()->m_wndOutput
.m_LogList
.m_logEntries
);
1707 void CTortoiseGitBlameView::OnSciPainted(NMHDR
*,LRESULT
*)
1712 void CTortoiseGitBlameView::OnLButtonDown(UINT nFlags
,CPoint point
)
1715 int line
= (int)SendEditor(SCI_GETFIRSTVISIBLELINE
);
1716 int height
= (int)SendEditor(SCI_TEXTHEIGHT
);
1717 line
= line
+ (int)(point
.y
/height
);
1719 if (line
< m_data
.GetNumberOfLines())
1721 SetSelectedLine(line
);
1722 if (m_data
.GetHash(line
) != m_SelectedHash
)
1724 m_SelectedHash
= m_data
.GetHash(line
);
1726 int logIndex
= m_lineToLogIndex
[line
];
1729 this->GetLogList()->SetItemState(logIndex
, LVIS_SELECTED
, LVIS_SELECTED
);
1730 this->GetLogList()->EnsureVisible(logIndex
, FALSE
);
1734 GitRevLoglist
* pRev
= m_data
.GetRev(line
, GetLogData()->m_pLogCache
->m_HashMap
);
1735 this->GetDocument()->GetMainFrame()->m_wndProperties
.UpdateProperties(pRev
);
1740 m_SelectedHash
.Empty();
1742 //::InvalidateRect( NULL, FALSE);
1744 this->m_TextView
.Invalidate();
1749 SetSelectedLine(-1);
1752 CView::OnLButtonDown(nFlags
,point
);
1755 void CTortoiseGitBlameView::OnSciGetBkColor(NMHDR
* hdr
, LRESULT
* /*result*/)
1757 SCNotification
*notification
=reinterpret_cast<SCNotification
*>(hdr
);
1759 if (notification
->line
< m_data
.GetNumberOfLines())
1761 if (m_data
.GetHash(notification
->line
) == this->m_SelectedHash
)
1762 notification
->lParam
= m_selectedauthorcolor
;
1764 notification
->lParam
= GetLineColor(notification
->line
);
1768 void CTortoiseGitBlameView::FocusOn(GitRevLoglist
* pRev
)
1770 this->GetDocument()->GetMainFrame()->m_wndProperties
.UpdateProperties(pRev
);
1774 if (m_SelectedHash
!= pRev
->m_CommitHash
) {
1775 m_SelectedHash
= pRev
->m_CommitHash
;
1776 int line
= m_data
.FindFirstLine(m_SelectedHash
, 0);
1780 m_TextView
.Invalidate();
1783 SendEditor(SCI_SETSEL
, INT_MAX
, -1);
1787 void CTortoiseGitBlameView::OnMouseHover(UINT
/*nFlags*/, CPoint point
)
1789 int line
= (int)SendEditor(SCI_GETFIRSTVISIBLELINE
);
1790 int height
= (int)SendEditor(SCI_TEXTHEIGHT
);
1791 line
= line
+ (point
.y
/height
);
1793 if (m_data
.IsValidLine(line
))
1795 if (line
!= m_MouseLine
)
1798 GitRev
*pRev
= nullptr;
1799 int logIndex
= m_lineToLogIndex
[line
];
1801 pRev
= &GetLogData()->GetGitRevAt(logIndex
);
1803 pRev
= m_data
.GetRev(line
, GetLogData()->m_pLogCache
->m_HashMap
);
1808 CString body
= pRev
->GetBody();
1812 while (iline
++ < maxLine
)
1814 int pos2
= body
.Find(_T("\n"), pos
);
1817 int lineLength
= pos2
- pos
- 1;
1819 iline
+= lineLength
/ 70;
1823 if ((m_bShowCompleteLog
&& m_bFollowRenames
) || !BlameIsLimitedToOneFilename(m_dwDetectMovedOrCopiedLines
) || m_bBlameOuputContainsOtherFilenames
)
1824 filename
.Format(_T("%s: %s\n"), (LPCTSTR
)m_sFileName
, (LPCTSTR
)m_data
.GetFilename(line
));
1827 str
.Format(_T("%s: %s\n%s%s: %s <%s>\n%s: %s\n%s:\n%s\n%s"), (LPCTSTR
)m_sRev
, (LPCTSTR
)pRev
->m_CommitHash
.ToString(), (LPCTSTR
)filename
,
1828 (LPCTSTR
)m_sAuthor
, (LPCTSTR
)pRev
->GetAuthorName(), (LPCTSTR
)pRev
->GetAuthorEmail(),
1829 (LPCTSTR
)m_sDate
, (LPCTSTR
)CLoglistUtils::FormatDateAndTime(pRev
->GetAuthorDate(), m_DateFormat
, true, m_bRelativeTimes
),
1830 (LPCTSTR
)m_sMessage
, (LPCTSTR
)pRev
->GetSubject(),
1831 iline
<= maxLine
? body
: (body
.Left(pos
) + _T("\n....................")));
1834 m_ToolTip
.AddTool(this, str
);
1837 rect
.left
=LOCATOR_WIDTH
;
1838 rect
.right
=this->m_blamewidth
+rect
.left
;
1839 rect
.top
= point
.y
- (LONG
)height
;
1840 rect
.bottom
= point
.y
+ (LONG
)height
;
1841 this->InvalidateRect(rect
);
1846 void CTortoiseGitBlameView::OnMouseMove(UINT
/*nFlags*/, CPoint
/*point*/)
1848 TRACKMOUSEEVENT tme
;
1849 tme
.cbSize
=sizeof(TRACKMOUSEEVENT
);
1850 tme
.dwFlags
=TME_HOVER
|TME_LEAVE
;
1851 tme
.hwndTrack
=this->m_hWnd
;
1853 TrackMouseEvent(&tme
);
1857 BOOL
CTortoiseGitBlameView::PreTranslateMessage(MSG
* pMsg
)
1859 if (m_ToolTip
.GetSafeHwnd())
1860 m_ToolTip
.RelayEvent(pMsg
);
1861 return CView::PreTranslateMessage(pMsg
);
1864 void CTortoiseGitBlameView::OnEditFind()
1869 m_pFindDialog
=new CFindReplaceDialog();
1871 CString oneline
= theApp
.GetString(_T("FindString"));
1872 if (m_TextView
.Call(SCI_GETSELECTIONSTART
) != m_TextView
.Call(SCI_GETSELECTIONEND
))
1874 LRESULT bufsize
= m_TextView
.Call(SCI_GETSELECTIONEND
) - m_TextView
.Call(SCI_GETSELECTIONSTART
);
1875 std::unique_ptr
<char> linebuf(new char[bufsize
+ 1]);
1876 SecureZeroMemory(linebuf
.get(), bufsize
+ 1);
1877 SendEditor(SCI_GETSELTEXT
, 0, (LPARAM
)linebuf
.get());
1878 oneline
= m_TextView
.StringFromControl(linebuf
.get());
1881 DWORD flags
= FR_DOWN
| FR_HIDEWHOLEWORD
| FR_HIDEUPDOWN
;
1882 if (theApp
.GetInt(_T("FindMatchCase")))
1883 flags
|= FR_MATCHCASE
;
1885 m_pFindDialog
->Create(TRUE
, oneline
, NULL
, flags
, this);
1888 void CTortoiseGitBlameView::OnEditGoto()
1891 if(dlg
.DoModal()==IDOK
)
1893 this->GotoLine(dlg
.m_LineNumber
);
1897 LRESULT
CTortoiseGitBlameView::OnFindDialogMessage(WPARAM
/*wParam*/, LPARAM
/*lParam*/)
1899 ASSERT(m_pFindDialog
!= NULL
);
1901 // If the FR_DIALOGTERM flag is set,
1902 // invalidate the handle identifying the dialog box.
1903 if (m_pFindDialog
->IsTerminating())
1905 m_pFindDialog
= NULL
;
1909 if (m_data
.GetNumberOfLines()==0)
1912 // If the FR_FINDNEXT flag is set,
1913 // call the application-defined search routine
1914 // to search for the requested string.
1915 if(m_pFindDialog
->FindNext())
1917 m_bMatchCase
= !!(m_pFindDialog
->m_nFlags
& FR_MATCHCASE
);
1918 m_sFindText
= m_pFindDialog
->GetFindString();
1920 theApp
.WriteInt(_T("FindMatchCase"), m_bMatchCase
? 1 : 0);
1921 theApp
.WriteString(_T("FindString"), m_sFindText
);
1923 DoSearch(CTortoiseGitBlameData::SearchNext
);
1929 void CTortoiseGitBlameView::OnViewNext()
1931 int startline
= (int)SendEditor(SCI_GETFIRSTVISIBLELINE
);
1932 int line
= m_data
.FindNextLine(this->m_SelectedHash
, (int)SendEditor(SCI_GETFIRSTVISIBLELINE
), false);
1934 SendEditor(SCI_LINESCROLL
, 0, line
- startline
- 2);
1936 void CTortoiseGitBlameView::OnViewPrev()
1938 int startline
= (int)SendEditor(SCI_GETFIRSTVISIBLELINE
);
1939 int line
= m_data
.FindNextLine(this->m_SelectedHash
, (int)SendEditor(SCI_GETFIRSTVISIBLELINE
), true);
1941 SendEditor(SCI_LINESCROLL
, 0, line
- startline
- 2);
1944 void CTortoiseGitBlameView::OnViewToggleAuthor()
1946 m_bShowAuthor
= ! m_bShowAuthor
;
1948 theApp
.WriteInt(_T("ShowAuthor"), m_bShowAuthor
);
1951 this->GetClientRect(&rect
);
1952 rect
.left
=GetBlameWidth();
1954 m_TextView
.MoveWindow(&rect
);
1957 void CTortoiseGitBlameView::OnUpdateViewToggleAuthor(CCmdUI
*pCmdUI
)
1959 pCmdUI
->SetCheck(m_bShowAuthor
);
1962 void CTortoiseGitBlameView::OnViewToggleDate()
1964 m_bShowDate
= ! m_bShowDate
;
1966 theApp
.WriteInt(_T("ShowDate"), m_bShowDate
);
1969 this->GetClientRect(&rect
);
1970 rect
.left
=GetBlameWidth();
1972 m_TextView
.MoveWindow(&rect
);
1975 void CTortoiseGitBlameView::OnUpdateViewToggleDate(CCmdUI
*pCmdUI
)
1977 pCmdUI
->SetCheck(m_bShowDate
);
1980 void CTortoiseGitBlameView::OnViewToggleShowFilename()
1982 m_bShowFilename
= ! m_bShowFilename
;
1984 theApp
.WriteInt(_T("ShowFilename"), m_bShowFilename
);
1987 this->GetClientRect(&rect
);
1988 rect
.left
= GetBlameWidth();
1990 m_TextView
.MoveWindow(&rect
);
1993 void CTortoiseGitBlameView::OnUpdateViewToggleShowFilename(CCmdUI
*pCmdUI
)
1995 pCmdUI
->SetCheck(m_bShowFilename
);
1998 void CTortoiseGitBlameView::OnViewToggleShowOriginalLineNumber()
2000 m_bShowOriginalLineNumber
= ! m_bShowOriginalLineNumber
;
2002 theApp
.WriteInt(_T("ShowOriginalLineNumber"), m_bShowOriginalLineNumber
);
2005 this->GetClientRect(&rect
);
2006 rect
.left
= GetBlameWidth();
2008 m_TextView
.MoveWindow(&rect
);
2011 void CTortoiseGitBlameView::OnUpdateViewToggleShowOriginalLineNumber(CCmdUI
*pCmdUI
)
2013 pCmdUI
->SetCheck(m_bShowOriginalLineNumber
);
2016 void CTortoiseGitBlameView::OnViewDetectMovedOrCopiedLines(DWORD dwDetectMovedOrCopiedLines
)
2018 m_dwDetectMovedOrCopiedLines
= dwDetectMovedOrCopiedLines
;
2020 theApp
.DoWaitCursor(1);
2022 theApp
.WriteInt(_T("DetectMovedOrCopiedLines"), m_dwDetectMovedOrCopiedLines
);
2024 CTortoiseGitBlameDoc
*document
= (CTortoiseGitBlameDoc
*) m_pDocument
;
2025 if (!document
->m_CurrentFileName
.IsEmpty())
2027 document
->m_lLine
= (int)SendEditor(SCI_GETFIRSTVISIBLELINE
) + 1;
2028 theApp
.m_pDocManager
->OnFileNew();
2029 document
->OnOpenDocument(document
->m_CurrentFileName
, document
->m_Rev
);
2031 theApp
.DoWaitCursor(-1);
2034 void CTortoiseGitBlameView::OnViewDetectMovedOrCopiedLinesToggleDisabled()
2036 OnViewDetectMovedOrCopiedLines(BLAME_DETECT_MOVED_OR_COPIED_LINES_DISABLED
);
2039 void CTortoiseGitBlameView::OnUpdateViewDetectMovedOrCopiedLinesToggleDisabled(CCmdUI
*pCmdUI
)
2041 pCmdUI
->SetRadio(m_dwDetectMovedOrCopiedLines
== BLAME_DETECT_MOVED_OR_COPIED_LINES_DISABLED
);
2044 void CTortoiseGitBlameView::OnViewDetectMovedOrCopiedLinesToggleWithinFile()
2046 OnViewDetectMovedOrCopiedLines(BLAME_DETECT_MOVED_OR_COPIED_LINES_WITHIN_FILE
);
2049 void CTortoiseGitBlameView::OnUpdateViewDetectMovedOrCopiedLinesToggleWithinFile(CCmdUI
*pCmdUI
)
2051 pCmdUI
->SetRadio(m_dwDetectMovedOrCopiedLines
== BLAME_DETECT_MOVED_OR_COPIED_LINES_WITHIN_FILE
);
2054 void CTortoiseGitBlameView::OnViewDetectMovedOrCopiedLinesToggleFromModifiedFiles()
2056 OnViewDetectMovedOrCopiedLines(BLAME_DETECT_MOVED_OR_COPIED_LINES_FROM_MODIFIED_FILES
);
2059 void CTortoiseGitBlameView::OnUpdateViewDetectMovedOrCopiedLinesToggleFromModifiedFiles(CCmdUI
*pCmdUI
)
2061 pCmdUI
->SetRadio(m_dwDetectMovedOrCopiedLines
== BLAME_DETECT_MOVED_OR_COPIED_LINES_FROM_MODIFIED_FILES
);
2064 void CTortoiseGitBlameView::OnViewDetectMovedOrCopiedLinesToggleFromExistingFilesAtFileCreation()
2066 OnViewDetectMovedOrCopiedLines(BLAME_DETECT_MOVED_OR_COPIED_LINES_FROM_EXISTING_FILES_AT_FILE_CREATION
);
2069 void CTortoiseGitBlameView::OnUpdateViewDetectMovedOrCopiedLinesToggleFromExistingFilesAtFileCreation(CCmdUI
*pCmdUI
)
2071 pCmdUI
->SetRadio(m_dwDetectMovedOrCopiedLines
== BLAME_DETECT_MOVED_OR_COPIED_LINES_FROM_EXISTING_FILES_AT_FILE_CREATION
);
2074 void CTortoiseGitBlameView::OnViewDetectMovedOrCopiedLinesToggleFromExistingFiles()
2076 OnViewDetectMovedOrCopiedLines(BLAME_DETECT_MOVED_OR_COPIED_LINES_FROM_EXISTING_FILES
);
2079 void CTortoiseGitBlameView::OnUpdateViewDetectMovedOrCopiedLinesToggleFromExistingFiles(CCmdUI
*pCmdUI
)
2081 pCmdUI
->SetRadio(m_dwDetectMovedOrCopiedLines
== BLAME_DETECT_MOVED_OR_COPIED_LINES_FROM_EXISTING_FILES
);
2084 void CTortoiseGitBlameView::ReloadDocument()
2086 theApp
.DoWaitCursor(1);
2087 CTortoiseGitBlameDoc
*document
= (CTortoiseGitBlameDoc
*) m_pDocument
;
2088 if (!document
->m_CurrentFileName
.IsEmpty())
2090 document
->m_lLine
= (int)SendEditor(SCI_GETFIRSTVISIBLELINE
) + 1;
2091 theApp
.m_pDocManager
->OnFileNew();
2092 document
->OnOpenDocument(document
->m_CurrentFileName
, document
->m_Rev
);
2094 theApp
.DoWaitCursor(-1);
2097 void CTortoiseGitBlameView::OnViewToggleIgnoreWhitespace()
2099 m_bIgnoreWhitespace
= ! m_bIgnoreWhitespace
;
2101 theApp
.WriteInt(_T("IgnoreWhitespace"), m_bIgnoreWhitespace
? 1 : 0);
2106 void CTortoiseGitBlameView::OnUpdateViewToggleIgnoreWhitespace(CCmdUI
*pCmdUI
)
2108 pCmdUI
->SetCheck(m_bIgnoreWhitespace
);
2111 void CTortoiseGitBlameView::OnViewToggleShowCompleteLog()
2113 m_bShowCompleteLog
= ! m_bShowCompleteLog
;
2115 theApp
.WriteInt(_T("ShowCompleteLog"), m_bShowCompleteLog
? 1 : 0);
2120 void CTortoiseGitBlameView::OnUpdateViewToggleShowCompleteLog(CCmdUI
*pCmdUI
)
2122 pCmdUI
->Enable(BlameIsLimitedToOneFilename(m_dwDetectMovedOrCopiedLines
));
2123 pCmdUI
->SetCheck(m_bShowCompleteLog
&& BlameIsLimitedToOneFilename(m_dwDetectMovedOrCopiedLines
));
2126 void CTortoiseGitBlameView::OnViewToggleFollowRenames()
2128 m_bFollowRenames
= ! m_bFollowRenames
;
2130 theApp
.WriteInt(_T("FollowRenames"), m_bFollowRenames
? 1 : 0);
2135 void CTortoiseGitBlameView::OnUpdateViewToggleFollowRenames(CCmdUI
*pCmdUI
)
2137 pCmdUI
->Enable(m_bShowCompleteLog
&& BlameIsLimitedToOneFilename(m_dwDetectMovedOrCopiedLines
));
2138 pCmdUI
->SetCheck(m_bFollowRenames
&& m_bShowCompleteLog
&& BlameIsLimitedToOneFilename(m_dwDetectMovedOrCopiedLines
));
2141 void CTortoiseGitBlameView::OnViewToggleColorByAge()
2143 m_colorage
= ! m_colorage
;
2145 theApp
.WriteInt(_T("ColorAge"), m_colorage
);
2147 m_TextView
.Invalidate();
2150 void CTortoiseGitBlameView::OnUpdateViewToggleColorByAge(CCmdUI
*pCmdUI
)
2152 pCmdUI
->SetCheck(m_colorage
);
2155 void CTortoiseGitBlameView::OnViewToggleLexer()
2157 m_bLexer
= !m_bLexer
;
2159 theApp
.WriteInt(_T("EnableLexer"), m_bLexer
);
2162 SetupLexer(GetDocument()->m_CurrentFileName
);
2166 void CTortoiseGitBlameView::OnUpdateViewToggleLexer(CCmdUI
*pCmdUI
)
2168 pCmdUI
->SetCheck(m_bLexer
);
2171 void CTortoiseGitBlameView::OnUpdateViewCopyToClipboard(CCmdUI
*pCmdUI
)
2173 CWnd
* wnd
= GetFocus();
2174 if (wnd
== GetLogList())
2176 pCmdUI
->Enable(GetLogList()->GetSelectedCount() > 0);
2180 if (CString(wnd
->GetRuntimeClass()->m_lpszClassName
) == _T("CMFCPropertyGridCtrl"))
2182 CMFCPropertyGridCtrl
*grid
= (CMFCPropertyGridCtrl
*)wnd
;
2183 pCmdUI
->Enable(grid
->GetCurSel() && !grid
->GetCurSel()->IsGroup() && !CString(grid
->GetCurSel()->GetValue()).IsEmpty());
2186 pCmdUI
->Enable(m_TextView
.Call(SCI_GETSELECTIONSTART
) != m_TextView
.Call(SCI_GETSELECTIONEND
));
2189 pCmdUI
->Enable(FALSE
);