forked from rizonesoft/Notepad3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNotepad3.h
261 lines (213 loc) · 10.9 KB
/
Notepad3.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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
// encoding: UTF-8
/******************************************************************************
* *
* *
* Notepad3 *
* *
* Notepad3.h *
* Global definitions and declarations *
* Based on code from Notepad2, (c) Florian Balmer 1996-2011 *
* *
* (c) Rizonesoft 2008-2023 *
* https://rizonesoft.com *
* *
* *
*******************************************************************************/
#pragma once
#ifndef _NP3_NOTEPAD3_H_
#define _NP3_NOTEPAD3_H_
#include "TypeDefs.h"
#include "SciCall.h"
#include "uthash/utarray.h"
//==== Main Window ============================================================
#define ONLINE_HELP_WEBSITE L"https://www.rizonesoft.com/documents/notepad3/"
//==== Data Type for WM_COPYDATA ==============================================
#define DATA_NOTEPAD3_PARAMS 0xFB10
typedef struct np3params {
int flagFileSpecified;
FILE_WATCHING_MODE flagChangeNotify;
int flagLexerSpecified;
int iInitialLexer;
int flagQuietCreate;
int flagJumpTo;
int iInitialLine;
int iInitialColumn;
cpi_enc_t flagSetEncoding;
int flagSetEOLMode;
int flagTitleExcerpt;
int flagMatchText;
WCHAR wchData;
}
np3params, *LPnp3params;
#pragma pack(push, 1)
typedef struct _undoSel {
int selMode_undo;
UT_array* anchorPos_undo;
UT_array* curPos_undo;
UT_array* anchorVS_undo;
UT_array* curVS_undo;
int selMode_redo;
UT_array* anchorPos_redo;
UT_array* curPos_redo;
UT_array* anchorVS_redo;
UT_array* curVS_redo;
}
UndoRedoSelection_t;
#pragma pack(pop)
//#define INIT_UNDOREDOSEL { SC_SEL_STREAM, (DocPos)-1, (DocPos)-1, 0, 0, SC_SEL_STREAM, (DocPos)-1, (DocPos)-1, 0, 0 }
#define INIT_UNDOREDOSEL { SC_SEL_STREAM, NULL, NULL, NULL, NULL, SC_SEL_STREAM, NULL, NULL, NULL, NULL }
#define NP3_SEL_MULTI (SC_SEL_RECTANGLE + SC_SEL_LINES + SC_SEL_THIN)
typedef enum {
UNDO = true,
REDO = false
} DoAction;
//==== Ids ====================================================================
#define IDC_STATUSBAR (0xFB00)
#define IDC_TOOLBAR (0xFB01)
#define IDC_REBAR (0xFB02)
#define IDC_EDIT (0xFB03)
#define IDC_EDITFRAME (0xFB04)
#define IDC_FILENAME (0xFB05)
#define IDC_REUSELOCK (0xFB06)
#define IDC_MARGIN (0xFB07)
#define IDC_NCAREA (0xFB08)
//==== Notifications ==========================================================
#define WM_TRAYMESSAGE (WM_USER + 1) // Callback Message from System Tray
#define WM_FILECHANGEDNOTIFY (WM_USER + 2) // Change Notifications
#define WM_RESTORE_UNDOREDOACTION (WM_USER + 3)
#define IDC_FILEMRU_UPDATE_VIEW (WM_USER + 4)
//#define WM_CHANGENOTIFYCLEAR (WM_USER + 5)
//==== Timer ==================================================================
#define ID_WATCHTIMER (0xA000) // File Watching
#define ID_PASTEBOARDTIMER (0xA001) // Paste Board
#define ID_AUTOSAVETIMER (0xA002) // Paste Board
//==== Reuse Window Lock Timeout ==============================================
#define REUSEWINDOWLOCKTIMEOUT (1000)
//==== Function Declarations ==================================================
bool InitApplication(const HINSTANCE hInstance);
//~bool InitToolbarWndClass(const HINSTANCE hInstance);
HWND InitInstance(const HINSTANCE hInstance, int nCmdShow);
void CreateBars(HWND hwnd, HINSTANCE hInstance);
WININFO GetFactoryDefaultWndPos(HWND hwnd, const int flagsPos);
WININFO GetWinInfoByFlag(HWND hwnd, const int flagsPos);
int CountRunningInstances();
bool ActivatePrevInst();
bool LaunchNewInstance(HWND hwnd, LPCWSTR lpszParameter, LPCWSTR lpszFilePath);
bool RelaunchMultiInst();
bool RelaunchElevated(LPCWSTR lpNewCmdLnArgs);
bool DoElevatedRelaunch(EditFileIOStatus* pFioStatus, bool bAutoSaveOnRelaunch);
void ShowNotifyIcon(HWND hwnd, bool bAdd);
void SetNotifyIconTitle(HWND hwnd);
void SetSaveDone();
void ParseCommandLine();
void CheckAutoLoadMostRecent();
void ShowZoomCallTip();
void ShowWrapAroundCallTip(bool forwardSearch);
void MarkAllOccurrences(const int64_t delay, const bool bForceClear);
void UpdateToolbar();
void UpdateStatusbar(const bool bForceRedraw);
void UpdateMargins(const bool bForce);
void UpdateSaveSettingsCmds();
void UpdateTitlebar(const HWND hwnd);
void UpdateContentArea();
void ResetMouseDWellTime();
void UndoRedoReset();
LONG BeginUndoActionSelection();
void EndUndoActionSelection(LONG token);
void HandleDWellStartEnd(const DocPos position, const UINT uid);
bool HandleHotSpotURLClicked(const DocPos position, const HYPERLINK_OPS operation);
void HandleColorDefClicked(HWND hwnd, const DocPos position);
bool IsFindPatternEmpty();
LPCWSTR GetFindPattern();
void GetFindPatternMB(LPSTR chPattern, int cch);
void SetFindPattern(LPCWSTR wchFindPattern);
void SetFindPatternMB(LPCSTR chFindPattern);
size_t LengthOfFindPattern();
size_t LengthOfFindPatternMB();
bool ConsistentIndentationCheck(EditFileIOStatus* status);
bool FileLoad(const HPATHL hfile_pth, const FileLoadFlags fLoadFlags);
bool FileSave(FileSaveFlags fSaveFlags);
bool FileRevert(const HPATHL hfile_pth, bool bIgnoreCmdLnEnc);
bool FileIO(bool fLoad, const HPATHL hfile_pth, EditFileIOStatus* status,
FileLoadFlags fLoadFlags, FileSaveFlags fSaveFlags, bool bSetSavePoint);
void CALLBACK PasteBoardTimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime);
void InstallFileWatching(const bool bInstall);
void AutoSaveStart(bool bReset);
void AutoSaveStop();
void AutoSaveDoWork(FileSaveFlags fSaveFlags);
void CALLBACK AutoSaveTimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime);
//LPCWSTR BackupGetDefaultFolder(HPATHL hfile_pth_io);
LRESULT CALLBACK MainWndProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam);
LRESULT MsgCreate(HWND hwnd, WPARAM wParam, LPARAM lParam);
LRESULT MsgEndSession(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam);
LRESULT MsgThemeChanged(HWND hwnd, WPARAM wParam, LPARAM lParam);
LRESULT MsgDPIChanged(HWND hwnd, WPARAM wParam, LPARAM lParam);
LRESULT MsgSize(HWND hwnd, WPARAM wParam, LPARAM lParam);
LRESULT MsgDrawItem(HWND hwnd, WPARAM wParam, LPARAM lParam);
LRESULT MsgDropFiles(HWND hwnd, WPARAM wParam, LPARAM lParam);
LRESULT MsgCopyData(HWND hwnd, WPARAM wParam, LPARAM lParam);
LRESULT MsgContextMenu(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam);
LRESULT MsgEnterMenuLoop(HWND hwnd, WPARAM wParam);
LRESULT MsgInitMenu(HWND hwnd, WPARAM wParam, LPARAM lParam);
LRESULT MsgExitMenuLoop(HWND hwnd, WPARAM wParam);
LRESULT MsgNotify(HWND hwnd, WPARAM wParam, LPARAM lParam);
LRESULT MsgFileChangeNotify(HWND hwnd, WPARAM wParam, LPARAM lParam);
LRESULT MsgTrayMessage(HWND hwnd, WPARAM wParam, LPARAM lParam);
//~LRESULT MsgKeyDown(HWND hwnd, WPARAM wParam, LPARAM lParam);
LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam);
LRESULT MsgSysCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam);
LRESULT MsgUahMenuBar(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam);
//LRESULT MsgNonClientAreaPaint(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam);
// ----------------------------------------------------------------------------
int DisableDocChangeNotification();
void EnableDocChangeNotification(const int evm);
#define LimitNotifyEvents() { int _evm_ = 0; __try { _evm_ = DisableDocChangeNotification(); SendMessage(Globals.hwndEdit, WM_SETREDRAW, FALSE, 0);
#define RestoreNotifyEvents() ;} __finally { EnableDocChangeNotification(_evm_); SendMessage(Globals.hwndEdit, WM_SETREDRAW, TRUE, 0); InvalidateRect(Globals.hwndEdit, NULL, TRUE); } }
// ----------------------------------------------------------------------------
// none msg change notify, preserve redo-undo selection stack
#define UndoTransActionBegin() { LONG _token_ = 0L; __try { _token_ = BeginUndoActionSelection();
#define EndUndoTransAction() ;} __finally { EndUndoActionSelection(_token_); } }
// ----------------------------------------------------------------------------
#define BeginWaitCursor(cond, text) { \
if (cond) { \
SciCall_SetCursor(SC_CURSORWAIT); \
SciCall_SetVScrollbar(false); \
SciCall_SetHScrollbar(false); \
StatusSetText(Globals.hwndStatus, STATUS_HELP, (text)); \
} \
LimitNotifyEvents()
#define BeginWaitCursorUID(cond, uid) { \
if (cond) { \
SciCall_SetCursor(SC_CURSORWAIT); \
SciCall_SetVScrollbar(false); \
SciCall_SetHScrollbar(false); \
StatusSetTextID(Globals.hwndStatus, STATUS_HELP, (uid)); \
} \
LimitNotifyEvents()
#define EndWaitCursor() \
RestoreNotifyEvents(); \
SciCall_SetCursor(SC_CURSORNORMAL); \
POINT pt; GetCursorPos(&pt); \
SetCursorPos(pt.x, pt.y); \
SciCall_SetHScrollbar(true); \
SciCall_SetVScrollbar(true); \
UpdateStatusbar(true); \
}
// ----------------------------------------------------------------------------
inline void UserMarkerDeleteAll(const DocLn ln)
{
//~~~ SciCall_MarkerDelete(line, -1);
int const bitmask = ALL_MARKERS_BITMASK();
int markers = SciCall_MarkerGet(ln);
while (markers & bitmask) {
for (int m = 0; m <= MARKER_NP3_BOOKMARK; ++m) {
if (TEST_BIT(int, m, markers)) {
SciCall_MarkerDelete(ln, m);
}
}
markers = SciCall_MarkerGet(ln);
}
}
// ----------------------------------------------------------------------------
#endif //_NP3_NOTEPAD3_H_
/// End of Notepad3.h ///