Allow to move item past last item
[TortoiseGit.git] / src / TortoiseProc / CommitDlg.h
blob5a4d22c45e4dec05d7283f5fbe543952f8c82aff
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2008 - TortoiseSVN
4 // Copyright (C) 2008-2016 - TortoiseGit
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.
20 #pragma once
22 #include "StandAloneDlg.h"
23 #include "GitStatusListCtrl.h"
24 #include "RegHistory.h"
25 #include "registry.h"
26 #include "SciEdit.h"
27 #include "SplitterControl.h"
28 #include "LinkControl.h"
29 #include "PathWatcher.h"
30 #include "BugTraqAssociations.h"
31 #include "..\IBugTraqProvider\IBugTraqProvider_h.h"
32 #include "Git.h"
33 #include "HyperLink.h"
34 #include "PatchViewDlg.h"
35 #include "MenuButton.h"
37 #include <regex>
39 #define ENDDIALOGTIMER 100
40 #define REFRESHTIMER 101
41 #define FILLPATCHVTIMER 102
43 typedef enum
45 GIT_POSTCOMMIT_CMD_NOTHING,
46 GIT_POSTCOMMIT_CMD_RECOMMIT,
47 GIT_POSTCOMMIT_CMD_PUSH,
48 GIT_POSTCOMMIT_CMD_DCOMMIT,
49 GIT_POSTCOMMIT_CMD_PULL,
50 GIT_POSTCOMMIT_CMD_CREATETAG,
51 } GIT_POSTCOMMIT_CMD;
54 /**
55 * \ingroup TortoiseProc
56 * Dialog to enter log messages used in a commit.
58 class CCommitDlg : public CResizableStandAloneDialog, public CSciEditContextMenuInterface, IHasPatchView
60 DECLARE_DYNAMIC(CCommitDlg)
62 public:
63 CCommitDlg(CWnd* pParent = nullptr); // standard constructor
64 virtual ~CCommitDlg();
66 protected:
67 // CSciEditContextMenuInterface
68 virtual void InsertMenuItems(CMenu& mPopup, int& nCmd);
69 virtual bool HandleMenuItemClick(int cmd, CSciEdit * pSciEdit);
70 virtual void HandleSnippet(int type, const CString &text, CSciEdit *pSciEdit);
72 public:
73 void ShowViewPatchText(bool b=true)
75 if(b)
76 this->m_ctrlShowPatch.SetWindowText(CString(MAKEINTRESOURCE(IDS_PROC_COMMIT_SHOWPATCH)));
77 else
78 this->m_ctrlShowPatch.SetWindowText(CString(MAKEINTRESOURCE(IDS_PROC_COMMIT_HIDEPATCH)));
80 m_ctrlShowPatch.Invalidate();
82 void SetAuthor(CString author)
84 m_bSetAuthor = TRUE;
85 m_sAuthor = author;
87 void SetTime(CTime time)
89 m_bSetCommitDateTime = TRUE;
90 m_wantCommitTime = time;
92 private:
93 CTime m_wantCommitTime;
94 void ReloadHistoryEntries();
95 static UINT StatusThreadEntry(LPVOID pVoid);
96 UINT StatusThread();
97 void FillPatchView(bool onlySetTimer = false);
98 CWnd * GetPatchViewParentWnd() { return this; }
99 virtual void TogglePatchView();
100 void SetDlgTitle();
101 CString GetSignedOffByLine();
102 CString m_sTitle;
104 // Dialog Data
105 enum { IDD = IDD_COMMITDLG };
107 protected:
108 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
110 virtual BOOL OnInitDialog();
111 virtual void OnOK();
112 virtual void OnCancel();
113 virtual BOOL PreTranslateMessage(MSG* pMsg);
114 virtual LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam);
115 afx_msg void OnBnClickedShowunversioned();
116 afx_msg void OnBnClickedHistory();
117 afx_msg void OnBnClickedBugtraqbutton();
118 afx_msg void OnEnChangeLogmessage();
119 afx_msg void OnStnClickedExternalwarning();
120 afx_msg void OnFocusMessage();
121 afx_msg void OnFocusFileList();
122 afx_msg LRESULT OnGitStatusListCtrlItemCountChanged(WPARAM, LPARAM);
123 afx_msg LRESULT OnGitStatusListCtrlNeedsRefresh(WPARAM, LPARAM);
124 afx_msg LRESULT OnGitStatusListCtrlCheckChanged(WPARAM, LPARAM);
125 afx_msg LRESULT OnGitStatusListCtrlItemChanged(WPARAM, LPARAM);
126 afx_msg void OnSysColorChange();
128 afx_msg LRESULT OnCheck(WPARAM count, LPARAM);
129 afx_msg LRESULT OnAutoListReady(WPARAM, LPARAM);
130 afx_msg LRESULT OnUpdateOKButton(WPARAM, LPARAM);
131 afx_msg LRESULT OnUpdateDataFalse(WPARAM, LPARAM);
132 afx_msg LRESULT OnFileDropped(WPARAM, LPARAM lParam);
133 afx_msg void OnTimer(UINT_PTR nIDEvent);
134 afx_msg void OnSize(UINT nType, int cx, int cy);
135 void Refresh();
136 void StartStatusThread();
137 void StopStatusThread();
138 void GetAutocompletionList();
139 void ScanFile(const CString& sFilePath, const CString& sRegex, const CString& sExt);
140 void DoSize(int delta);
141 void SetSplitterRange();
142 void SaveSplitterPos();
143 void UpdateCheckLinks();
144 void ParseRegexFile(const CString& sFile, std::map<CString, CString>& mapRegex);
145 void ParseSnippetFile(const CString& sFile, std::map<CString, CString>& mapSnippet);
146 bool RunStartCommitHook();
148 DECLARE_MESSAGE_MAP()
150 public:
151 CString m_sLogMessage;
152 BOOL m_bKeepChangeList;
153 BOOL m_bDoNotAutoselectSubmodules;
154 bool m_bForceCommitAmend;
155 BOOL m_bCommitAmend;
156 BOOL m_bNoPostActions;
157 bool m_bSelectFilesForCommit;
158 bool m_bAutoClose;
159 CString m_AmendStr;
160 CString m_sBugID;
161 BOOL m_bWholeProject;
162 BOOL m_bWholeProject2;
163 CTGitPathList m_pathList;
164 CTGitPathList m_checkedPathList;
165 CTGitPathList m_updatedPathList;
166 GIT_POSTCOMMIT_CMD m_PostCmd;
167 BOOL m_bAmendDiffToLastCommit;
168 BOOL m_bCommitMessageOnly;
169 bool m_bWarnDetachedHead;
171 protected:
172 CTGitPathList m_selectedPathList;
173 CSciEdit m_cLogMessage;
174 INT_PTR m_itemsCount;
175 CComPtr<IBugTraqProvider> m_BugTraqProvider;
176 CString m_NoAmendStr;
177 BOOL m_bCreateNewBranch;
178 CString m_sCreateNewBranch;
179 BOOL m_bSetAuthor;
180 CString m_sAuthor;
181 volatile bool m_bDoNotStoreLastSelectedLine; // true on first start of commit dialog and set on recommit
183 int CheckHeadDetach();
185 private:
186 CWinThread* m_pThread;
187 std::map<CString, int> m_autolist;
188 std::map<CString, CString> m_snippet;
189 CGitStatusListCtrl m_ListCtrl;
190 BOOL m_bShowUnversioned;
191 volatile LONG m_bBlock;
192 volatile LONG m_bThreadRunning;
193 volatile LONG m_bRunThread;
194 CRegDWORD m_regAddBeforeCommit;
195 CRegDWORD m_regKeepChangelists;
196 CRegDWORD m_regDoNotAutoselectSubmodules;
197 CRegDWORD m_regShowWholeProject;
198 ProjectProperties m_ProjectProperties;
199 CString m_sWindowTitle;
200 static UINT WM_AUTOLISTREADY;
201 static UINT WM_UPDATEOKBUTTON;
202 static UINT WM_UPDATEDATAFALSE;
203 int m_nPopupPickCommitHash;
204 int m_nPopupPickCommitMessage;
205 int m_nPopupPasteListCmd;
206 int m_nPopupPasteLastMessage;
207 int m_nPopupRecentMessage;
208 CRegHistory m_History;
209 bool m_bCancelled;
210 CSplitterControl m_wndSplitter;
211 CRect m_DlgOrigRect;
212 CRect m_LogMsgOrigRect;
213 CPathWatcher m_pathwatcher;
214 CHyperLink m_ctrlShowPatch;
215 CPatchViewDlg m_patchViewdlg;
216 BOOL m_bSetCommitDateTime;
217 CDateTimeCtrl m_CommitDate;
218 CDateTimeCtrl m_CommitTime;
219 CButton m_AsCommitDateCtrl;
220 CLinkControl m_linkControl;
221 CString m_sLogTemplate;
222 CMenuButton m_ctrlOkButton;
223 CRegDWORD m_regLastAction;
224 void PrepareOkButton();
225 typedef struct
227 int id;
228 int cnt;
229 int wmid;
230 } ACCELLERATOR;
231 std::map<TCHAR, ACCELLERATOR> m_accellerators;
232 HACCEL m_hAccelOkButton;
234 CBugTraqAssociation m_bugtraq_association;
235 HACCEL m_hAccel;
236 bool RestoreFiles(bool doNotAsk = false, bool allowCancel = true);
238 protected:
239 afx_msg void OnBnClickedSignOff();
240 afx_msg void OnBnClickedCommitAmend();
241 afx_msg void OnBnClickedCommitMessageOnly();
242 afx_msg void OnBnClickedWholeProject();
243 afx_msg void OnScnUpdateUI(NMHDR *pNMHDR, LRESULT *pResult);
244 afx_msg void OnStnClickedViewPatch();
245 afx_msg void OnMoving(UINT fwSide, LPRECT pRect);
246 afx_msg void OnSizing(UINT fwSide, LPRECT pRect);
247 afx_msg void OnHdnItemchangedFilelist(NMHDR *pNMHDR, LRESULT *pResult);
248 afx_msg void OnBnClickedCommitAmenddiff();
249 afx_msg void OnBnClickedNoautoselectsubmodules();
250 afx_msg void OnBnClickedCommitSetDateTime();
251 afx_msg void OnBnClickedCommitAsCommitDate();
252 afx_msg void OnBnClickedCheckNewBranch();
253 afx_msg void OnBnClickedCommitSetauthor();
255 CLinkControl m_CheckAll;
256 CLinkControl m_CheckNone;
257 CLinkControl m_CheckUnversioned;
258 CLinkControl m_CheckVersioned;
259 CLinkControl m_CheckAdded;
260 CLinkControl m_CheckDeleted;
261 CLinkControl m_CheckModified;
262 CLinkControl m_CheckFiles;
263 CLinkControl m_CheckSubmodules;