Skip to content

Commit 6357cb4

Browse files
committed
merge with master e707c27
1 parent bcb9788 commit 6357cb4

File tree

76 files changed

+2521
-1016
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+2521
-1016
lines changed

NppPlugin/include/Common.h

Lines changed: 59 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
//
1414
// You should have received a copy of the GNU General Public License
1515
// along with this program. If not, see <https://www.gnu.org/licenses/>.
16+
1617
#pragma once
1718
#include <vector>
1819
#include <string>
@@ -24,6 +25,9 @@
2425
#include <algorithm>
2526
#include <tchar.h>
2627

28+
#pragma deprecated(PathFileExists) // Use doesFileExist, doesDirectoryExist or doesPathExist (for file or directory) instead.
29+
#pragma deprecated(PathIsDirectory) // Use doesDirectoryExist instead.
30+
2731

2832
const bool dirUp = true;
2933
const bool dirDown = false;
@@ -46,35 +50,34 @@ const bool dirDown = false;
4650

4751
#define NPP_INTERNAL_FUCTION_STR L"Notepad++::InternalFunction"
4852

49-
typedef std::basic_string<TCHAR> generic_string;
50-
typedef std::basic_stringstream<TCHAR> generic_stringstream;
5153

52-
generic_string folderBrowser(HWND parent, const generic_string & title = TEXT(""), int outputCtrlID = 0, const TCHAR *defaultStr = NULL);
53-
generic_string getFolderName(HWND parent, const TCHAR *defaultDir = NULL);
54+
std::wstring folderBrowser(HWND parent, const std::wstring & title = L"", int outputCtrlID = 0, const wchar_t *defaultStr = NULL);
55+
std::wstring getFolderName(HWND parent, const wchar_t *defaultDir = NULL);
5456

5557
void printInt(int int2print);
56-
void printStr(const TCHAR *str2print);
57-
generic_string commafyInt(size_t n);
58+
void printStr(const wchar_t *str2print);
59+
std::wstring commafyInt(size_t n);
5860

59-
void writeLog(const TCHAR *logFileName, const char *log2write);
61+
void writeLog(const wchar_t* logFileName, const char* log2write);
62+
void writeLog(const wchar_t* logFileName, const wchar_t* log2write);
6063
int filter(unsigned int code, struct _EXCEPTION_POINTERS *ep);
61-
generic_string purgeMenuItemString(const TCHAR * menuItemStr, bool keepAmpersand = false);
62-
std::vector<generic_string> tokenizeString(const generic_string & tokenString, const char delim);
64+
std::wstring purgeMenuItemString(const wchar_t* menuItemStr, bool keepAmpersand = false);
65+
std::vector<std::wstring> tokenizeString(const std::wstring & tokenString, const char delim);
6366

6467
void ClientRectToScreenRect(HWND hWnd, RECT* rect);
6568
void ScreenRectToClientRect(HWND hWnd, RECT* rect);
6669

6770
std::wstring string2wstring(const std::string & rString, UINT codepage);
6871
std::string wstring2string(const std::wstring & rwString, UINT codepage);
69-
bool isInList(const TCHAR *token, const TCHAR *list);
70-
generic_string BuildMenuFileName(int filenameLen, unsigned int pos, const generic_string &filename, bool ordinalNumber = true);
72+
bool isInList(const wchar_t *token, const wchar_t *list);
73+
std::wstring BuildMenuFileName(int filenameLen, unsigned int pos, const std::wstring &filename, bool ordinalNumber = true);
7174

