1 // TortoiseGitBlame - a Viewer for Git Blames
3 // Copyright (C) 2008-2014 - 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_VIEW_SHOWAUTHOR
, OnViewToggleAuthor
)
68 ON_UPDATE_COMMAND_UI(ID_VIEW_SHOWAUTHOR
, OnUpdateViewToggleAuthor
)
69 ON_COMMAND(ID_VIEW_SHOWDATE
, OnViewToggleDate
)
70 ON_UPDATE_COMMAND_UI(ID_VIEW_SHOWDATE
, OnUpdateViewToggleDate
)
71 ON_COMMAND(ID_VIEW_SHOWFILENAME
, OnViewToggleShowFilename
)
72 ON_UPDATE_COMMAND_UI(ID_VIEW_SHOWFILENAME
, OnUpdateViewToggleShowFilename
)
73 ON_COMMAND(ID_VIEW_SHOWORIGINALLINENUMBER
, OnViewToggleShowOriginalLineNumber
)
74 ON_UPDATE_COMMAND_UI(ID_VIEW_SHOWORIGINALLINENUMBER
, OnUpdateViewToggleShowOriginalLineNumber
)
75 ON_COMMAND(ID_VIEW_DETECT_MOVED_OR_COPIED_LINES_DISABLED
, OnViewDetectMovedOrCopiedLinesToggleDisabled
)
76 ON_UPDATE_COMMAND_UI(ID_VIEW_DETECT_MOVED_OR_COPIED_LINES_DISABLED
, OnUpdateViewDetectMovedOrCopiedLinesToggleDisabled
)
77 ON_COMMAND(ID_VIEW_DETECT_MOVED_OR_COPIED_LINES_WITHIN_FILE
, OnViewDetectMovedOrCopiedLinesToggleWithinFile
)
78 ON_UPDATE_COMMAND_UI(ID_VIEW_DETECT_MOVED_OR_COPIED_LINES_WITHIN_FILE
, OnUpdateViewDetectMovedOrCopiedLinesToggleWithinFile
)
79 ON_COMMAND(ID_VIEW_DETECT_MOVED_OR_COPIED_LINES_FROM_MODIFIED_FILES
, OnViewDetectMovedOrCopiedLinesToggleFromModifiedFiles
)
80 ON_UPDATE_COMMAND_UI(ID_VIEW_DETECT_MOVED_OR_COPIED_LINES_FROM_MODIFIED_FILES
, OnUpdateViewDetectMovedOrCopiedLinesToggleFromModifiedFiles
)
81 ON_COMMAND(ID_VIEW_DETECT_MOVED_OR_COPIED_LINES_FROM_EXISTING_FILES_AT_FILE_CREATION
, OnViewDetectMovedOrCopiedLinesToggleFromExistingFilesAtFileCreation
)
82 ON_UPDATE_COMMAND_UI(ID_VIEW_DETECT_MOVED_OR_COPIED_LINES_FROM_EXISTING_FILES_AT_FILE_CREATION
, OnUpdateViewDetectMovedOrCopiedLinesToggleFromExistingFilesAtFileCreation
)
83 ON_COMMAND(ID_VIEW_DETECT_MOVED_OR_COPIED_LINES_FROM_EXISTING_FILES
, OnViewDetectMovedOrCopiedLinesToggleFromExistingFiles
)
84 ON_UPDATE_COMMAND_UI(ID_VIEW_DETECT_MOVED_OR_COPIED_LINES_FROM_EXISTING_FILES
, OnUpdateViewDetectMovedOrCopiedLinesToggleFromExistingFiles
)
85 ON_COMMAND(ID_VIEW_IGNORE_WHITESPACE
, OnViewToggleIgnoreWhitespace
)
86 ON_UPDATE_COMMAND_UI(ID_VIEW_IGNORE_WHITESPACE
, OnUpdateViewToggleIgnoreWhitespace
)
87 ON_COMMAND(ID_VIEW_SHOWCOMPLETELOG
, OnViewToggleShowCompleteLog
)
88 ON_UPDATE_COMMAND_UI(ID_VIEW_SHOWCOMPLETELOG
, OnUpdateViewToggleShowCompleteLog
)
89 ON_COMMAND(ID_VIEW_FOLLOWRENAMES
, OnViewToggleFollowRenames
)
90 ON_UPDATE_COMMAND_UI(ID_VIEW_FOLLOWRENAMES
, OnUpdateViewToggleFollowRenames
)
91 ON_COMMAND(ID_VIEW_COLORBYAGE
, OnViewToggleColorByAge
)
92 ON_UPDATE_COMMAND_UI(ID_VIEW_COLORBYAGE
, OnUpdateViewToggleColorByAge
)
93 ON_COMMAND_RANGE(IDM_FORMAT_ENCODE
, IDM_FORMAT_ENCODE_END
, OnChangeEncode
)
102 ON_NOTIFY(SCN_PAINTED
, IDC_SCINTILLA
, OnSciPainted
)
103 ON_NOTIFY(SCN_GETBKCOLOR
, IDC_SCINTILLA
, OnSciGetBkColor
)
104 ON_REGISTERED_MESSAGE(m_FindDialogMessage
, OnFindDialogMessage
)
108 // CTortoiseGitBlameView construction/destruction
110 CTortoiseGitBlameView::CTortoiseGitBlameView()
115 , bIgnoreSpaces(false)
116 , bIgnoreAllSpaces(false)
133 m_originalLineNumberWidth
= 0;
136 m_windowcolor
= ::GetSysColor(COLOR_WINDOW
);
137 m_textcolor
= ::GetSysColor(COLOR_WINDOWTEXT
);
138 m_texthighlightcolor
= ::GetSysColor(COLOR_HIGHLIGHTTEXT
);
139 m_mouserevcolor
= InterColor(m_windowcolor
, m_textcolor
, 20);
140 m_mouseauthorcolor
= InterColor(m_windowcolor
, m_textcolor
, 10);
141 m_selectedrevcolor
= ::GetSysColor(COLOR_HIGHLIGHT
);
142 m_selectedauthorcolor
= InterColor(m_selectedrevcolor
, m_texthighlightcolor
, 35);
146 m_directFunction
= 0;
148 m_colorage
= !!theApp
.GetInt(_T("ColorAge"));
152 m_bShowAuthor
= (theApp
.GetInt(_T("ShowAuthor"), 1) == 1);
153 m_bShowDate
= (theApp
.GetInt(_T("ShowDate"), 0) == 1);
154 m_bShowFilename
= (theApp
.GetInt(_T("ShowFilename"), 0) == 1);
155 m_bShowOriginalLineNumber
= (theApp
.GetInt(_T("ShowOriginalLineNumber"), 0) == 1);
156 m_dwDetectMovedOrCopiedLines
= theApp
.GetInt(_T("DetectMovedOrCopiedLines"), 0);
157 m_bIgnoreWhitespace
= (theApp
.GetInt(_T("IgnoreWhitespace"), 0) == 1);
158 m_bShowCompleteLog
= (theApp
.GetInt(_T("ShowCompleteLog"), 1) == 1);
159 m_bFollowRenames
= (theApp
.GetInt(_T("FollowRenames"), 0) == 1);
160 m_bBlameOuputContainsOtherFilenames
= FALSE
;
162 m_FindDialogMessage
= ::RegisterWindowMessage(FINDMSGSTRING
);
163 m_pFindDialog
= NULL
;
164 // get short/long datetime setting from registry
165 DWORD RegUseShortDateFormat
= CRegDWORD(_T("Software\\TortoiseGit\\LogDateFormat"), TRUE
);
166 if ( RegUseShortDateFormat
)
168 m_DateFormat
= DATE_SHORTDATE
;
172 m_DateFormat
= DATE_LONGDATE
;
174 // get relative time display setting from registry
175 DWORD regRelativeTimes
= CRegDWORD(_T("Software\\TortoiseGit\\RelativeTimes"), FALSE
);
176 m_bRelativeTimes
= (regRelativeTimes
!= 0);
178 m_sRev
.LoadString(IDS_LOG_REVISION
);
179 m_sFileName
.LoadString(IDS_FILENAME
);
180 m_sAuthor
.LoadString(IDS_LOG_AUTHOR
);
181 m_sDate
.LoadString(IDS_LOG_DATE
);
182 m_sMessage
.LoadString(IDS_LOG_MESSAGE
);
184 #ifdef USE_TEMPFILENAME
189 CTortoiseGitBlameView::~CTortoiseGitBlameView()
192 DeleteObject(m_font
);
194 DeleteObject(m_italicfont
);
196 #ifdef USE_TEMPFILENAME
210 static EncodingUnit encodings
[] = {
211 {1250, "windows-1250"}, //IDM_FORMAT_WIN_1250
212 {1251, "windows-1251"}, //IDM_FORMAT_WIN_1251
213 {1252, "windows-1252"}, //IDM_FORMAT_WIN_1252
214 {1253, "windows-1253"}, //IDM_FORMAT_WIN_1253
215 {1254, "windows-1254"}, //IDM_FORMAT_WIN_1254
216 {1255, "windows-1255"}, //IDM_FORMAT_WIN_1255
217 {1256, "windows-1256"}, //IDM_FORMAT_WIN_1256
218 {1257, "windows-1257"}, //IDM_FORMAT_WIN_1257
219 {1258, "windows-1258"}, //IDM_FORMAT_WIN_1258
220 {28591, "latin1 ISO_8859-1 ISO-8859-1 CP819 IBM819 csISOLatin1 iso-ir-100 l1"}, //IDM_FORMAT_ISO_8859_1
221 {28592, "latin2 ISO_8859-2 ISO-8859-2 csISOLatin2 iso-ir-101 l2"}, //IDM_FORMAT_ISO_8859_2
222 {28593, "latin3 ISO_8859-3 ISO-8859-3 csISOLatin3 iso-ir-109 l3"}, //IDM_FORMAT_ISO_8859_3
223 {28594, "latin4 ISO_8859-4 ISO-8859-4 csISOLatin4 iso-ir-110 l4"}, //IDM_FORMAT_ISO_8859_4
224 {28595, "cyrillic ISO_8859-5 ISO-8859-5 csISOLatinCyrillic iso-ir-144"}, //IDM_FORMAT_ISO_8859_5
225 {28596, "arabic ISO_8859-6 ISO-8859-6 csISOLatinArabic iso-ir-127 ASMO-708 ECMA-114"}, //IDM_FORMAT_ISO_8859_6
226 {28597, "greek ISO_8859-7 ISO-8859-7 csISOLatinGreek greek8 iso-ir-126 ELOT_928 ECMA-118"}, //IDM_FORMAT_ISO_8859_7
227 {28598, "hebrew ISO_8859-8 ISO-8859-8 csISOLatinHebrew iso-ir-138"}, //IDM_FORMAT_ISO_8859_8
228 {28599, "latin5 ISO_8859-9 ISO-8859-9 csISOLatin5 iso-ir-148 l5"}, //IDM_FORMAT_ISO_8859_9
229 {28600, "latin6 ISO_8859-10 ISO-8859-10 csISOLatin6 iso-ir-157 l6"}, //IDM_FORMAT_ISO_8859_10
230 {28601, "ISO_8859-11 ISO-8859-11"}, //IDM_FORMAT_ISO_8859_11
231 {28603, "ISO_8859-13 ISO-8859-13"}, //IDM_FORMAT_ISO_8859_13
232 {28604, "iso-celtic latin8 ISO_8859-14 ISO-8859-14 18 iso-ir-199"}, //IDM_FORMAT_ISO_8859_14
233 {28605, "Latin-9 ISO_8859-15 ISO-8859-15"}, //IDM_FORMAT_ISO_8859_15
234 {28606, "latin10 ISO_8859-16 ISO-8859-16 110 iso-ir-226"}, //IDM_FORMAT_ISO_8859_16
235 {437, "IBM437 cp437 437 csPC8CodePage437"}, //IDM_FORMAT_DOS_437
236 {720, "IBM720 cp720 oem720 720"}, //IDM_FORMAT_DOS_720
237 {737, "IBM737 cp737 oem737 737"}, //IDM_FORMAT_DOS_737
238 {775, "IBM775 cp775 oem775 775"}, //IDM_FORMAT_DOS_775
239 {850, "IBM850 cp850 oem850 850"}, //IDM_FORMAT_DOS_850
240 {852, "IBM852 cp852 oem852 852"}, //IDM_FORMAT_DOS_852
241 {855, "IBM855 cp855 oem855 855 csIBM855"}, //IDM_FORMAT_DOS_855
242 {857, "IBM857 cp857 oem857 857"}, //IDM_FORMAT_DOS_857
243 {858, "IBM858 cp858 oem858 858"}, //IDM_FORMAT_DOS_858
244 {860, "IBM860 cp860 oem860 860"}, //IDM_FORMAT_DOS_860
245 {861, "IBM861 cp861 oem861 861"}, //IDM_FORMAT_DOS_861
246 {862, "IBM862 cp862 oem862 862"}, //IDM_FORMAT_DOS_862
247 {863, "IBM863 cp863 oem863 863"}, //IDM_FORMAT_DOS_863
248 {865, "IBM865 cp865 oem865 865"}, //IDM_FORMAT_DOS_865
249 {866, "IBM866 cp866 oem866 866"}, //IDM_FORMAT_DOS_866
250 {869, "IBM869 cp869 oem869 869"}, //IDM_FORMAT_DOS_869
251 {950, "big5 csBig5"}, //IDM_FORMAT_BIG5
252 {936, "gb2312 gbk csGB2312"}, //IDM_FORMAT_GB2312
253 {932, "Shift_JIS MS_Kanji csShiftJIS csWindows31J"}, //IDM_FORMAT_SHIFT_JIS
254 {949, "windows-949 korean"}, //IDM_FORMAT_KOREAN_WIN
255 {51949, "euc-kr csEUCKR"}, //IDM_FORMAT_EUC_KR
256 {874, "tis-620"}, //IDM_FORMAT_TIS_620
257 {10007, "x-mac-cyrillic xmaccyrillic"}, //IDM_FORMAT_MAC_CYRILLIC
258 {21866, "koi8_u"}, //IDM_FORMAT_KOI8U_CYRILLIC
259 {20866, "koi8_r csKOI8R"}, //IDM_FORMAT_KOI8R_CYRILLIC
260 {65001, "UTF-8"}, //IDM_FORMAT_UTF8
261 {1200, "UTF-16 LE"}, //IDM_FORMAT_UTF16LE
262 {1201, "UTF-16 BE"}, //IDM_FORMAT_UTF16BE
264 void CTortoiseGitBlameView::OnChangeEncode(UINT nId
)
266 if(nId
>= IDM_FORMAT_ENCODE
&& nId
<= IDM_FORMAT_ENCODE_END
)
267 this->UpdateInfo(encodings
[nId
- IDM_FORMAT_ENCODE
].id
);
269 int CTortoiseGitBlameView::OnCreate(LPCREATESTRUCT lpcs
)
273 this->GetWindowRect(&rect1
);
274 rect
.left
=m_blamewidth
+LOCATOR_WIDTH
;
275 rect
.right
=rect
.Width();
277 rect
.bottom
=rect
.Height();
278 if (!m_TextView
.Create(_T("Scintilla"), _T("source"), 0, rect
, this, IDC_SCINTILLA
, 0))
280 TRACE0("Failed to create view\n");
281 return -1; // fail to create
283 m_TextView
.Init(0,FALSE
);
284 m_TextView
.ShowWindow( SW_SHOW
);
285 m_wEditor
= m_TextView
.m_hWnd
;
288 m_ToolTip
.Create(this->GetParent());
290 ::AfxGetApp()->GetMainWnd();
291 return CView::OnCreate(lpcs
);
295 void CTortoiseGitBlameView::OnSize(UINT
/*nType*/, int cx
, int cy
)
299 rect
.left
=m_blamewidth
;
304 m_TextView
.MoveWindow(&rect
);
307 BOOL
CTortoiseGitBlameView::PreCreateWindow(CREATESTRUCT
& cs
)
309 return CView::PreCreateWindow(cs
);
312 // CTortoiseGitBlameView drawing
314 void CTortoiseGitBlameView::OnDraw(CDC
* /*pDC*/)
316 CTortoiseGitBlameDoc
* pDoc
= GetDocument();
321 DrawBlame(this->GetDC()->m_hDC
);
322 DrawLocatorBar(this->GetDC()->m_hDC
);
323 // TODO: add draw code for native data here
327 // CTortoiseGitBlameView printing
330 void CTortoiseGitBlameView::OnFilePrintPreview()
332 AFXPrintPreview(this);
335 BOOL
CTortoiseGitBlameView::OnPreparePrinting(CPrintInfo
* pInfo
)
337 // default preparation
338 return DoPreparePrinting(pInfo
);
341 void CTortoiseGitBlameView::OnBeginPrinting(CDC
* /*pDC*/, CPrintInfo
* /*pInfo*/)
343 // TODO: add extra initialization before printing
346 void CTortoiseGitBlameView::OnEndPrinting(CDC
* /*pDC*/, CPrintInfo
* /*pInfo*/)
348 // TODO: add cleanup after printing
351 void CTortoiseGitBlameView::OnRButtonUp(UINT
/*nFlags*/, CPoint point
)
353 int line
= (int)SendEditor(SCI_GETFIRSTVISIBLELINE
);
354 int height
= (int)SendEditor(SCI_TEXTHEIGHT
);
355 line
= line
+ (int)(point
.y
/ height
);
356 if (m_data
.IsValidLine(line
))
359 ClientToScreen(&point
);
361 CGitHash hash
= m_data
.GetHash(line
);
362 CString hashStr
= hash
.ToString();
364 GitRev
* pRev
= nullptr;
365 int logIndex
= m_lineToLogIndex
[line
];
367 pRev
= &GetLogData()->GetGitRevAt(logIndex
);
370 pRev
= m_data
.GetRev(line
, GetLogData()->m_pLogCache
->m_HashMap
);
371 if (pRev
->m_ParentHash
.empty())
375 pRev
->GetParentFromHash(pRev
->m_CommitHash
);
377 catch (const char* msg
)
379 MessageBox(_T("Could not get parent.\nlibgit reports:\n") + CString(msg
), _T("TortoiseGit"), MB_ICONERROR
);
388 CIconMenu blamemenu
, diffmenu
;
390 if (!popup
.CreatePopupMenu())
393 // Now find the relevant parent commits, they must contain the file which is blamed to be the source of the selected line,
394 // otherwise there is no previous file to compare to (only another previous revision).
396 GIT_REV_LIST parentHashWithFile
;
397 std::vector
<CString
> parentFilename
;
400 CTGitPath
path(m_data
.GetFilename(line
));
401 const CTGitPathList
& files
= pRev
->GetFiles(NULL
);
402 for (int j
= 0, j_size
= files
.GetCount(); j
< j_size
; ++j
)
404 const CTGitPath
&file
= files
[j
];
405 if (file
.IsEquivalentTo(path
))
407 if (!(file
.m_ParentNo
& MERGE_MASK
))
409 int action
= file
.m_Action
;
410 // ignore (action & CTGitPath::LOGACTIONS_ADDED), as then there is nothing to blame/diff
411 // ignore (action & CTGitPath::LOGACTIONS_DELETED), should never happen as the file must exist
412 if (action
& (CTGitPath::LOGACTIONS_MODIFIED
| CTGitPath::LOGACTIONS_REPLACED
))
414 int parentNo
= file
.m_ParentNo
& PARENT_MASK
;
415 if (parentNo
>= 0 && (size_t)parentNo
< pRev
->m_ParentHash
.size())
417 parentHashWithFile
.push_back(pRev
->m_ParentHash
[parentNo
]);
418 parentFilename
.push_back((action
& CTGitPath::LOGACTIONS_REPLACED
) ? file
.GetGitOldPathString() : file
.GetGitPathString());
425 catch (const char* msg
)
427 MessageBox(_T("Could not get files of parents.\nlibgit reports:\n") + CString(msg
), _T("TortoiseGit"), MB_ICONERROR
);
431 if (!parentHashWithFile
.empty())
433 if (parentHashWithFile
.size() == 1)
435 popup
.AppendMenuIcon(ID_BLAMEPREVIOUS
, IDS_BLAME_POPUP_BLAME
, IDI_BLAME_POPUP_BLAME
);
439 blamemenu
.CreatePopupMenu();
440 popup
.AppendMenuIcon(ID_BLAMEPREVIOUS
, IDS_BLAME_POPUP_BLAME
, IDI_BLAME_POPUP_BLAME
, blamemenu
.m_hMenu
);
442 for (size_t i
= 0; i
< parentHashWithFile
.size(); ++i
)
445 str
.Format(IDS_PARENT
, i
+ 1);
446 blamemenu
.AppendMenuIcon(ID_BLAMEPREVIOUS
+ ((i
+ 1) << 16), str
);
451 // compare with previous
452 if (!parentHashWithFile
.empty())
454 if (parentHashWithFile
.size() == 1)
456 popup
.AppendMenuIcon(ID_COMPAREWITHPREVIOUS
, IDS_BLAME_POPUP_COMPARE
, IDI_BLAME_POPUP_COMPARE
);
457 if (CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE
))
458 popup
.SetDefaultItem(ID_COMPAREWITHPREVIOUS
, FALSE
);
462 diffmenu
.CreatePopupMenu();
463 popup
.AppendMenuIcon(ID_COMPAREWITHPREVIOUS
, IDS_BLAME_POPUP_COMPARE
, IDI_BLAME_POPUP_COMPARE
, diffmenu
.m_hMenu
);
464 for (size_t i
= 0; i
< parentHashWithFile
.size(); ++i
)
467 str
.Format(IDS_BLAME_POPUP_PARENT
, i
+ 1);
468 diffmenu
.AppendMenuIcon((UINT
)(ID_COMPAREWITHPREVIOUS
+ ((i
+ 1) << 16)),str
);
469 if (i
== 0 && CRegDWORD(_T("Software\\TortoiseGit\\DiffByDoubleClickInLog"), FALSE
))
471 popup
.SetDefaultItem(ID_COMPAREWITHPREVIOUS
, FALSE
);
472 diffmenu
.SetDefaultItem((UINT
)(ID_COMPAREWITHPREVIOUS
+ ((i
+ 1) << 16)), FALSE
);
478 popup
.AppendMenuIcon(ID_SHOWLOG
, IDS_BLAME_POPUP_LOG
, IDI_BLAME_POPUP_LOG
);
479 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
480 popup
.AppendMenuIcon(ID_COPYHASHTOCLIPBOARD
, IDS_BLAME_POPUP_COPYHASHTOCLIPBOARD
, IDI_BLAME_POPUP_COPY
);
481 popup
.AppendMenuIcon(ID_COPYLOGTOCLIPBOARD
, IDS_BLAME_POPUP_COPYLOGTOCLIPBOARD
, IDI_BLAME_POPUP_COPY
);
483 int cmd
= popup
.TrackPopupMenu(TPM_RETURNCMD
| TPM_LEFTALIGN
| TPM_NONOTIFY
, point
.x
, point
.y
, this, 0);
484 this->ContextMenuAction(cmd
, pRev
, parentHashWithFile
, parentFilename
);
488 void CTortoiseGitBlameView::ContextMenuAction(int cmd
, GitRev
*pRev
, GIT_REV_LIST
& parentHashWithFile
, const std::vector
<CString
>& parentFilename
)
490 switch (cmd
& 0xFFFF)
492 case ID_BLAMEPREVIOUS
:
494 int index
= (cmd
>>16) & 0xFFFF;
498 CString path
= ResolveCommitFile(parentFilename
[index
]);
499 CString endrev
= parentHashWithFile
[index
].ToString();
500 int line
= m_data
.GetOriginalLineNumber(m_MouseLine
);
502 lineNumber
.Format(_T("%d"), line
);
504 CString procCmd
= _T("/path:\"") + path
+ _T("\" ");
505 procCmd
+= _T(" /command:blame");
506 procCmd
+= _T(" /endrev:") + endrev
;
507 procCmd
+= _T(" /line:") + lineNumber
;
509 CCommonAppUtils::RunTortoiseGitProc(procCmd
);
513 case ID_COMPAREWITHPREVIOUS
:
515 int index
= (cmd
>> 16) & 0xFFFF;
519 CString path
= ResolveCommitFile(parentFilename
[index
]);
520 CString startrev
= pRev
->m_CommitHash
.ToString();
521 CString endrev
= parentHashWithFile
[index
].ToString();
523 CString procCmd
= _T("/path:\"") + path
+ _T("\" ");
524 procCmd
+= _T(" /command:diff");
525 procCmd
+= _T(" /startrev:") + startrev
;
526 procCmd
+= _T(" /endrev:") + endrev
;
528 CCommonAppUtils::RunTortoiseGitProc(procCmd
);
534 CString path
= ResolveCommitFile(m_MouseLine
);
535 CString rev
= m_data
.GetHash(m_MouseLine
).ToString();
537 CString procCmd
= _T("/path:\"") + path
+ _T("\" ");
538 procCmd
+= _T(" /command:log");
539 procCmd
+= _T(" /rev:") + 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 if (m_directFunction
)
623 return ((SciFnDirect
) m_directFunction
)(m_directPointer
, Msg
, wParam
, lParam
);
625 return ::SendMessage(m_wEditor
, Msg
, wParam
, lParam
);
628 void CTortoiseGitBlameView::SetAStyle(int style
, COLORREF fore
, COLORREF back
, int size
, const char *face
)
630 SendEditor(SCI_STYLESETFORE
, style
, fore
);
631 SendEditor(SCI_STYLESETBACK
, style
, back
);
633 SendEditor(SCI_STYLESETSIZE
, style
, size
);
635 SendEditor(SCI_STYLESETFONT
, style
, reinterpret_cast<LPARAM
>(face
));
638 void CTortoiseGitBlameView::InitialiseEditor()
641 m_directFunction
= ::SendMessage(m_wEditor
, SCI_GETDIRECTFUNCTION
, 0, 0);
642 m_directPointer
= ::SendMessage(m_wEditor
, SCI_GETDIRECTPOINTER
, 0, 0);
643 // Set up the global default style. These attributes are used wherever no explicit choices are made.
644 std::string fontName
= CUnicodeUtils::StdGetUTF8((stdstring
)CRegStdString(_T("Software\\TortoiseGit\\BlameFontName"), _T("Courier New")));
645 SetAStyle(STYLE_DEFAULT
,
648 (DWORD
)CRegStdDWORD(_T("Software\\TortoiseGit\\BlameFontSize"), 10),
651 SendEditor(SCI_SETTABWIDTH
, (DWORD
)CRegStdDWORD(_T("Software\\TortoiseGit\\BlameTabSize"), 4));
652 SendEditor(SCI_SETREADONLY
, TRUE
);
653 LRESULT pix
= SendEditor(SCI_TEXTWIDTH
, STYLE_LINENUMBER
, (LPARAM
)this->m_TextView
.StringForControl(_T("_99999")).GetBuffer());
655 SendEditor(SCI_SETMARGINWIDTHN
, 0, pix
);
657 SendEditor(SCI_SETMARGINWIDTHN
, 0);
658 SendEditor(SCI_SETMARGINWIDTHN
, 1);
659 SendEditor(SCI_SETMARGINWIDTHN
, 2);
660 //Set the default windows colors for edit controls
661 SendEditor(SCI_STYLESETFORE
, STYLE_DEFAULT
, ::GetSysColor(COLOR_WINDOWTEXT
));
662 SendEditor(SCI_STYLESETBACK
, STYLE_DEFAULT
, ::GetSysColor(COLOR_WINDOW
));
663 SendEditor(SCI_SETSELFORE
, TRUE
, ::GetSysColor(COLOR_HIGHLIGHTTEXT
));
664 SendEditor(SCI_SETSELBACK
, TRUE
, ::GetSysColor(COLOR_HIGHLIGHT
));
665 SendEditor(SCI_SETCARETFORE
, ::GetSysColor(COLOR_WINDOWTEXT
));
666 m_regOldLinesColor
= CRegStdDWORD(_T("Software\\TortoiseGit\\BlameOldColor"), BLAMEOLDCOLOR
);
667 m_regNewLinesColor
= CRegStdDWORD(_T("Software\\TortoiseGit\\BlameNewColor"), BLAMENEWCOLOR
);
668 CRegStdDWORD
used2d(L
"Software\\TortoiseGit\\ScintillaDirect2D", FALSE
);
669 if (SysInfo::Instance().IsWin7OrLater() && DWORD(used2d
))
671 SendEditor(SCI_SETTECHNOLOGY
, SC_TECHNOLOGY_DIRECTWRITERETAIN
);
672 SendEditor(SCI_SETBUFFEREDDRAW
, 0);
675 this->m_TextView
.Call(SCI_SETWRAPMODE
, SC_WRAP_NONE
);
679 bool CTortoiseGitBlameView::DoSearch(CString what
, DWORD flags
)
681 int pos
= (int)SendEditor(SCI_GETCURRENTPOS
);
682 int line
= (int)SendEditor(SCI_LINEFROMPOSITION
, pos
);
683 bool bCaseSensitive
= !!(flags
& FR_MATCHCASE
);
684 theApp
.WriteInt(_T("FindMatchCase"), bCaseSensitive
? 1 : 0);
685 theApp
.WriteString(_T("FindString"), what
);
687 int i
= m_data
.FindFirstLineWrapAround(what
, line
, bCaseSensitive
);
691 int selstart
= (int)SendEditor(SCI_GETCURRENTPOS
);
692 int selend
= (int)SendEditor(SCI_POSITIONFROMLINE
, i
+ 1);
693 SendEditor(SCI_SETSELECTIONSTART
, selstart
);
694 SendEditor(SCI_SETSELECTIONEND
, selend
);
699 ::MessageBox(m_pFindDialog
&& m_pFindDialog
->GetSafeHwnd() ? m_pFindDialog
->GetSafeHwnd() : wMain
, _T("\"") + what
+ _T("\" ") + CString(MAKEINTRESOURCE(IDS_NOTFOUND
)), _T("TortoiseGitBlame"), MB_ICONINFORMATION
);
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('.'));
1084 //_tcscpy_s(line, 20, lineptr+1);
1085 //_tcslwr_s(line, 20);
1086 CString ext
=filename
.Right(filename
.GetLength()-start
-1);
1087 TCHAR
* line
= ext
.GetBuffer();
1089 if ((_tcscmp(line
, _T("py"))==0)||
1090 (_tcscmp(line
, _T("pyw"))==0))
1092 SendEditor(SCI_SETLEXER
, SCLEX_PYTHON
);
1093 SendEditor(SCI_SETKEYWORDS
, 0, (LPARAM
)(m_TextView
.StringForControl(_T("and assert break class continue def del elif \
1094 else except exec finally for from global if import in is lambda None \
1095 not or pass print raise return try while yield")).GetBuffer()));
1096 SetAStyle(SCE_P_DEFAULT
, black
);
1097 SetAStyle(SCE_P_COMMENTLINE
, darkGreen
);
1098 SetAStyle(SCE_P_NUMBER
, RGB(0, 0x80, 0x80));
1099 SetAStyle(SCE_P_STRING
, RGB(0, 0, 0x80));
1100 SetAStyle(SCE_P_CHARACTER
, RGB(0, 0, 0x80));
1101 SetAStyle(SCE_P_WORD
, RGB(0x80, 0, 0x80));
1102 SetAStyle(SCE_P_TRIPLE
, black
);
1103 SetAStyle(SCE_P_TRIPLEDOUBLE
, black
);
1104 SetAStyle(SCE_P_CLASSNAME
, darkBlue
);
1105 SetAStyle(SCE_P_DEFNAME
, darkBlue
);
1106 SetAStyle(SCE_P_OPERATOR
, darkBlue
);
1107 SetAStyle(SCE_P_IDENTIFIER
, darkBlue
);
1108 SetAStyle(SCE_P_COMMENTBLOCK
, darkGreen
);
1109 SetAStyle(SCE_P_STRINGEOL
, red
);
1111 if ((_tcscmp(line
, _T("c"))==0)||
1112 (_tcscmp(line
, _T("cc"))==0)||
1113 (_tcscmp(line
, _T("cpp"))==0)||
1114 (_tcscmp(line
, _T("cxx"))==0)||
1115 (_tcscmp(line
, _T("h"))==0)||
1116 (_tcscmp(line
, _T("hh"))==0)||
1117 (_tcscmp(line
, _T("hpp"))==0)||
1118 (_tcscmp(line
, _T("hxx"))==0)||
1119 (_tcscmp(line
, _T("dlg"))==0)||
1120 (_tcscmp(line
, _T("mak"))==0))
1122 SendEditor(SCI_SETLEXER
, SCLEX_CPP
);
1123 SendEditor(SCI_SETKEYWORDS
, 0, (LPARAM
)(m_TextView
.StringForControl(_T("and and_eq asm auto bitand bitor bool break \
1124 case catch char class compl const const_cast continue \
1125 default delete do double dynamic_cast else enum explicit export extern false float for \
1126 friend goto if inline int long mutable namespace new not not_eq \
1127 operator or or_eq private protected public \
1128 register reinterpret_cast return short signed sizeof static static_cast struct switch \
1129 template this throw true try typedef typeid typename union unsigned using \
1130 virtual void volatile wchar_t while xor xor_eq")).GetBuffer()));
1131 SendEditor(SCI_SETKEYWORDS
, 3, (LPARAM
)(m_TextView
.StringForControl(_T("a addindex addtogroup anchor arg attention \
1132 author b brief bug c class code date def defgroup deprecated dontinclude \
1133 e em endcode endhtmlonly endif endlatexonly endlink endverbatim enum example exception \
1134 f$ f[ f] file fn hideinitializer htmlinclude htmlonly \
1135 if image include ingroup internal invariant interface latexonly li line link \
1136 mainpage name namespace nosubgrouping note overload \
1137 p page par param post pre ref relates remarks return retval \
1138 sa section see showinitializer since skip skipline struct subsection \
1139 test throw todo typedef union until \
1140 var verbatim verbinclude version warning weakgroup $ @ \\ & < > # { }")).GetBuffer()));
1143 if (_tcscmp(line
, _T("cs"))==0)
1145 SendEditor(SCI_SETLEXER
, SCLEX_CPP
);
1146 SendEditor(SCI_SETKEYWORDS
, 0, (LPARAM
)(m_TextView
.StringForControl(_T("abstract as base bool break byte case catch char checked class \
1147 const continue decimal default delegate do double else enum \
1148 event explicit extern false finally fixed float for foreach goto if \
1149 implicit in int interface internal is lock long namespace new null \
1150 object operator out override params private protected public \
1151 readonly ref return sbyte sealed short sizeof stackalloc static \
1152 string struct switch this throw true try typeof uint ulong \
1153 unchecked unsafe ushort using virtual void while")).GetBuffer()));
1156 if ((_tcscmp(line
, _T("rc"))==0)||
1157 (_tcscmp(line
, _T("rc2"))==0))
1159 SendEditor(SCI_SETLEXER
, SCLEX_CPP
);
1160 SendEditor(SCI_SETKEYWORDS
, 0, (LPARAM
)(m_TextView
.StringForControl(_T("ACCELERATORS ALT AUTO3STATE AUTOCHECKBOX AUTORADIOBUTTON \
1161 BEGIN BITMAP BLOCK BUTTON CAPTION CHARACTERISTICS CHECKBOX CLASS \
1162 COMBOBOX CONTROL CTEXT CURSOR DEFPUSHBUTTON DIALOG DIALOGEX DISCARDABLE \
1163 EDITTEXT END EXSTYLE FONT GROUPBOX ICON LANGUAGE LISTBOX LTEXT \
1164 MENU MENUEX MENUITEM MESSAGETABLE POPUP \
1165 PUSHBUTTON RADIOBUTTON RCDATA RTEXT SCROLLBAR SEPARATOR SHIFT STATE3 \
1166 STRINGTABLE STYLE TEXTINCLUDE VALUE VERSION VERSIONINFO VIRTKEY")).GetBuffer()));
1169 if ((_tcscmp(line
, _T("idl"))==0)||
1170 (_tcscmp(line
, _T("odl"))==0))
1172 SendEditor(SCI_SETLEXER
, SCLEX_CPP
);
1173 SendEditor(SCI_SETKEYWORDS
, 0, (LPARAM
)(m_TextView
.StringForControl(_T("aggregatable allocate appobject arrays async async_uuid \
1175 bindable boolean broadcast byte byte_count \
1176 call_as callback char coclass code comm_status \
1177 const context_handle context_handle_noserialize \
1178 context_handle_serialize control cpp_quote custom \
1179 decode default defaultbind defaultcollelem \
1180 defaultvalue defaultvtable dispinterface displaybind dllname \
1182 enable_allocate encode endpoint entry enum error_status_t \
1184 fault_status first_is float \
1185 handle_t heap helpcontext helpfile helpstring \
1186 helpstringcontext helpstringdll hidden hyper \
1187 id idempotent ignore iid_as iid_is immediatebind implicit_handle \
1188 import importlib in include in_line int __int64 __int3264 interface \
1189 last_is lcid length_is library licensed local long \
1190 max_is maybe message methods midl_pragma \
1191 midl_user_allocate midl_user_free min_is module ms_union \
1192 ncacn_at_dsp ncacn_dnet_nsp ncacn_http ncacn_ip_tcp \
1193 ncacn_nb_ipx ncacn_nb_nb ncacn_nb_tcp ncacn_np \
1194 ncacn_spx ncacn_vns_spp ncadg_ip_udp ncadg_ipx ncadg_mq \
1195 ncalrpc nocode nonbrowsable noncreatable nonextensible notify \
1196 object odl oleautomation optimize optional out out_of_line \
1197 pipe pointer_default pragma properties propget propput propputref \
1199 range readonly ref represent_as requestedit restricted retval \
1200 shape short signed size_is small source strict_context_handle \
1201 string struct switch switch_is switch_type \
1202 transmit_as typedef \
1203 uidefault union unique unsigned user_marshal usesgetlasterror uuid \
1204 v1_enum vararg version void wchar_t wire_marshal")).GetBuffer()));
1207 if (_tcscmp(line
, _T("java"))==0)
1209 SendEditor(SCI_SETLEXER
, SCLEX_CPP
);
1210 SendEditor(SCI_SETKEYWORDS
, 0, (LPARAM
)(m_TextView
.StringForControl(_T("abstract assert boolean break byte case catch char class \
1211 const continue default do double else extends final finally float for future \
1212 generic goto if implements import inner instanceof int interface long \
1213 native new null outer package private protected public rest \
1214 return short static super switch synchronized this throw throws \
1215 transient try var void volatile while")).GetBuffer()));
1218 if (_tcscmp(line
, _T("js"))==0)
1220 SendEditor(SCI_SETLEXER
, SCLEX_CPP
);
1221 SendEditor(SCI_SETKEYWORDS
, 0, (LPARAM
)(m_TextView
.StringForControl(_T("abstract boolean break byte case catch char class \
1222 const continue debugger default delete do double else enum export extends \
1223 final finally float for function goto if implements import in instanceof \
1224 int interface long native new package private protected public \
1225 return short static super switch synchronized this throw throws \
1226 transient try typeof var void volatile while with")).GetBuffer()));
1229 if ((_tcscmp(line
, _T("pas"))==0)||
1230 (_tcscmp(line
, _T("dpr"))==0)||
1231 (_tcscmp(line
, _T("pp"))==0))
1233 SendEditor(SCI_SETLEXER
, SCLEX_PASCAL
);
1234 SendEditor(SCI_SETKEYWORDS
, 0, (LPARAM
)(m_TextView
.StringForControl(_T("and array as begin case class const constructor \
1235 destructor div do downto else end except file finally \
1236 for function goto if implementation in inherited \
1237 interface is mod not object of on or packed \
1238 procedure program property raise record repeat \
1239 set shl shr then threadvar to try type unit \
1240 until uses var while with xor")).GetBuffer()));
1243 if ((_tcscmp(line
, _T("as"))==0)||
1244 (_tcscmp(line
, _T("asc"))==0)||
1245 (_tcscmp(line
, _T("jsfl"))==0))
1247 SendEditor(SCI_SETLEXER
, SCLEX_CPP
);
1248 SendEditor(SCI_SETKEYWORDS
, 0, (LPARAM
)(m_TextView
.StringForControl(_T("add and break case catch class continue default delete do \
1249 dynamic else eq extends false finally for function ge get gt if implements import in \
1250 instanceof interface intrinsic le lt ne new not null or private public return \
1251 set static super switch this throw true try typeof undefined var void while with")).GetBuffer()));
1252 SendEditor(SCI_SETKEYWORDS
, 1, (LPARAM
)(m_TextView
.StringForControl(_T("Array Arguments Accessibility Boolean Button Camera Color \
1253 ContextMenu ContextMenuItem Date Error Function Key LoadVars LocalConnection Math \
1254 Microphone Mouse MovieClip MovieClipLoader NetConnection NetStream Number Object \
1255 PrintJob Selection SharedObject Sound Stage String StyleSheet System TextField \
1256 TextFormat TextSnapshot Video Void XML XMLNode XMLSocket \
1257 _accProps _focusrect _global _highquality _parent _quality _root _soundbuftime \
1258 arguments asfunction call capabilities chr clearInterval duplicateMovieClip \
1259 escape eval fscommand getProperty getTimer getURL getVersion gotoAndPlay gotoAndStop \
1260 ifFrameLoaded Infinity -Infinity int isFinite isNaN length loadMovie loadMovieNum \
1261 loadVariables loadVariablesNum maxscroll mbchr mblength mbord mbsubstring MMExecute \
1262 NaN newline nextFrame nextScene on onClipEvent onUpdate ord parseFloat parseInt play \
1263 prevFrame prevScene print printAsBitmap printAsBitmapNum printNum random removeMovieClip \
1264 scroll set setInterval setProperty startDrag stop stopAllSounds stopDrag substring \
1265 targetPath tellTarget toggleHighQuality trace unescape unloadMovie unLoadMovieNum updateAfterEvent")).GetBuffer()));
1268 if ((_tcscmp(line
, _T("html"))==0)||
1269 (_tcscmp(line
, _T("htm"))==0)||
1270 (_tcscmp(line
, _T("shtml"))==0)||
1271 (_tcscmp(line
, _T("htt"))==0)||
1272 (_tcscmp(line
, _T("xml"))==0)||
1273 (_tcscmp(line
, _T("asp"))==0)||
1274 (_tcscmp(line
, _T("xsl"))==0)||
1275 (_tcscmp(line
, _T("php"))==0)||
1276 (_tcscmp(line
, _T("xhtml"))==0)||
1277 (_tcscmp(line
, _T("phtml"))==0)||
1278 (_tcscmp(line
, _T("cfm"))==0)||
1279 (_tcscmp(line
, _T("tpl"))==0)||
1280 (_tcscmp(line
, _T("dtd"))==0)||
1281 (_tcscmp(line
, _T("hta"))==0)||
1282 (_tcscmp(line
, _T("htd"))==0)||
1283 (_tcscmp(line
, _T("wxs"))==0))
1285 SendEditor(SCI_SETLEXER
, SCLEX_HTML
);
1286 SendEditor(SCI_SETSTYLEBITS
, 7);
1287 SendEditor(SCI_SETKEYWORDS
, 0, (LPARAM
)(m_TextView
.StringForControl(_T("a abbr acronym address applet area b base basefont \
1288 bdo big blockquote body br button caption center \
1289 cite code col colgroup dd del dfn dir div dl dt em \
1290 fieldset font form frame frameset h1 h2 h3 h4 h5 h6 \
1291 head hr html i iframe img input ins isindex kbd label \
1292 legend li link map menu meta noframes noscript \
1293 object ol optgroup option p param pre q s samp \
1294 script select small span strike strong style sub sup \
1295 table tbody td textarea tfoot th thead title tr tt u ul \
1296 var xml xmlns abbr accept-charset accept accesskey action align alink \
1297 alt archive axis background bgcolor border \
1298 cellpadding cellspacing char charoff charset checked cite \
1299 class classid clear codebase codetype color cols colspan \
1300 compact content coords \
1301 data datafld dataformatas datapagesize datasrc datetime \
1302 declare defer dir disabled enctype event \
1303 face for frame frameborder \
1304 headers height href hreflang hspace http-equiv \
1305 id ismap label lang language leftmargin link longdesc \
1306 marginwidth marginheight maxlength media method multiple \
1307 name nohref noresize noshade nowrap \
1308 object onblur onchange onclick ondblclick onfocus \
1309 onkeydown onkeypress onkeyup onload onmousedown \
1310 onmousemove onmouseover onmouseout onmouseup \
1311 onreset onselect onsubmit onunload \
1312 profile prompt readonly rel rev rows rowspan rules \
1313 scheme scope selected shape size span src standby start style \
1314 summary tabindex target text title topmargin type usemap \
1315 valign value valuetype version vlink vspace width \
1316 text password checkbox radio submit reset \
1317 file hidden image")).GetBuffer()));
1318 SendEditor(SCI_SETKEYWORDS
, 1, (LPARAM
)(m_TextView
.StringForControl(_T("assign audio block break catch choice clear disconnect else elseif \
1319 emphasis enumerate error exit field filled form goto grammar help \
1320 if initial link log menu meta noinput nomatch object option p paragraph \
1321 param phoneme prompt property prosody record reprompt return s say-as \
1322 script sentence subdialog submit throw transfer value var voice vxml")).GetBuffer()));
1323 SendEditor(SCI_SETKEYWORDS
, 2, (LPARAM
)(m_TextView
.StringForControl(_T("accept age alphabet anchor application base beep bridge category charset \
1324 classid cond connecttimeout content contour count dest destexpr dtmf dtmfterm \
1325 duration enctype event eventexpr expr expritem fetchtimeout finalsilence \
1326 gender http-equiv id level maxage maxstale maxtime message messageexpr \
1327 method mime modal mode name namelist next nextitem ph pitch range rate \
1328 scope size sizeexpr skiplist slot src srcexpr sub time timeexpr timeout \
1329 transferaudio type value variant version volume xml:lang")).GetBuffer()));
1330 SendEditor(SCI_SETKEYWORDS
, 3, (LPARAM
)(m_TextView
.StringForControl(_T("and assert break class continue def del elif \
1331 else except exec finally for from global if import in is lambda None \
1332 not or pass print raise return try while yield")).GetBuffer()));
1333 SendEditor(SCI_SETKEYWORDS
, 4, (LPARAM
)(m_TextView
.StringForControl(_T("and argv as argc break case cfunction class continue declare default do \
1334 die echo else elseif empty enddeclare endfor endforeach endif endswitch \
1335 endwhile e_all e_parse e_error e_warning eval exit extends false for \
1336 foreach function global http_cookie_vars http_get_vars http_post_vars \
1337 http_post_files http_env_vars http_server_vars if include include_once \
1338 list new not null old_function or parent php_os php_self php_version \
1339 print require require_once return static switch stdclass this true var \
1340 xor virtual while __file__ __line__ __sleep __wakeup")).GetBuffer()));
1342 SetAStyle(SCE_H_TAG
, darkBlue
);
1343 SetAStyle(SCE_H_TAGUNKNOWN
, red
);
1344 SetAStyle(SCE_H_ATTRIBUTE
, darkBlue
);
1345 SetAStyle(SCE_H_ATTRIBUTEUNKNOWN
, red
);
1346 SetAStyle(SCE_H_NUMBER
, RGB(0x80,0,0x80));
1347 SetAStyle(SCE_H_DOUBLESTRING
, RGB(0,0x80,0));
1348 SetAStyle(SCE_H_SINGLESTRING
, RGB(0,0x80,0));
1349 SetAStyle(SCE_H_OTHER
, RGB(0x80,0,0x80));
1350 SetAStyle(SCE_H_COMMENT
, RGB(0x80,0x80,0));
1351 SetAStyle(SCE_H_ENTITY
, RGB(0x80,0,0x80));
1353 SetAStyle(SCE_H_TAGEND
, darkBlue
);
1354 SetAStyle(SCE_H_XMLSTART
, darkBlue
); // <?
1355 SetAStyle(SCE_H_QUESTION
, darkBlue
); // <?
1356 SetAStyle(SCE_H_XMLEND
, darkBlue
); // ?>
1357 SetAStyle(SCE_H_SCRIPT
, darkBlue
); // <script
1358 SetAStyle(SCE_H_ASP
, RGB(0x4F, 0x4F, 0), RGB(0xFF, 0xFF, 0)); // <% ... %>
1359 SetAStyle(SCE_H_ASPAT
, RGB(0x4F, 0x4F, 0), RGB(0xFF, 0xFF, 0)); // <%@ ... %>
1361 SetAStyle(SCE_HB_DEFAULT
, black
);
1362 SetAStyle(SCE_HB_COMMENTLINE
, darkGreen
);
1363 SetAStyle(SCE_HB_NUMBER
, RGB(0,0x80,0x80));
1364 SetAStyle(SCE_HB_WORD
, darkBlue
);
1365 SendEditor(SCI_STYLESETBOLD
, SCE_HB_WORD
, 1);
1366 SetAStyle(SCE_HB_STRING
, RGB(0x80,0,0x80));
1367 SetAStyle(SCE_HB_IDENTIFIER
, black
);
1369 // This light blue is found in the windows system palette so is safe to use even in 256 colour modes.
1370 // Show the whole section of VBScript with light blue background
1371 for (int bstyle
= SCE_HB_DEFAULT
; bstyle
<= SCE_HB_STRINGEOL
; ++bstyle
) {
1372 SendEditor(SCI_STYLESETFONT
, bstyle
,
1373 reinterpret_cast<LPARAM
>(m_TextView
.StringForControl(_T("Lucida Console")).GetBuffer()));
1374 SendEditor(SCI_STYLESETBACK
, bstyle
, lightBlue
);
1375 // This call extends the backround colour of the last style on the line to the edge of the window
1376 SendEditor(SCI_STYLESETEOLFILLED
, bstyle
, 1);
1378 SendEditor(SCI_STYLESETBACK
, SCE_HB_STRINGEOL
, RGB(0x7F,0x7F,0xFF));
1379 SendEditor(SCI_STYLESETFONT
, SCE_HB_COMMENTLINE
,
1380 reinterpret_cast<LPARAM
>(m_TextView
.StringForControl(_T("Lucida Console")).GetBuffer()));
1382 SetAStyle(SCE_HBA_DEFAULT
, black
);
1383 SetAStyle(SCE_HBA_COMMENTLINE
, darkGreen
);
1384 SetAStyle(SCE_HBA_NUMBER
, RGB(0,0x80,0x80));
1385 SetAStyle(SCE_HBA_WORD
, darkBlue
);
1386 SendEditor(SCI_STYLESETBOLD
, SCE_HBA_WORD
, 1);
1387 SetAStyle(SCE_HBA_STRING
, RGB(0x80,0,0x80));
1388 SetAStyle(SCE_HBA_IDENTIFIER
, black
);
1390 // Show the whole section of ASP VBScript with bright yellow background
1391 for (int bastyle
= SCE_HBA_DEFAULT
; bastyle
<= SCE_HBA_STRINGEOL
; ++bastyle
) {
1392 SendEditor(SCI_STYLESETFONT
, bastyle
,
1393 reinterpret_cast<LPARAM
>(m_TextView
.StringForControl(_T("Lucida Console")).GetBuffer()));
1394 SendEditor(SCI_STYLESETBACK
, bastyle
, RGB(0xFF, 0xFF, 0));
1395 // This call extends the backround colour of the last style on the line to the edge of the window
1396 SendEditor(SCI_STYLESETEOLFILLED
, bastyle
, 1);
1398 SendEditor(SCI_STYLESETBACK
, SCE_HBA_STRINGEOL
, RGB(0xCF,0xCF,0x7F));
1399 SendEditor(SCI_STYLESETFONT
, SCE_HBA_COMMENTLINE
,
1400 reinterpret_cast<LPARAM
>(m_TextView
.StringForControl(_T("Lucida Console")).GetBuffer()));
1402 // If there is no need to support embedded Javascript, the following code can be dropped.
1403 // Javascript will still be correctly processed but will be displayed in just the default style.
1405 SetAStyle(SCE_HJ_START
, RGB(0x80,0x80,0));
1406 SetAStyle(SCE_HJ_DEFAULT
, black
);
1407 SetAStyle(SCE_HJ_COMMENT
, darkGreen
);
1408 SetAStyle(SCE_HJ_COMMENTLINE
, darkGreen
);
1409 SetAStyle(SCE_HJ_COMMENTDOC
, darkGreen
);
1410 SetAStyle(SCE_HJ_NUMBER
, RGB(0,0x80,0x80));
1411 SetAStyle(SCE_HJ_WORD
, black
);
1412 SetAStyle(SCE_HJ_KEYWORD
, darkBlue
);
1413 SetAStyle(SCE_HJ_DOUBLESTRING
, RGB(0x80,0,0x80));
1414 SetAStyle(SCE_HJ_SINGLESTRING
, RGB(0x80,0,0x80));
1415 SetAStyle(SCE_HJ_SYMBOLS
, black
);
1417 SetAStyle(SCE_HJA_START
, RGB(0x80,0x80,0));
1418 SetAStyle(SCE_HJA_DEFAULT
, black
);
1419 SetAStyle(SCE_HJA_COMMENT
, darkGreen
);
1420 SetAStyle(SCE_HJA_COMMENTLINE
, darkGreen
);
1421 SetAStyle(SCE_HJA_COMMENTDOC
, darkGreen
);
1422 SetAStyle(SCE_HJA_NUMBER
, RGB(0,0x80,0x80));
1423 SetAStyle(SCE_HJA_WORD
, black
);
1424 SetAStyle(SCE_HJA_KEYWORD
, darkBlue
);
1425 SetAStyle(SCE_HJA_DOUBLESTRING
, RGB(0x80,0,0x80));
1426 SetAStyle(SCE_HJA_SINGLESTRING
, RGB(0x80,0,0x80));
1427 SetAStyle(SCE_HJA_SYMBOLS
, black
);
1429 SetAStyle(SCE_HPHP_DEFAULT
, black
);
1430 SetAStyle(SCE_HPHP_HSTRING
, RGB(0x80,0,0x80));
1431 SetAStyle(SCE_HPHP_SIMPLESTRING
, RGB(0x80,0,0x80));
1432 SetAStyle(SCE_HPHP_WORD
, darkBlue
);
1433 SetAStyle(SCE_HPHP_NUMBER
, RGB(0,0x80,0x80));
1434 SetAStyle(SCE_HPHP_VARIABLE
, red
);
1435 SetAStyle(SCE_HPHP_HSTRING_VARIABLE
, red
);
1436 SetAStyle(SCE_HPHP_COMPLEX_VARIABLE
, red
);
1437 SetAStyle(SCE_HPHP_COMMENT
, darkGreen
);
1438 SetAStyle(SCE_HPHP_COMMENTLINE
, darkGreen
);
1439 SetAStyle(SCE_HPHP_OPERATOR
, darkBlue
);
1441 // Show the whole section of Javascript with off white background
1442 for (int jstyle
= SCE_HJ_DEFAULT
; jstyle
<= SCE_HJ_SYMBOLS
; ++jstyle
) {
1443 SendEditor(SCI_STYLESETFONT
, jstyle
,
1444 reinterpret_cast<LPARAM
>(m_TextView
.StringForControl(_T("Lucida Console")).GetBuffer()));
1445 SendEditor(SCI_STYLESETBACK
, jstyle
, offWhite
);
1446 SendEditor(SCI_STYLESETEOLFILLED
, jstyle
, 1);
1448 SendEditor(SCI_STYLESETBACK
, SCE_HJ_STRINGEOL
, RGB(0xDF, 0xDF, 0x7F));
1449 SendEditor(SCI_STYLESETEOLFILLED
, SCE_HJ_STRINGEOL
, 1);
1451 // Show the whole section of Javascript with brown background
1452 for (int jastyle
= SCE_HJA_DEFAULT
; jastyle
<= SCE_HJA_SYMBOLS
; ++jastyle
) {
1453 SendEditor(SCI_STYLESETFONT
, jastyle
,
1454 reinterpret_cast<LPARAM
>(m_TextView
.StringForControl(_T("Lucida Console")).GetBuffer()));
1455 SendEditor(SCI_STYLESETBACK
, jastyle
, RGB(0xDF, 0xDF, 0x7F));
1456 SendEditor(SCI_STYLESETEOLFILLED
, jastyle
, 1);
1458 SendEditor(SCI_STYLESETBACK
, SCE_HJA_STRINGEOL
, RGB(0x0,0xAF,0x5F));
1459 SendEditor(SCI_STYLESETEOLFILLED
, SCE_HJA_STRINGEOL
, 1);
1464 SendEditor(SCI_SETLEXER
, SCLEX_CPP
);
1467 SendEditor(SCI_COLOURISE
, 0, -1);
1471 void CTortoiseGitBlameView::SetupCppLexer()
1473 SetAStyle(SCE_C_DEFAULT
, RGB(0, 0, 0));
1474 SetAStyle(SCE_C_COMMENT
, RGB(0, 0x80, 0));
1475 SetAStyle(SCE_C_COMMENTLINE
, RGB(0, 0x80, 0));
1476 SetAStyle(SCE_C_COMMENTDOC
, RGB(0, 0x80, 0));
1477 SetAStyle(SCE_C_COMMENTLINEDOC
, RGB(0, 0x80, 0));
1478 SetAStyle(SCE_C_COMMENTDOCKEYWORD
, RGB(0, 0x80, 0));
1479 SetAStyle(SCE_C_COMMENTDOCKEYWORDERROR
, RGB(0, 0x80, 0));
1480 SetAStyle(SCE_C_NUMBER
, RGB(0, 0x80, 0x80));
1481 SetAStyle(SCE_C_WORD
, RGB(0, 0, 0x80));
1482 SendEditor(SCE_C_WORD
, 1);
1483 SetAStyle(SCE_C_STRING
, RGB(0x80, 0, 0x80));
1484 SetAStyle(SCE_C_IDENTIFIER
, RGB(0, 0, 0));
1485 SetAStyle(SCE_C_PREPROCESSOR
, RGB(0x80, 0, 0));
1486 SetAStyle(SCE_C_OPERATOR
, RGB(0x80, 0x80, 0));
1487 SendEditor(SCI_SETPROPERTY
, (WPARAM
)"lexer.cpp.track.preprocessor", (LPARAM
)"0");
1490 int CTortoiseGitBlameView::GetEncode(unsigned char *buff
, int size
, int *bomoffset
)
1492 CFileTextLines textlines
;
1493 CFileTextLines::UnicodeType type
= textlines
.CheckUnicodeType(buff
, size
);
1495 if(type
== CFileTextLines::UTF8BOM
)
1500 if(type
== CFileTextLines::UTF8
)
1503 if(type
== CFileTextLines::UTF16_LE
)
1505 if (type
== CFileTextLines::UTF16_LEBOM
)
1511 if(type
== CFileTextLines::UTF16_BE
)
1513 if (type
== CFileTextLines::UTF16_BEBOM
)
1522 void CTortoiseGitBlameView::ParseBlame()
1524 m_data
.ParseBlameOutput(GetDocument()->m_BlameData
, GetLogData()->m_pLogCache
->m_HashMap
, m_DateFormat
, m_bRelativeTimes
);
1525 CString filename
= GetDocument()->m_GitPath
.GetGitPathString();
1526 m_bBlameOuputContainsOtherFilenames
= m_data
.ContainsOnlyFilename(filename
) ? FALSE
: TRUE
;
1529 void CTortoiseGitBlameView::MapLineToLogIndex()
1531 std::vector
<int> lineToLogIndex
;
1534 int numberOfLines
= m_data
.GetNumberOfLines();
1535 lineToLogIndex
.reserve(numberOfLines
);
1536 size_t logSize
= this->GetLogData()->size();
1537 for (int j
= 0; j
< numberOfLines
; ++j
)
1539 CGitHash
& hash
= m_data
.GetHash(j
);
1542 for (size_t i
= 0; i
< logSize
; ++i
)
1544 if (hash
== this->GetLogData()->at(i
))
1550 lineToLogIndex
.push_back(index
);
1552 this->m_lineToLogIndex
.swap(lineToLogIndex
);
1555 void CTortoiseGitBlameView::UpdateInfo(int Encode
)
1559 SendEditor(SCI_SETREADONLY
, FALSE
);
1560 SendEditor(SCI_CLEARALL
);
1561 SendEditor(EM_EMPTYUNDOBUFFER
);
1562 SendEditor(SCI_SETSAVEPOINT
);
1563 SendEditor(SCI_CANCEL
);
1564 SendEditor(SCI_SETUNDOCOLLECTION
, 0);
1566 SendEditor(SCI_SETCODEPAGE
, SC_CP_UTF8
);
1568 int encoding
= m_data
.UpdateEncoding(Encode
);
1570 int numberOfLines
= m_data
.GetNumberOfLines();
1571 if (numberOfLines
> 0)
1573 for (int i
= 0; i
< numberOfLines
- 1; ++i
)
1575 SendEditor(SCI_REPLACESEL
, 0, (LPARAM
)(LPCSTR
)m_data
.GetUtf8Line(i
));
1576 SendEditor(SCI_REPLACESEL
, 0, (LPARAM
)(LPCSTR
)"\n\0\0\0");
1579 // as it will add another line number in scintilla which has no counter part in the blame output
1580 // prevent carriage return and line feed for the last line
1581 CStringA s
= m_data
.GetUtf8Line(numberOfLines
- 1);
1582 int length
= s
.GetLength();
1583 if (length
> 0 && s
.GetAt(length
- 1) == '\r')
1584 s
.Truncate(length
- 1);
1585 SendEditor(SCI_REPLACESEL
, 0, (LPARAM
)(LPCSTR
)s
);
1593 int nIndex
= ((CMainFrame
*)::AfxGetApp()->GetMainWnd())->m_wndStatusBar
.CommandToIndex(ID_INDICATOR_ENCODING
);
1594 ((CMainFrame
*)::AfxGetApp()->GetMainWnd())->m_wndStatusBar
.GetPaneInfo(nIndex
, nID
, nStyle
, cxWidth
);
1595 CString sBarText
= L
"";
1596 for (int i
= 0; i
< _countof(encodings
); ++i
)
1598 if (encodings
[i
].id
== encoding
)
1600 sBarText
= CString(encodings
[i
].name
);
1604 //calculate the width of the text
1605 CDC
* pDC
= ((CMainFrame
*)::AfxGetApp()->GetMainWnd())->m_wndStatusBar
.GetDC();
1608 CSize size
= pDC
->GetTextExtent(sBarText
);
1609 ((CMainFrame
*)::AfxGetApp()->GetMainWnd())->m_wndStatusBar
.SetPaneInfo(nIndex
, nID
, nStyle
, size
.cx
+2);
1612 ((CMainFrame
*)::AfxGetApp()->GetMainWnd())->m_wndStatusBar
.SetPaneText(nIndex
, sBarText
);
1615 #ifdef USE_TEMPFILENAME
1623 file
.Open(this->GetDocument()->m_TempFileName
,CFile::modeRead
);
1625 m_Buffer
= new char[file
.GetLength()+4];
1626 m_Buffer
[file
.GetLength()] =0;
1627 m_Buffer
[file
.GetLength()+1] =0;
1628 m_Buffer
[file
.GetLength()+2] =0;
1629 m_Buffer
[file
.GetLength()+3] =0;
1631 file
.Read(m_Buffer
, file
.GetLength());
1634 int encoding
= GetEncode( (unsigned char *)m_Buffer
, file
.GetLength(), &bomoffset
);
1637 //SendEditor(SCI_SETCODEPAGE, encoding);
1639 //SendEditor(SCI_REPLACESEL, 0, (LPARAM)(LPCSTR)(m_Buffer + bomoffset));
1641 SetupLexer(GetDocument()->m_CurrentFileName
);
1643 SendEditor(SCI_SETUNDOCOLLECTION
, 1);
1644 SendEditor(EM_EMPTYUNDOBUFFER
);
1645 SendEditor(SCI_SETSAVEPOINT
);
1646 SendEditor(SCI_GOTOPOS
, 0);
1647 SendEditor(SCI_SETSCROLLWIDTHTRACKING
, TRUE
);
1648 SendEditor(SCI_SETREADONLY
, TRUE
);
1652 this->GetClientRect(rect
);
1653 //this->m_TextView.GetWindowRect(rect);
1654 //this->m_TextView.ScreenToClient(rect);
1655 rect
.left
=this->m_blamewidth
;
1656 this->m_TextView
.MoveWindow(rect
);
1661 CString
CTortoiseGitBlameView::ResolveCommitFile(int line
)
1663 return ResolveCommitFile(m_data
.GetFilename(line
));
1666 CString
CTortoiseGitBlameView::ResolveCommitFile(const CString
& path
)
1670 return ((CMainFrame
*)::AfxGetApp()->GetMainWnd())->GetActiveView()->GetDocument()->GetPathName();
1674 return g_Git
.CombinePath(path
);
1678 COLORREF
CTortoiseGitBlameView::GetLineColor(int line
)
1680 if (m_colorage
&& m_data
.IsValidLine(line
))
1682 int logIndex
= m_lineToLogIndex
[line
];
1685 int slider
= (int)((GetLogData()->size() - logIndex
) * 100 / (GetLogData()->size() + 1));
1686 return InterColor(DWORD(m_regOldLinesColor
), DWORD(m_regNewLinesColor
), slider
);
1689 return m_windowcolor
;
1692 CGitBlameLogList
* CTortoiseGitBlameView::GetLogList()
1694 return &(GetDocument()->GetMainFrame()->m_wndOutput
.m_LogList
);
1698 CLogDataVector
* CTortoiseGitBlameView::GetLogData()
1700 return &(GetDocument()->GetMainFrame()->m_wndOutput
.m_LogList
.m_logEntries
);
1703 void CTortoiseGitBlameView::OnSciPainted(NMHDR
*,LRESULT
*)
1708 void CTortoiseGitBlameView::OnLButtonDown(UINT nFlags
,CPoint point
)
1711 int line
= (int)SendEditor(SCI_GETFIRSTVISIBLELINE
);
1712 int height
= (int)SendEditor(SCI_TEXTHEIGHT
);
1713 line
= line
+ (int)(point
.y
/height
);
1715 if (line
< m_data
.GetNumberOfLines())
1717 SetSelectedLine(line
);
1718 if (m_data
.GetHash(line
) != m_SelectedHash
)
1720 m_SelectedHash
= m_data
.GetHash(line
);
1722 int logIndex
= m_lineToLogIndex
[line
];
1725 this->GetLogList()->SetItemState(logIndex
, LVIS_SELECTED
, LVIS_SELECTED
);
1726 this->GetLogList()->EnsureVisible(logIndex
, FALSE
);
1730 GitRev
*pRev
= m_data
.GetRev(line
, GetLogData()->m_pLogCache
->m_HashMap
);
1731 this->GetDocument()->GetMainFrame()->m_wndProperties
.UpdateProperties(pRev
);
1736 m_SelectedHash
.Empty();
1738 //::InvalidateRect( NULL, FALSE);
1740 this->m_TextView
.Invalidate();
1745 SetSelectedLine(-1);
1748 CView::OnLButtonDown(nFlags
,point
);
1751 void CTortoiseGitBlameView::OnSciGetBkColor(NMHDR
* hdr
, LRESULT
* /*result*/)
1753 SCNotification
*notification
=reinterpret_cast<SCNotification
*>(hdr
);
1755 if (notification
->line
< m_data
.GetNumberOfLines())
1757 if (m_data
.GetHash(notification
->line
) == this->m_SelectedHash
)
1758 notification
->lParam
= m_selectedauthorcolor
;
1760 notification
->lParam
= GetLineColor(notification
->line
);
1764 void CTortoiseGitBlameView::FocusOn(GitRev
*pRev
)
1766 this->GetDocument()->GetMainFrame()->m_wndProperties
.UpdateProperties(pRev
);
1770 if (m_SelectedHash
!= pRev
->m_CommitHash
) {
1771 m_SelectedHash
= pRev
->m_CommitHash
;
1772 int line
= m_data
.FindFirstLine(m_SelectedHash
, 0);
1776 m_TextView
.Invalidate();
1779 SendEditor(SCI_SETSEL
, INT_MAX
, -1);
1783 void CTortoiseGitBlameView::OnMouseHover(UINT
/*nFlags*/, CPoint point
)
1785 int line
= (int)SendEditor(SCI_GETFIRSTVISIBLELINE
);
1786 int height
= (int)SendEditor(SCI_TEXTHEIGHT
);
1787 line
= line
+ (point
.y
/height
);
1789 if (m_data
.IsValidLine(line
))
1791 if (line
!= m_MouseLine
)
1794 GitRev
*pRev
= nullptr;
1795 int logIndex
= m_lineToLogIndex
[line
];
1797 pRev
= &GetLogData()->GetGitRevAt(logIndex
);
1799 pRev
= m_data
.GetRev(line
, GetLogData()->m_pLogCache
->m_HashMap
);
1804 CString body
= pRev
->GetBody();
1808 while (iline
++ < maxLine
)
1810 int pos2
= body
.Find(_T("\n"), pos
);
1813 int lineLength
= pos2
- pos
- 1;
1815 iline
+= lineLength
/ 70;
1819 if ((m_bShowCompleteLog
&& m_bFollowRenames
) || !BlameIsLimitedToOneFilename(m_dwDetectMovedOrCopiedLines
) || m_bBlameOuputContainsOtherFilenames
)
1820 filename
.Format(_T("%s: %s\n"), m_sFileName
, m_data
.GetFilename(line
));
1823 str
.Format(_T("%s: %s\n%s%s: %s <%s>\n%s: %s\n%s:\n%s\n%s"), m_sRev
, pRev
->m_CommitHash
.ToString(), filename
,
1824 m_sAuthor
, pRev
->GetAuthorName(), pRev
->GetAuthorEmail(),
1825 m_sDate
, CLoglistUtils::FormatDateAndTime(pRev
->GetAuthorDate(), m_DateFormat
, true, m_bRelativeTimes
),
1826 m_sMessage
, pRev
->GetSubject(),
1827 iline
<= maxLine
? body
: (body
.Left(pos
) + _T("\n....................")));
1830 m_ToolTip
.AddTool(this, str
);
1833 rect
.left
=LOCATOR_WIDTH
;
1834 rect
.right
=this->m_blamewidth
+rect
.left
;
1835 rect
.top
= point
.y
- (LONG
)height
;
1836 rect
.bottom
= point
.y
+ (LONG
)height
;
1837 this->InvalidateRect(rect
);
1842 void CTortoiseGitBlameView::OnMouseMove(UINT
/*nFlags*/, CPoint
/*point*/)
1844 TRACKMOUSEEVENT tme
;
1845 tme
.cbSize
=sizeof(TRACKMOUSEEVENT
);
1846 tme
.dwFlags
=TME_HOVER
|TME_LEAVE
;
1847 tme
.hwndTrack
=this->m_hWnd
;
1849 TrackMouseEvent(&tme
);
1853 BOOL
CTortoiseGitBlameView::PreTranslateMessage(MSG
* pMsg
)
1855 m_ToolTip
.RelayEvent(pMsg
);
1856 return CView::PreTranslateMessage(pMsg
);
1859 void CTortoiseGitBlameView::OnEditFind()
1864 m_pFindDialog
=new CFindReplaceDialog();
1866 CString oneline
= theApp
.GetString(_T("FindString"));
1867 if (m_TextView
.Call(SCI_GETSELECTIONSTART
) != m_TextView
.Call(SCI_GETSELECTIONEND
))
1869 LRESULT bufsize
= m_TextView
.Call(SCI_GETSELECTIONEND
) - m_TextView
.Call(SCI_GETSELECTIONSTART
);
1870 std::unique_ptr
<char> linebuf(new char[bufsize
+ 1]);
1871 SecureZeroMemory(linebuf
.get(), bufsize
+ 1);
1872 SendEditor(SCI_GETSELTEXT
, 0, (LPARAM
)linebuf
.get());
1873 oneline
= m_TextView
.StringFromControl(linebuf
.get());
1876 DWORD flags
= FR_DOWN
| FR_HIDEWHOLEWORD
| FR_HIDEUPDOWN
;
1877 if (theApp
.GetInt(_T("FindMatchCase")))
1878 flags
|= FR_MATCHCASE
;
1880 m_pFindDialog
->Create(TRUE
, oneline
, NULL
, flags
, this);
1883 void CTortoiseGitBlameView::OnEditGoto()
1886 if(dlg
.DoModal()==IDOK
)
1888 this->GotoLine(dlg
.m_LineNumber
);
1892 LRESULT
CTortoiseGitBlameView::OnFindDialogMessage(WPARAM
/*wParam*/, LPARAM
/*lParam*/)
1894 ASSERT(m_pFindDialog
!= NULL
);
1896 // If the FR_DIALOGTERM flag is set,
1897 // invalidate the handle identifying the dialog box.
1898 if (m_pFindDialog
->IsTerminating())
1900 m_pFindDialog
= NULL
;
1904 if (m_data
.GetNumberOfLines()==0)
1907 // If the FR_FINDNEXT flag is set,
1908 // call the application-defined search routine
1909 // to search for the requested string.
1910 if(m_pFindDialog
->FindNext())
1912 //read data from dialog
1913 CString FindName
= m_pFindDialog
->GetFindString();
1915 DoSearch(FindName
,m_pFindDialog
->m_fr
.Flags
);
1921 void CTortoiseGitBlameView::OnViewNext()
1923 int startline
= (int)SendEditor(SCI_GETFIRSTVISIBLELINE
);
1924 int line
= m_data
.FindNextLine(this->m_SelectedHash
, (int)SendEditor(SCI_GETFIRSTVISIBLELINE
), false);
1926 SendEditor(SCI_LINESCROLL
, 0, line
- startline
- 2);
1928 void CTortoiseGitBlameView::OnViewPrev()
1930 int startline
= (int)SendEditor(SCI_GETFIRSTVISIBLELINE
);
1931 int line
= m_data
.FindNextLine(this->m_SelectedHash
, (int)SendEditor(SCI_GETFIRSTVISIBLELINE
), true);
1933 SendEditor(SCI_LINESCROLL
, 0, line
- startline
- 2);
1936 void CTortoiseGitBlameView::OnViewToggleAuthor()
1938 m_bShowAuthor
= ! m_bShowAuthor
;
1940 theApp
.WriteInt(_T("ShowAuthor"), m_bShowAuthor
);
1943 this->GetClientRect(&rect
);
1944 rect
.left
=GetBlameWidth();
1946 m_TextView
.MoveWindow(&rect
);
1949 void CTortoiseGitBlameView::OnUpdateViewToggleAuthor(CCmdUI
*pCmdUI
)
1951 pCmdUI
->SetCheck(m_bShowAuthor
);
1954 void CTortoiseGitBlameView::OnViewToggleDate()
1956 m_bShowDate
= ! m_bShowDate
;
1958 theApp
.WriteInt(_T("ShowDate"), m_bShowDate
);
1961 this->GetClientRect(&rect
);
1962 rect
.left
=GetBlameWidth();
1964 m_TextView
.MoveWindow(&rect
);
1967 void CTortoiseGitBlameView::OnUpdateViewToggleDate(CCmdUI
*pCmdUI
)
1969 pCmdUI
->SetCheck(m_bShowDate
);
1972 void CTortoiseGitBlameView::OnViewToggleShowFilename()
1974 m_bShowFilename
= ! m_bShowFilename
;
1976 theApp
.WriteInt(_T("ShowFilename"), m_bShowFilename
);
1979 this->GetClientRect(&rect
);
1980 rect
.left
= GetBlameWidth();
1982 m_TextView
.MoveWindow(&rect
);
1985 void CTortoiseGitBlameView::OnUpdateViewToggleShowFilename(CCmdUI
*pCmdUI
)
1987 pCmdUI
->SetCheck(m_bShowFilename
);
1990 void CTortoiseGitBlameView::OnViewToggleShowOriginalLineNumber()
1992 m_bShowOriginalLineNumber
= ! m_bShowOriginalLineNumber
;
1994 theApp
.WriteInt(_T("ShowOriginalLineNumber"), m_bShowOriginalLineNumber
);
1997 this->GetClientRect(&rect
);
1998 rect
.left
= GetBlameWidth();
2000 m_TextView
.MoveWindow(&rect
);
2003 void CTortoiseGitBlameView::OnUpdateViewToggleShowOriginalLineNumber(CCmdUI
*pCmdUI
)
2005 pCmdUI
->SetCheck(m_bShowOriginalLineNumber
);
2008 void CTortoiseGitBlameView::OnViewDetectMovedOrCopiedLines(DWORD dwDetectMovedOrCopiedLines
)
2010 m_dwDetectMovedOrCopiedLines
= dwDetectMovedOrCopiedLines
;
2012 theApp
.DoWaitCursor(1);
2014 theApp
.WriteInt(_T("DetectMovedOrCopiedLines"), m_dwDetectMovedOrCopiedLines
);
2016 CTortoiseGitBlameDoc
*document
= (CTortoiseGitBlameDoc
*) m_pDocument
;
2017 if (!document
->m_CurrentFileName
.IsEmpty())
2019 document
->m_lLine
= (int)SendEditor(SCI_GETFIRSTVISIBLELINE
) + 1;
2020 theApp
.m_pDocManager
->OnFileNew();
2021 document
->OnOpenDocument(document
->m_CurrentFileName
, document
->m_Rev
);
2023 theApp
.DoWaitCursor(-1);
2026 void CTortoiseGitBlameView::OnViewDetectMovedOrCopiedLinesToggleDisabled()
2028 OnViewDetectMovedOrCopiedLines(BLAME_DETECT_MOVED_OR_COPIED_LINES_DISABLED
);
2031 void CTortoiseGitBlameView::OnUpdateViewDetectMovedOrCopiedLinesToggleDisabled(CCmdUI
*pCmdUI
)
2033 pCmdUI
->SetRadio(m_dwDetectMovedOrCopiedLines
== BLAME_DETECT_MOVED_OR_COPIED_LINES_DISABLED
);
2036 void CTortoiseGitBlameView::OnViewDetectMovedOrCopiedLinesToggleWithinFile()
2038 OnViewDetectMovedOrCopiedLines(BLAME_DETECT_MOVED_OR_COPIED_LINES_WITHIN_FILE
);
2041 void CTortoiseGitBlameView::OnUpdateViewDetectMovedOrCopiedLinesToggleWithinFile(CCmdUI
*pCmdUI
)
2043 pCmdUI
->SetRadio(m_dwDetectMovedOrCopiedLines
== BLAME_DETECT_MOVED_OR_COPIED_LINES_WITHIN_FILE
);
2046 void CTortoiseGitBlameView::OnViewDetectMovedOrCopiedLinesToggleFromModifiedFiles()
2048 OnViewDetectMovedOrCopiedLines(BLAME_DETECT_MOVED_OR_COPIED_LINES_FROM_MODIFIED_FILES
);
2051 void CTortoiseGitBlameView::OnUpdateViewDetectMovedOrCopiedLinesToggleFromModifiedFiles(CCmdUI
*pCmdUI
)
2053 pCmdUI
->SetRadio(m_dwDetectMovedOrCopiedLines
== BLAME_DETECT_MOVED_OR_COPIED_LINES_FROM_MODIFIED_FILES
);
2056 void CTortoiseGitBlameView::OnViewDetectMovedOrCopiedLinesToggleFromExistingFilesAtFileCreation()
2058 OnViewDetectMovedOrCopiedLines(BLAME_DETECT_MOVED_OR_COPIED_LINES_FROM_EXISTING_FILES_AT_FILE_CREATION
);
2061 void CTortoiseGitBlameView::OnUpdateViewDetectMovedOrCopiedLinesToggleFromExistingFilesAtFileCreation(CCmdUI
*pCmdUI
)
2063 pCmdUI
->SetRadio(m_dwDetectMovedOrCopiedLines
== BLAME_DETECT_MOVED_OR_COPIED_LINES_FROM_EXISTING_FILES_AT_FILE_CREATION
);
2066 void CTortoiseGitBlameView::OnViewDetectMovedOrCopiedLinesToggleFromExistingFiles()
2068 OnViewDetectMovedOrCopiedLines(BLAME_DETECT_MOVED_OR_COPIED_LINES_FROM_EXISTING_FILES
);
2071 void CTortoiseGitBlameView::OnUpdateViewDetectMovedOrCopiedLinesToggleFromExistingFiles(CCmdUI
*pCmdUI
)
2073 pCmdUI
->SetRadio(m_dwDetectMovedOrCopiedLines
== BLAME_DETECT_MOVED_OR_COPIED_LINES_FROM_EXISTING_FILES
);
2076 void CTortoiseGitBlameView::ReloadDocument()
2078 theApp
.DoWaitCursor(1);
2079 CTortoiseGitBlameDoc
*document
= (CTortoiseGitBlameDoc
*) m_pDocument
;
2080 if (!document
->m_CurrentFileName
.IsEmpty())
2082 document
->m_lLine
= (int)SendEditor(SCI_GETFIRSTVISIBLELINE
) + 1;
2083 theApp
.m_pDocManager
->OnFileNew();
2084 document
->OnOpenDocument(document
->m_CurrentFileName
, document
->m_Rev
);
2086 theApp
.DoWaitCursor(-1);
2089 void CTortoiseGitBlameView::OnViewToggleIgnoreWhitespace()
2091 m_bIgnoreWhitespace
= ! m_bIgnoreWhitespace
;
2093 theApp
.WriteInt(_T("IgnoreWhitespace"), m_bIgnoreWhitespace
? 1 : 0);
2098 void CTortoiseGitBlameView::OnUpdateViewToggleIgnoreWhitespace(CCmdUI
*pCmdUI
)
2100 pCmdUI
->SetCheck(m_bIgnoreWhitespace
);
2103 void CTortoiseGitBlameView::OnViewToggleShowCompleteLog()
2105 m_bShowCompleteLog
= ! m_bShowCompleteLog
;
2107 theApp
.WriteInt(_T("ShowCompleteLog"), m_bShowCompleteLog
? 1 : 0);
2112 void CTortoiseGitBlameView::OnUpdateViewToggleShowCompleteLog(CCmdUI
*pCmdUI
)
2114 pCmdUI
->Enable(BlameIsLimitedToOneFilename(m_dwDetectMovedOrCopiedLines
));
2115 pCmdUI
->SetCheck(m_bShowCompleteLog
&& BlameIsLimitedToOneFilename(m_dwDetectMovedOrCopiedLines
));
2118 void CTortoiseGitBlameView::OnViewToggleFollowRenames()
2120 m_bFollowRenames
= ! m_bFollowRenames
;
2122 theApp
.WriteInt(_T("FollowRenames"), m_bFollowRenames
? 1 : 0);
2127 void CTortoiseGitBlameView::OnUpdateViewToggleFollowRenames(CCmdUI
*pCmdUI
)
2129 pCmdUI
->Enable(m_bShowCompleteLog
&& BlameIsLimitedToOneFilename(m_dwDetectMovedOrCopiedLines
));
2130 pCmdUI
->SetCheck(m_bFollowRenames
&& m_bShowCompleteLog
&& BlameIsLimitedToOneFilename(m_dwDetectMovedOrCopiedLines
));
2133 void CTortoiseGitBlameView::OnViewToggleColorByAge()
2135 m_colorage
= ! m_colorage
;
2137 theApp
.WriteInt(_T("ColorAge"), m_colorage
);
2139 m_TextView
.Invalidate();
2142 void CTortoiseGitBlameView::OnUpdateViewToggleColorByAge(CCmdUI
*pCmdUI
)
2144 pCmdUI
->SetCheck(m_colorage
);
2147 void CTortoiseGitBlameView::OnUpdateViewCopyToClipboard(CCmdUI
*pCmdUI
)
2149 CWnd
* wnd
= GetFocus();
2150 if (wnd
== GetLogList())
2152 pCmdUI
->Enable(GetLogList()->GetSelectedCount() > 0);
2156 if (CString(wnd
->GetRuntimeClass()->m_lpszClassName
) == _T("CMFCPropertyGridCtrl"))
2158 CMFCPropertyGridCtrl
*grid
= (CMFCPropertyGridCtrl
*)wnd
;
2159 pCmdUI
->Enable(grid
->GetCurSel() && !grid
->GetCurSel()->IsGroup() && !CString(grid
->GetCurSel()->GetValue()).IsEmpty());
2162 pCmdUI
->Enable(m_TextView
.Call(SCI_GETSELECTIONSTART
) != m_TextView
.Call(SCI_GETSELECTIONEND
));
2165 pCmdUI
->Enable(FALSE
);