2 // TortoiseGitBlameView.h : interface of the CTortoiseGitBlameView class
13 #include "GitBlameLogList.h"
16 const COLORREF black
= RGB(0,0,0);
17 const COLORREF white
= RGB(0xff,0xff,0xff);
18 const COLORREF red
= RGB(0xFF, 0, 0);
19 const COLORREF offWhite
= RGB(0xFF, 0xFB, 0xF0);
20 const COLORREF darkGreen
= RGB(0, 0x80, 0);
21 const COLORREF darkBlue
= RGB(0, 0, 0x80);
22 const COLORREF lightBlue
= RGB(0xA6, 0xCA, 0xF0);
23 const int blockSize
= 128 * 1024;
26 #define HEADER_HEIGHT 18
27 #define LOCATOR_WIDTH 10
29 #define MAX_LOG_LENGTH 2000
33 #define GET_X_LPARAM(lp) ((int)(short)LOWORD(lp))
36 #define GET_Y_LPARAM(lp) ((int)(short)HIWORD(lp))
39 class CSciEditBlame
: public CSciEdit
41 DECLARE_DYNAMIC(CSciEditBlame
)
43 afx_msg
void OnKeyDown(UINT nChar
, UINT nRepCnt
, UINT nFlags
)
49 if ((Call(SCI_AUTOCACTIVE
)==0)&&(Call(SCI_CALLTIPACTIVE
)==0))
51 ::SendMessage(::AfxGetApp()->GetMainWnd()->m_hWnd
, WM_CLOSE
, 0, 0);
57 CWnd::OnKeyDown(nChar
, nRepCnt
, nFlags
);
61 class CTortoiseGitBlameView
: public CView
63 protected: // create from serialization only
64 CTortoiseGitBlameView();
65 DECLARE_DYNCREATE(CTortoiseGitBlameView
)
69 CTortoiseGitBlameDoc
* GetDocument() const;
70 int GetEncode(unsigned char * buffer
, int size
, int *bomoffset
);
76 virtual void OnDraw(CDC
* pDC
); // overridden to draw this view
77 virtual BOOL
PreCreateWindow(CREATESTRUCT
& cs
);
79 virtual BOOL
OnPreparePrinting(CPrintInfo
* pInfo
);
80 virtual void OnBeginPrinting(CDC
* pDC
, CPrintInfo
* pInfo
);
81 virtual void OnEndPrinting(CDC
* pDC
, CPrintInfo
* pInfo
);
85 virtual ~CTortoiseGitBlameView();
87 virtual void AssertValid() const;
88 virtual void Dump(CDumpContext
& dc
) const;
93 // Generated message map functions
95 BOOL
PreTranslateMessage(MSG
* pMsg
);
96 afx_msg
void OnChangeEncode(UINT nID
);
97 afx_msg
void OnEditFind();
98 afx_msg
void OnEditGoto();
99 afx_msg
void OnFilePrintPreview();
100 afx_msg
void OnRButtonUp(UINT nFlags
, CPoint point
);
101 afx_msg
void OnContextMenu(CWnd
* pWnd
, CPoint point
);
102 afx_msg
int OnCreate(LPCREATESTRUCT lpcs
);
103 afx_msg
void OnSize(UINT nType
, int cx
, int cy
);
104 afx_msg
void OnSciPainted(NMHDR
*, LRESULT
*);
105 afx_msg
void OnLButtonDown(UINT nFlags
,CPoint point
);
106 afx_msg
void OnRButtonDown(UINT nFlags
,CPoint point
){OnLButtonDown(nFlags
,point
);CView::OnRButtonDown(nFlags
,point
);};
107 afx_msg
void OnSciGetBkColor(NMHDR
*, LRESULT
*);
108 afx_msg
void OnMouseHover(UINT nFlags
, CPoint point
);
109 afx_msg
void OnMouseMove(UINT nFlags
, CPoint point
);
110 afx_msg LRESULT
OnFindDialogMessage(WPARAM wParam
, LPARAM lParam
);
111 afx_msg
void OnViewNext();
112 afx_msg
void OnViewPrev();
114 int FindNextLine(CGitHash commithash
, bool bUpOrDown
=false);
115 int FindFirstLine(CGitHash commithash
, int line
)
119 if( m_CommitHash
[line
] != commithash
)
128 DECLARE_MESSAGE_MAP()
130 static UINT m_FindDialogMessage
;
134 void FocusOn(GitRev
*pRev
);
136 CSciEditBlame m_TextView
;
151 BOOL bIgnoreAllSpaces
;
157 LRESULT
SendEditor(UINT Msg
, WPARAM wParam
=0, LPARAM lParam
=0);
159 void GetRange(int start
, int end
, char *text
);
162 BOOL
OpenFile(const char *fileName
);
163 BOOL
OpenLogFile(const char *fileName
);
165 void Command(int id
);
166 void Notify(SCNotification
*notification
);
168 void SetAStyle(int style
, COLORREF fore
, COLORREF back
=::GetSysColor(COLOR_WINDOW
), int size
=-1, CString
*face
=0);
170 void InitialiseEditor();
172 LONG
GetBlameWidth();
173 void DrawBlame(HDC hDC
);
174 void DrawHeader(HDC hDC
);
175 void DrawLocatorBar(HDC hDC
);
177 void CopySelectedLogToClipboard();
178 void BlamePreviousRevision();
179 void DiffPreviousRevision();
181 bool DoSearch(CString what
, DWORD flags
);
182 bool GotoLine(long line
);
183 bool ScrollToLine(long line
);
185 static INT_PTR CALLBACK
GotoDlgProc(HWND hwndDlg
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
);
187 void SetSelectedLine(LONG line
) { m_SelectedLine
=line
;};
192 LONG m_selectedorigrev
;
193 CGitHash m_SelectedHash
;
194 CGitHash m_selecteddate
;
195 static long m_gotoline
;
200 // std::vector<bool> m_Mergelines;
201 std::vector
<LONG
> m_ID
;
202 std::vector
<LONG
> m_LineNum
;
203 // std::vector<LONG> m_Origrevs;
204 std::vector
<CString
> m_Dates
;
205 std::vector
<CString
> m_Authors
;
206 std::vector
<CGitHash
> m_CommitHash
;
208 std::map
<CString
,GitRev
> m_NoListCommit
;
210 // std::vector<CString> m_Paths;
211 // std::map<LONG, CString> logmessages;
212 char m_szTip
[MAX_LOG_LENGTH
*2+6];
213 wchar_t m_wszTip
[MAX_LOG_LENGTH
*2+6];
214 void StringExpand(LPSTR str
);
215 void StringExpand(LPWSTR str
);
218 CLogDataVector
* GetLogData();
224 void SetupLexer(CString filename
);
225 void SetupCppLexer();
226 COLORREF
InterColor(COLORREF c1
, COLORREF c2
, int Slider
);
227 CString
GetAppDirectory();
228 std::vector
<COLORREF
> colors
;
237 LONG m_SelectedLine
; ///< zero-based
239 COLORREF m_mouserevcolor
;
240 COLORREF m_mouseauthorcolor
;
241 COLORREF m_selectedrevcolor
;
242 COLORREF m_selectedauthorcolor
;
243 COLORREF m_windowcolor
;
244 COLORREF m_textcolor
;
245 COLORREF m_texthighlightcolor
;
247 LRESULT m_directFunction
;
248 LRESULT m_directPointer
;
250 TCHAR szFindWhat
[80];
252 CRegStdWORD m_regOldLinesColor
;
253 CRegStdWORD m_regNewLinesColor
;
255 CGitBlameLogList
* GetLogList();
257 CFindReplaceDialog
*m_pFindDialog
;
261 DWORD m_DateFormat
; // DATE_SHORTDATE or DATE_LONGDATE
262 virtual BOOL
OnCommand(WPARAM wParam
, LPARAM lParam
);
265 #ifndef _DEBUG // debug version in TortoiseGitBlameView.cpp
266 inline CTortoiseGitBlameDoc
* CTortoiseGitBlameView::GetDocument() const
267 { return reinterpret_cast<CTortoiseGitBlameDoc
*>(m_pDocument
); }