GitProcessList: Add success/failure info when finish command
[TortoiseGit.git] / src / TortoiseGitBlame / TortoiseGitBlameView.h
blob15eaf333681919fc8ef7356aacb0d96c088fe57f
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2013 - TortoiseGit
4 // Copyright (C) 2003-2008 - TortoiseSVN
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software Foundation,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 // TortoiseGitBlameView.h : interface of the CTortoiseGitBlameView class
26 #pragma once
28 #include "Scintilla.h"
29 #include "SciLexer.h"
30 #include "registry.h"
31 #include "SciEdit.h"
33 #include "GitBlameLogList.h"
34 #include "Tooltip.h"
36 const COLORREF black = RGB(0,0,0);
37 const COLORREF white = RGB(0xff,0xff,0xff);
38 const COLORREF red = RGB(0xFF, 0, 0);
39 const COLORREF offWhite = RGB(0xFF, 0xFB, 0xF0);
40 const COLORREF darkGreen = RGB(0, 0x80, 0);
41 const COLORREF darkBlue = RGB(0, 0, 0x80);
42 const COLORREF lightBlue = RGB(0xA6, 0xCA, 0xF0);
43 const int blockSize = 128 * 1024;
45 #define BLAMESPACE 5
46 #define HEADER_HEIGHT 18
47 #define LOCATOR_WIDTH 10
49 #define MAX_LOG_LENGTH 2000
52 #ifndef GET_X_LPARAM
53 #define GET_X_LPARAM(lp) ((int)(short)LOWORD(lp))
54 #endif
55 #ifndef GET_Y_LPARAM
56 #define GET_Y_LPARAM(lp) ((int)(short)HIWORD(lp))
57 #endif
59 class CSciEditBlame: public CSciEdit
61 DECLARE_DYNAMIC(CSciEditBlame)
62 public:
63 afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
65 switch (nChar)
67 case (VK_ESCAPE):
69 if ((Call(SCI_AUTOCACTIVE)==0)&&(Call(SCI_CALLTIPACTIVE)==0))
71 ::SendMessage(::AfxGetApp()->GetMainWnd()->m_hWnd, WM_CLOSE, 0, 0);
72 return;
75 break;
77 CWnd::OnKeyDown(nChar, nRepCnt, nFlags);
81 class CTortoiseGitBlameView : public CView
83 protected: // create from serialization only
84 CTortoiseGitBlameView();
85 DECLARE_DYNCREATE(CTortoiseGitBlameView)
87 // Attributes
88 public:
89 CTortoiseGitBlameDoc* GetDocument() const;
90 int GetEncode(unsigned char * buffer, int size, int *bomoffset);
91 // Operations
92 public:
94 // Overrides
95 public:
96 virtual void OnDraw(CDC* pDC); // overridden to draw this view
97 virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
98 protected:
99 virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
100 virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
101 virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
103 // Implementation
104 public:
105 virtual ~CTortoiseGitBlameView();
106 #ifdef _DEBUG
107 virtual void AssertValid() const;
108 virtual void Dump(CDumpContext& dc) const;
109 #endif
111 protected:
113 // Generated message map functions
114 protected:
115 BOOL PreTranslateMessage(MSG* pMsg);
116 afx_msg void OnChangeEncode(UINT nID);
117 afx_msg void OnEditFind();
118 afx_msg void OnEditGoto();
119 afx_msg void OnFilePrintPreview();
120 afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
121 afx_msg int OnCreate(LPCREATESTRUCT lpcs);
122 afx_msg void OnSize(UINT nType, int cx, int cy);
123 afx_msg void OnSciPainted(NMHDR*, LRESULT*);
124 afx_msg void OnLButtonDown(UINT nFlags,CPoint point);
125 afx_msg void OnRButtonDown(UINT nFlags,CPoint point){OnLButtonDown(nFlags,point);CView::OnRButtonDown(nFlags,point);};
126 afx_msg void OnSciGetBkColor(NMHDR*, LRESULT*);
127 afx_msg void OnMouseHover(UINT nFlags, CPoint point);
128 afx_msg void OnMouseMove(UINT nFlags, CPoint point);
129 afx_msg LRESULT OnFindDialogMessage(WPARAM wParam, LPARAM lParam);
130 afx_msg void OnViewNext();
131 afx_msg void OnViewPrev();
132 afx_msg void OnViewToggleAuthor();
133 afx_msg void OnUpdateViewToggleAuthor(CCmdUI *pCmdUI);
134 afx_msg void OnViewToggleDate();
135 afx_msg void OnUpdateViewToggleDate(CCmdUI *pCmdUI);
136 afx_msg void OnViewToggleFollowRenames();
137 afx_msg void OnUpdateViewToggleFollowRenames(CCmdUI *pCmdUI);
138 afx_msg void CopyHashToClipboard();
139 afx_msg void OnUpdateBlamePopupBlamePrevious(CCmdUI *pCmdUI);
140 afx_msg void OnUpdateBlamePopupDiffPrevious(CCmdUI *pCmdUI);
141 afx_msg void OnUpdateViewCopyToClipboard(CCmdUI *pCmdUI);
143 int FindNextLine(CGitHash commithash, bool bUpOrDown=false);
144 int FindFirstLine(CGitHash commithash, int line)
146 while(line>=0)
148 if( m_CommitHash[line] != commithash )
150 return line++;
152 --line;
154 return line;
157 DECLARE_MESSAGE_MAP()
159 static UINT m_FindDialogMessage;
160 public:
162 void UpdateInfo(int encode = 0);
163 void FocusOn(GitRev *pRev);
165 CSciEditBlame m_TextView;
166 CToolTips m_ToolTip;
168 HINSTANCE hInstance;
169 HINSTANCE hResource;
170 HWND currentDialog;
171 HWND wMain;
172 HWND m_wEditor;
173 HWND wBlame;
174 HWND wHeader;
175 HWND wLocator;
176 HWND hwndTT;
178 BOOL bIgnoreEOL;
179 BOOL bIgnoreSpaces;
180 BOOL bIgnoreAllSpaces;
182 BOOL m_bShowAuthor;
183 BOOL m_bShowDate;
184 BOOL m_bFollowRenames;
186 LRESULT SendEditor(UINT Msg, WPARAM wParam=0, LPARAM lParam=0);
188 void SetAStyle(int style, COLORREF fore, COLORREF back = ::GetSysColor(COLOR_WINDOW), int size = -1, CString *face = NULL);
190 void InitialiseEditor();
191 LONG GetBlameWidth();
192 void DrawBlame(HDC hDC);
193 void DrawLocatorBar(HDC hDC);
194 void CopyToClipboard();
195 void CopySelectedLogToClipboard();
196 void BlamePreviousRevision();
197 void DiffPreviousRevision();
198 void ShowLog();
199 bool DoSearch(CString what, DWORD flags);
200 bool GotoLine(long line);
201 bool ScrollToLine(long line);
202 void GotoLineDlg();
203 static INT_PTR CALLBACK GotoDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
205 void SetSelectedLine(LONG line) { m_SelectedLine=line;};
207 LONG m_mouserev;
208 LONG m_MouseLine;
209 LONG m_selectedrev;
210 LONG m_selectedorigrev;
211 CGitHash m_SelectedHash;
212 CGitHash m_selecteddate;
213 static long m_gotoline;
214 long m_lowestrev;
215 long m_highestrev;
216 bool m_colorage;
218 std::vector<LONG> m_ID;
219 std::vector<LONG> m_LineNum;
220 std::vector<CString> m_Dates;
221 std::vector<CString> m_Authors;
222 std::vector<CGitHash> m_CommitHash;
224 std::map<CString,GitRev> m_NoListCommit;
226 char m_szTip[MAX_LOG_LENGTH*2+6];
227 wchar_t m_wszTip[MAX_LOG_LENGTH*2+6];
228 void StringExpand(LPSTR str);
229 void StringExpand(LPWSTR str);
230 BOOL ttVisible;
232 CLogDataVector * GetLogData();
234 BOOL m_bShowLine;
236 protected:
237 void CreateFont();
238 void SetupLexer(CString filename);
239 void SetupCppLexer();
240 COLORREF InterColor(COLORREF c1, COLORREF c2, int Slider);
241 CString GetAppDirectory();
242 std::vector<COLORREF> colors;
243 HFONT m_font;
244 HFONT m_italicfont;
245 LONG m_blamewidth;
246 LONG m_revwidth;
247 LONG m_datewidth;
248 LONG m_authorwidth;
249 LONG m_linewidth;
250 LONG m_SelectedLine; ///< zero-based
252 COLORREF m_mouserevcolor;
253 COLORREF m_mouseauthorcolor;
254 COLORREF m_selectedrevcolor;
255 COLORREF m_selectedauthorcolor;
256 COLORREF m_windowcolor;
257 COLORREF m_textcolor;
258 COLORREF m_texthighlightcolor;
260 LRESULT m_directFunction;
261 LRESULT m_directPointer;
262 FINDREPLACE fr;
263 TCHAR szFindWhat[80];
265 CRegStdDWORD m_regOldLinesColor;
266 CRegStdDWORD m_regNewLinesColor;
268 CGitBlameLogList * GetLogList();
270 CFindReplaceDialog *m_pFindDialog;
272 char *m_Buffer;
274 DWORD m_DateFormat; // DATE_SHORTDATE or DATE_LONGDATE
275 bool m_bRelativeTimes; // Show relative times
277 CString m_sRev;
278 CString m_sAuthor;
279 CString m_sDate;
280 CString m_sMessage;
283 #ifndef _DEBUG // debug version in TortoiseGitBlameView.cpp
284 inline CTortoiseGitBlameDoc* CTortoiseGitBlameView::GetDocument() const
285 { return reinterpret_cast<CTortoiseGitBlameDoc*>(m_pDocument); }
286 #endif