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