1 // TortoiseGitBlame - a Viewer for Git Blames
3 // Copyright (C) 2008-2016 - TortoiseGit
4 // Copyright (C) 2003-2008, 2014 - TortoiseSVN
6 // Copyright (C)2003 Don HO <donho@altern.org>
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License
10 // as published by the Free Software Foundation; either version 2
11 // of the License, or (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software Foundation,
20 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 // CTortoiseGitBlameView.cpp : implementation of the CTortoiseGitBlameView class
26 #include "TortoiseGitBlame.h"
27 #include "CommonAppUtils.h"
28 #include "TortoiseGitBlameDoc.h"
29 #include "TortoiseGitBlameView.h"
31 #include "EditGotoDlg.h"
32 #include "LoglistUtils.h"
33 #include "FileTextLines.h"
34 #include "UnicodeUtils.h"
35 #include "MenuEncode.h"
37 #include "StringUtils.h"
38 #include "BlameIndexColors.h"
39 #include "BlameDetectMovedOrCopiedLines.h"
47 UINT
CTortoiseGitBlameView::m_FindDialogMessage
;
49 // CTortoiseGitBlameView
50 IMPLEMENT_DYNAMIC(CSciEditBlame
,CSciEdit
)
52 IMPLEMENT_DYNCREATE(CTortoiseGitBlameView
, CView
)
54 BEGIN_MESSAGE_MAP(CTortoiseGitBlameView
, CView
)
55 // Standard printing commands
56 ON_COMMAND(ID_FILE_PRINT
, &CView::OnFilePrint
)
57 ON_COMMAND(ID_FILE_PRINT_DIRECT
, &CView::OnFilePrint
)
58 ON_COMMAND(ID_FILE_PRINT_PREVIEW
, &CTortoiseGitBlameView::OnFilePrintPreview
)
59 ON_COMMAND(ID_EDIT_FIND
,OnEditFind
)
60 ON_COMMAND(ID_EDIT_GOTO
,OnEditGoto
)
61 ON_COMMAND(ID_EDIT_COPY
, CopyToClipboard
)
62 ON_UPDATE_COMMAND_UI(ID_EDIT_COPY
, OnUpdateViewCopyToClipboard
)
63 ON_COMMAND(ID_VIEW_NEXT
,OnViewNext
)
64 ON_COMMAND(ID_VIEW_PREV
,OnViewPrev
)
65 ON_COMMAND(ID_FIND_NEXT
, OnFindNext
)
66 ON_COMMAND(ID_FIND_PREV
, OnFindPrev
)
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_ONLYCONSIDERFIRSTPARENTS
, OnViewToggleOnlyFirstParent
)
90 ON_UPDATE_COMMAND_UI(ID_VIEW_ONLYCONSIDERFIRSTPARENTS
, OnUpdateViewToggleOnlyFirstParent
)
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_WM_SYSCOLORCHANGE()
107 ON_NOTIFY(SCN_PAINTED
, IDC_SCINTILLA
, OnSciPainted
)
108 ON_NOTIFY(SCN_GETBKCOLOR
, IDC_SCINTILLA
, OnSciGetBkColor
)
109 ON_REGISTERED_MESSAGE(m_FindDialogMessage
, OnFindDialogMessage
)
113 // CTortoiseGitBlameView construction/destruction
115 CTortoiseGitBlameView::CTortoiseGitBlameView()
120 , bIgnoreSpaces(false)
121 , bIgnoreAllSpaces(false)
123 , m_bMatchCase(false)
136 m_originalLineNumberWidth
= 0;
139 m_windowcolor
= ::GetSysColor(COLOR_WINDOW
);
140 m_textcolor
= ::GetSysColor(COLOR_WINDOWTEXT
);
141 m_texthighlightcolor
= ::GetSysColor(COLOR_HIGHLIGHTTEXT
);
142 m_mouserevcolor
= InterColor(m_windowcolor
, m_textcolor
, 20);
143 m_mouseauthorcolor
= InterColor(m_windowcolor
, m_textcolor
, 10);
144 m_selectedrevcolor
= ::GetSysColor(COLOR_HIGHLIGHT
);
145 m_selectedauthorcolor
= InterColor(m_selectedrevcolor
, m_texthighlightcolor
, 35);
149 HIGHCONTRAST highContrast
= { 0 };
150 highContrast
.cbSize
= sizeof(HIGHCONTRAST
);
151 BOOL highContrastModeEnabled
= SystemParametersInfo(SPI_GETHIGHCONTRAST
, 0, &highContrast
, 0) == TRUE
&& (highContrast
.dwFlags
& HCF_HIGHCONTRASTON
);
152 m_colorage
= !!theApp
.GetInt(L
"ColorAge", !highContrastModeEnabled
);
153 m_bLexer
= !!theApp
.GetInt(L
"EnableLexer", !highContrastModeEnabled
);
157 m_bShowAuthor
= (theApp
.GetInt(L
"ShowAuthor", 1) == 1);
158 m_bShowDate
= (theApp
.GetInt(L
"ShowDate", 0) == 1);
159 m_bShowFilename
= (theApp
.GetInt(L
"ShowFilename", 0) == 1);
160 m_bShowOriginalLineNumber
= (theApp
.GetInt(L
"ShowOriginalLineNumber", 0) == 1);
161 m_dwDetectMovedOrCopiedLines
= theApp
.GetInt(L
"DetectMovedOrCopiedLines", 0);
162 m_bIgnoreWhitespace
= (theApp
.GetInt(L
"IgnoreWhitespace", 0) == 1);
163 m_bShowCompleteLog
= (theApp
.GetInt(L
"ShowCompleteLog", 1) == 1);
164 m_bOnlyFirstParent
= (theApp
.GetInt(L
"OnlyFirstParent", 0) == 1);
165 m_bFollowRenames
= (theApp
.GetInt(L
"FollowRenames", 0) == 1);
166 m_bBlameOuputContainsOtherFilenames
= FALSE
;
168 m_FindDialogMessage
= ::RegisterWindowMessage(FINDMSGSTRING
);
169 m_pFindDialog
= nullptr;
170 // get short/long datetime setting from registry
171 DWORD RegUseShortDateFormat
= CRegDWORD(L
"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(L
"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()
197 #ifdef USE_TEMPFILENAME
208 static EncodingUnit encodings
[] = {
209 {1250, "windows-1250"}, //IDM_FORMAT_WIN_1250
210 {1251, "windows-1251"}, //IDM_FORMAT_WIN_1251
211 {1252, "windows-1252"}, //IDM_FORMAT_WIN_1252
212 {1253, "windows-1253"}, //IDM_FORMAT_WIN_1253
213 {1254, "windows-1254"}, //IDM_FORMAT_WIN_1254
214 {1255, "windows-1255"}, //IDM_FORMAT_WIN_1255
215 {1256, "windows-1256"}, //IDM_FORMAT_WIN_1256
216 {1257, "windows-1257"}, //IDM_FORMAT_WIN_1257
217 {1258, "windows-1258"}, //IDM_FORMAT_WIN_1258
218 {28591, "latin1 ISO_8859-1 ISO-8859-1 CP819 IBM819 csISOLatin1 iso-ir-100 l1"}, //IDM_FORMAT_ISO_8859_1
219 {28592, "latin2 ISO_8859-2 ISO-8859-2 csISOLatin2 iso-ir-101 l2"}, //IDM_FORMAT_ISO_8859_2
220 {28593, "latin3 ISO_8859-3 ISO-8859-3 csISOLatin3 iso-ir-109 l3"}, //IDM_FORMAT_ISO_8859_3
221 {28594, "latin4 ISO_8859-4 ISO-8859-4 csISOLatin4 iso-ir-110 l4"}, //IDM_FORMAT_ISO_8859_4
222 {28595, "cyrillic ISO_8859-5 ISO-8859-5 csISOLatinCyrillic iso-ir-144"}, //IDM_FORMAT_ISO_8859_5
223 {28596, "arabic ISO_8859-6 ISO-8859-6 csISOLatinArabic iso-ir-127 ASMO-708 ECMA-114"}, //IDM_FORMAT_ISO_8859_6
224 {28597, "greek ISO_8859-7 ISO-8859-7 csISOLatinGreek greek8 iso-ir-126 ELOT_928 ECMA-118"}, //IDM_FORMAT_ISO_8859_7
225 {28598, "hebrew ISO_8859-8 ISO-8859-8 csISOLatinHebrew iso-ir-138"}, //IDM_FORMAT_ISO_8859_8
226 {28599, "latin5 ISO_8859-9 ISO-8859-9 csISOLatin5 iso-ir-148 l5"}, //IDM_FORMAT_ISO_8859_9
227 {28600, "latin6 ISO_8859-10 ISO-8859-10 csISOLatin6 iso-ir-157 l6"}, //IDM_FORMAT_ISO_8859_10
228 {28601, "ISO_8859-11 ISO-8859-11"}, //IDM_FORMAT_ISO_8859_11
229 {28603, "ISO_8859-13 ISO-8859-13"}, //IDM_FORMAT_ISO_8859_13
230 {28604, "iso-celtic latin8 ISO_8859-14 ISO-8859-14 18 iso-ir-199"}, //IDM_FORMAT_ISO_8859_14
231 {28605, "Latin-9 ISO_8859-15 ISO-8859-15"}, //IDM_FORMAT_ISO_8859_15
232 {28606, "latin10 ISO_8859-16 ISO-8859-16 110 iso-ir-226"}, //IDM_FORMAT_ISO_8859_16
233 {437, "IBM437 cp437 437 csPC8CodePage437"}, //IDM_FORMAT_DOS_437
234 {720, "IBM720 cp720 oem720 720"}, //IDM_FORMAT_DOS_720
235 {737, "IBM737 cp737 oem737 737"}, //IDM_FORMAT_DOS_737
236 {775, "IBM775 cp775 oem775 775"}, //IDM_FORMAT_DOS_775
237 {850, "IBM850 cp850 oem850 850"}, //IDM_FORMAT_DOS_850
238 {852, "IBM852 cp852 oem852 852"}, //IDM_FORMAT_DOS_852
239 {855, "IBM855 cp855 oem855 855 csIBM855"}, //IDM_FORMAT_DOS_855
240 {857, "IBM857 cp857 oem857 857"}, //IDM_FORMAT_DOS_857
241 {858, "IBM858 cp858 oem858 858"}, //IDM_FORMAT_DOS_858
242 {860, "IBM860 cp860 oem860 860"}, //IDM_FORMAT_DOS_860
243 {861, "IBM861 cp861 oem861 861"}, //IDM_FORMAT_DOS_861
244 {862, "IBM862 cp862 oem862 862"}, //IDM_FORMAT_DOS_862
245 {863, "IBM863 cp863 oem863 863"}, //IDM_FORMAT_DOS_863
246 {865, "IBM865 cp865 oem865 865"}, //IDM_FORMAT_DOS_865
247 {866, "IBM866 cp866 oem866 866"}, //IDM_FORMAT_DOS_866
248 {869, "IBM869 cp869 oem869 869"}, //IDM_FORMAT_DOS_869
249 {950, "big5 csBig5"}, //IDM_FORMAT_BIG5
250 {936, "gb2312 gbk csGB2312"}, //IDM_FORMAT_GB2312
251 {932, "Shift_JIS MS_Kanji csShiftJIS csWindows31J"}, //IDM_FORMAT_SHIFT_JIS
252 {949, "windows-949 korean"}, //IDM_FORMAT_KOREAN_WIN
253 {51949, "euc-kr csEUCKR"}, //IDM_FORMAT_EUC_KR
254 {874, "tis-620"}, //IDM_FORMAT_TIS_620
255 {10007, "x-mac-cyrillic xmaccyrillic"}, //IDM_FORMAT_MAC_CYRILLIC
256 {21866, "koi8_u"}, //IDM_FORMAT_KOI8U_CYRILLIC
257 {20866, "koi8_r csKOI8R"}, //IDM_FORMAT_KOI8R_CYRILLIC
258 {65001, "UTF-8"}, //IDM_FORMAT_UTF8
259 {1200, "UTF-16 LE"}, //IDM_FORMAT_UTF16LE
260 {1201, "UTF-16 BE"}, //IDM_FORMAT_UTF16BE
262 void CTortoiseGitBlameView::OnChangeEncode(UINT nId
)
264 if(nId
>= IDM_FORMAT_ENCODE
&& nId
<= IDM_FORMAT_ENCODE_END
)
265 this->UpdateInfo(encodings
[nId
- IDM_FORMAT_ENCODE
].id
);
267 int CTortoiseGitBlameView::OnCreate(LPCREATESTRUCT lpcs
)
270 this->GetWindowRect(&rect1
);
271 rect
.left
=m_blamewidth
+LOCATOR_WIDTH
;
272 rect
.right
=rect
.Width();
274 rect
.bottom
=rect
.Height();
275 if (!m_TextView
.Create(L
"Scintilla", L
"source", 0, rect
, this, IDC_SCINTILLA
, 0))
277 TRACE0("Failed to create view\n");
278 return -1; // fail to create
281 m_TextView
.ShowWindow( SW_SHOW
);
283 SendEditor(SCI_SETREADONLY
, TRUE
);
284 m_ToolTip
.Create(this->GetParent());
286 ::AfxGetApp()->GetMainWnd();
287 return CView::OnCreate(lpcs
);
290 void CTortoiseGitBlameView::OnSize(UINT
/*nType*/, int cx
, int cy
)
293 rect
.left
=m_blamewidth
;
298 m_TextView
.MoveWindow(&rect
);
300 BOOL
CTortoiseGitBlameView::PreCreateWindow(CREATESTRUCT
& cs
)
302 return CView::PreCreateWindow(cs
);
305 // CTortoiseGitBlameView drawing
307 void CTortoiseGitBlameView::OnDraw(CDC
* /*pDC*/)
309 CTortoiseGitBlameDoc
* pDoc
= GetDocument();
314 DrawBlame(this->GetDC()->m_hDC
);
315 DrawLocatorBar(this->GetDC()->m_hDC
);
316 // TODO: add draw code for native data here
320 // CTortoiseGitBlameView printing
323 void CTortoiseGitBlameView::OnFilePrintPreview()
325 AFXPrintPreview(this);
328 BOOL
CTortoiseGitBlameView::OnPreparePrinting(CPrintInfo
* pInfo
)
330 // default preparation
331 return DoPreparePrinting(pInfo
);
334 void CTortoiseGitBlameView::OnBeginPrinting(CDC
* /*pDC*/, CPrintInfo
* /*pInfo*/)
336 // TODO: add extra initialization before printing
339 void CTortoiseGitBlameView::OnEndPrinting(CDC
* /*pDC*/, CPrintInfo
* /*pInfo*/)
341 // TODO: add cleanup after printing
344 void CTortoiseGitBlameView::OnRButtonUp(UINT
/*nFlags*/, CPoint point
)
346 int line
= (int)SendEditor(SCI_GETFIRSTVISIBLELINE
);
347 int height
= (int)SendEditor(SCI_TEXTHEIGHT
);
348 line
= line
+ (int)(point
.y
/ height
);
349 if (m_data
.IsValidLine(line
))
352 ClientToScreen(&point
);
354 CGitHash hash
= m_data
.GetHash(line
);
355 CString hashStr
= hash
.ToString();
357 GitRevLoglist
* pRev
= nullptr;
358 int logIndex
= m_lineToLogIndex
[line
];
360 pRev
= &GetLogData()->GetGitRevAt(logIndex
);
363 pRev
= m_data
.GetRev(line
, GetLogData()->m_pLogCache
->m_HashMap
);
364 if (pRev
&& pRev
->m_ParentHash
.empty())
366 if (pRev
->GetParentFromHash(pRev
->m_CommitHash
))
367 MessageBox(pRev
->GetLastErr(), L
"TortoiseGit", MB_ICONERROR
);
375 CIconMenu blamemenu
, diffmenu
;
377 if (!popup
.CreatePopupMenu())
380 // Now find the relevant parent commits, they must contain the file which is blamed to be the source of the selected line,
381 // otherwise there is no previous file to compare to (only another previous revision).
383 GIT_REV_LIST parentHashWithFile
;
384 std::vector
<CString
> parentFilename
;
387 CTGitPath
path(m_data
.GetFilename(line
));
388 const CTGitPathList
& files
= pRev
->GetFiles(nullptr);
389 for (int j
= 0, j_size
= files
.GetCount(); j
< j_size
; ++j
)
391 const CTGitPath
&file
= files
[j
];
392 if (file
.IsEquivalentTo(path
))
394 if (!(file
.m_ParentNo
& MERGE_MASK
))
396 int action
= file
.m_Action
;
397 // ignore (action & CTGitPath::LOGACTIONS_ADDED), as then there is nothing to blame/diff
398 // ignore (action & CTGitPath::LOGACTIONS_DELETED), should never happen as the file must exist
399 if (action
& (CTGitPath::LOGACTIONS_MODIFIED
| CTGitPath::LOGACTIONS_REPLACED
))
401 int parentNo
= file
.m_ParentNo
& PARENT_MASK
;
402 if (parentNo
>= 0 && (size_t)parentNo
< pRev
->m_ParentHash
.size())
404 parentHashWithFile
.push_back(pRev
->m_ParentHash
[parentNo
]);
405 parentFilename
.push_back((action
& CTGitPath::LOGACTIONS_REPLACED
) ? file
.GetGitOldPathString() : file
.GetGitPathString());
412 catch (const char* msg
)
414 MessageBox(L
"Could not get files of parents.\nlibgit reports:\n" + CString(msg
), L
"TortoiseGit", MB_ICONERROR
);
418 if (!parentHashWithFile
.empty())
420 if (parentHashWithFile
.size() == 1)
422 popup
.AppendMenuIcon(ID_BLAMEPREVIOUS
, IDS_BLAME_POPUP_BLAME
, IDI_BLAME_POPUP_BLAME
);
426 blamemenu
.CreatePopupMenu();
427 popup
.AppendMenuIcon(ID_BLAMEPREVIOUS
, IDS_BLAME_POPUP_BLAME
, IDI_BLAME_POPUP_BLAME
, blamemenu
.m_hMenu
);
429 for (size_t i
= 0; i
< parentHashWithFile
.size(); ++i
)
432 str
.Format(IDS_PARENT
, i
+ 1);
433 blamemenu
.AppendMenuIcon(ID_BLAMEPREVIOUS
+ ((i
+ 1) << 16), str
);
438 // compare with previous
439 if (!parentHashWithFile
.empty())
441 if (parentHashWithFile
.size() == 1)
443 popup
.AppendMenuIcon(ID_COMPAREWITHPREVIOUS
, IDS_BLAME_POPUP_COMPARE
, IDI_BLAME_POPUP_COMPARE
);
444 if (CRegDWORD(L
"Software\\TortoiseGit\\DiffByDoubleClickInLog", FALSE
))
445 popup
.SetDefaultItem(ID_COMPAREWITHPREVIOUS
, FALSE
);
449 diffmenu
.CreatePopupMenu();
450 popup
.AppendMenuIcon(ID_COMPAREWITHPREVIOUS
, IDS_BLAME_POPUP_COMPARE
, IDI_BLAME_POPUP_COMPARE
, diffmenu
.m_hMenu
);
451 for (size_t i
= 0; i
< parentHashWithFile
.size(); ++i
)
454 str
.Format(IDS_BLAME_POPUP_PARENT
, i
+ 1);
455 diffmenu
.AppendMenuIcon((UINT
)(ID_COMPAREWITHPREVIOUS
+ ((i
+ 1) << 16)),str
);
456 if (i
== 0 && CRegDWORD(L
"Software\\TortoiseGit\\DiffByDoubleClickInLog", FALSE
))
458 popup
.SetDefaultItem(ID_COMPAREWITHPREVIOUS
, FALSE
);
459 diffmenu
.SetDefaultItem((UINT
)(ID_COMPAREWITHPREVIOUS
+ ((i
+ 1) << 16)), FALSE
);
465 popup
.AppendMenuIcon(ID_SHOWLOG
, IDS_BLAME_POPUP_LOG
, IDI_BLAME_POPUP_LOG
);
466 popup
.AppendMenu(MF_SEPARATOR
, NULL
);
467 popup
.AppendMenuIcon(ID_COPYHASHTOCLIPBOARD
, IDS_BLAME_POPUP_COPYHASHTOCLIPBOARD
, IDI_BLAME_POPUP_COPY
);
468 popup
.AppendMenuIcon(ID_COPYLOGTOCLIPBOARD
, IDS_BLAME_POPUP_COPYLOGTOCLIPBOARD
, IDI_BLAME_POPUP_COPY
);
470 int cmd
= popup
.TrackPopupMenu(TPM_RETURNCMD
| TPM_LEFTALIGN
| TPM_NONOTIFY
, point
.x
, point
.y
, this);
471 this->ContextMenuAction(cmd
, pRev
, parentHashWithFile
, parentFilename
);
475 void CTortoiseGitBlameView::ContextMenuAction(int cmd
, GitRev
*pRev
, GIT_REV_LIST
& parentHashWithFile
, const std::vector
<CString
>& parentFilename
)
477 switch (cmd
& 0xFFFF)
479 case ID_BLAMEPREVIOUS
:
481 int index
= (cmd
>>16) & 0xFFFF;
485 CString path
= ResolveCommitFile(parentFilename
[index
]);
486 CString endrev
= parentHashWithFile
[index
].ToString();
487 int line
= m_data
.GetOriginalLineNumber(m_MouseLine
);
489 CString procCmd
= L
"/path:\"" + path
+ L
"\" ";
490 procCmd
+= L
" /command:blame";
491 procCmd
+= L
" /endrev:" + endrev
;
492 procCmd
+= L
" /line:";
493 procCmd
.AppendFormat(L
"%d", line
);
495 CCommonAppUtils::RunTortoiseGitProc(procCmd
);
499 case ID_COMPAREWITHPREVIOUS
:
501 int index
= (cmd
>> 16) & 0xFFFF;
505 CString path
= ResolveCommitFile(parentFilename
[index
]);
506 CString startrev
= pRev
->m_CommitHash
.ToString();
507 CString endrev
= parentHashWithFile
[index
].ToString();
509 CString procCmd
= L
"/path:\"" + path
+ L
"\" ";
510 procCmd
+= L
" /command:diff";
511 procCmd
+= L
" /startrev:" + startrev
;
512 procCmd
+= L
" /endrev:" + endrev
;
513 if (!!(GetAsyncKeyState(VK_SHIFT
) & 0x8000))
514 procCmd
+= L
" /alternative";
516 CCommonAppUtils::RunTortoiseGitProc(procCmd
);
522 CString path
= ResolveCommitFile(m_MouseLine
);
523 CString rev
= m_data
.GetHash(m_MouseLine
).ToString();
525 CString procCmd
= L
"/path:\"" + path
+ L
"\" ";
526 procCmd
+= L
" /command:log";
527 procCmd
+= L
" /rev:" + rev
;
528 procCmd
+= L
" /endrev:" + rev
;
530 CCommonAppUtils::RunTortoiseGitProc(procCmd
);
534 case ID_COPYHASHTOCLIPBOARD
:
535 this->GetLogList()->CopySelectionToClipBoard(CGitLogListBase::ID_COPY_HASH
);
538 case ID_COPYLOGTOCLIPBOARD
:
539 this->GetLogList()->CopySelectionToClipBoard();
544 // CTortoiseGitBlameView diagnostics
547 void CTortoiseGitBlameView::AssertValid() const
549 CView::AssertValid();
552 void CTortoiseGitBlameView::Dump(CDumpContext
& dc
) const
557 CTortoiseGitBlameDoc
* CTortoiseGitBlameView::GetDocument() const // non-debug version is inline
559 ASSERT(m_pDocument
->IsKindOf(RUNTIME_CLASS(CTortoiseGitBlameDoc
)));
560 return (CTortoiseGitBlameDoc
*)m_pDocument
;
565 // Return a color which is interpolated between c1 and c2.
566 // Slider controls the relative proportions as a percentage:
567 // Slider = 0 represents pure c1
568 // Slider = 50 represents equal mixture
569 // Slider = 100 represents pure c2
570 COLORREF
CTortoiseGitBlameView::InterColor(COLORREF c1
, COLORREF c2
, int Slider
)
574 // Limit Slider to 0..100% range
580 // The color components have to be treated individually.
581 r
= (GetRValue(c2
) * Slider
+ GetRValue(c1
) * (100 - Slider
)) / 100;
582 g
= (GetGValue(c2
) * Slider
+ GetGValue(c1
) * (100 - Slider
)) / 100;
583 b
= (GetBValue(c2
) * Slider
+ GetBValue(c1
) * (100 - Slider
)) / 100;
588 LRESULT
CTortoiseGitBlameView::SendEditor(UINT Msg
, WPARAM wParam
, LPARAM lParam
)
590 return m_TextView
.Call(Msg
, wParam
, lParam
);
593 void CTortoiseGitBlameView::SetAStyle(int style
, COLORREF fore
, COLORREF back
, int size
, const char *face
)
595 if (fore
== back
&& fore
== m_windowcolor
)
597 m_TextView
.SetAStyle(style
, fore
, back
, size
, face
);
600 void CTortoiseGitBlameView::InitialiseEditor()
602 SendEditor(SCI_STYLERESETDEFAULT
);
603 // Set up the global default style. These attributes are used wherever no explicit choices are made.
604 std::string fontName
= CUnicodeUtils::StdGetUTF8((std::wstring
)CRegStdString(L
"Software\\TortoiseGit\\BlameFontName", L
"Consolas"));
605 SetAStyle(STYLE_DEFAULT
,
606 ::GetSysColor(COLOR_WINDOWTEXT
),
607 ::GetSysColor(COLOR_WINDOW
),
608 (DWORD
)CRegStdDWORD(L
"Software\\TortoiseGit\\BlameFontSize", 10),
611 SendEditor(SCI_SETTABWIDTH
, (DWORD
)CRegStdDWORD(L
"Software\\TortoiseGit\\BlameTabSize", 4));
612 SendEditor(SCI_SETREADONLY
, TRUE
);
613 LRESULT pix
= SendEditor(SCI_TEXTWIDTH
, STYLE_LINENUMBER
, (LPARAM
)this->m_TextView
.StringForControl(L
"_99999").GetBuffer());
615 SendEditor(SCI_SETMARGINWIDTHN
, 0, pix
);
617 SendEditor(SCI_SETMARGINWIDTHN
, 0);
618 SendEditor(SCI_SETMARGINWIDTHN
, 1);
619 SendEditor(SCI_SETMARGINWIDTHN
, 2);
620 //Set the default windows colors for edit controls
621 SendEditor(SCI_SETSELFORE
, TRUE
, ::GetSysColor(COLOR_HIGHLIGHTTEXT
));
622 SendEditor(SCI_SETSELBACK
, TRUE
, ::GetSysColor(COLOR_HIGHLIGHT
));
623 SendEditor(SCI_SETCARETFORE
, ::GetSysColor(COLOR_WINDOWTEXT
));
624 m_regOldLinesColor
= CRegStdDWORD(L
"Software\\TortoiseGit\\BlameOldColor", BLAMEOLDCOLOR
);
625 m_regNewLinesColor
= CRegStdDWORD(L
"Software\\TortoiseGit\\BlameNewColor", BLAMENEWCOLOR
);
626 if (CRegStdDWORD(L
"Software\\TortoiseGit\\ScintillaDirect2D", FALSE
) != FALSE
)
628 SendEditor(SCI_SETTECHNOLOGY
, SC_TECHNOLOGY_DIRECTWRITERETAIN
);
629 SendEditor(SCI_SETBUFFEREDDRAW
, 0);
632 SendEditor(SCI_SETWRAPMODE
, SC_WRAP_NONE
);
633 SendEditor(SCI_STYLECLEARALL
);
636 bool CTortoiseGitBlameView::DoSearch(CTortoiseGitBlameData::SearchDirection direction
)
638 int pos
= (int)SendEditor(SCI_GETCURRENTPOS
);
639 int line
= (int)SendEditor(SCI_LINEFROMPOSITION
, pos
);
641 int i
= m_data
.FindFirstLineWrapAround(direction
, m_sFindText
, line
, m_bMatchCase
);
645 int selstart
= (int)SendEditor(SCI_GETCURRENTPOS
);
646 int selend
= (int)SendEditor(SCI_POSITIONFROMLINE
, i
+ 1);
647 SendEditor(SCI_SETSELECTIONSTART
, selstart
);
648 SendEditor(SCI_SETSELECTIONEND
, selend
);
652 ::MessageBox(m_pFindDialog
&& m_pFindDialog
->GetSafeHwnd() ? m_pFindDialog
->GetSafeHwnd() : wMain
, L
"\"" + m_sFindText
+ L
"\" " + CString(MAKEINTRESOURCE(IDS_NOTFOUND
)), L
"TortoiseGitBlame", MB_ICONINFORMATION
);
657 void CTortoiseGitBlameView::OnFindPrev()
659 if (m_sFindText
.IsEmpty())
661 DoSearch(CTortoiseGitBlameData::SearchPrevious
);
664 void CTortoiseGitBlameView::OnFindNext()
666 if (m_sFindText
.IsEmpty())
668 DoSearch(CTortoiseGitBlameData::SearchNext
);
671 bool CTortoiseGitBlameView::GotoLine(int line
)
674 int numberOfLines
= m_data
.GetNumberOfLines();
675 if (line
< 0 || numberOfLines
== 0)
677 if (line
>= numberOfLines
)
679 line
= numberOfLines
- 1;
682 int nCurrentPos
= (int)SendEditor(SCI_GETCURRENTPOS
);
683 int nCurrentLine
= (int)SendEditor(SCI_LINEFROMPOSITION
,nCurrentPos
);
684 int nFirstVisibleLine
= (int)SendEditor(SCI_GETFIRSTVISIBLELINE
);
685 int nLinesOnScreen
= (int)SendEditor(SCI_LINESONSCREEN
);
687 if ( line
>=nFirstVisibleLine
&& line
<=nFirstVisibleLine
+nLinesOnScreen
)
690 SendEditor(SCI_GOTOLINE
, line
);
694 // Place the requested line one third from the top
695 if ( line
> nCurrentLine
)
697 SendEditor(SCI_GOTOLINE
, (WPARAM
)(line
+(int)nLinesOnScreen
*(2/3.0)));
701 SendEditor(SCI_GOTOLINE
, (WPARAM
)(line
-(int)nLinesOnScreen
*(1/3.0)));
705 // Highlight the line
706 int nPosStart
= (int)SendEditor(SCI_POSITIONFROMLINE
,line
);
707 int nPosEnd
= (int)SendEditor(SCI_GETLINEENDPOSITION
,line
);
708 SendEditor(SCI_SETSEL
,nPosEnd
,nPosStart
);
713 bool CTortoiseGitBlameView::ScrollToLine(long line
)
718 int nCurrentLine
= (int)SendEditor(SCI_GETFIRSTVISIBLELINE
);
720 int scrolldelta
= line
- nCurrentLine
;
721 SendEditor(SCI_LINESCROLL
, 0, scrolldelta
);
726 void CTortoiseGitBlameView::CopyToClipboard()
728 CWnd
* wnd
= GetFocus();
729 if (wnd
== this->GetLogList())
730 GetLogList()->CopySelectionToClipBoard();
733 if (CString(wnd
->GetRuntimeClass()->m_lpszClassName
) == L
"CMFCPropertyGridCtrl")
735 CMFCPropertyGridCtrl
*grid
= (CMFCPropertyGridCtrl
*)wnd
;
736 if (grid
->GetCurSel() && !grid
->GetCurSel()->IsGroup())
737 CStringUtils::WriteAsciiStringToClipboard(grid
->GetCurSel()->GetValue(), GetSafeHwnd());
740 m_TextView
.Call(SCI_COPY
);
744 LONG
CTortoiseGitBlameView::GetBlameWidth()
749 HDC hDC
= this->GetDC()->m_hDC
;
750 HFONT oldfont
= (HFONT
)::SelectObject(hDC
, m_font
.GetSafeHandle());
752 CString
shortHash('f', g_Git
.GetShortHASHLength() + 1);
753 ::GetTextExtentPoint32(hDC
, shortHash
, g_Git
.GetShortHASHLength() + 1, &width
);
754 m_revwidth
= width
.cx
+ BLAMESPACE
;
755 blamewidth
+= m_revwidth
;
761 int numberOfLines
= m_data
.GetNumberOfLines();
762 for (int i
= 0; i
< numberOfLines
; ++i
)
764 ::GetTextExtentPoint32(hDC
, m_data
.GetDate(i
), m_data
.GetDate(i
).GetLength(), &width
);
765 if (width
.cx
> maxwidth
.cx
)
768 m_datewidth
= maxwidth
.cx
+ BLAMESPACE
;
769 blamewidth
+= m_datewidth
;
775 int numberOfLines
= m_data
.GetNumberOfLines();
776 for (int i
= 0; i
< numberOfLines
; ++i
)
778 ::GetTextExtentPoint32(hDC
,m_data
.GetAuthor(i
) , m_data
.GetAuthor(i
).GetLength(), &width
);
779 if (width
.cx
> maxwidth
.cx
)
782 m_authorwidth
= maxwidth
.cx
+ BLAMESPACE
;
783 blamewidth
+= m_authorwidth
;
789 int numberOfLines
= m_data
.GetNumberOfLines();
790 for (int i
= 0; i
< numberOfLines
; ++i
)
792 ::GetTextExtentPoint32(hDC
, m_data
.GetFilename(i
), m_data
.GetFilename(i
).GetLength(), &width
);
793 if (width
.cx
> maxwidth
.cx
)
796 m_filenameWidth
= maxwidth
.cx
+ BLAMESPACE
;
797 blamewidth
+= m_filenameWidth
;
799 if (m_bShowOriginalLineNumber
)
803 int numberOfLines
= m_data
.GetNumberOfLines();
805 for (int i
= 0; i
< numberOfLines
; ++i
)
807 str
.Format(L
"%5d", m_data
.GetOriginalLineNumber(i
));
808 ::GetTextExtentPoint32(hDC
, str
, str
.GetLength(), &width
);
809 if (width
.cx
> maxwidth
.cx
)
812 m_originalLineNumberWidth
= maxwidth
.cx
+ BLAMESPACE
;
813 blamewidth
+= m_originalLineNumberWidth
;
815 ::SelectObject(hDC
, oldfont
);
816 POINT pt
= {blamewidth
, 0};
819 //::ReleaseDC(wBlame, hDC);
823 void CTortoiseGitBlameView::CreateFont()
825 if (m_font
.GetSafeHandle())
829 HDC hDC
= ::GetDC(wBlame
);
830 lf
.lfHeight
= -MulDiv((DWORD
)CRegStdDWORD(L
"Software\\TortoiseGit\\BlameFontSize", 10), GetDeviceCaps(hDC
, LOGPIXELSY
), 72);
831 lf
.lfCharSet
= DEFAULT_CHARSET
;
832 CRegStdString fontname
= CRegStdString(L
"Software\\TortoiseGit\\BlameFontName", L
"Consolas");
833 wcscpy_s(lf
.lfFaceName
, 32, ((std::wstring
)fontname
).c_str());
834 m_font
.CreateFontIndirect(&lf
);
837 m_italicfont
.CreateFontIndirect(&lf
);
839 ::ReleaseDC(wBlame
, hDC
);
842 void CTortoiseGitBlameView::DrawBlame(HDC hDC
)
846 if (!m_font
.GetSafeHandle())
849 HFONT oldfont
= nullptr;
850 int line
= (int)SendEditor(SCI_GETFIRSTVISIBLELINE
);
851 int linesonscreen
= (int)SendEditor(SCI_LINESONSCREEN
);
852 int height
= (int)SendEditor(SCI_TEXTHEIGHT
);
854 TCHAR buf
[MAX_PATH
] = {0};
857 //::GetClientRect(this->m_hWnd, &rc);
858 for (int i
= line
; i
< (line
+ linesonscreen
); ++i
)
861 if (i
< m_data
.GetNumberOfLines())
863 CGitHash
hash(m_data
.GetHash(i
));
864 // if (mergelines[i])
865 // oldfont = (HFONT)::SelectObject(hDC, m_italicfont.GetSafeHwnd());
867 oldfont
= (HFONT
)::SelectObject(hDC
, m_font
.GetSafeHandle());
868 ::SetBkColor(hDC
, m_windowcolor
);
869 ::SetTextColor(hDC
, m_textcolor
);
872 //if (m_CommitHash[i].Compare(m_MouseHash)==0)
873 // ::SetBkColor(hDC, m_mouseauthorcolor);
874 if (hash
== m_SelectedHash
)
876 ::SetBkColor(hDC
, m_selectedauthorcolor
);
877 ::SetTextColor(hDC
, m_texthighlightcolor
);
883 ::SetBkColor(hDC
, m_mouserevcolor
);
885 //if ((revs[i] == m_mouserev)&&(!sel))
886 // ::SetBkColor(hDC, m_mouserevcolor);
887 //if (revs[i] == m_selectedrev)
889 // ::SetBkColor(hDC, m_selectedrevcolor);
890 // ::SetTextColor(hDC, m_texthighlightcolor);
893 CString shortHashStr
;
894 shortHashStr
= hash
.ToString().Left(g_Git
.GetShortHASHLength());
896 //swprintf_s(buf, MAX_PATH, L"%8ld ", revs[i]);
898 rc
.left
=LOCATOR_WIDTH
;
899 rc
.bottom
= (LONG
)(Y
+ height
);
900 rc
.right
= rc
.left
+ m_blamewidth
;
901 ::ExtTextOut(hDC
, LOCATOR_WIDTH
, Y
, ETO_CLIPPED
, &rc
, shortHashStr
, shortHashStr
.GetLength(), 0);
902 int Left
= m_revwidth
;
906 rc
.right
= rc
.left
+ Left
+ m_authorwidth
;
907 ::ExtTextOut(hDC
, Left
, Y
, ETO_CLIPPED
, &rc
, m_data
.GetAuthor(i
), m_data
.GetAuthor(i
).GetLength(), 0);
908 Left
+= m_authorwidth
;
912 rc
.right
= rc
.left
+ Left
+ m_datewidth
;
913 ::ExtTextOut(hDC
, Left
, Y
, ETO_CLIPPED
, &rc
, m_data
.GetDate(i
), m_data
.GetDate(i
).GetLength(), 0);
918 rc
.right
= rc
.left
+ Left
+ m_filenameWidth
;
919 ::ExtTextOut(hDC
, Left
, (int)Y
, ETO_CLIPPED
, &rc
, m_data
.GetFilename(i
), m_data
.GetFilename(i
).GetLength(), 0);
920 Left
+= m_filenameWidth
;
922 if (m_bShowOriginalLineNumber
)
924 rc
.right
= rc
.left
+ Left
+ m_originalLineNumberWidth
;
926 str
.Format(L
"%5d", m_data
.GetOriginalLineNumber(i
));
927 ::ExtTextOut(hDC
, Left
, (int)Y
, ETO_CLIPPED
, &rc
, str
, str
.GetLength(), 0);
928 Left
+= m_originalLineNumberWidth
;
930 if ((i
==m_SelectedLine
)&&(m_pFindDialog
))
933 brush
.lbColor
= m_textcolor
;
935 brush
.lbStyle
= BS_SOLID
;
936 HPEN pen
= ExtCreatePen(PS_SOLID
| PS_GEOMETRIC
, 2, &brush
, 0, nullptr);
937 HGDIOBJ hPenOld
= SelectObject(hDC
, pen
);
940 rc2
.bottom
= (LONG
)(Y
+ height
);
941 ::MoveToEx(hDC
, rc2
.left
, rc2
.top
, nullptr);
942 ::LineTo(hDC
, rc2
.right
, rc2
.top
);
943 ::LineTo(hDC
, rc2
.right
, rc2
.bottom
);
944 ::LineTo(hDC
, rc2
.left
, rc2
.bottom
);
945 ::LineTo(hDC
, rc2
.left
, rc2
.top
);
946 SelectObject(hDC
, hPenOld
);
950 ::SelectObject(hDC
, oldfont
);
954 ::SetBkColor(hDC
, m_windowcolor
);
955 for (int j
=0; j
< MAX_PATH
; ++j
)
957 ::ExtTextOut(hDC
, 0, (int)Y
, ETO_CLIPPED
, &rc
, buf
, MAX_PATH
-1, 0);
963 void CTortoiseGitBlameView::DrawLocatorBar(HDC hDC
)
968 int line
= (int)SendEditor(SCI_GETFIRSTVISIBLELINE
);
969 int linesonscreen
= (int)SendEditor(SCI_LINESONSCREEN
);
971 COLORREF blackColor
= GetSysColor(COLOR_WINDOWTEXT
);
974 //::GetClientRect(wLocator, &rc);
975 this->GetClientRect(&rc
);
977 rc
.right
=LOCATOR_WIDTH
;
980 LONG height
= rc
.bottom
-rc
.top
;
982 int numberOfLines
= m_data
.GetNumberOfLines();
983 // draw the colored bar
984 for (int currentLine
= 0; currentLine
<numberOfLines
; ++currentLine
)
986 COLORREF cr
= GetLineColor(currentLine
);
987 // get the line color
988 if ((currentLine
>= line
)&&(currentLine
< (line
+ linesonscreen
)))
990 cr
= InterColor(cr
, blackColor
, 10);
993 lineRect
.top
= (LONG
)Y
;
994 lineRect
.bottom
= ((currentLine
+ 1) * height
/ numberOfLines
);
995 ::ExtTextOut(hDC
, 0, 0, ETO_OPAQUE
, &lineRect
, nullptr, 0, nullptr);
999 if (numberOfLines
> 0)
1001 // now draw two lines indicating the scroll position of the source view
1002 SetBkColor(hDC
, blackColor
);
1003 lineRect
.top
= (LONG
)line
* height
/ numberOfLines
;
1004 lineRect
.bottom
= lineRect
.top
+1;
1005 ::ExtTextOut(hDC
, 0, 0, ETO_OPAQUE
, &lineRect
, nullptr, 0, nullptr);
1006 lineRect
.top
= (LONG
)(line
+ linesonscreen
) * height
/ numberOfLines
;
1007 lineRect
.bottom
= lineRect
.top
+1;
1008 ::ExtTextOut(hDC
, 0, 0, ETO_OPAQUE
, &lineRect
, nullptr, 0, nullptr);
1012 void CTortoiseGitBlameView::SetupLexer(CString filename
)
1014 int start
= filename
.ReverseFind(L
'.');
1015 SendEditor(SCI_SETLEXER
, SCLEX_NULL
);
1020 //wcscpy_s(line, 20, lineptr+1);
1021 //_wcslwr_s(line, 20);
1022 CString ext
=filename
.Right(filename
.GetLength()-start
-1);
1023 const TCHAR
* line
= ext
;
1025 if ((wcscmp(line
, L
"py") == 0) ||
1026 (wcscmp(line
, L
"pyw") == 0))
1028 SendEditor(SCI_SETLEXER
, SCLEX_PYTHON
);
1029 SendEditor(SCI_SETKEYWORDS
, 0, (LPARAM
)(m_TextView
.StringForControl(L
"and assert break class continue def del elif \
1030 else except exec finally for from global if import in is lambda None \
1031 not or pass print raise return try while yield").GetBuffer()));
1032 SetAStyle(SCE_P_DEFAULT
, black
);
1033 SetAStyle(SCE_P_COMMENTLINE
, darkGreen
);
1034 SetAStyle(SCE_P_NUMBER
, RGB(0, 0x80, 0x80));
1035 SetAStyle(SCE_P_STRING
, RGB(0, 0, 0x80));
1036 SetAStyle(SCE_P_CHARACTER
, RGB(0, 0, 0x80));
1037 SetAStyle(SCE_P_WORD
, RGB(0x80, 0, 0x80));
1038 SetAStyle(SCE_P_TRIPLE
, black
);
1039 SetAStyle(SCE_P_TRIPLEDOUBLE
, black
);
1040 SetAStyle(SCE_P_CLASSNAME
, darkBlue
);
1041 SetAStyle(SCE_P_DEFNAME
, darkBlue
);
1042 SetAStyle(SCE_P_OPERATOR
, darkBlue
);
1043 SetAStyle(SCE_P_IDENTIFIER
, darkBlue
);
1044 SetAStyle(SCE_P_COMMENTBLOCK
, darkGreen
);
1045 SetAStyle(SCE_P_STRINGEOL
, red
);
1047 if ((wcscmp(line
, L
"c") == 0) ||
1048 (wcscmp(line
, L
"cc") == 0) ||
1049 (wcscmp(line
, L
"cpp") == 0) ||
1050 (wcscmp(line
, L
"cxx") == 0) ||
1051 (wcscmp(line
, L
"h") == 0) ||
1052 (wcscmp(line
, L
"hh") == 0) ||
1053 (wcscmp(line
, L
"hpp") == 0) ||
1054 (wcscmp(line
, L
"hxx") == 0) ||
1055 (wcscmp(line
, L
"dlg") == 0) ||
1056 (wcscmp(line
, L
"mak") == 0))
1058 SendEditor(SCI_SETLEXER
, SCLEX_CPP
);
1059 SendEditor(SCI_SETKEYWORDS
, 0, (LPARAM
)(m_TextView
.StringForControl(L
"and and_eq asm auto bitand bitor bool break \
1060 case catch char class compl const const_cast continue \
1061 default delete do double dynamic_cast else enum explicit export extern false float for \
1062 friend goto if inline int long mutable namespace new not not_eq \
1063 operator or or_eq private protected public \
1064 register reinterpret_cast return short signed sizeof static static_cast struct switch \
1065 template this throw true try typedef typeid typename union unsigned using \
1066 virtual void volatile wchar_t while xor xor_eq").GetBuffer()));
1067 SendEditor(SCI_SETKEYWORDS
, 3, (LPARAM
)(m_TextView
.StringForControl(L
"a addindex addtogroup anchor arg attention \
1068 author b brief bug c class code date def defgroup deprecated dontinclude \
1069 e em endcode endhtmlonly endif endlatexonly endlink endverbatim enum example exception \
1070 f$ f[ f] file fn hideinitializer htmlinclude htmlonly \
1071 if image include ingroup internal invariant interface latexonly li line link \
1072 mainpage name namespace nosubgrouping note overload \
1073 p page par param post pre ref relates remarks return retval \
1074 sa section see showinitializer since skip skipline struct subsection \
1075 test throw todo typedef union until \
1076 var verbatim verbinclude version warning weakgroup $ @ \\ & < > # { }").GetBuffer()));
1079 if (wcscmp(line
, L
"cs") == 0)
1081 SendEditor(SCI_SETLEXER
, SCLEX_CPP
);
1082 SendEditor(SCI_SETKEYWORDS
, 0, (LPARAM
)(m_TextView
.StringForControl(L
"abstract as base bool break byte case catch char checked class \
1083 const continue decimal default delegate do double else enum \
1084 event explicit extern false finally fixed float for foreach goto if \
1085 implicit in int interface internal is lock long namespace new null \
1086 object operator out override params private protected public \
1087 readonly ref return sbyte sealed short sizeof stackalloc static \
1088 string struct switch this throw true try typeof uint ulong \
1089 unchecked unsafe ushort using virtual void while").GetBuffer()));
1092 if ((wcscmp(line
, L
"rc") == 0) ||
1093 (wcscmp(line
, L
"rc2") == 0))
1095 SendEditor(SCI_SETLEXER
, SCLEX_CPP
);
1096 SendEditor(SCI_SETKEYWORDS
, 0, (LPARAM
)(m_TextView
.StringForControl(L
"ACCELERATORS ALT AUTO3STATE AUTOCHECKBOX AUTORADIOBUTTON \
1097 BEGIN BITMAP BLOCK BUTTON CAPTION CHARACTERISTICS CHECKBOX CLASS \
1098 COMBOBOX CONTROL CTEXT CURSOR DEFPUSHBUTTON DIALOG DIALOGEX DISCARDABLE \
1099 EDITTEXT END EXSTYLE FONT GROUPBOX ICON LANGUAGE LISTBOX LTEXT \
1100 MENU MENUEX MENUITEM MESSAGETABLE POPUP \
1101 PUSHBUTTON RADIOBUTTON RCDATA RTEXT SCROLLBAR SEPARATOR SHIFT STATE3 \
1102 STRINGTABLE STYLE TEXTINCLUDE VALUE VERSION VERSIONINFO VIRTKEY").GetBuffer()));
1105 if ((wcscmp(line
, L
"idl") == 0) ||
1106 (wcscmp(line
, L
"odl") == 0))
1108 SendEditor(SCI_SETLEXER
, SCLEX_CPP
);
1109 SendEditor(SCI_SETKEYWORDS
, 0, (LPARAM
)(m_TextView
.StringForControl(L
"aggregatable allocate appobject arrays async async_uuid \
1111 bindable boolean broadcast byte byte_count \
1112 call_as callback char coclass code comm_status \
1113 const context_handle context_handle_noserialize \
1114 context_handle_serialize control cpp_quote custom \
1115 decode default defaultbind defaultcollelem \
1116 defaultvalue defaultvtable dispinterface displaybind dllname \
1118 enable_allocate encode endpoint entry enum error_status_t \
1120 fault_status first_is float \
1121 handle_t heap helpcontext helpfile helpstring \
1122 helpstringcontext helpstringdll hidden hyper \
1123 id idempotent ignore iid_as iid_is immediatebind implicit_handle \
1124 import importlib in include in_line int __int64 __int3264 interface \
1125 last_is lcid length_is library licensed local long \
1126 max_is maybe message methods midl_pragma \
1127 midl_user_allocate midl_user_free min_is module ms_union \
1128 ncacn_at_dsp ncacn_dnet_nsp ncacn_http ncacn_ip_tcp \
1129 ncacn_nb_ipx ncacn_nb_nb ncacn_nb_tcp ncacn_np \
1130 ncacn_spx ncacn_vns_spp ncadg_ip_udp ncadg_ipx ncadg_mq \
1131 ncalrpc nocode nonbrowsable noncreatable nonextensible notify \
1132 object odl oleautomation optimize optional out out_of_line \
1133 pipe pointer_default pragma properties propget propput propputref \
1135 range readonly ref represent_as requestedit restricted retval \
1136 shape short signed size_is small source strict_context_handle \
1137 string struct switch switch_is switch_type \
1138 transmit_as typedef \
1139 uidefault union unique unsigned user_marshal usesgetlasterror uuid \
1140 v1_enum vararg version void wchar_t wire_marshal").GetBuffer()));
1143 if (wcscmp(line
, L
"java") == 0)
1145 SendEditor(SCI_SETLEXER
, SCLEX_CPP
);
1146 SendEditor(SCI_SETKEYWORDS
, 0, (LPARAM
)(m_TextView
.StringForControl(L
"abstract assert boolean break byte case catch char class \
1147 const continue default do double else extends final finally float for future \
1148 generic goto if implements import inner instanceof int interface long \
1149 native new null outer package private protected public rest \
1150 return short static super switch synchronized this throw throws \
1151 transient try var void volatile while").GetBuffer()));
1154 if (wcscmp(line
, L
"js") == 0)
1156 SendEditor(SCI_SETLEXER
, SCLEX_CPP
);
1157 SendEditor(SCI_SETKEYWORDS
, 0, (LPARAM
)(m_TextView
.StringForControl(L
"abstract boolean break byte case catch char class \
1158 const continue debugger default delete do double else enum export extends \
1159 final finally float for function goto if implements import in instanceof \
1160 int interface long native new package private protected public \
1161 return short static super switch synchronized this throw throws \
1162 transient try typeof var void volatile while with").GetBuffer()));
1165 if ((wcscmp(line
, L
"pas") == 0) ||
1166 (wcscmp(line
, L
"dpr") == 0) ||
1167 (wcscmp(line
, L
"pp") == 0))
1169 SendEditor(SCI_SETLEXER
, SCLEX_PASCAL
);
1170 SendEditor(SCI_SETKEYWORDS
, 0, (LPARAM
)(m_TextView
.StringForControl(L
"and array as begin case class const constructor \
1171 destructor div do downto else end except file finally \
1172 for function goto if implementation in inherited \
1173 interface is mod not object of on or packed \
1174 procedure program property raise record repeat \
1175 set shl shr then threadvar to try type unit \
1176 until uses var while with xor").GetBuffer()));
1179 if ((wcscmp(line
, L
"as") == 0) ||
1180 (wcscmp(line
, L
"asc") == 0) ||
1181 (wcscmp(line
, L
"jsfl") == 0))
1183 SendEditor(SCI_SETLEXER
, SCLEX_CPP
);
1184 SendEditor(SCI_SETKEYWORDS
, 0, (LPARAM
)(m_TextView
.StringForControl(L
"add and break case catch class continue default delete do \
1185 dynamic else eq extends false finally for function ge get gt if implements import in \
1186 instanceof interface intrinsic le lt ne new not null or private public return \
1187 set static super switch this throw true try typeof undefined var void while with").GetBuffer()));
1188 SendEditor(SCI_SETKEYWORDS
, 1, (LPARAM
)(m_TextView
.StringForControl(L
"Array Arguments Accessibility Boolean Button Camera Color \
1189 ContextMenu ContextMenuItem Date Error Function Key LoadVars LocalConnection Math \
1190 Microphone Mouse MovieClip MovieClipLoader NetConnection NetStream Number Object \
1191 PrintJob Selection SharedObject Sound Stage String StyleSheet System TextField \
1192 TextFormat TextSnapshot Video Void XML XMLNode XMLSocket \
1193 _accProps _focusrect _global _highquality _parent _quality _root _soundbuftime \
1194 arguments asfunction call capabilities chr clearInterval duplicateMovieClip \
1195 escape eval fscommand getProperty getTimer getURL getVersion gotoAndPlay gotoAndStop \
1196 ifFrameLoaded Infinity -Infinity int isFinite isNaN length loadMovie loadMovieNum \
1197 loadVariables loadVariablesNum maxscroll mbchr mblength mbord mbsubstring MMExecute \
1198 NaN newline nextFrame nextScene on onClipEvent onUpdate ord parseFloat parseInt play \
1199 prevFrame prevScene print printAsBitmap printAsBitmapNum printNum random removeMovieClip \
1200 scroll set setInterval setProperty startDrag stop stopAllSounds stopDrag substring \
1201 targetPath tellTarget toggleHighQuality trace unescape unloadMovie unLoadMovieNum updateAfterEvent").GetBuffer()));
1204 if ((wcscmp(line
, L
"html") == 0) ||
1205 (wcscmp(line
, L
"htm") == 0) ||
1206 (wcscmp(line
, L
"shtml") == 0) ||
1207 (wcscmp(line
, L
"htt") == 0) ||
1208 (wcscmp(line
, L
"xml") == 0) ||
1209 (wcscmp(line
, L
"asp") == 0) ||
1210 (wcscmp(line
, L
"xsl") == 0) ||
1211 (wcscmp(line
, L
"php") == 0) ||
1212 (wcscmp(line
, L
"xhtml") == 0) ||
1213 (wcscmp(line
, L
"phtml") == 0) ||
1214 (wcscmp(line
, L
"cfm") == 0) ||
1215 (wcscmp(line
, L
"tpl") == 0) ||
1216 (wcscmp(line
, L
"dtd") == 0) ||
1217 (wcscmp(line
, L
"hta") == 0) ||
1218 (wcscmp(line
, L
"htd") == 0) ||
1219 (wcscmp(line
, L
"wxs") == 0))
1221 SendEditor(SCI_SETLEXER
, SCLEX_HTML
);
1222 SendEditor(SCI_SETSTYLEBITS
, 7);
1223 SendEditor(SCI_SETKEYWORDS
, 0, (LPARAM
)(m_TextView
.StringForControl(L
"a abbr acronym address applet area b base basefont \
1224 bdo big blockquote body br button caption center \
1225 cite code col colgroup dd del dfn dir div dl dt em \
1226 fieldset font form frame frameset h1 h2 h3 h4 h5 h6 \
1227 head hr html i iframe img input ins isindex kbd label \
1228 legend li link map menu meta noframes noscript \
1229 object ol optgroup option p param pre q s samp \
1230 script select small span strike strong style sub sup \
1231 table tbody td textarea tfoot th thead title tr tt u ul \
1232 var xml xmlns abbr accept-charset accept accesskey action align alink \
1233 alt archive axis background bgcolor border \
1234 cellpadding cellspacing char charoff charset checked cite \
1235 class classid clear codebase codetype color cols colspan \
1236 compact content coords \
1237 data datafld dataformatas datapagesize datasrc datetime \
1238 declare defer dir disabled enctype event \
1239 face for frame frameborder \
1240 headers height href hreflang hspace http-equiv \
1241 id ismap label lang language leftmargin link longdesc \
1242 marginwidth marginheight maxlength media method multiple \
1243 name nohref noresize noshade nowrap \
1244 object onblur onchange onclick ondblclick onfocus \
1245 onkeydown onkeypress onkeyup onload onmousedown \
1246 onmousemove onmouseover onmouseout onmouseup \
1247 onreset onselect onsubmit onunload \
1248 profile prompt readonly rel rev rows rowspan rules \
1249 scheme scope selected shape size span src standby start style \
1250 summary tabindex target text title topmargin type usemap \
1251 valign value valuetype version vlink vspace width \
1252 text password checkbox radio submit reset \
1253 file hidden image").GetBuffer()));
1254 SendEditor(SCI_SETKEYWORDS
, 1, (LPARAM
)(m_TextView
.StringForControl(L
"assign audio block break catch choice clear disconnect else elseif \
1255 emphasis enumerate error exit field filled form goto grammar help \
1256 if initial link log menu meta noinput nomatch object option p paragraph \
1257 param phoneme prompt property prosody record reprompt return s say-as \
1258 script sentence subdialog submit throw transfer value var voice vxml").GetBuffer()));
1259 SendEditor(SCI_SETKEYWORDS
, 2, (LPARAM
)(m_TextView
.StringForControl(L
"accept age alphabet anchor application base beep bridge category charset \
1260 classid cond connecttimeout content contour count dest destexpr dtmf dtmfterm \
1261 duration enctype event eventexpr expr expritem fetchtimeout finalsilence \
1262 gender http-equiv id level maxage maxstale maxtime message messageexpr \
1263 method mime modal mode name namelist next nextitem ph pitch range rate \
1264 scope size sizeexpr skiplist slot src srcexpr sub time timeexpr timeout \
1265 transferaudio type value variant version volume xml:lang").GetBuffer()));
1266 SendEditor(SCI_SETKEYWORDS
, 3, (LPARAM
)(m_TextView
.StringForControl(L
"and assert break class continue def del elif \
1267 else except exec finally for from global if import in is lambda None \
1268 not or pass print raise return try while yield").GetBuffer()));
1269 SendEditor(SCI_SETKEYWORDS
, 4, (LPARAM
)(m_TextView
.StringForControl(L
"and argv as argc break case cfunction class continue declare default do \
1270 die echo else elseif empty enddeclare endfor endforeach endif endswitch \
1271 endwhile e_all e_parse e_error e_warning eval exit extends false for \
1272 foreach function global http_cookie_vars http_get_vars http_post_vars \
1273 http_post_files http_env_vars http_server_vars if include include_once \
1274 list new not null old_function or parent php_os php_self php_version \
1275 print require require_once return static switch stdclass this true var \
1276 xor virtual while __file__ __line__ __sleep __wakeup").GetBuffer()));
1278 SetAStyle(SCE_H_TAG
, darkBlue
);
1279 SetAStyle(SCE_H_TAGUNKNOWN
, red
);
1280 SetAStyle(SCE_H_ATTRIBUTE
, darkBlue
);
1281 SetAStyle(SCE_H_ATTRIBUTEUNKNOWN
, red
);
1282 SetAStyle(SCE_H_NUMBER
, RGB(0x80,0,0x80));
1283 SetAStyle(SCE_H_DOUBLESTRING
, RGB(0,0x80,0));
1284 SetAStyle(SCE_H_SINGLESTRING
, RGB(0,0x80,0));
1285 SetAStyle(SCE_H_OTHER
, RGB(0x80,0,0x80));
1286 SetAStyle(SCE_H_COMMENT
, RGB(0x80,0x80,0));
1287 SetAStyle(SCE_H_ENTITY
, RGB(0x80,0,0x80));
1289 SetAStyle(SCE_H_TAGEND
, darkBlue
);
1290 SetAStyle(SCE_H_XMLSTART
, darkBlue
); // <?
1291 SetAStyle(SCE_H_QUESTION
, darkBlue
); // <?
1292 SetAStyle(SCE_H_XMLEND
, darkBlue
); // ?>
1293 SetAStyle(SCE_H_SCRIPT
, darkBlue
); // <script
1294 SetAStyle(SCE_H_ASP
, RGB(0x4F, 0x4F, 0), RGB(0xFF, 0xFF, 0)); // <% ... %>
1295 SetAStyle(SCE_H_ASPAT
, RGB(0x4F, 0x4F, 0), RGB(0xFF, 0xFF, 0)); // <%@ ... %>
1297 SetAStyle(SCE_HB_DEFAULT
, black
);
1298 SetAStyle(SCE_HB_COMMENTLINE
, darkGreen
);
1299 SetAStyle(SCE_HB_NUMBER
, RGB(0,0x80,0x80));
1300 SetAStyle(SCE_HB_WORD
, darkBlue
);
1301 SendEditor(SCI_STYLESETBOLD
, SCE_HB_WORD
, 1);
1302 SetAStyle(SCE_HB_STRING
, RGB(0x80,0,0x80));
1303 SetAStyle(SCE_HB_IDENTIFIER
, black
);
1305 // This light blue is found in the windows system palette so is safe to use even in 256 colour modes.
1306 // Show the whole section of VBScript with light blue background
1307 for (int bstyle
= SCE_HB_DEFAULT
; bstyle
<= SCE_HB_STRINGEOL
; ++bstyle
) {
1308 SendEditor(SCI_STYLESETFONT
, bstyle
,
1309 reinterpret_cast<LPARAM
>(m_TextView
.StringForControl(L
"Lucida Console").GetBuffer()));
1310 SendEditor(SCI_STYLESETBACK
, bstyle
, lightBlue
);
1311 // This call extends the backround colour of the last style on the line to the edge of the window
1312 SendEditor(SCI_STYLESETEOLFILLED
, bstyle
, 1);
1314 SendEditor(SCI_STYLESETBACK
, SCE_HB_STRINGEOL
, RGB(0x7F,0x7F,0xFF));
1315 SendEditor(SCI_STYLESETFONT
, SCE_HB_COMMENTLINE
,
1316 reinterpret_cast<LPARAM
>(m_TextView
.StringForControl(L
"Lucida Console").GetBuffer()));
1318 SetAStyle(SCE_HBA_DEFAULT
, black
);
1319 SetAStyle(SCE_HBA_COMMENTLINE
, darkGreen
);
1320 SetAStyle(SCE_HBA_NUMBER
, RGB(0,0x80,0x80));
1321 SetAStyle(SCE_HBA_WORD
, darkBlue
);
1322 SendEditor(SCI_STYLESETBOLD
, SCE_HBA_WORD
, 1);
1323 SetAStyle(SCE_HBA_STRING
, RGB(0x80,0,0x80));
1324 SetAStyle(SCE_HBA_IDENTIFIER
, black
);
1326 // Show the whole section of ASP VBScript with bright yellow background
1327 for (int bastyle
= SCE_HBA_DEFAULT
; bastyle
<= SCE_HBA_STRINGEOL
; ++bastyle
) {
1328 SendEditor(SCI_STYLESETFONT
, bastyle
,
1329 reinterpret_cast<LPARAM
>(m_TextView
.StringForControl(L
"Lucida Console").GetBuffer()));
1330 SendEditor(SCI_STYLESETBACK
, bastyle
, RGB(0xFF, 0xFF, 0));
1331 // This call extends the backround colour of the last style on the line to the edge of the window
1332 SendEditor(SCI_STYLESETEOLFILLED
, bastyle
, 1);
1334 SendEditor(SCI_STYLESETBACK
, SCE_HBA_STRINGEOL
, RGB(0xCF,0xCF,0x7F));
1335 SendEditor(SCI_STYLESETFONT
, SCE_HBA_COMMENTLINE
,
1336 reinterpret_cast<LPARAM
>(m_TextView
.StringForControl(L
"Lucida Console").GetBuffer()));
1338 // If there is no need to support embedded Javascript, the following code can be dropped.
1339 // Javascript will still be correctly processed but will be displayed in just the default style.
1341 SetAStyle(SCE_HJ_START
, RGB(0x80,0x80,0));
1342 SetAStyle(SCE_HJ_DEFAULT
, black
);
1343 SetAStyle(SCE_HJ_COMMENT
, darkGreen
);
1344 SetAStyle(SCE_HJ_COMMENTLINE
, darkGreen
);
1345 SetAStyle(SCE_HJ_COMMENTDOC
, darkGreen
);
1346 SetAStyle(SCE_HJ_NUMBER
, RGB(0,0x80,0x80));
1347 SetAStyle(SCE_HJ_WORD
, black
);
1348 SetAStyle(SCE_HJ_KEYWORD
, darkBlue
);
1349 SetAStyle(SCE_HJ_DOUBLESTRING
, RGB(0x80,0,0x80));
1350 SetAStyle(SCE_HJ_SINGLESTRING
, RGB(0x80,0,0x80));
1351 SetAStyle(SCE_HJ_SYMBOLS
, black
);
1353 SetAStyle(SCE_HJA_START
, RGB(0x80,0x80,0));
1354 SetAStyle(SCE_HJA_DEFAULT
, black
);
1355 SetAStyle(SCE_HJA_COMMENT
, darkGreen
);
1356 SetAStyle(SCE_HJA_COMMENTLINE
, darkGreen
);
1357 SetAStyle(SCE_HJA_COMMENTDOC
, darkGreen
);
1358 SetAStyle(SCE_HJA_NUMBER
, RGB(0,0x80,0x80));
1359 SetAStyle(SCE_HJA_WORD
, black
);
1360 SetAStyle(SCE_HJA_KEYWORD
, darkBlue
);
1361 SetAStyle(SCE_HJA_DOUBLESTRING
, RGB(0x80,0,0x80));
1362 SetAStyle(SCE_HJA_SINGLESTRING
, RGB(0x80,0,0x80));
1363 SetAStyle(SCE_HJA_SYMBOLS
, black
);
1365 SetAStyle(SCE_HPHP_DEFAULT
, black
);
1366 SetAStyle(SCE_HPHP_HSTRING
, RGB(0x80,0,0x80));
1367 SetAStyle(SCE_HPHP_SIMPLESTRING
, RGB(0x80,0,0x80));
1368 SetAStyle(SCE_HPHP_WORD
, darkBlue
);
1369 SetAStyle(SCE_HPHP_NUMBER
, RGB(0,0x80,0x80));
1370 SetAStyle(SCE_HPHP_VARIABLE
, red
);
1371 SetAStyle(SCE_HPHP_HSTRING_VARIABLE
, red
);
1372 SetAStyle(SCE_HPHP_COMPLEX_VARIABLE
, red
);
1373 SetAStyle(SCE_HPHP_COMMENT
, darkGreen
);
1374 SetAStyle(SCE_HPHP_COMMENTLINE
, darkGreen
);
1375 SetAStyle(SCE_HPHP_OPERATOR
, darkBlue
);
1377 // Show the whole section of Javascript with off white background
1378 for (int jstyle
= SCE_HJ_DEFAULT
; jstyle
<= SCE_HJ_SYMBOLS
; ++jstyle
) {
1379 SendEditor(SCI_STYLESETFONT
, jstyle
,
1380 reinterpret_cast<LPARAM
>(m_TextView
.StringForControl(L
"Lucida Console").GetBuffer()));
1381 SendEditor(SCI_STYLESETBACK
, jstyle
, offWhite
);
1382 SendEditor(SCI_STYLESETEOLFILLED
, jstyle
, 1);
1384 SendEditor(SCI_STYLESETBACK
, SCE_HJ_STRINGEOL
, RGB(0xDF, 0xDF, 0x7F));
1385 SendEditor(SCI_STYLESETEOLFILLED
, SCE_HJ_STRINGEOL
, 1);
1387 // Show the whole section of Javascript with brown background
1388 for (int jastyle
= SCE_HJA_DEFAULT
; jastyle
<= SCE_HJA_SYMBOLS
; ++jastyle
) {
1389 SendEditor(SCI_STYLESETFONT
, jastyle
,
1390 reinterpret_cast<LPARAM
>(m_TextView
.StringForControl(L
"Lucida Console").GetBuffer()));
1391 SendEditor(SCI_STYLESETBACK
, jastyle
, RGB(0xDF, 0xDF, 0x7F));
1392 SendEditor(SCI_STYLESETEOLFILLED
, jastyle
, 1);
1394 SendEditor(SCI_STYLESETBACK
, SCE_HJA_STRINGEOL
, RGB(0x0,0xAF,0x5F));
1395 SendEditor(SCI_STYLESETEOLFILLED
, SCE_HJA_STRINGEOL
, 1);
1400 SendEditor(SCI_SETLEXER
, SCLEX_CPP
);
1403 SendEditor(SCI_COLOURISE
, 0, -1);
1406 void CTortoiseGitBlameView::SetupCppLexer()
1408 SetAStyle(SCE_C_DEFAULT
, RGB(0, 0, 0));
1409 SetAStyle(SCE_C_COMMENT
, RGB(0, 0x80, 0));
1410 SetAStyle(SCE_C_COMMENTLINE
, RGB(0, 0x80, 0));
1411 SetAStyle(SCE_C_COMMENTDOC
, RGB(0, 0x80, 0));
1412 SetAStyle(SCE_C_COMMENTLINEDOC
, RGB(0, 0x80, 0));
1413 SetAStyle(SCE_C_COMMENTDOCKEYWORD
, RGB(0, 0x80, 0));
1414 SetAStyle(SCE_C_COMMENTDOCKEYWORDERROR
, RGB(0, 0x80, 0));
1415 SetAStyle(SCE_C_NUMBER
, RGB(0, 0x80, 0x80));
1416 SetAStyle(SCE_C_WORD
, RGB(0, 0, 0x80));
1417 SendEditor(SCE_C_WORD
, 1);
1418 SetAStyle(SCE_C_STRING
, RGB(0x80, 0, 0x80));
1419 SetAStyle(SCE_C_IDENTIFIER
, RGB(0, 0, 0));
1420 SetAStyle(SCE_C_PREPROCESSOR
, RGB(0x80, 0, 0));
1421 SetAStyle(SCE_C_OPERATOR
, RGB(0x80, 0x80, 0));
1422 SendEditor(SCI_SETPROPERTY
, (WPARAM
)"lexer.cpp.track.preprocessor", (LPARAM
)"0");
1425 int CTortoiseGitBlameView::GetEncode(unsigned char *buff
, int size
, int *bomoffset
)
1427 CFileTextLines textlines
;
1428 CFileTextLines::UnicodeType type
= textlines
.CheckUnicodeType(buff
, size
);
1430 if(type
== CFileTextLines::UTF8BOM
)
1435 if(type
== CFileTextLines::UTF8
)
1438 if(type
== CFileTextLines::UTF16_LE
)
1440 if (type
== CFileTextLines::UTF16_LEBOM
)
1446 if(type
== CFileTextLines::UTF16_BE
)
1448 if (type
== CFileTextLines::UTF16_BEBOM
)
1457 void CTortoiseGitBlameView::ParseBlame()
1459 m_data
.ParseBlameOutput(GetDocument()->m_BlameData
, GetLogData()->m_pLogCache
->m_HashMap
, m_DateFormat
, m_bRelativeTimes
);
1460 CString filename
= GetDocument()->m_GitPath
.GetGitPathString();
1461 m_bBlameOuputContainsOtherFilenames
= m_data
.ContainsOnlyFilename(filename
) ? FALSE
: TRUE
;
1464 void CTortoiseGitBlameView::MapLineToLogIndex()
1466 std::vector
<int> lineToLogIndex
;
1469 int numberOfLines
= m_data
.GetNumberOfLines();
1470 lineToLogIndex
.reserve(numberOfLines
);
1471 size_t logSize
= this->GetLogData()->size();
1472 for (int j
= 0; j
< numberOfLines
; ++j
)
1474 CGitHash
& hash
= m_data
.GetHash(j
);
1477 for (size_t i
= 0; i
< logSize
; ++i
)
1479 if (hash
== this->GetLogData()->at(i
))
1485 lineToLogIndex
.push_back(index
);
1487 this->m_lineToLogIndex
.swap(lineToLogIndex
);
1490 void CTortoiseGitBlameView::UpdateInfo(int Encode
)
1495 SendEditor(SCI_SETREADONLY
, FALSE
);
1496 SendEditor(SCI_CLEARALL
);
1497 SendEditor(EM_EMPTYUNDOBUFFER
);
1498 SendEditor(SCI_SETSAVEPOINT
);
1499 SendEditor(SCI_CANCEL
);
1500 SendEditor(SCI_SETUNDOCOLLECTION
, 0);
1502 SendEditor(SCI_SETCODEPAGE
, SC_CP_UTF8
);
1504 int encoding
= m_data
.UpdateEncoding(Encode
);
1506 int numberOfLines
= m_data
.GetNumberOfLines();
1507 if (numberOfLines
> 0)
1510 for (int i
= 0; i
< numberOfLines
; ++i
)
1512 text
+= m_data
.GetUtf8Line(i
);
1515 text
.TrimRight("\r\n");
1516 SendEditor(SCI_REPLACESEL
, 0, (LPARAM
)(LPCSTR
)text
);
1523 int nIndex
= ((CMainFrame
*)::AfxGetApp()->GetMainWnd())->m_wndStatusBar
.CommandToIndex(ID_INDICATOR_ENCODING
);
1524 ((CMainFrame
*)::AfxGetApp()->GetMainWnd())->m_wndStatusBar
.GetPaneInfo(nIndex
, nID
, nStyle
, cxWidth
);
1526 for (int i
= 0; i
< _countof(encodings
); ++i
)
1528 if (encodings
[i
].id
== encoding
)
1530 sBarText
= CString(encodings
[i
].name
);
1534 //calculate the width of the text
1535 CDC
* pDC
= ((CMainFrame
*)::AfxGetApp()->GetMainWnd())->m_wndStatusBar
.GetDC();
1538 CSize size
= pDC
->GetTextExtent(sBarText
);
1539 ((CMainFrame
*)::AfxGetApp()->GetMainWnd())->m_wndStatusBar
.SetPaneInfo(nIndex
, nID
, nStyle
, size
.cx
+2);
1542 ((CMainFrame
*)::AfxGetApp()->GetMainWnd())->m_wndStatusBar
.SetPaneText(nIndex
, sBarText
);
1545 #ifdef USE_TEMPFILENAME
1550 file
.Open(this->GetDocument()->m_TempFileName
,CFile::modeRead
);
1552 m_Buffer
= new char[file
.GetLength()+4];
1553 m_Buffer
[file
.GetLength()] =0;
1554 m_Buffer
[file
.GetLength()+1] =0;
1555 m_Buffer
[file
.GetLength()+2] =0;
1556 m_Buffer
[file
.GetLength()+3] =0;
1558 file
.Read(m_Buffer
, file
.GetLength());
1561 int encoding
= GetEncode( (unsigned char *)m_Buffer
, file
.GetLength(), &bomoffset
);
1564 //SendEditor(SCI_SETCODEPAGE, encoding);
1566 //SendEditor(SCI_REPLACESEL, 0, (LPARAM)(LPCSTR)(m_Buffer + bomoffset));
1568 SetupLexer(GetDocument()->m_CurrentFileName
);
1570 SendEditor(SCI_SETUNDOCOLLECTION
, 1);
1571 SendEditor(EM_EMPTYUNDOBUFFER
);
1572 SendEditor(SCI_SETSAVEPOINT
);
1573 SendEditor(SCI_GOTOPOS
, 0);
1574 SendEditor(SCI_SETSCROLLWIDTHTRACKING
, TRUE
);
1575 SendEditor(SCI_SETREADONLY
, TRUE
);
1579 this->GetClientRect(rect
);
1580 //this->m_TextView.GetWindowRect(rect);
1581 //this->m_TextView.ScreenToClient(rect);
1582 rect
.left
=this->m_blamewidth
;
1583 this->m_TextView
.MoveWindow(rect
);
1588 CString
CTortoiseGitBlameView::ResolveCommitFile(int line
)
1590 return ResolveCommitFile(m_data
.GetFilename(line
));
1593 CString
CTortoiseGitBlameView::ResolveCommitFile(const CString
& path
)
1597 return ((CMainFrame
*)::AfxGetApp()->GetMainWnd())->GetActiveView()->GetDocument()->GetPathName();
1601 return g_Git
.CombinePath(path
);
1605 COLORREF
CTortoiseGitBlameView::GetLineColor(int line
)
1607 if (m_colorage
&& line
>= 0 && (size_t)line
< m_lineToLogIndex
.size())
1609 int logIndex
= m_lineToLogIndex
[line
];
1612 int slider
= (int)((GetLogData()->size() - logIndex
) * 100 / (GetLogData()->size() + 1));
1613 return InterColor(DWORD(m_regOldLinesColor
), DWORD(m_regNewLinesColor
), slider
);
1616 return m_windowcolor
;
1619 CGitBlameLogList
* CTortoiseGitBlameView::GetLogList()
1621 return &(GetDocument()->GetMainFrame()->m_wndOutput
.m_LogList
);
1625 CLogDataVector
* CTortoiseGitBlameView::GetLogData()
1627 return &(GetDocument()->GetMainFrame()->m_wndOutput
.m_LogList
.m_logEntries
);
1630 void CTortoiseGitBlameView::OnSciPainted(NMHDR
*,LRESULT
*)
1635 void CTortoiseGitBlameView::OnLButtonDown(UINT nFlags
,CPoint point
)
1637 int line
= (int)SendEditor(SCI_GETFIRSTVISIBLELINE
);
1638 int height
= (int)SendEditor(SCI_TEXTHEIGHT
);
1639 line
= line
+ (int)(point
.y
/height
);
1641 if (line
< m_data
.GetNumberOfLines())
1643 SetSelectedLine(line
);
1644 if (m_data
.GetHash(line
) != m_SelectedHash
)
1646 m_SelectedHash
= m_data
.GetHash(line
);
1648 int logIndex
= m_lineToLogIndex
[line
];
1651 this->GetLogList()->SetItemState(logIndex
, LVIS_SELECTED
, LVIS_SELECTED
);
1652 this->GetLogList()->EnsureVisible(logIndex
, FALSE
);
1656 GitRevLoglist
* pRev
= m_data
.GetRev(line
, GetLogData()->m_pLogCache
->m_HashMap
);
1657 this->GetDocument()->GetMainFrame()->m_wndProperties
.UpdateProperties(pRev
);
1662 m_SelectedHash
.Empty();
1664 //::InvalidateRect(nullptr, FALSE);
1666 this->m_TextView
.Invalidate();
1671 SetSelectedLine(-1);
1674 CView::OnLButtonDown(nFlags
,point
);
1677 void CTortoiseGitBlameView::OnSciGetBkColor(NMHDR
* hdr
, LRESULT
* /*result*/)
1679 SCNotification
*notification
=reinterpret_cast<SCNotification
*>(hdr
);
1681 if (notification
->line
< m_data
.GetNumberOfLines())
1683 if (m_data
.GetHash(notification
->line
) == this->m_SelectedHash
)
1684 notification
->lParam
= m_selectedauthorcolor
;
1686 notification
->lParam
= GetLineColor(notification
->line
);
1690 void CTortoiseGitBlameView::FocusOn(GitRevLoglist
* pRev
)
1692 this->GetDocument()->GetMainFrame()->m_wndProperties
.UpdateProperties(pRev
);
1696 if (m_SelectedHash
!= pRev
->m_CommitHash
) {
1697 m_SelectedHash
= pRev
->m_CommitHash
;
1698 int line
= m_data
.FindFirstLine(m_SelectedHash
, 0);
1702 m_TextView
.Invalidate();
1705 SendEditor(SCI_SETSEL
, INT_MAX
, -1);
1709 void CTortoiseGitBlameView::OnMouseHover(UINT
/*nFlags*/, CPoint point
)
1711 int line
= (int)SendEditor(SCI_GETFIRSTVISIBLELINE
);
1712 int height
= (int)SendEditor(SCI_TEXTHEIGHT
);
1713 line
= line
+ (point
.y
/height
);
1715 if (m_data
.IsValidLine(line
))
1717 if (line
!= m_MouseLine
)
1720 GitRev
*pRev
= nullptr;
1721 int logIndex
= m_lineToLogIndex
[line
];
1723 pRev
= &GetLogData()->GetGitRevAt(logIndex
);
1725 pRev
= m_data
.GetRev(line
, GetLogData()->m_pLogCache
->m_HashMap
);
1730 CString body
= pRev
->GetBody();
1734 while (iline
++ < maxLine
)
1736 int pos2
= body
.Find(L
'\n', pos
);
1739 int lineLength
= pos2
- pos
- 1;
1741 iline
+= lineLength
/ 70;
1745 if ((m_bShowCompleteLog
&& m_bFollowRenames
&& !m_bOnlyFirstParent
) || !BlameIsLimitedToOneFilename(m_dwDetectMovedOrCopiedLines
) || m_bBlameOuputContainsOtherFilenames
)
1746 filename
.Format(L
"%s: %s\n", (LPCTSTR
)m_sFileName
, (LPCTSTR
)m_data
.GetFilename(line
));
1749 str
.Format(L
"%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
,
1750 (LPCTSTR
)m_sAuthor
, (LPCTSTR
)pRev
->GetAuthorName(), (LPCTSTR
)pRev
->GetAuthorEmail(),
1751 (LPCTSTR
)m_sDate
, (LPCTSTR
)CLoglistUtils::FormatDateAndTime(pRev
->GetAuthorDate(), m_DateFormat
, true, m_bRelativeTimes
),
1752 (LPCTSTR
)m_sMessage
, (LPCTSTR
)pRev
->GetSubject(),
1753 iline
<= maxLine
? body
: (body
.Left(pos
) + L
"\n...................."));
1756 m_ToolTip
.AddTool(this, str
);
1759 rect
.left
=LOCATOR_WIDTH
;
1760 rect
.right
=this->m_blamewidth
+rect
.left
;
1761 rect
.top
= point
.y
- (LONG
)height
;
1762 rect
.bottom
= point
.y
+ (LONG
)height
;
1763 this->InvalidateRect(rect
);
1768 void CTortoiseGitBlameView::OnMouseMove(UINT
/*nFlags*/, CPoint
/*point*/)
1770 TRACKMOUSEEVENT tme
;
1771 tme
.cbSize
=sizeof(TRACKMOUSEEVENT
);
1772 tme
.dwFlags
=TME_HOVER
|TME_LEAVE
;
1773 tme
.hwndTrack
=this->m_hWnd
;
1775 TrackMouseEvent(&tme
);
1779 BOOL
CTortoiseGitBlameView::PreTranslateMessage(MSG
* pMsg
)
1781 if (m_ToolTip
.GetSafeHwnd())
1782 m_ToolTip
.RelayEvent(pMsg
);
1783 return CView::PreTranslateMessage(pMsg
);
1786 void CTortoiseGitBlameView::OnEditFind()
1791 m_pFindDialog
=new CFindReplaceDialog();
1793 CString oneline
= theApp
.GetString(L
"FindString");
1794 if (m_TextView
.Call(SCI_GETSELECTIONSTART
) != m_TextView
.Call(SCI_GETSELECTIONEND
))
1796 LRESULT bufsize
= m_TextView
.Call(SCI_GETSELECTIONEND
) - m_TextView
.Call(SCI_GETSELECTIONSTART
);
1797 auto linebuf
= std::make_unique
<char[]>(bufsize
+ 1);
1798 SecureZeroMemory(linebuf
.get(), bufsize
+ 1);
1799 SendEditor(SCI_GETSELTEXT
, 0, (LPARAM
)linebuf
.get());
1800 oneline
= m_TextView
.StringFromControl(linebuf
.get());
1803 DWORD flags
= FR_DOWN
| FR_HIDEWHOLEWORD
| FR_HIDEUPDOWN
;
1804 if (theApp
.GetInt(L
"FindMatchCase"))
1805 flags
|= FR_MATCHCASE
;
1807 m_pFindDialog
->Create(TRUE
, oneline
, nullptr, flags
, this);
1810 void CTortoiseGitBlameView::OnEditGoto()
1813 if(dlg
.DoModal()==IDOK
)
1815 this->GotoLine(dlg
.m_LineNumber
);
1819 LRESULT
CTortoiseGitBlameView::OnFindDialogMessage(WPARAM
/*wParam*/, LPARAM
/*lParam*/)
1821 ASSERT(m_pFindDialog
);
1823 // If the FR_DIALOGTERM flag is set,
1824 // invalidate the handle identifying the dialog box.
1825 if (m_pFindDialog
->IsTerminating())
1827 m_pFindDialog
= nullptr;
1831 if (m_data
.GetNumberOfLines()==0)
1834 // If the FR_FINDNEXT flag is set,
1835 // call the application-defined search routine
1836 // to search for the requested string.
1837 if(m_pFindDialog
->FindNext())
1839 m_bMatchCase
= !!(m_pFindDialog
->m_nFlags
& FR_MATCHCASE
);
1840 m_sFindText
= m_pFindDialog
->GetFindString();
1842 theApp
.WriteInt(L
"FindMatchCase", m_bMatchCase
? 1 : 0);
1843 theApp
.WriteString(L
"FindString", m_sFindText
);
1845 DoSearch(CTortoiseGitBlameData::SearchNext
);
1851 void CTortoiseGitBlameView::OnViewNext()
1853 int startline
= (int)SendEditor(SCI_GETFIRSTVISIBLELINE
);
1854 int line
= m_data
.FindNextLine(this->m_SelectedHash
, (int)SendEditor(SCI_GETFIRSTVISIBLELINE
), false);
1856 SendEditor(SCI_LINESCROLL
, 0, line
- startline
- 2);
1858 void CTortoiseGitBlameView::OnViewPrev()
1860 int startline
= (int)SendEditor(SCI_GETFIRSTVISIBLELINE
);
1861 int line
= m_data
.FindNextLine(this->m_SelectedHash
, (int)SendEditor(SCI_GETFIRSTVISIBLELINE
), true);
1863 SendEditor(SCI_LINESCROLL
, 0, line
- startline
- 2);
1866 void CTortoiseGitBlameView::OnViewToggleAuthor()
1868 m_bShowAuthor
= ! m_bShowAuthor
;
1870 theApp
.WriteInt(L
"ShowAuthor", m_bShowAuthor
);
1873 this->GetClientRect(&rect
);
1874 rect
.left
=GetBlameWidth();
1876 m_TextView
.MoveWindow(&rect
);
1879 void CTortoiseGitBlameView::OnUpdateViewToggleAuthor(CCmdUI
*pCmdUI
)
1881 pCmdUI
->SetCheck(m_bShowAuthor
);
1884 void CTortoiseGitBlameView::OnViewToggleDate()
1886 m_bShowDate
= ! m_bShowDate
;
1888 theApp
.WriteInt(L
"ShowDate", m_bShowDate
);
1891 this->GetClientRect(&rect
);
1892 rect
.left
=GetBlameWidth();
1894 m_TextView
.MoveWindow(&rect
);
1897 void CTortoiseGitBlameView::OnUpdateViewToggleDate(CCmdUI
*pCmdUI
)
1899 pCmdUI
->SetCheck(m_bShowDate
);
1902 void CTortoiseGitBlameView::OnViewToggleShowFilename()
1904 m_bShowFilename
= ! m_bShowFilename
;
1906 theApp
.WriteInt(L
"ShowFilename", m_bShowFilename
);
1909 this->GetClientRect(&rect
);
1910 rect
.left
= GetBlameWidth();
1912 m_TextView
.MoveWindow(&rect
);
1915 void CTortoiseGitBlameView::OnUpdateViewToggleShowFilename(CCmdUI
*pCmdUI
)
1917 pCmdUI
->SetCheck(m_bShowFilename
);
1920 void CTortoiseGitBlameView::OnViewToggleShowOriginalLineNumber()
1922 m_bShowOriginalLineNumber
= ! m_bShowOriginalLineNumber
;
1924 theApp
.WriteInt(L
"ShowOriginalLineNumber", m_bShowOriginalLineNumber
);
1927 this->GetClientRect(&rect
);
1928 rect
.left
= GetBlameWidth();
1930 m_TextView
.MoveWindow(&rect
);
1933 void CTortoiseGitBlameView::OnUpdateViewToggleShowOriginalLineNumber(CCmdUI
*pCmdUI
)
1935 pCmdUI
->SetCheck(m_bShowOriginalLineNumber
);
1938 void CTortoiseGitBlameView::OnViewDetectMovedOrCopiedLines(DWORD dwDetectMovedOrCopiedLines
)
1940 m_dwDetectMovedOrCopiedLines
= dwDetectMovedOrCopiedLines
;
1942 theApp
.DoWaitCursor(1);
1944 theApp
.WriteInt(L
"DetectMovedOrCopiedLines", m_dwDetectMovedOrCopiedLines
);
1946 auto document
= static_cast<CTortoiseGitBlameDoc
*>(m_pDocument
);
1947 if (!document
->m_CurrentFileName
.IsEmpty())
1949 document
->m_lLine
= (int)SendEditor(SCI_GETFIRSTVISIBLELINE
) + 1;
1950 theApp
.m_pDocManager
->OnFileNew();
1951 document
->OnOpenDocument(document
->m_CurrentFileName
, document
->m_Rev
);
1953 theApp
.DoWaitCursor(-1);
1956 void CTortoiseGitBlameView::OnViewDetectMovedOrCopiedLinesToggleDisabled()
1958 OnViewDetectMovedOrCopiedLines(BLAME_DETECT_MOVED_OR_COPIED_LINES_DISABLED
);
1961 void CTortoiseGitBlameView::OnUpdateViewDetectMovedOrCopiedLinesToggleDisabled(CCmdUI
*pCmdUI
)
1963 pCmdUI
->SetRadio(m_dwDetectMovedOrCopiedLines
== BLAME_DETECT_MOVED_OR_COPIED_LINES_DISABLED
);
1966 void CTortoiseGitBlameView::OnViewDetectMovedOrCopiedLinesToggleWithinFile()
1968 OnViewDetectMovedOrCopiedLines(BLAME_DETECT_MOVED_OR_COPIED_LINES_WITHIN_FILE
);
1971 void CTortoiseGitBlameView::OnUpdateViewDetectMovedOrCopiedLinesToggleWithinFile(CCmdUI
*pCmdUI
)
1973 pCmdUI
->SetRadio(m_dwDetectMovedOrCopiedLines
== BLAME_DETECT_MOVED_OR_COPIED_LINES_WITHIN_FILE
);
1976 void CTortoiseGitBlameView::OnViewDetectMovedOrCopiedLinesToggleFromModifiedFiles()
1978 OnViewDetectMovedOrCopiedLines(BLAME_DETECT_MOVED_OR_COPIED_LINES_FROM_MODIFIED_FILES
);
1981 void CTortoiseGitBlameView::OnUpdateViewDetectMovedOrCopiedLinesToggleFromModifiedFiles(CCmdUI
*pCmdUI
)
1983 pCmdUI
->SetRadio(m_dwDetectMovedOrCopiedLines
== BLAME_DETECT_MOVED_OR_COPIED_LINES_FROM_MODIFIED_FILES
);
1986 void CTortoiseGitBlameView::OnViewDetectMovedOrCopiedLinesToggleFromExistingFilesAtFileCreation()
1988 OnViewDetectMovedOrCopiedLines(BLAME_DETECT_MOVED_OR_COPIED_LINES_FROM_EXISTING_FILES_AT_FILE_CREATION
);
1991 void CTortoiseGitBlameView::OnUpdateViewDetectMovedOrCopiedLinesToggleFromExistingFilesAtFileCreation(CCmdUI
*pCmdUI
)
1993 pCmdUI
->SetRadio(m_dwDetectMovedOrCopiedLines
== BLAME_DETECT_MOVED_OR_COPIED_LINES_FROM_EXISTING_FILES_AT_FILE_CREATION
);
1996 void CTortoiseGitBlameView::OnViewDetectMovedOrCopiedLinesToggleFromExistingFiles()
1998 OnViewDetectMovedOrCopiedLines(BLAME_DETECT_MOVED_OR_COPIED_LINES_FROM_EXISTING_FILES
);
2001 void CTortoiseGitBlameView::OnUpdateViewDetectMovedOrCopiedLinesToggleFromExistingFiles(CCmdUI
*pCmdUI
)
2003 pCmdUI
->SetRadio(m_dwDetectMovedOrCopiedLines
== BLAME_DETECT_MOVED_OR_COPIED_LINES_FROM_EXISTING_FILES
);
2006 void CTortoiseGitBlameView::ReloadDocument()
2008 theApp
.DoWaitCursor(1);
2009 auto document
= static_cast<CTortoiseGitBlameDoc
*>(m_pDocument
);
2010 if (!document
->m_CurrentFileName
.IsEmpty())
2012 document
->m_lLine
= (int)SendEditor(SCI_GETFIRSTVISIBLELINE
) + 1;
2013 theApp
.m_pDocManager
->OnFileNew();
2014 document
->OnOpenDocument(document
->m_CurrentFileName
, document
->m_Rev
);
2016 theApp
.DoWaitCursor(-1);
2019 void CTortoiseGitBlameView::OnViewToggleIgnoreWhitespace()
2021 m_bIgnoreWhitespace
= ! m_bIgnoreWhitespace
;
2023 theApp
.WriteInt(L
"IgnoreWhitespace", m_bIgnoreWhitespace
? 1 : 0);
2028 void CTortoiseGitBlameView::OnUpdateViewToggleIgnoreWhitespace(CCmdUI
*pCmdUI
)
2030 pCmdUI
->SetCheck(m_bIgnoreWhitespace
);
2033 void CTortoiseGitBlameView::OnViewToggleShowCompleteLog()
2035 m_bShowCompleteLog
= ! m_bShowCompleteLog
;
2037 theApp
.WriteInt(L
"ShowCompleteLog", m_bShowCompleteLog
? 1 : 0);
2042 void CTortoiseGitBlameView::OnUpdateViewToggleOnlyFirstParent(CCmdUI
* pCmdUI
)
2044 pCmdUI
->SetCheck(m_bOnlyFirstParent
);
2047 void CTortoiseGitBlameView::OnViewToggleOnlyFirstParent()
2049 m_bOnlyFirstParent
= !m_bOnlyFirstParent
;
2051 theApp
.WriteInt(L
"OnlyFirstParent", m_bOnlyFirstParent
? 1 : 0);
2056 void CTortoiseGitBlameView::OnUpdateViewToggleShowCompleteLog(CCmdUI
*pCmdUI
)
2058 pCmdUI
->Enable(BlameIsLimitedToOneFilename(m_dwDetectMovedOrCopiedLines
) && !m_bOnlyFirstParent
);
2059 pCmdUI
->SetCheck(m_bShowCompleteLog
&& BlameIsLimitedToOneFilename(m_dwDetectMovedOrCopiedLines
) && !m_bOnlyFirstParent
);
2062 void CTortoiseGitBlameView::OnViewToggleFollowRenames()
2064 m_bFollowRenames
= ! m_bFollowRenames
;
2066 theApp
.WriteInt(L
"FollowRenames", m_bFollowRenames
? 1 : 0);
2071 void CTortoiseGitBlameView::OnUpdateViewToggleFollowRenames(CCmdUI
*pCmdUI
)
2073 pCmdUI
->Enable(m_bShowCompleteLog
&& BlameIsLimitedToOneFilename(m_dwDetectMovedOrCopiedLines
) && !m_bOnlyFirstParent
);
2074 pCmdUI
->SetCheck(m_bFollowRenames
&& m_bShowCompleteLog
&& BlameIsLimitedToOneFilename(m_dwDetectMovedOrCopiedLines
) && !m_bOnlyFirstParent
);
2077 void CTortoiseGitBlameView::OnViewToggleColorByAge()
2079 m_colorage
= ! m_colorage
;
2081 theApp
.WriteInt(L
"ColorAge", m_colorage
);
2083 m_TextView
.Invalidate();
2086 void CTortoiseGitBlameView::OnUpdateViewToggleColorByAge(CCmdUI
*pCmdUI
)
2088 pCmdUI
->SetCheck(m_colorage
);
2091 void CTortoiseGitBlameView::OnViewToggleLexer()
2093 m_bLexer
= !m_bLexer
;
2095 theApp
.WriteInt(L
"EnableLexer", m_bLexer
);
2098 SetupLexer(GetDocument()->m_CurrentFileName
);
2102 void CTortoiseGitBlameView::OnUpdateViewToggleLexer(CCmdUI
*pCmdUI
)
2104 pCmdUI
->SetCheck(m_bLexer
);
2107 void CTortoiseGitBlameView::OnUpdateViewCopyToClipboard(CCmdUI
*pCmdUI
)
2109 CWnd
* wnd
= GetFocus();
2110 if (wnd
== GetLogList())
2111 pCmdUI
->Enable(GetLogList()->GetSelectedCount() > 0);
2114 if (CString(wnd
->GetRuntimeClass()->m_lpszClassName
) == L
"CMFCPropertyGridCtrl")
2116 CMFCPropertyGridCtrl
*grid
= (CMFCPropertyGridCtrl
*)wnd
;
2117 pCmdUI
->Enable(grid
->GetCurSel() && !grid
->GetCurSel()->IsGroup() && !CString(grid
->GetCurSel()->GetValue()).IsEmpty());
2120 pCmdUI
->Enable(m_TextView
.Call(SCI_GETSELECTIONSTART
) != m_TextView
.Call(SCI_GETSELECTIONEND
));
2123 pCmdUI
->Enable(FALSE
);
2126 void CTortoiseGitBlameView::OnSysColorChange()
2128 __super::OnSysColorChange();
2129 m_windowcolor
= ::GetSysColor(COLOR_WINDOW
);
2130 m_textcolor
= ::GetSysColor(COLOR_WINDOWTEXT
);
2131 m_texthighlightcolor
= ::GetSysColor(COLOR_HIGHLIGHTTEXT
);
2132 m_mouserevcolor
= InterColor(m_windowcolor
, m_textcolor
, 20);
2133 m_mouseauthorcolor
= InterColor(m_windowcolor
, m_textcolor
, 10);
2134 m_selectedrevcolor
= ::GetSysColor(COLOR_HIGHLIGHT
);
2135 m_selectedauthorcolor
= InterColor(m_selectedrevcolor
, m_texthighlightcolor
, 35);
2137 SetupLexer(GetDocument()->m_CurrentFileName
);