/
Merge.h
185 lines (163 loc) · 6.08 KB
/
Merge.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
/////////////////////////////////////////////////////////////////////////////
// WinMerge: an interactive diff/merge utility
// Copyright (C) 1997 Dean P. Grimm
// SPDX-License-Identifier: GPL-2.0-or-later
/////////////////////////////////////////////////////////////////////////////
/**
* @file Merge.h
*
* @brief main header file for the MERGE application
*
*/
#pragma once
#define WMU_CHILDFRAMEADDED (WM_APP + 10)
#define WMU_CHILDFRAMEREMOVED (WM_APP + 11)
#define WMU_CHILDFRAMEACTIVATE (WM_APP + 12)
#define WMU_CHILDFRAMEACTIVATED (WM_APP + 13)
#define IDT_UPDATEMAINMENU 1
#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
#endif
#include <memory>
#include "MergeCmdLineInfo.h"
#include "resource.h" // main symbols
struct FileFilter;
class FileFilterHelper;
class CAssureScriptsForThread;
class CMainFrame;
class CLanguageSelect;
class MergeCmdLineInfo;
class ProjectFile;
class COptionsMgr;
class LineFiltersList;
class SyntaxColors;
class CCrystalTextMarkers;
class FilterCommentsManager;
/////////////////////////////////////////////////////////////////////////////
// CMergeApp:
// See Merge.cpp for the implementation of this class
//
enum { IDLE_TIMER = 9754 };
/**
* @brief WinMerge application class
*/
class CMergeApp : public CWinApp
{
public:
bool m_bNeedIdleTimer;
CMultiDocTemplate* m_pOpenTemplate;
CMultiDocTemplate* m_pDiffTemplate;
CMultiDocTemplate* m_pHexMergeTemplate;
CMultiDocTemplate* m_pDirTemplate;
std::unique_ptr<CLanguageSelect> m_pLangDlg;
std::unique_ptr<FileFilterHelper> m_pGlobalFileFilter;
std::unique_ptr<SyntaxColors> m_pSyntaxColors; /**< Syntax color container */
std::unique_ptr<CCrystalTextMarkers> m_pMarkers; /**< Marker container */
String m_strSaveAsPath; /**< "3rd path" where output saved if given */
bool m_bEscShutdown; /**< If commandline switch -e given ESC closes appliction */
SyntaxColors * GetMainSyntaxColors() { return m_pSyntaxColors.get(); }
CCrystalTextMarkers * GetMainMarkers() const { return m_pMarkers.get(); }
MergeCmdLineInfo::ExitNoDiff m_bExitIfNoDiff; /**< Exit if files are identical? */
std::unique_ptr<LineFiltersList> m_pLineFilters; /**< List of linefilters */
std::unique_ptr<FilterCommentsManager> m_pFilterCommentsManager;
WORD GetLangId() const;
void SetIndicators(CStatusBar &, const UINT *, int) const;
void TranslateMenu(HMENU) const;
void TranslateDialog(HWND) const;
String LoadString(UINT) const;
bool TranslateString(const std::string&, String&) const;
std::wstring LoadDialogCaption(LPCTSTR) const;
CMergeApp();
~CMergeApp();
public:
void AddToRecentProjectsMRU(LPCTSTR sPathName);
void SetNeedIdleTimer();
void SetLastCompareResult(int nResult) { m_nLastCompareResult = nResult; }
COptionsMgr * GetMergeOptionsMgr() { return static_cast<COptionsMgr *> (m_pOptions.get()); }
FileFilterHelper * GetGlobalFileFilter() { return m_pGlobalFileFilter.get(); }
void ShowHelp(LPCTSTR helpLocation = nullptr);
void OpenFileToExternalEditor(const String& file, int nLineNumber = 1);
void OpenFileOrUrl(LPCTSTR szFile, LPCTSTR szUrl);
bool CreateBackup(bool bFolder, const String& pszPath);
int HandleReadonlySave(String& strSavePath, bool bMultiFile, bool &bApplyToAll);
bool GetMergingMode() const;
void SetMergingMode(bool bMergingMode);
void SetupTempPath();
bool IsReallyIdle() const;
virtual UINT GetProfileInt(LPCTSTR lpszSection, LPCTSTR lpszEntry, int nDefault) override;
virtual BOOL WriteProfileInt(LPCTSTR lpszSection, LPCTSTR lpszEntry, int nValue) override;
virtual CString GetProfileString(LPCTSTR lpszSection, LPCTSTR lpszEntry, LPCTSTR lpszDefault = NULL) override;
virtual BOOL WriteProfileString(LPCTSTR lpszSection, LPCTSTR lpszEntry, LPCTSTR lpszValue) override;
// Implementation
protected:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMergeApp)
public:
virtual BOOL InitInstance();
virtual int ExitInstance();
virtual int DoMessageBox(LPCTSTR lpszPrompt, UINT nType, UINT nIDPrompt);
virtual BOOL OnIdle(LONG lCount);
//}}AFX_VIRTUAL
void InitializeFileFilters();
bool ParseArgsAndDoOpen(MergeCmdLineInfo& cmdInfo, CMainFrame* pMainFrame);
void UpdateDefaultCodepage(int cpDefaultMode, int cpCustomCodepage);
void UpdateCodepageModule();
void ApplyCommandLineConfigOptions(MergeCmdLineInfo & cmdInfo);
// End MergeArgs.cpp
bool LoadProjectFile(const String& sProject, ProjectFile &project);
bool SaveProjectFile(const String& sProject, const ProjectFile &project);
bool LoadAndOpenProjectFile(const String& sFilepath, const String& sReportFile = _T(""));
bool IsProjectFile(const String& filepath) const;
//@{
/**
* @name Active operations counter.
* These functions implement counter for active operations. We need to
* track active operations during whose user cannot exit the application.
* E.g. copying files in folder compare is such an operation.
*/
/**
* Increment the active operation counter.
*/
void AddOperation() { InterlockedIncrement(&m_nActiveOperations); }
/**
* Decrement the active operation counter.
*/
void RemoveOperation()
{
ASSERT(m_nActiveOperations > 0);
InterlockedDecrement( &m_nActiveOperations);
}
/**
* Get the active operations count.
*/
LONG GetActiveOperations() const { return m_nActiveOperations; }
//@}
//{{AFX_MSG(CMergeApp)
afx_msg BOOL OnOpenRecentFile(UINT nID);
afx_msg void OnAppAbout();
afx_msg void OnHelp();
afx_msg void OnMergingMode();
afx_msg void OnUpdateMergingMode(CCmdUI* pCmdUI);
afx_msg void OnUpdateMergingStatus(CCmdUI* pCmdUI);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
std::unique_ptr<COptionsMgr> m_pOptions;
CAssureScriptsForThread * m_mainThreadScripts;
int m_nLastCompareResult;
bool m_bNonInteractive;
LONG m_nActiveOperations; /**< Active operations count. */
bool m_bMergingMode; /**< Merging or Edit mode */
CFont m_fontGUI;
ATL::CImage m_imageForInitializingGdiplus;
};
extern CMergeApp theApp;
/**
* @brief Set flag so that application will broadcast notification at next
* idle time (via WM_TIMER id=IDLE_TIMER)
*/
inline void CMergeApp::SetNeedIdleTimer()
{
m_bNeedIdleTimer = true;
}