72-
std::string getFileContent(const TCHAR *file2read);
73-
generic_string relativeFilePathToFullFilePath(const TCHAR *relativeFilePath);
74-
void writeFileContent(const TCHAR *file2write, const char *content2write);
75-
bool matchInList(const TCHAR *fileName, const std::vector<generic_string> & patterns);
76-
bool matchInExcludeDirList(const TCHAR* dirName, const std::vector<generic_string>& patterns, size_t level);
77-
bool allPatternsAreExclusion(const std::vector<generic_string> patterns);
75+
std::string getFileContent(const wchar_t *file2read);
76+
std::wstring relativeFilePathToFullFilePath(const wchar_t *relativeFilePath);
77+
void writeFileContent(const wchar_t *file2write, const char *content2write);
78+
bool matchInList(const wchar_t *fileName, const std::vector<std::wstring> & patterns);
79+
bool matchInExcludeDirList(const wchar_t* dirName, const std::vector<std::wstring>& patterns, size_t level);
80+
bool allPatternsAreExclusion(const std::vector<std::wstring>& patterns);
7881

7982
class WcharMbcsConvertor final
8083
{
@@ -151,41 +154,36 @@ class WcharMbcsConvertor final
151154

152155
#define REBARBAND_SIZE sizeof(REBARBANDINFO)
153156

154-
generic_string PathRemoveFileSpec(generic_string & path);
155-
generic_string pathAppend(generic_string &strDest, const generic_string & str2append);
157+
std::wstring pathRemoveFileSpec(std::wstring & path);
158+
std::wstring pathAppend(std::wstring &strDest, const std::wstring & str2append);
156159
COLORREF getCtrlBgColor(HWND hWnd);
157-
generic_string stringToUpper(generic_string strToConvert);
158-
generic_string stringToLower(generic_string strToConvert);
159-
generic_string stringReplace(generic_string subject, const generic_string& search, const generic_string& replace);
160-
void stringSplit(const generic_string& input, const generic_string& delimiter, std::vector<generic_string>& output);
161-
bool str2numberVector(generic_string str2convert, std::vector<size_t>& numVect);
162-
void stringJoin(const std::vector<generic_string>& strings, const generic_string& separator, generic_string& joinedString);
163-
generic_string stringTakeWhileAdmissable(const generic_string& input, const generic_string& admissable);
164-
double stodLocale(const generic_string& str, _locale_t loc, size_t* idx = NULL);
165-
166-
int OrdinalIgnoreCaseCompareStrings(LPCTSTR sz1, LPCTSTR sz2);
167-
168-
bool str2Clipboard(const generic_string &str2cpy, HWND hwnd);
160+
std::wstring stringToUpper(std::wstring strToConvert);
161+
std::wstring stringToLower(std::wstring strToConvert);
162+
std::wstring stringReplace(std::wstring subject, const std::wstring& search, const std::wstring& replace);
163+
void stringSplit(const std::wstring& input, const std::wstring& delimiter, std::vector<std::wstring>& output);
164+
bool str2numberVector(std::wstring str2convert, std::vector<size_t>& numVect);
165+
void stringJoin(const std::vector<std::wstring>& strings, const std::wstring& separator, std::wstring& joinedString);
166+
std::wstring stringTakeWhileAdmissable(const std::wstring& input, const std::wstring& admissable);
167+
double stodLocale(const std::wstring& str, _locale_t loc, size_t* idx = NULL);
168+
169+
bool str2Clipboard(const std::wstring &str2cpy, HWND hwnd);
169170
class Buffer;
170171
bool buf2Clipboard(const std::vector<Buffer*>& buffers, bool isFullPath, HWND hwnd);
171172

172-
generic_string GetLastErrorAsString(DWORD errorCode = 0);
173+
std::wstring GetLastErrorAsString(DWORD errorCode = 0);
173174

174-
generic_string intToString(int val);
175-
generic_string uintToString(unsigned int val);
175+
std::wstring intToString(int val);
176+
std::wstring uintToString(unsigned int val);
176177

177178
HWND CreateToolTip(int toolID, HWND hDlg, HINSTANCE hInst, const PTSTR pszText, bool isRTL);
178179
HWND CreateToolTipRect(int toolID, HWND hWnd, HINSTANCE hInst, const PTSTR pszText, const RECT rc);
179180

180-
bool isCertificateValidated(const generic_string & fullFilePath, const generic_string & subjectName2check);
181+
bool isCertificateValidated(const std::wstring & fullFilePath, const std::wstring & subjectName2check);
181182
bool isAssoCommandExisting(LPCTSTR FullPathName);
182183

183-
std::wstring s2ws(const std::string& str);
184-
std::string ws2s(const std::wstring& wstr);
185-
186-
bool deleteFileOrFolder(const generic_string& f2delete);
184+
bool deleteFileOrFolder(const std::wstring& f2delete);
187185

188-
void getFilesInFolder(std::vector<generic_string>& files, const generic_string& extTypeFilter, const generic_string& inFolder);
186+
void getFilesInFolder(std::vector<std::wstring>& files, const std::wstring& extTypeFilter, const std::wstring& inFolder);
189187

190188
template<typename T> size_t vecRemoveDuplicates(std::vector<T>& vec, bool isSorted = false, bool canSort = false)
191189
{
@@ -217,27 +215,27 @@ void trim(std::wstring& str);
217215

218216
int nbDigitsFromNbLines(size_t nbLines);
219217

220-
generic_string getDateTimeStrFrom(const generic_string& dateTimeFormat, const SYSTEMTIME& st);
218+
std::wstring getDateTimeStrFrom(const std::wstring& dateTimeFormat, const SYSTEMTIME& st);
221219

222-
HFONT createFont(const TCHAR* fontName, int fontSize, bool isBold, HWND hDestParent);
220+
HFONT createFont(const wchar_t* fontName, int fontSize, bool isBold, HWND hDestParent);
223221
bool removeReadOnlyFlagFromFileAttributes(const wchar_t* fileFullPath);
224222

225-
bool isWin32NamespacePrefixedFileName(const generic_string& fileName);
226-
bool isWin32NamespacePrefixedFileName(const TCHAR* szFileName);
227-
bool isUnsupportedFileName(const generic_string& fileName);
228-
bool isUnsupportedFileName(const TCHAR* szFileName);
223+
bool isWin32NamespacePrefixedFileName(const std::wstring& fileName);
224+
bool isWin32NamespacePrefixedFileName(const wchar_t* szFileName);
225+
bool isUnsupportedFileName(const std::wstring& fileName);
226+
bool isUnsupportedFileName(const wchar_t* szFileName);
229227

230228
class Version final
231229
{
232230
public:
233231
Version() = default;
234-
Version(const generic_string& versionStr);
232+
Version(const std::wstring& versionStr);
235233

236-
void setVersionFrom(const generic_string& filePath);
237-
generic_string toString();
238-
bool isNumber(const generic_string& s) const {
234+
void setVersionFrom(const std::wstring& filePath);
235+
std::wstring toString();
236+
bool isNumber(const std::wstring& s) const {
239237
return !s.empty() &&
240-
find_if(s.begin(), s.end(), [](TCHAR c) { return !_istdigit(c); }) == s.end();
238+
find_if(s.begin(), s.end(), [](wchar_t c) { return !_istdigit(c); }) == s.end();
241239
};
242240

243241
int compareTo(const Version& v2c) const;
@@ -280,3 +278,13 @@ class Version final
280278
unsigned long _patch = 0;
281279
unsigned long _build = 0;
282280
};
281+
282+
283+
BOOL getDiskFreeSpaceWithTimeout(const wchar_t* dirPath, ULARGE_INTEGER* freeBytesForUser,
284+
DWORD milliSec2wait = 0, bool* isTimeoutReached = nullptr);
285+
BOOL getFileAttributesExWithTimeout(const wchar_t* filePath, WIN32_FILE_ATTRIBUTE_DATA* fileAttr,
286+
DWORD milliSec2wait = 0, bool* isTimeoutReached = nullptr, DWORD* pdwWin32ApiError = nullptr);
287+
288+
bool doesFileExist(const wchar_t* filePath, DWORD milliSec2wait = 0, bool* isTimeoutReached = nullptr);
289+
bool doesDirectoryExist(const wchar_t* dirPath, DWORD milliSec2wait = 0, bool* isTimeoutReached = nullptr);
290+
bool doesPathExist(const wchar_t* path, DWORD milliSec2wait = 0, bool* isTimeoutReached = nullptr);

NppPlugin/include/Docking.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,18 @@
4949

5050
struct tTbData {
5151
HWND hClient = nullptr; // client Window Handle
52-
const TCHAR* pszName = nullptr; // name of plugin (shown in window)
52+
const wchar_t* pszName = nullptr; // name of plugin (shown in window)
5353
int dlgID = 0; // a funcItem provides the function pointer to start a dialog. Please parse here these ID
5454

5555
// user modifications
5656
UINT uMask = 0; // mask params: look to above defines
5757
HICON hIconTab = nullptr; // icon for tabs
58-
const TCHAR* pszAddInfo = nullptr; // for plugin to display additional informations
58+
const wchar_t* pszAddInfo = nullptr; // for plugin to display additional informations
5959

6060
// internal data, do not use !!!
6161
RECT rcFloat = {}; // floating position
6262
int iPrevCont = 0; // stores the privious container (toggling between float and dock)
63-
const TCHAR* pszModuleName = nullptr; // it's the plugin file name. It's used to identify the plugin
63+
const wchar_t* pszModuleName = nullptr; // it's the plugin file name. It's used to identify the plugin
6464
};
6565

6666

NppPlugin/include/DockingDlgInterface.h

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,21 @@ class DockingDlgInterface : public StaticDialog
3434
DockingDlgInterface() = default;
3535
explicit DockingDlgInterface(int dlgID): _dlgID(dlgID) {}
3636

37-
virtual void init(HINSTANCE hInst, HWND parent) {
37+
void init(HINSTANCE hInst, HWND parent) override {
3838
StaticDialog::init(hInst, parent);
39-
TCHAR temp[MAX_PATH];
39+
wchar_t temp[MAX_PATH];
4040
::GetModuleFileName(hInst, temp, MAX_PATH);
4141
_moduleName = ::PathFindFileName(temp);
4242
}
4343

44-
void create(tTbData* data, bool isRTL = false) {
44+
void create(tTbData* data, bool isRTL = false) {
4545
assert(data != nullptr);
4646
StaticDialog::create(_dlgID, isRTL);
47-
TCHAR temp[MAX_PATH];
47+
wchar_t temp[MAX_PATH];
4848
::GetWindowText(_hSelf, temp, MAX_PATH);
4949
_pluginName = temp;
5050

51-
// user information
51+
// user information
5252
data->hClient = _hSelf;
5353
data->pszName = _pluginName.c_str();
5454

@@ -63,14 +63,10 @@ class DockingDlgInterface : public StaticDialog
6363
::SendMessage(_hParent, NPPM_DMMUPDATEDISPINFO, 0, reinterpret_cast<LPARAM>(_hSelf));
6464
}
6565

66-
virtual void destroy() {
67-
StaticDialog::destroy();
68-
}
69-
7066
virtual void setBackgroundColor(COLORREF) {}
7167
virtual void setForegroundColor(COLORREF) {}
7268

73-
virtual void display(bool toShow = true) const {
69+
void display(bool toShow = true) const override {
7470
::SendMessage(_hParent, toShow ? NPPM_DMMSHOW : NPPM_DMMHIDE, 0, reinterpret_cast<LPARAM>(_hSelf));
7571
}
7672

@@ -82,19 +78,19 @@ class DockingDlgInterface : public StaticDialog
8278
_isClosed = toClose;
8379
}
8480

85-
const TCHAR * getPluginFileName() const {
81+
const wchar_t * getPluginFileName() const {
8682
return _moduleName.c_str();
8783
}
8884

8985
protected :
9086
int _dlgID = -1;
9187
bool _isFloating = true;
9288
int _iDockedPos = 0;
93-
generic_string _moduleName;
94-
generic_string _pluginName;
89+
std::wstring _moduleName;
90+
std::wstring _pluginName;
9591
bool _isClosed = false;
9692

97-
virtual intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) {
93+
intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) override {
9894
switch (message)
9995
{
10096
case WM_ERASEBKGND:

0 commit comments

Comments
 (0)