diff --git a/Common/Ccpp/Common.cpp b/Common/Ccpp/Common.cpp index eb65107..d161812 100644 --- a/Common/Ccpp/Common.cpp +++ b/Common/Ccpp/Common.cpp @@ -59,7 +59,7 @@ std::string getFileContent(const TCHAR *file2read) const size_t blockSize = 1024; char data[blockSize]; std::string wholeFileContent = ""; - FILE *fp = generic_fopen(file2read, TEXT("rb")); + FILE *fp = _wfopen(file2read, TEXT("rb")); size_t lenFile = 0; do @@ -128,16 +128,16 @@ void writeLog(const TCHAR *logFileName, const char *log2write) const DWORD accessParam{ GENERIC_READ | GENERIC_WRITE }; const DWORD shareParam{ FILE_SHARE_READ | FILE_SHARE_WRITE }; const DWORD dispParam{ OPEN_ALWAYS }; // Open existing file for writing without destroying it or create new - const DWORD attribParam{ FILE_ATTRIBUTE_NORMAL | FILE_FLAG_WRITE_THROUGH }; + const DWORD attribParam{ FILE_ATTRIBUTE_NORMAL }; HANDLE hFile = ::CreateFileW(logFileName, accessParam, shareParam, NULL, dispParam, attribParam, NULL); if (hFile != INVALID_HANDLE_VALUE) { - LARGE_INTEGER offset; + LARGE_INTEGER offset{}; offset.QuadPart = 0; ::SetFilePointerEx(hFile, offset, NULL, FILE_END); - SYSTEMTIME currentTime = { 0 }; + SYSTEMTIME currentTime = {}; ::GetLocalTime(¤tTime); generic_string dateTimeStrW = getDateTimeStrFrom(TEXT("yyyy-MM-dd HH:mm:ss"), currentTime); std::wstring_convert> converter; @@ -150,6 +150,7 @@ void writeLog(const TCHAR *logFileName, const char *log2write) ::WriteFile(hFile, log2writeStr.c_str(), static_cast(log2writeStr.length()), &bytes_written, NULL); ::FlushFileBuffers(hFile); + ::CloseHandle(hFile); } } @@ -190,7 +191,7 @@ NOT USED by HEXEDIT*/ void ClientRectToScreenRect(HWND hWnd, RECT* rect) { - POINT pt; + POINT pt{}; pt.x = rect->left; pt.y = rect->top; @@ -231,7 +232,7 @@ std::vector tokenizeString(const generic_string & tokenString, c void ScreenRectToClientRect(HWND hWnd, RECT* rect) { - POINT pt; + POINT pt{}; pt.x = rect->left; pt.y = rect->top; @@ -263,7 +264,7 @@ bool isInList(const TCHAR *token, const TCHAR *list) const size_t wordLen = 64; size_t listLen = lstrlen(list); - TCHAR word[wordLen]; + TCHAR word[wordLen] = { '\0' }; size_t i = 0; size_t j = 0; @@ -276,7 +277,7 @@ bool isInList(const TCHAR *token, const TCHAR *list) word[j] = '\0'; j = 0; - if (!generic_stricmp(token, word)) + if (!_wcsicmp(token, word)) return true; } } @@ -334,7 +335,7 @@ const wchar_t * WcharMbcsConvertor::char2wchar(const char * mbcs2Convert, size_t return nullptr; // Do not process empty strings - if (lenMbcs == 0 || lenMbcs == -1 && mbcs2Convert[0] == 0) + if (lenMbcs == 0 || (lenMbcs == -1 && mbcs2Convert[0] == 0)) { _wideCharStr.empty(); return _wideCharStr; @@ -433,8 +434,9 @@ const wchar_t * WcharMbcsConvertor::char2wchar(const char * mbcs2Convert, size_t const char* WcharMbcsConvertor::wchar2char(const wchar_t * wcharStr2Convert, size_t codepage, int lenWc, int* pLenMbcs) { - if (nullptr == wcharStr2Convert) + if (!wcharStr2Convert) return nullptr; + UINT cp = static_cast(codepage); int lenMbcs = WideCharToMultiByte(cp, 0, wcharStr2Convert, lenWc, NULL, 0, NULL, NULL); if (lenMbcs > 0) @@ -453,8 +455,9 @@ const char* WcharMbcsConvertor::wchar2char(const wchar_t * wcharStr2Convert, siz const char * WcharMbcsConvertor::wchar2char(const wchar_t * wcharStr2Convert, size_t codepage, intptr_t* mstart, intptr_t* mend) { - if (nullptr == wcharStr2Convert) + if (!wcharStr2Convert) return nullptr; + UINT cp = static_cast(codepage); int len = WideCharToMultiByte(cp, 0, wcharStr2Convert, -1, NULL, 0, NULL, NULL); if (len > 0) @@ -559,24 +562,34 @@ generic_string uintToString(unsigned int val) } // Build Recent File menu entries from given -generic_string BuildMenuFileName(int filenameLen, unsigned int pos, const generic_string &filename) +generic_string BuildMenuFileName(int filenameLen, unsigned int pos, const generic_string &filename, bool ordinalNumber) { generic_string strTemp; - if (pos < 9) - { - strTemp.push_back('&'); - strTemp.push_back('1' + static_cast(pos)); - } - else if (pos == 9) + if (ordinalNumber) { - strTemp.append(TEXT("1&0")); + if (pos < 9) + { + strTemp.push_back('&'); + strTemp.push_back('1' + static_cast(pos)); + } + else if (pos == 9) + { + strTemp.append(TEXT("1&0")); + } + else + { + div_t splitDigits = div(pos + 1, 10); + strTemp.append(uintToString(splitDigits.quot)); + strTemp.push_back('&'); + strTemp.append(uintToString(splitDigits.rem)); + } + strTemp.append(TEXT(": ")); } else { - strTemp.append(uintToString(pos + 1)); + strTemp.push_back('&'); } - strTemp.append(TEXT(": ")); if (filenameLen > 0) { @@ -711,7 +724,7 @@ COLORREF getCtrlBgColor(HWND hWnd) generic_string stringToUpper(generic_string strToConvert) { std::transform(strToConvert.begin(), strToConvert.end(), strToConvert.begin(), - [](TCHAR ch){ return static_cast(_totupper(ch)); } + [](wchar_t ch){ return static_cast(towupper(ch)); } ); return strToConvert; } @@ -735,11 +748,10 @@ generic_string stringReplace(generic_string subject, const generic_string& searc } -std::vector stringSplit(const generic_string& input, const generic_string& delimiter) +void stringSplit(const generic_string& input, const generic_string& delimiter, std::vector& output) { size_t start = 0U; size_t end = input.find(delimiter); - std::vector output; const size_t delimiterLength = delimiter.length(); while (end != std::string::npos) { @@ -748,7 +760,6 @@ std::vector stringSplit(const generic_string& input, const gener end = input.find(delimiter, start); } output.push_back(input.substr(start, end)); - return output; } @@ -773,8 +784,9 @@ bool str2numberVector(generic_string str2convert, std::vector& numVect) } } - std::vector v = stringSplit(str2convert, TEXT(" ")); - for (auto i : v) + std::vector v; + stringSplit(str2convert, TEXT(" "), v); + for (const auto& i : v) { // Don't treat empty string and the number greater than 9999 if (!i.empty() && i.length() < 5) @@ -785,19 +797,17 @@ bool str2numberVector(generic_string str2convert, std::vector& numVect) return true; } -generic_string stringJoin(const std::vector& strings, const generic_string& separator) +void stringJoin(const std::vector& strings, const generic_string& separator, generic_string& joinedString) { - generic_string joined; size_t length = strings.size(); for (size_t i = 0; i < length; ++i) { - joined += strings.at(i); + joinedString += strings.at(i); if (i != length - 1) { - joined += separator; + joinedString += separator; } } - return joined; } @@ -816,7 +826,7 @@ generic_string stringTakeWhileAdmissable(const generic_string& input, const gene } -double stodLocale(const generic_string& str, _locale_t loc, size_t* idx) +double stodLocale(const generic_string& str, [[maybe_unused]] _locale_t loc, size_t* idx) { // Copied from the std::stod implementation but uses _wcstod_l instead of wcstod. const wchar_t* ptr = str.c_str(); @@ -923,7 +933,7 @@ bool str2Clipboard(const generic_string &str2cpy, HWND hwnd) ::CloseClipboard(); return false; } - _tcscpy_s(pStr, len2Allocate / sizeof(TCHAR), str2cpy.c_str()); + wcscpy_s(pStr, len2Allocate / sizeof(TCHAR), str2cpy.c_str()); ::GlobalUnlock(hglbCopy); // Place the handle on the clipboard. unsigned int clipBoardFormat = CF_UNICODETEXT; @@ -953,7 +963,7 @@ bool buf2Clipborad(const std::vector& buffers, bool isFullPath, HWND hw if (fileName) selection += fileName; } - if (!selection.empty() && !endsWith(selection, crlf)) + if (!selection.empty() && !selection.ends_with(crlf)) selection += crlf; } if (!selection.empty()) @@ -1068,7 +1078,7 @@ HWND CreateToolTip(int toolID, HWND hDlg, HINSTANCE hInst, const PTSTR pszText, NppDarkMode::setDarkTooltips(hwndTip, NppDarkMode::ToolTipsType::tooltip); // Associate the tooltip with the tool. - TOOLINFO toolInfo = { 0 }; + TOOLINFO toolInfo = {}; toolInfo.cbSize = sizeof(toolInfo); toolInfo.hwnd = hDlg; toolInfo.uFlags = TTF_IDISHWND | TTF_SUBCLASS; @@ -1109,7 +1119,7 @@ HWND CreateToolTipRect(int toolID, HWND hWnd, HINSTANCE hInst, const PTSTR pszTe } // Associate the tooltip with the tool. - TOOLINFO toolInfo = { 0 }; + TOOLINFO toolInfo = {}; toolInfo.cbSize = sizeof(toolInfo); toolInfo.hwnd = hWnd; toolInfo.uFlags = TTF_SUBCLASS; @@ -1143,7 +1153,7 @@ bool isCertificateValidated(const generic_string & fullFilePath, const generic_s DWORD dwFormatType = 0; PCMSG_SIGNER_INFO pSignerInfo = NULL; DWORD dwSignerInfo = 0; - CERT_INFO CertInfo; + CERT_INFO CertInfo{}; LPTSTR szName = NULL; generic_string subjectName; @@ -1280,11 +1290,10 @@ bool isAssoCommandExisting(LPCTSTR FullPathName) // check if association exist hres = AssocQueryString(ASSOCF_VERIFY|ASSOCF_INIT_IGNOREUNKNOWN, ASSOCSTR_COMMAND, ext, NULL, buffer, &bufferLen); - + isAssoCommandExisting = (hres == S_OK) // check if association exist and no error - && (buffer != NULL) // check if buffer is not NULL && (wcsstr(buffer, TEXT("notepad++.exe")) == NULL); // check association with notepad++ - + } return isAssoCommandExisting; } @@ -1292,7 +1301,7 @@ bool isAssoCommandExisting(LPCTSTR FullPathName) std::wstring s2ws(const std::string& str) { using convert_typeX = std::codecvt_utf8; - std::wstring_convert converterX("Error in N++ string conversion s2ws!", L"Error in N++ string conversion s2ws!"); + std::wstring_convert converterX("Error in Notepad++ string conversion s2ws!", L"Error in Notepad++ string conversion s2ws!"); return converterX.from_bytes(str); } @@ -1300,7 +1309,7 @@ std::wstring s2ws(const std::string& str) std::string ws2s(const std::wstring& wstr) { using convert_typeX = std::codecvt_utf8; - std::wstring_convert converterX("Error in N++ string conversion ws2s!", L"Error in N++ string conversion ws2s!"); + std::wstring_convert converterX("Error in Notepad++ string conversion ws2s!", L"Error in Notepad++ string conversion ws2s!"); return converterX.to_bytes(wstr); } @@ -1313,7 +1322,7 @@ bool deleteFileOrFolder(const generic_string& f2delete) actionFolder[len] = 0; actionFolder[len + 1] = 0; - SHFILEOPSTRUCT fileOpStruct = { 0 }; + SHFILEOPSTRUCT fileOpStruct = {}; fileOpStruct.hwnd = NULL; fileOpStruct.pFrom = actionFolder; fileOpStruct.pTo = NULL; @@ -1354,30 +1363,20 @@ void getFilesInFolder(std::vector& files, const generic_string& ::FindClose(hFindFile); } -void trim(generic_string& str) +// remove any leading or trailing spaces from str +void trim(std::wstring& str) { - // remove any leading or trailing spaces from str + std::wstring::size_type pos = str.find_last_not_of(' '); - generic_string::size_type pos = str.find_last_not_of(' '); - - if (pos != generic_string::npos) + if (pos != std::wstring::npos) { str.erase(pos + 1); pos = str.find_first_not_of(' '); - if (pos != generic_string::npos) str.erase(0, pos); + if (pos != std::wstring::npos) str.erase(0, pos); } else str.erase(str.begin(), str.end()); } -bool endsWith(const generic_string& s, const generic_string& suffix) -{ -#if defined(_MSVC_LANG) && (_MSVC_LANG > 201402L) -#error Replace this function with basic_string::ends_with -#endif - size_t pos = s.find(suffix); - return pos != s.npos && ((s.length() - pos) == suffix.length()); -} - int nbDigitsFromNbLines(size_t nbLines) { int nbDigits = 0; // minimum number of digit should be 4 @@ -1390,7 +1389,7 @@ int nbDigitsFromNbLines(size_t nbLines) else // rare case { nbDigits = 7; - nbLines /= 1000000; + nbLines /= 10000000; while (nbLines) { @@ -1510,12 +1509,12 @@ HFONT createFont(const TCHAR* fontName, int fontSize, bool isBold, HWND hDestPar { HDC hdc = GetDC(hDestParent); - LOGFONT logFont = { 0 }; + LOGFONT logFont = {}; logFont.lfHeight = -MulDiv(fontSize, GetDeviceCaps(hdc, LOGPIXELSY), 72); if (isBold) logFont.lfWeight = FW_BOLD; - _tcscpy_s(logFont.lfFaceName, fontName); + wcscpy_s(logFont.lfFaceName, fontName); HFONT newFont = CreateFontIndirect(&logFont); @@ -1523,3 +1522,310 @@ HFONT createFont(const TCHAR* fontName, int fontSize, bool isBold, HWND hDestPar return newFont; } + +bool removeReadOnlyFlagFromFileAttributes(const wchar_t* fileFullPath) +{ + if (!PathFileExists(fileFullPath)) + return false; + + DWORD dwFileAttribs = ::GetFileAttributes(fileFullPath); + dwFileAttribs &= ~FILE_ATTRIBUTE_READONLY; + return (::SetFileAttributes(fileFullPath, dwFileAttribs) != FALSE); +} + +/*NOT USED by HEXEDIT + +// "For file I/O, the "\\?\" prefix to a path string tells the Windows APIs to disable all string parsing +// and to send the string that follows it straight to the file system..." +// Ref: https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#win32-file-namespaces +bool isWin32NamespacePrefixedFileName(const generic_string& fileName) +{ + // TODO: + // ?! how to handle similar NT Object Manager path style prefix case \??\... + // (the \??\ prefix instructs the NT Object Manager to search in the caller's local device directory for an alias...) + + // the following covers the \\?\... raw Win32-filenames or the \\?\UNC\... UNC equivalents + // and also its *nix like forward slash equivalents + return (fileName.starts_with(TEXT("\\\\?\\")) || fileName.starts_with(TEXT("//?/"))); +} + +bool isWin32NamespacePrefixedFileName(const TCHAR* szFileName) +{ + const generic_string fileName = szFileName; + return isWin32NamespacePrefixedFileName(fileName); +} + + +bool isUnsupportedFileName(const generic_string& fileName) +{ + bool isUnsupported = true; + + // until the Notepad++ (and its plugins) will not be prepared for filenames longer than the MAX_PATH, + // we have to limit also the maximum supported length below + if ((fileName.size() > 0) && (fileName.size() < MAX_PATH)) + { + // possible raw filenames can contain space(s) or dot(s) at its end (e.g. "\\?\C:\file."), but the Notepad++ advanced + // Open/SaveAs IFileOpenDialog/IFileSaveDialog COM-interface based dialogs currently do not handle this well + // (but e.g. direct Notepad++ Ctrl+S works ok even with these filenames) + // + // Exception for the standard filenames ending with the dot-char: + // - when someone tries to open e.g. the 'C:\file.', we will accept that as this is the way how to work with filenames + // without an extension (some of the WINAPI calls used later trim that dot-char automatically ...) + if (!(fileName.ends_with(_T('.')) && isWin32NamespacePrefixedFileName(fileName)) && !fileName.ends_with(_T(' '))) + { + bool invalidASCIIChar = false; + + for (size_t pos = 0; pos < fileName.size(); ++pos) + { + TCHAR c = fileName.at(pos); + if (c <= 31) + { + invalidASCIIChar = true; + } + else + { + // as this could be also a complete filename with path and there could be also a globbing used, + // we tolerate here some other reserved Win32-filename chars: /, \, :, ?, * + switch (c) + { + case '<': + case '>': + case '"': + case '|': + invalidASCIIChar = true; + break; + } + } + + if (invalidASCIIChar) + break; + } + + if (!invalidASCIIChar) + { + // strip input string to a filename without a possible path and extension(s) + generic_string fileNameOnly; + size_t pos = fileName.find_first_of(TEXT(".")); + if (pos != std::string::npos) + fileNameOnly = fileName.substr(0, pos); + else + fileNameOnly = fileName; + + pos = fileNameOnly.find_last_of(TEXT("\\")); + if (pos == std::string::npos) + pos = fileNameOnly.find_last_of(TEXT("/")); + if (pos != std::string::npos) + fileNameOnly = fileNameOnly.substr(pos + 1); + + const std::vector reservedWin32NamespaceDeviceList{ + TEXT("CON"), TEXT("PRN"), TEXT("AUX"), TEXT("NUL"), + TEXT("COM1"), TEXT("COM2"), TEXT("COM3"), TEXT("COM4"), TEXT("COM5"), TEXT("COM6"), TEXT("COM7"), TEXT("COM8"), TEXT("COM9"), + TEXT("LPT1"), TEXT("LPT2"), TEXT("LPT3"), TEXT("LPT4"), TEXT("LPT5"), TEXT("LPT6"), TEXT("LPT7"), TEXT("LPT8"), TEXT("LPT9") + }; + + // last check is for all the old reserved Windows OS filenames + if (std::find(reservedWin32NamespaceDeviceList.begin(), reservedWin32NamespaceDeviceList.end(), fileNameOnly) == reservedWin32NamespaceDeviceList.end()) + { + // ok, the current filename tested is not even on the blacklist + isUnsupported = false; + } + } + } + } + + return isUnsupported; +} + + +bool isUnsupportedFileName(const TCHAR* szFileName) +{ + const generic_string fileName = szFileName; + return isUnsupportedFileName(fileName); +} +NOT USED by HEXEDIT*/ + +Version::Version(const generic_string& versionStr) +{ + try { + auto ss = tokenizeString(versionStr, '.'); + + if (ss.size() > 4) + { + std::wstring msg(L"\""); + msg += versionStr; + msg += L"\""; + msg += TEXT(": Version parts are more than 4. The string to parse is not a valid version format. Let's make it default value in catch block."); + throw msg; + } + + int i = 0; + std::vector v = { &_major, &_minor, &_patch, &_build }; + for (const auto& s : ss) + { + if (!isNumber(s)) + { + std::wstring msg(L"\""); + msg += versionStr; + msg += L"\""; + msg += TEXT(": One of version character is not number. The string to parse is not a valid version format. Let's make it default value in catch block."); + throw msg; + } + *(v[i]) = std::stoi(s); + + ++i; + } + } +#ifdef DEBUG + catch (const std::wstring& s) + { + _major = 0; + _minor = 0; + _patch = 0; + _build = 0; + + throw s; + } +#endif + catch (...) + { + _major = 0; + _minor = 0; + _patch = 0; + _build = 0; +#ifdef DEBUG + throw std::wstring(TEXT("Unknown exception from \"Version::Version(const generic_string& versionStr)\"")); +#endif + } +} + +/*NOT USED by HEXEDIT +void Version::setVersionFrom(const generic_string& filePath) +{ + if (!filePath.empty() && ::PathFileExists(filePath.c_str())) + { + DWORD uselessArg = 0; // this variable is for passing the ignored argument to the functions + DWORD bufferSize = ::GetFileVersionInfoSize(filePath.c_str(), &uselessArg); + + if (bufferSize <= 0) + return; + + unsigned char* buffer = new unsigned char[bufferSize]; + ::GetFileVersionInfo(filePath.c_str(), 0, bufferSize, buffer); + + VS_FIXEDFILEINFO* lpFileInfo = nullptr; + UINT cbFileInfo = 0; + VerQueryValue(buffer, TEXT("\\"), reinterpret_cast(&lpFileInfo), &cbFileInfo); + if (cbFileInfo) + { + _major = (lpFileInfo->dwFileVersionMS & 0xFFFF0000) >> 16; + _minor = lpFileInfo->dwFileVersionMS & 0x0000FFFF; + _patch = (lpFileInfo->dwFileVersionLS & 0xFFFF0000) >> 16; + _build = lpFileInfo->dwFileVersionLS & 0x0000FFFF; + } + delete[] buffer; + } +} +NOT USED by HEXEDIT*/ + +generic_string Version::toString() +{ + if (_build == 0 && _patch == 0 && _minor == 0 && _major == 0) // "" + { + return TEXT(""); + } + else if (_build == 0 && _patch == 0 && _minor == 0) // "major" + { + return std::to_wstring(_major); + } + else if (_build == 0 && _patch == 0) // "major.minor" + { + std::wstring v = std::to_wstring(_major); + v += TEXT("."); + v += std::to_wstring(_minor); + return v; + } + else if (_build == 0) // "major.minor.patch" + { + std::wstring v = std::to_wstring(_major); + v += TEXT("."); + v += std::to_wstring(_minor); + v += TEXT("."); + v += std::to_wstring(_patch); + return v; + } + + // "major.minor.patch.build" + std::wstring ver = std::to_wstring(_major); + ver += TEXT("."); + ver += std::to_wstring(_minor); + ver += TEXT("."); + ver += std::to_wstring(_patch); + ver += TEXT("."); + ver += std::to_wstring(_build); + + return ver; +} + +int Version::compareTo(const Version& v2c) const +{ + if (_major > v2c._major) + return 1; + else if (_major < v2c._major) + return -1; + else // (_major == v2c._major) + { + if (_minor > v2c._minor) + return 1; + else if (_minor < v2c._minor) + return -1; + else // (_minor == v2c._minor) + { + if (_patch > v2c._patch) + return 1; + else if (_patch < v2c._patch) + return -1; + else // (_patch == v2c._patch) + { + if (_build > v2c._build) + return 1; + else if (_build < v2c._build) + return -1; + else // (_build == v2c._build) + { + return 0; + } + } + } + } +} + +bool Version::isCompatibleTo(const Version& from, const Version& to) const +{ + // This method determinates if Version object is in between "from" version and "to" version, it's useful for testing compatibility of application. + // test in versions example: + // 1. <0.0.0.0, 0.0.0.0>: both from to versions are empty, so it's + // 2. <6.9, 6.9>: plugin is compatible to only v6.9 + // 3. <4.2, 6.6.6>: from v4.2 (included) to v6.6.6 (included) + // 4. <0.0.0.0, 8.2.1>: all version until v8.2.1 (included) + // 5. <8.3, 0.0.0.0>: from v8.3 (included) to the latest verrsion + + if (empty()) // if this version is empty, then no compatible to all version + return false; + + if (from.empty() && to.empty()) // both versions "from" and "to" are empty: it's considered compatible, whatever this version is (match to 1) + { + return true; + } + + if (from <= *this && to >= *this) // from_ver <= this_ver <= to_ver (match to 2, 3 and 4) + { + return true; + } + + if (from <= *this && to.empty()) // from_ver <= this_ver (match to 5) + { + return true; + } + + return false; +} diff --git a/Common/Ccpp/Common.h b/Common/Ccpp/Common.h index 8a43f22..3c6ea8e 100644 --- a/Common/Ccpp/Common.h +++ b/Common/Ccpp/Common.h @@ -22,6 +22,7 @@ #include #include #include +#include const bool dirUp = true; @@ -36,31 +37,20 @@ const bool dirDown = false; #define BCKGRD_COLOR (RGB(255,102,102)) #define TXT_COLOR (RGB(255,255,255)) -#define generic_strtol wcstol -#define generic_strncpy wcsncpy -#define generic_stricmp _wcsicmp //MODIFIED by HEXEDIT -#define generic_strncmp wcsncmp -#define generic_strnicmp wcsnicmp -#define generic_strncat wcsncat -#define generic_strchr wcschr -#define generic_atoi _wtoi -#define generic_itoa _itow -#define generic_atof _wtof -#define generic_strtok wcstok -#define generic_strftime wcsftime -#define generic_fprintf fwprintf -#define generic_sprintf swprintf -#define generic_sscanf swscanf -#define generic_fopen _wfopen -#define generic_fgets fgetws -#define COPYDATA_FILENAMES COPYDATA_FILENAMESW -#define NPP_INTERNAL_FUCTION_STR TEXT("Notepad++::InternalFunction") +#ifndef __MINGW32__ +#define WCSTOK wcstok +#else +#define WCSTOK wcstok_s +#endif + + +#define NPP_INTERNAL_FUCTION_STR L"Notepad++::InternalFunction" typedef std::basic_string generic_string; typedef std::basic_stringstream generic_stringstream; -//NOT USED by HEXEDIT generic_string folderBrowser(HWND parent, const generic_string & title = TEXT(""), int outputCtrlID = 0, const TCHAR *defaultStr = NULL); -//NOT USED by HEXEDIT generic_string getFolderName(HWND parent, const TCHAR *defaultDir = NULL); +generic_string folderBrowser(HWND parent, const generic_string & title = TEXT(""), int outputCtrlID = 0, const TCHAR *defaultStr = NULL); +generic_string getFolderName(HWND parent, const TCHAR *defaultDir = NULL); void printInt(int int2print); void printStr(const TCHAR *str2print); @@ -77,7 +67,7 @@ void ScreenRectToClientRect(HWND hWnd, RECT* rect); std::wstring string2wstring(const std::string & rString, UINT codepage); std::string wstring2string(const std::wstring & rwString, UINT codepage); bool isInList(const TCHAR *token, const TCHAR *list); -generic_string BuildMenuFileName(int filenameLen, unsigned int pos, const generic_string &filename); +generic_string BuildMenuFileName(int filenameLen, unsigned int pos, const generic_string &filename, bool ordinalNumber = true); std::string getFileContent(const TCHAR *file2read); generic_string relativeFilePathToFullFilePath(const TCHAR *relativeFilePath); @@ -131,7 +121,7 @@ class WcharMbcsConvertor final { if (_allocLen) delete[] _str; - _allocLen = max(size, initSize); + _allocLen = std::max(size, initSize); _str = new T[_allocLen]; } } @@ -159,10 +149,6 @@ class WcharMbcsConvertor final }; - -#define MACRO_RECORDING_IN_PROGRESS 1 -#define MACRO_RECORDING_HAS_STOPPED 2 - #define REBARBAND_SIZE sizeof(REBARBANDINFO) generic_string PathRemoveFileSpec(generic_string & path); @@ -171,9 +157,9 @@ COLORREF getCtrlBgColor(HWND hWnd); generic_string stringToUpper(generic_string strToConvert); generic_string stringToLower(generic_string strToConvert); generic_string stringReplace(generic_string subject, const generic_string& search, const generic_string& replace); -std::vector stringSplit(const generic_string& input, const generic_string& delimiter); +void stringSplit(const generic_string& input, const generic_string& delimiter, std::vector& output); bool str2numberVector(generic_string str2convert, std::vector& numVect); -generic_string stringJoin(const std::vector& strings, const generic_string& separator); +void stringJoin(const std::vector& strings, const generic_string& separator, generic_string& joinedString); generic_string stringTakeWhileAdmissable(const generic_string& input, const generic_string& admissable); double stodLocale(const generic_string& str, _locale_t loc, size_t* idx = NULL); @@ -191,7 +177,7 @@ generic_string uintToString(unsigned int val); HWND CreateToolTip(int toolID, HWND hDlg, HINSTANCE hInst, const PTSTR pszText, bool isRTL); HWND CreateToolTipRect(int toolID, HWND hWnd, HINSTANCE hInst, const PTSTR pszText, const RECT rc); -//NOT USED by HEXEDIT bool isCertificateValidated(const generic_string & fullFilePath, const generic_string & subjectName2check); +bool isCertificateValidated(const generic_string & fullFilePath, const generic_string & subjectName2check); bool isAssoCommandExisting(LPCTSTR FullPathName); std::wstring s2ws(const std::string& str); @@ -227,11 +213,70 @@ template size_t vecRemoveDuplicates(std::vector& vec, bool isSort return vec.size(); } -void trim(generic_string& str); -bool endsWith(const generic_string& s, const generic_string& suffix); +void trim(std::wstring& str); int nbDigitsFromNbLines(size_t nbLines); generic_string getDateTimeStrFrom(const generic_string& dateTimeFormat, const SYSTEMTIME& st); HFONT createFont(const TCHAR* fontName, int fontSize, bool isBold, HWND hDestParent); +bool removeReadOnlyFlagFromFileAttributes(const wchar_t* fileFullPath); + +bool isWin32NamespacePrefixedFileName(const generic_string& fileName); +bool isWin32NamespacePrefixedFileName(const TCHAR* szFileName); +bool isUnsupportedFileName(const generic_string& fileName); +bool isUnsupportedFileName(const TCHAR* szFileName); + +class Version final +{ +public: + Version() = default; + Version(const generic_string& versionStr); + + void setVersionFrom(const generic_string& filePath); + generic_string toString(); + bool isNumber(const generic_string& s) const { + return !s.empty() && + find_if(s.begin(), s.end(), [](TCHAR c) { return !_istdigit(c); }) == s.end(); + }; + + int compareTo(const Version& v2c) const; + + bool operator < (const Version& v2c) const { + return compareTo(v2c) == -1; + }; + + bool operator <= (const Version& v2c) const { + int r = compareTo(v2c); + return r == -1 || r == 0; + }; + + bool operator > (const Version& v2c) const { + return compareTo(v2c) == 1; + }; + + bool operator >= (const Version& v2c) const { + int r = compareTo(v2c); + return r == 1 || r == 0; + }; + + bool operator == (const Version& v2c) const { + return compareTo(v2c) == 0; + }; + + bool operator != (const Version& v2c) const { + return compareTo(v2c) != 0; + }; + + bool empty() const { + return _major == 0 && _minor == 0 && _patch == 0 && _build == 0; + } + + bool isCompatibleTo(const Version& from, const Version& to) const; + +private: + unsigned long _major = 0; + unsigned long _minor = 0; + unsigned long _patch = 0; + unsigned long _build = 0; +}; diff --git a/Common/Ccpp/Notepad_plus_msgs.h b/Common/Ccpp/Notepad_plus_msgs.h index a31f69a..a2a3db5 100644 --- a/Common/Ccpp/Notepad_plus_msgs.h +++ b/Common/Ccpp/Notepad_plus_msgs.h @@ -32,12 +32,15 @@ enum LangType {L_TEXT, L_PHP , L_C, L_CPP, L_CS, L_OBJC, L_JAVA, L_RC,\ L_ASN1, L_AVS, L_BLITZBASIC, L_PUREBASIC, L_FREEBASIC, \ L_CSOUND, L_ERLANG, L_ESCRIPT, L_FORTH, L_LATEX, \ L_MMIXAL, L_NIM, L_NNCRONTAB, L_OSCRIPT, L_REBOL, \ - L_REGISTRY, L_RUST, L_SPICE, L_TXT2TAGS, L_VISUALPROLOG, L_TYPESCRIPT,\ + L_REGISTRY, L_RUST, L_SPICE, L_TXT2TAGS, L_VISUALPROLOG,\ + L_TYPESCRIPT, L_JSON5, L_MSSQL, L_GDSCRIPT, L_HOLLYWOOD,\ // Don't use L_JS, use L_JAVASCRIPT instead // The end of enumated language type, so it should be always at the end L_EXTERNAL}; +enum class ExternalLexerAutoIndentMode { Standard, C_Like, Custom }; +enum class MacroStatus { Idle, RecordInProgress, RecordingStopped, PlayingBack }; -enum winVer{ WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV_S2003, WV_XPX64, WV_VISTA, WV_WIN7, WV_WIN8, WV_WIN81, WV_WIN10 }; +enum winVer { WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV_S2003, WV_XPX64, WV_VISTA, WV_WIN7, WV_WIN8, WV_WIN81, WV_WIN10, WV_WIN11 }; enum Platform { PF_UNKNOWN, PF_X86, PF_X64, PF_IA64, PF_ARM64 }; @@ -165,8 +168,8 @@ enum Platform { PF_UNKNOWN, PF_X86, PF_X64, PF_IA64, PF_ARM64 }; #define NPPM_MAKECURRENTBUFFERDIRTY (NPPMSG + 44) //BOOL NPPM_MAKECURRENTBUFFERDIRTY(0, 0) - #define NPPM_GETENABLETHEMETEXTUREFUNC (NPPMSG + 45) - //BOOL NPPM_GETENABLETHEMETEXTUREFUNC(0, 0) + #define NPPM_GETENABLETHEMETEXTUREFUNC_DEPRECATED (NPPMSG + 45) + //BOOL NPPM_GETENABLETHEMETEXTUREFUNC(0, 0) -- DEPRECATED : use EnableThemeDialogTexture from uxtheme.h instead #define NPPM_GETPLUGINSCONFIGDIR (NPPMSG + 46) //INT NPPM_GETPLUGINSCONFIGDIR(int strLen, TCHAR *str) @@ -195,11 +198,31 @@ enum Platform { PF_UNKNOWN, PF_X86, PF_X64, PF_IA64, PF_ARM64 }; //void NPPM_TRIGGERTABBARCONTEXTMENU(int view, int index2Activate) #define NPPM_GETNPPVERSION (NPPMSG + 50) - // int NPPM_GETNPPVERSION(0, 0) - // return version - // ex : v4.6 - // HIWORD(version) == 4 - // LOWORD(version) == 6 + // int NPPM_GETNPPVERSION(BOOL ADD_ZERO_PADDING, 0) + // Get Notepad++ version + // HIWORD(returned_value) is major part of version: the 1st number + // LOWORD(returned_value) is minor part of version: the 3 last numbers + // + // ADD_ZERO_PADDING == TRUE + // + // version | HIWORD | LOWORD + //------------------------------ + // 8.9.6.4 | 8 | 964 + // 9 | 9 | 0 + // 6.9 | 6 | 900 + // 6.6.6 | 6 | 660 + // 13.6.6.6 | 13 | 666 + // + // + // ADD_ZERO_PADDING == FALSE + // + // version | HIWORD | LOWORD + //------------------------------ + // 8.9.6.4 | 8 | 964 + // 9 | 9 | 0 + // 6.9 | 6 | 9 + // 6.6.6 | 6 | 66 + // 13.6.6.6 | 13 | 666 #define NPPM_HIDETABBAR (NPPMSG + 51) // BOOL NPPM_HIDETABBAR(0, BOOL hideOrNot) @@ -345,7 +368,7 @@ enum Platform { PF_UNKNOWN, PF_X86, PF_X64, PF_IA64, PF_ARM64 }; #define NPPM_ALLOCATEMARKER (NPPMSG + 82) // BOOL NPPM_ALLOCATEMARKER(int numberRequested, int* startNumber) - // sets startNumber to the initial command ID if successful + // sets startNumber to the initial marker ID if successful // Allocates a marker number to a plugin: if a plugin need to add a marker on Notepad++'s Scintilla marker margin, // it has to use this message to get marker number, in order to prevent from the conflict with the other plugins. // Returns: TRUE if successful, FALSE otherwise. startNumber will also be set to 0 if unsuccessful @@ -454,20 +477,144 @@ enum Platform { PF_UNKNOWN, PF_X86, PF_X64, PF_IA64, PF_ARM64 }; HICON hToolbarIconDarkMode; }; -#define VAR_NOT_RECOGNIZED 0 -#define FULL_CURRENT_PATH 1 -#define CURRENT_DIRECTORY 2 -#define FILE_NAME 3 -#define NAME_PART 4 -#define EXT_PART 5 -#define CURRENT_WORD 6 -#define NPP_DIRECTORY 7 -#define CURRENT_LINE 8 -#define CURRENT_COLUMN 9 -#define NPP_FULL_FILE_PATH 10 -#define GETFILENAMEATCURSOR 11 - -#define RUNCOMMAND_USER (WM_USER + 3000) + #define NPPM_GETEXTERNALLEXERAUTOINDENTMODE (NPPMSG + 103) + // BOOL NPPM_GETEXTERNALLEXERAUTOINDENTMODE(const TCHAR *languageName, ExternalLexerAutoIndentMode &autoIndentMode) + // Get ExternalLexerAutoIndentMode for an installed external programming language. + // - Standard means Notepad++ will keep the same TAB indentation between lines; + // - C_Like means Notepad++ will perform a C-Language style indentation for the selected external language; + // - Custom means a Plugin will be controlling auto-indentation for the current language. + // returned values: TRUE for successful searches, otherwise FALSE. + + #define NPPM_SETEXTERNALLEXERAUTOINDENTMODE (NPPMSG + 104) + // BOOL NPPM_SETEXTERNALLEXERAUTOINDENTMODE(const TCHAR *languageName, ExternalLexerAutoIndentMode autoIndentMode) + // Set ExternalLexerAutoIndentMode for an installed external programming language. + // - Standard means Notepad++ will keep the same TAB indentation between lines; + // - C_Like means Notepad++ will perform a C-Language style indentation for the selected external language; + // - Custom means a Plugin will be controlling auto-indentation for the current language. + // returned value: TRUE if function call was successful, otherwise FALSE. + + #define NPPM_ISAUTOINDENTON (NPPMSG + 105) + // BOOL NPPM_ISAUTOINDENTON(0, 0) + // Returns the current Use Auto-Indentation setting in Notepad++ Preferences. + + #define NPPM_GETCURRENTMACROSTATUS (NPPMSG + 106) + // MacroStatus NPPM_GETCURRENTMACROSTATUS(0, 0) + // Gets current enum class MacroStatus { Idle - means macro is not in use and it's empty, RecordInProgress, RecordingStopped, PlayingBack } + + #define NPPM_ISDARKMODEENABLED (NPPMSG + 107) + // bool NPPM_ISDARKMODEENABLED(0, 0) + // Returns true when Notepad++ Dark Mode is enable, false when it is not. + + #define NPPM_GETDARKMODECOLORS (NPPMSG + 108) + // bool NPPM_GETDARKMODECOLORS (size_t cbSize, NppDarkMode::Colors* returnColors) + // - cbSize must be filled with sizeof(NppDarkMode::Colors). + // - returnColors must be a pre-allocated NppDarkMode::Colors struct. + // Returns true when successful, false otherwise. + // You need to uncomment the following code to use NppDarkMode::Colors structure: + // + // namespace NppDarkMode + // { + // struct Colors + // { + // COLORREF background = 0; + // COLORREF softerBackground = 0; + // COLORREF hotBackground = 0; + // COLORREF pureBackground = 0; + // COLORREF errorBackground = 0; + // COLORREF text = 0; + // COLORREF darkerText = 0; + // COLORREF disabledText = 0; + // COLORREF linkText = 0; + // COLORREF edge = 0; + // COLORREF hotEdge = 0; + // COLORREF disabledEdge = 0; + // }; + // } + // + // Note: in the case of calling failure ("false" is returned), you may need to change NppDarkMode::Colors structure to: + // https://github.com/notepad-plus-plus/notepad-plus-plus/blob/master/PowerEditor/src/NppDarkMode.h#L32 + + #define NPPM_GETCURRENTCMDLINE (NPPMSG + 109) + // INT NPPM_GETCURRENTCMDLINE(size_t strLen, TCHAR *commandLineStr) + // Get the Current Command Line string. + // Returns the number of TCHAR copied/to copy. + // Users should call it with commandLineStr as NULL to get the required number of TCHAR (not including the terminating nul character), + // allocate commandLineStr buffer with the return value + 1, then call it again to get the current command line string. + + #define NPPM_CREATELEXER (NPPMSG + 110) + // void* NPPM_CREATELEXER(0, const TCHAR *lexer_name) + // Returns the ILexer pointer created by Lexilla + + #define NPPM_GETBOOKMARKID (NPPMSG + 111) + // void* NPPM_GETBOOKMARKID(0, 0) + // Returns the bookmark ID + + #define NPPM_DARKMODESUBCLASSANDTHEME (NPPMSG + 112) + // ULONG NPPM_DARKMODESUBCLASSANDTHEME(ULONG dmFlags, HWND hwnd) + // Add support for generic dark mode. + // + // Docking panels don't need to call NPPM_DARKMODESUBCLASSANDTHEME for main hwnd. + // Subclassing is applied automatically unless DWS_USEOWNDARKMODE flag is used. + // + // Might not work properly in C# plugins. + // + // Returns succesful combinations of flags. + // + + namespace NppDarkMode + { + // Standard flags for main parent after its children are initialized. + constexpr ULONG dmfInit = 0x0000000BUL; + + // Standard flags for main parent usually used in NPPN_DARKMODECHANGED. + constexpr ULONG dmfHandleChange = 0x0000000CUL; + }; + + // Examples: + // + // - after controls initializations in WM_INITDIALOG, in WM_CREATE or after CreateWindow: + // + //auto success = static_cast(::SendMessage(nppData._nppHandle, NPPM_DARKMODESUBCLASSANDTHEME, static_cast(NppDarkMode::dmfInit), reinterpret_cast(mainHwnd))); + // + // - handling dark mode change: + // + //extern "C" __declspec(dllexport) void beNotified(SCNotification * notifyCode) + //{ + // switch (notifyCode->nmhdr.code) + // { + // case NPPN_DARKMODECHANGED: + // { + // ::SendMessage(nppData._nppHandle, NPPM_DARKMODESUBCLASSANDTHEME, static_cast(dmfHandleChange), reinterpret_cast(mainHwnd)); + // ::SetWindowPos(mainHwnd, nullptr, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); // to redraw titlebar and window + // break; + // } + // } + //} + + #define NPPM_ALLOCATEINDICATOR (NPPMSG + 113) + // BOOL NPPM_ALLOCATEINDICATOR(int numberRequested, int* startNumber) + // sets startNumber to the initial indicator ID if successful + // Allocates an indicator number to a plugin: if a plugin needs to add an indicator, + // it has to use this message to get the indicator number, in order to prevent a conflict with the other plugins. + // Returns: TRUE if successful, FALSE otherwise. + + // For RUNCOMMAND_USER + #define VAR_NOT_RECOGNIZED 0 + #define FULL_CURRENT_PATH 1 + #define CURRENT_DIRECTORY 2 + #define FILE_NAME 3 + #define NAME_PART 4 + #define EXT_PART 5 + #define CURRENT_WORD 6 + #define NPP_DIRECTORY 7 + #define CURRENT_LINE 8 + #define CURRENT_COLUMN 9 + #define NPP_FULL_FILE_PATH 10 + #define GETFILENAMEATCURSOR 11 + #define CURRENT_LINESTR 12 + + #define RUNCOMMAND_USER (WM_USER + 3000) + #define NPPM_GETFULLCURRENTPATH (RUNCOMMAND_USER + FULL_CURRENT_PATH) #define NPPM_GETCURRENTDIRECTORY (RUNCOMMAND_USER + CURRENT_DIRECTORY) #define NPPM_GETFILENAME (RUNCOMMAND_USER + FILE_NAME) @@ -476,6 +623,7 @@ enum Platform { PF_UNKNOWN, PF_X86, PF_X64, PF_IA64, PF_ARM64 }; #define NPPM_GETCURRENTWORD (RUNCOMMAND_USER + CURRENT_WORD) #define NPPM_GETNPPDIRECTORY (RUNCOMMAND_USER + NPP_DIRECTORY) #define NPPM_GETFILENAMEATCURSOR (RUNCOMMAND_USER + GETFILENAMEATCURSOR) + #define NPPM_GETCURRENTLINESTR (RUNCOMMAND_USER + CURRENT_LINESTR) // BOOL NPPM_GETXXXXXXXXXXXXXXXX(size_t strLen, TCHAR *str) // where str is the allocated TCHAR array, // strLen is the allocated array size @@ -492,7 +640,6 @@ enum Platform { PF_UNKNOWN, PF_X86, PF_X64, PF_IA64, PF_ARM64 }; #define NPPM_GETNPPFULLFILEPATH (RUNCOMMAND_USER + NPP_FULL_FILE_PATH) - // Notification code #define NPPN_FIRST 1000 #define NPPN_READY (NPPN_FIRST + 1) // To notify plugins that all the procedures of launchment of notepad++ are done. @@ -636,3 +783,18 @@ enum Platform { PF_UNKNOWN, PF_X86, PF_X64, PF_IA64, PF_ARM64 }; //scnNotification->nmhdr.code = NPPN_FILEDELETED; //scnNotification->nmhdr.hwndFrom = hwndNpp; //scnNotification->nmhdr.idFrom = BufferID; + + #define NPPN_DARKMODECHANGED (NPPN_FIRST + 27) // To notify plugins that Dark Mode was enabled/disabled + //scnNotification->nmhdr.code = NPPN_DARKMODECHANGED; + //scnNotification->nmhdr.hwndFrom = hwndNpp; + //scnNotification->nmhdr.idFrom = 0; + + #define NPPN_CMDLINEPLUGINMSG (NPPN_FIRST + 28) // To notify plugins that the new argument for plugins (via '-pluginMessage="YOUR_PLUGIN_ARGUMENT"' in command line) is available + //scnNotification->nmhdr.code = NPPN_CMDLINEPLUGINMSG; + //scnNotification->nmhdr.hwndFrom = hwndNpp; + //scnNotification->nmhdr.idFrom = pluginMessage; //where pluginMessage is pointer of type wchar_t + + #define NPPN_EXTERNALLEXERBUFFER (NPPN_FIRST + 29) // To notify lexer plugins that the buffer (in idFrom) is just applied to a external lexer + //scnNotification->nmhdr.code = NPPN_EXTERNALLEXERBUFFER; + //scnNotification->nmhdr.hwndFrom = hwndNpp; + //scnNotification->nmhdr.idFrom = BufferID; //where pluginMessage is pointer of type wchar_t diff --git a/Common/Ccpp/Notepad_plus_rc.h b/Common/Ccpp/Notepad_plus_rc.h index c18a304..26e89b8 100644 --- a/Common/Ccpp/Notepad_plus_rc.h +++ b/Common/Ccpp/Notepad_plus_rc.h @@ -1,5 +1,5 @@ // This file is part of Notepad++ project -// Copyright (C)2021 Don HO +// Copyright (C)2023 Don HO // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -19,12 +19,14 @@ // // Notepad++ version: begin // -#define NOTEPAD_PLUS_VERSION TEXT("Notepad++ v8.1") +#define NOTEPAD_PLUS_VERSION TEXT("Notepad++ v8.5.7") // should be X.Y : ie. if VERSION_DIGITALVALUE == 4, 7, 1, 0 , then X = 4, Y = 71 // ex : #define VERSION_VALUE TEXT("5.63\0") -#define VERSION_VALUE TEXT("8.1\0") -#define VERSION_DIGITALVALUE 8, 1, 0, 0 +#define VERSION_INTERNAL_VALUE TEXT("8.57\0") + +#define VERSION_PRODUCT_VALUE TEXT("8.5.7\0") +#define VERSION_DIGITALVALUE 8, 5, 7, 0 // Notepad++ version: end @@ -33,8 +35,10 @@ #define IDC_STATIC -1 #endif +#define IDI_NPPABOUT_LOGO 99 #define IDI_M30ICON 100 #define IDI_CHAMELEON 101 +#define IDI_CHAMELEON_DM 102 //#define IDI_JESUISCHARLIE 102 //#define IDI_GILETJAUNE 102 //#define IDI_SAMESEXMARRIAGE 102 @@ -89,6 +93,7 @@ #define IDI_VIEW_FILEBROWSER_ICON 243 #define IDI_VIEW_FUNCLIST_ICON 244 #define IDI_VIEW_MONITORING_ICON 245 +#define IDI_VIEW_DOCLIST_ICON 392 //continuing from IDI_VIEW_DOCLIST_ICON_DM2's ID // // TOOLBAR ICO - set 1, Dark Mode @@ -138,6 +143,7 @@ #define IDI_VIEW_FILEBROWSER_ICON_DM 288 #define IDI_VIEW_FUNCLIST_ICON_DM 289 #define IDI_VIEW_MONITORING_ICON_DM 290 +#define IDI_VIEW_DOCLIST_ICON_DM 393 //continuing from IDI_VIEW_DOCLIST_ICON's ID // // TOOLBAR ICO - set 2 @@ -187,6 +193,7 @@ #define IDI_VIEW_FILEBROWSER_ICON2 343 #define IDI_VIEW_FUNCLIST_ICON2 344 #define IDI_VIEW_MONITORING_ICON2 345 +#define IDI_VIEW_DOCLIST_ICON2 394 //continuing from IDI_VIEW_DOCLIST_ICON_DM's ID // // TOOLBAR ICO - set 2, Dark Mode @@ -236,6 +243,7 @@ #define IDI_VIEW_FILEBROWSER_ICON_DM2 388 #define IDI_VIEW_FUNCLIST_ICON_DM2 389 #define IDI_VIEW_MONITORING_ICON_DM2 390 +#define IDI_VIEW_DOCLIST_ICON_DM2 391 @@ -254,26 +262,32 @@ #define IDI_DELETE_ICON 525 -#define IDI_PROJECT_WORKSPACE 601 -#define IDI_PROJECT_WORKSPACEDIRTY 602 +#define IDI_PROJECT_WORKSPACE 601 +#define IDI_PROJECT_WORKSPACEDIRTY 602 #define IDI_PROJECT_PROJECT 603 -#define IDI_PROJECT_FOLDEROPEN 604 +#define IDI_PROJECT_FOLDEROPEN 604 #define IDI_PROJECT_FOLDERCLOSE 605 -#define IDI_PROJECT_FILE 606 +#define IDI_PROJECT_FILE 606 #define IDI_PROJECT_FILEINVALID 607 -#define IDI_FB_ROOTOPEN 608 -#define IDI_FB_ROOTCLOSE 609 -#define IDI_FB_SELECTCURRENTFILE 610 -#define IDI_FB_FOLDALL 611 -#define IDI_FB_EXPANDALL 612 - -#define IDI_FUNCLIST_ROOT 620 -#define IDI_FUNCLIST_NODE 621 -#define IDI_FUNCLIST_LEAF 622 +#define IDI_FB_ROOTOPEN 608 +#define IDI_FB_ROOTCLOSE 609 +#define IDI_FB_SELECTCURRENTFILE 610 +#define IDI_FB_FOLDALL 611 +#define IDI_FB_EXPANDALL 612 +#define IDI_FB_SELECTCURRENTFILE_DM 613 +#define IDI_FB_FOLDALL_DM 614 +#define IDI_FB_EXPANDALL_DM 615 -#define IDI_FUNCLIST_SORTBUTTON 631 -#define IDI_FUNCLIST_RELOADBUTTON 632 +#define IDI_FUNCLIST_ROOT 620 +#define IDI_FUNCLIST_NODE 621 +#define IDI_FUNCLIST_LEAF 622 +#define IDI_FUNCLIST_SORTBUTTON 631 +#define IDI_FUNCLIST_RELOADBUTTON 632 +#define IDI_FUNCLIST_PREFERENCEBUTTON 633 +#define IDI_FUNCLIST_SORTBUTTON_DM 634 +#define IDI_FUNCLIST_RELOADBUTTON_DM 635 +#define IDI_FUNCLIST_PREFERENCEBUTTON_DM 636 @@ -337,25 +351,78 @@ #define IDR_CLOSETAB_INACT_DM 1543 #define IDR_CLOSETAB_HOVER_DM 1544 #define IDR_CLOSETAB_PUSH_DM 1545 +#define IDR_DOCLIST 1546 +#define IDR_DOCLIST_ICO 1547 + +#define IDR_FILEBROWSER_ICO2 1550 +#define IDR_FILEBROWSER_ICO_DM 1551 +#define IDR_FUNC_LIST_ICO2 1552 +#define IDR_FUNC_LIST_ICO_DM 1553 +#define IDR_DOCMAP_ICO2 1554 +#define IDR_DOCMAP_ICO_DM 1555 +#define IDR_DOCLIST_ICO2 1556 +#define IDR_DOCLIST_ICO_DM 1557 +#define IDR_PROJECTPANEL_ICO2 1558 +#define IDR_PROJECTPANEL_ICO_DM 1559 +#define IDR_CLIPBOARDPANEL_ICO2 1560 +#define IDR_CLIPBOARDPANEL_ICO_DM 1561 +#define IDR_ASCIIPANEL_ICO2 1562 +#define IDR_ASCIIPANEL_ICO_DM 1563 + +#define ID_MACRO 20000 +// O . +// C . +// C . +// U . +// P . +// I . +// E . +// D . +#define ID_MACRO_LIMIT 20499 + + +#define ID_USER_CMD 21000 +// O . +// C . +// C . +// U . +// P . +// I . +// E . +// D . +#define ID_USER_CMD_LIMIT 21499 + + +#define ID_PLUGINS_CMD 22000 +// O . +// C . +// C . +// U . +// P . +// I . +// E . +// D . +#define ID_PLUGINS_CMD_LIMIT 22999 + + +#define ID_PLUGINS_CMD_DYNAMIC 23000 +// O . +// C . +// C . +// U . +// P . +// I . +// E . +// D . +#define ID_PLUGINS_CMD_DYNAMIC_LIMIT 24999 + + +#define MARKER_PLUGINS 1 +#define MARKER_PLUGINS_LIMIT 15 + +#define INDICATOR_PLUGINS 9 // indicators 8 and below are reserved by Notepad++ (URL_INDIC=8) +#define INDICATOR_PLUGINS_LIMIT 20 // indicators 21 and up are reserved by Notepad++ (SCE_UNIVERSAL_FOUND_STYLE_EXT5=21) -#define ID_MACRO 20000 -#define ID_MACRO_LIMIT 20200 - -#define ID_USER_CMD 21000 -#define ID_USER_CMD_LIMIT 21200 - -#define ID_PLUGINS_CMD 22000 -#define ID_PLUGINS_CMD_LIMIT 22500 - -#define ID_PLUGINS_CMD_DYNAMIC 23000 -#define ID_PLUGINS_CMD_DYNAMIC_LIMIT 24999 - -#define MARKER_PLUGINS 3 -#define MARKER_PLUGINS_LIMIT 19 -/*UNLOAD -#define ID_PLUGINS_REMOVING 22501 -#define ID_PLUGINS_REMOVING_END 22600 -*/ //#define IDM 40000 @@ -424,8 +491,11 @@ #define IDC_DEBUGINFO_EDIT 1751 #define IDC_DEBUGINFO_COPYLINK 1752 -#define IDD_DOSAVEORNOTBOX 1760 -#define IDC_DOSAVEORNOTTEX 1761 +#define IDD_DOSAVEORNOTBOX 1760 +#define IDC_DOSAVEORNOTTEXT 1761 + +#define IDD_DOSAVEALLBOX 1765 +#define IDC_DOSAVEALLTEXT 1766 //#define IDD_USER_DEFINE_BOX 1800 //#define IDD_RUN_DLG 1900 @@ -452,9 +522,9 @@ //#define IDD_STYLER_DLG 2200 //#define IDD_GLOBAL_STYLER_DLG 2300 -#define IDD_VALUE_DLG 2400 -#define IDC_VALUE_STATIC 2401 -#define IDC_VALUE_EDIT 2402 +//#define IDD_VALUE_DLG 2400 +//#define IDC_VALUE_STATIC 2401 +//#define IDC_VALUE_EDIT 2402 #define IDD_BUTTON_DLG 2410 #define IDC_RESTORE_BUTTON 2411 @@ -478,7 +548,7 @@ //#define IDD_FINDCHARACTERS 2900 //See VerticalFileSwitcher_rc.h -//#define IDD_FILESWITCHER_PANEL 3000 +//#define IDD_DOCLIST 3000 //See ProjectPanel_rc.h //#define IDD_PROJECTPANEL 3100 @@ -557,7 +627,7 @@ #define NPPM_INTERNAL_EXPORTFUNCLISTANDQUIT (NOTEPADPLUS_USER_INTERNAL + 46) #define NPPM_INTERNAL_PRNTANDQUIT (NOTEPADPLUS_USER_INTERNAL + 47) #define NPPM_INTERNAL_SAVEBACKUP (NOTEPADPLUS_USER_INTERNAL + 48) - #define NPPM_INTERNAL_STOPMONITORING (NOTEPADPLUS_USER_INTERNAL + 49) // Used by Monitoring feature + #define NPPM_INTERNAL_STOPMONITORING (NOTEPADPLUS_USER_INTERNAL + 49) // Used by Monitoring feature #define NPPM_INTERNAL_EDGEBACKGROUND (NOTEPADPLUS_USER_INTERNAL + 50) #define NPPM_INTERNAL_EDGEMULTISETSIZE (NOTEPADPLUS_USER_INTERNAL + 51) #define NPPM_INTERNAL_UPDATECLICKABLELINKS (NOTEPADPLUS_USER_INTERNAL + 52) @@ -569,6 +639,22 @@ #define NPPM_INTERNAL_UPDATETEXTZONEPADDING (NOTEPADPLUS_USER_INTERNAL + 58) #define NPPM_INTERNAL_REFRESHDARKMODE (NOTEPADPLUS_USER_INTERNAL + 59) #define NPPM_INTERNAL_SCINTILLAFINDERCOPYPATHS (NOTEPADPLUS_USER_INTERNAL + 60) + #define NPPM_INTERNAL_REFRESHWORKDIR (NOTEPADPLUS_USER_INTERNAL + 61) + #define NPPM_INTERNAL_VIRTUALSPACE (NOTEPADPLUS_USER_INTERNAL + 62) + #define NPPM_INTERNAL_CARETLINEFRAME (NOTEPADPLUS_USER_INTERNAL + 63) + #define NPPM_INTERNAL_CRLFFORMCHANGED (NOTEPADPLUS_USER_INTERNAL + 64) + #define NPPM_INTERNAL_CRLFLAUNCHSTYLECONF (NOTEPADPLUS_USER_INTERNAL + 65) + #define NPPM_INTERNAL_LAUNCHPREFERENCES (NOTEPADPLUS_USER_INTERNAL + 66) + #define NPPM_INTERNAL_ENABLECHANGEHISTORY (NOTEPADPLUS_USER_INTERNAL + 67) + #define NPPM_INTERNAL_CLEANSMARTHILITING (NOTEPADPLUS_USER_INTERNAL + 68) + #define NPPM_INTERNAL_CLEANBRACEMATCH (NOTEPADPLUS_USER_INTERNAL + 69) + #define NPPM_INTERNAL_WINDOWSSESSIONEXIT (NOTEPADPLUS_USER_INTERNAL + 70) + #define NPPM_INTERNAL_RESTOREFROMTRAY (NOTEPADPLUS_USER_INTERNAL + 71) + #define NPPM_INTERNAL_SETNPC (NOTEPADPLUS_USER_INTERNAL + 72) + #define NPPM_INTERNAL_NPCFORMCHANGED (NOTEPADPLUS_USER_INTERNAL + 73) + #define NPPM_INTERNAL_NPCLAUNCHSTYLECONF (NOTEPADPLUS_USER_INTERNAL + 74) + #define NPPM_INTERNAL_CLOSEDOC (NOTEPADPLUS_USER_INTERNAL + 75) + #define NPPM_INTERNAL_EXTERNALLEXERBUFFER (NOTEPADPLUS_USER_INTERNAL + 76) // See Notepad_plus_msgs.h //#define NOTEPADPLUS_USER (WM_USER + 1000) @@ -603,7 +689,7 @@ #define MACRO_USER (WM_USER + 4000) - #define WM_GETCURRENTMACROSTATUS (MACRO_USER + 01) +// #define WM_GETCURRENTMACROSTATUS (MACRO_USER + 01) // Replaced with NPPM_GETCURRENTMACROSTATUS #define WM_MACRODLGRUNMACRO (MACRO_USER + 02) @@ -627,3 +713,6 @@ #define MENUINDEX_MACRO 8 #define MENUINDEX_RUN 9 #define MENUINDEX_PLUGINS 10 +#define MENUINDEX_WINDOW 11 +#define MENUINDEX_HELP 12 +#define MENUINDEX_LIST 14 diff --git a/Common/Ccpp/NppDarkMode.h b/Common/Ccpp/NppDarkMode.h index 2cb60fc..f14abca 100644 --- a/Common/Ccpp/NppDarkMode.h +++ b/Common/Ccpp/NppDarkMode.h @@ -16,16 +16,9 @@ #pragma once -#include - -constexpr COLORREF HEXRGB(DWORD rrggbb) { - // from 0xRRGGBB like natural #RRGGBB - // to the little-endian 0xBBGGRR - return - ((rrggbb & 0xFF0000) >> 16) | - ((rrggbb & 0x00FF00) ) | - ((rrggbb & 0x0000FF) << 16); -} +#include + +#include "Common.h" // for generic_string namespace NppDarkMode { @@ -41,12 +34,22 @@ namespace NppDarkMode COLORREF disabledText = 0; COLORREF linkText = 0; COLORREF edge = 0; + COLORREF hotEdge = 0; + COLORREF disabledEdge = 0; }; struct Options { bool enable = false; bool enableMenubar = false; + bool enablePlugin = false; + }; + + struct NppDarkModeParams + { + const wchar_t* _themeClassName = nullptr; + bool _subclass = false; + bool _theme = false; }; enum class ToolTipsType @@ -76,14 +79,47 @@ namespace NppDarkMode dark = 2 }; + struct AdvOptDefaults + { + generic_string _xmlFileName; + int _toolBarIconSet = -1; + int _tabIconSet = -1; + bool _tabUseTheme = false; + }; + + struct AdvancedOptions + { + bool _enableWindowsMode = false; + + NppDarkMode::AdvOptDefaults _darkDefaults{ L"DarkModeDefault.xml", 0, 2, false }; + NppDarkMode::AdvOptDefaults _lightDefaults{ L"", 4, 0, true }; + }; + void initDarkMode(); // pulls options from NppParameters void refreshDarkMode(HWND hwnd, bool forceRefresh = false); // attempts to apply new options from NppParameters, sends NPPM_INTERNAL_REFRESHDARKMODE to hwnd's top level parent + void initAdvancedOptions(); + bool isEnabled(); bool isDarkMenuEnabled(); + bool isEnabledForPlugins(); + bool isExperimentalActive(); bool isExperimentalSupported(); + bool isWindowsModeEnabled(); + void setWindowsMode(bool enable); + generic_string getThemeName(); + void setThemeName(const generic_string& newThemeName); + int getToolBarIconSet(bool useDark); + void setToolBarIconSet(int state2Set, bool useDark); + int getTabIconSet(bool useDark); + void setTabIconSet(bool useAltIcons, bool useDark); + bool useTabTheme(); + void setAdvancedOptions(); + + bool isWindows10(); bool isWindows11(); + DWORD getWindowsBuildNumber(); COLORREF invertLightness(COLORREF c); COLORREF invertLightnessSofter(COLORREF c); @@ -103,6 +139,8 @@ namespace NppDarkMode COLORREF getLinkTextColor(); COLORREF getEdgeColor(); + COLORREF getHotEdgeColor(); + COLORREF getDisabledEdgeColor(); HBRUSH getBackgroundBrush(); HBRUSH getDarkerBackgroundBrush(); @@ -110,8 +148,16 @@ namespace NppDarkMode HBRUSH getHotBackgroundBrush(); HBRUSH getErrorBackgroundBrush(); + HBRUSH getEdgeBrush(); + HBRUSH getHotEdgeBrush(); + HBRUSH getDisabledEdgeBrush(); + HPEN getDarkerTextPen(); HPEN getEdgePen(); + HPEN getHotEdgePen(); + HPEN getDisabledEdgePen(); + + COLORREF getIndividualTabColour(int colourIndex, bool themeDependant, bool saturated); void setBackgroundColor(COLORREF c); void setSofterBackgroundColor(COLORREF c); @@ -123,12 +169,15 @@ namespace NppDarkMode void setDisabledTextColor(COLORREF c); void setLinkTextColor(COLORREF c); void setEdgeColor(COLORREF c); + void setHotEdgeColor(COLORREF c); + void setDisabledEdgeColor(COLORREF c); Colors getDarkModeDefaultColors(); void changeCustomTheme(const Colors& colors); // handle events - void handleSettingChange(HWND hwnd, LPARAM lParam); + void handleSettingChange(HWND hwnd, LPARAM lParam, bool isFromBtn = false); + bool isDarkModeReg(); // processes messages related to UAH / custom menubar drawing. // return true if handled, false to continue with normal processing in your wndproc @@ -145,14 +194,34 @@ namespace NppDarkMode // enhancements to DarkMode.h void enableDarkScrollBarForWindowAndChildren(HWND hwnd); + inline void paintRoundFrameRect(HDC hdc, const RECT rect, const HPEN hpen, int width = 0, int height = 0); + void subclassButtonControl(HWND hwnd); void subclassGroupboxControl(HWND hwnd); void subclassTabControl(HWND hwnd); void subclassComboBoxControl(HWND hwnd); + bool subclassTabUpDownControl(HWND hwnd); + + void subclassAndThemeButton(HWND hwnd, NppDarkModeParams p); + void subclassAndThemeComboBox(HWND hwnd, NppDarkModeParams p); + void subclassAndThemeListBoxOrEditControl(HWND hwnd, NppDarkModeParams p, bool isListBox); + void subclassAndThemeListView(HWND hwnd, NppDarkModeParams p); + void themeTreeView(HWND hwnd, NppDarkModeParams p); + void themeToolbar(HWND hwnd, NppDarkModeParams p); + void themeRichEdit(HWND hwnd, NppDarkModeParams p); + void autoSubclassAndThemeChildControls(HWND hwndParent, bool subclass = true, bool theme = true); void autoThemeChildControls(HWND hwndParent); + LRESULT darkToolBarNotifyCustomDraw(LPARAM lParam); + LRESULT darkListViewNotifyCustomDraw(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, bool isPlugin); + LRESULT darkTreeViewNotifyCustomDraw(LPARAM lParam); + + void autoSubclassAndThemePluginDockWindow(HWND hwnd); + ULONG autoSubclassAndThemePlugin(HWND hwnd, ULONG dmFlags); + void autoSubclassAndThemeWindowNotify(HWND hwnd); + void setDarkTitleBar(HWND hwnd); void setDarkExplorerTheme(HWND hwnd); void setDarkScrollBar(HWND hwnd); @@ -163,10 +232,16 @@ namespace NppDarkMode void disableVisualStyle(HWND hwnd, bool doDisable); void calculateTreeViewStyle(); void setTreeViewStyle(HWND hwnd); + bool isThemeDark(); void setBorder(HWND hwnd, bool border = true); + BOOL CALLBACK enumAutocompleteProc(HWND hwnd, LPARAM lParam); + void setDarkAutoCompletion(); + LRESULT onCtlColor(HDC hdc); LRESULT onCtlColorSofter(HDC hdc); LRESULT onCtlColorDarker(HDC hdc); LRESULT onCtlColorError(HDC hdc); + LRESULT onCtlColorDarkerBGStaticText(HDC hdc, bool isTextEnabled); + INT_PTR onCtlColorListbox(WPARAM wParam, LPARAM lParam); } diff --git a/Common/Ccpp/Sci_Position.h b/Common/Ccpp/Sci_Position.h index bad91b4..88ad513 100644 --- a/Common/Ccpp/Sci_Position.h +++ b/Common/Ccpp/Sci_Position.h @@ -15,10 +15,8 @@ typedef ptrdiff_t Sci_Position; // Unsigned variant used for ILexer::Lex and ILexer::Fold -// Definitions of common types typedef size_t Sci_PositionU; - // For Sci_CharacterRange which is defined as long to be compatible with Win32 CHARRANGE typedef intptr_t Sci_PositionCR; diff --git a/Common/Ccpp/Scintilla.h b/Common/Ccpp/Scintilla.h index 201d49e..d9cd36b 100644 --- a/Common/Ccpp/Scintilla.h +++ b/Common/Ccpp/Scintilla.h @@ -20,7 +20,6 @@ extern "C" { int Scintilla_RegisterClasses(void *hInstance); int Scintilla_ReleaseResources(void); #endif -int Scintilla_LinkLexers(void); #ifdef __cplusplus } @@ -37,6 +36,7 @@ typedef intptr_t sptr_t; #include "Sci_Position.h" typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, sptr_t lParam); +typedef sptr_t (*SciFnDirectStatus)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, sptr_t lParam, int *pStatus); #ifndef SCI_DISABLE_AUTOGENERATED @@ -57,11 +57,13 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_GETCURRENTPOS 2008 #define SCI_GETANCHOR 2009 #define SCI_GETSTYLEAT 2010 +#define SCI_GETSTYLEINDEXAT 2038 #define SCI_REDO 2011 #define SCI_SETUNDOCOLLECTION 2012 #define SCI_SELECTALL 2013 #define SCI_SETSAVEPOINT 2014 #define SCI_GETSTYLEDTEXT 2015 +#define SCI_GETSTYLEDTEXTFULL 2778 #define SCI_CANREDO 2016 #define SCI_MARKERLINEFROMHANDLE 2017 #define SCI_MARKERDELETEHANDLE 2018 @@ -104,6 +106,8 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_GETNEXTTABSTOP 2677 #define SC_CP_UTF8 65001 #define SCI_SETCODEPAGE 2037 +#define SCI_SETFONTLOCALE 2760 +#define SCI_GETFONTLOCALE 2761 #define SC_IME_WINDOWED 0 #define SC_IME_INLINE 1 #define SCI_GETIMEINTERACTION 2678 @@ -149,7 +153,12 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SC_MARK_RGBAIMAGE 30 #define SC_MARK_BOOKMARK 31 #define SC_MARK_VERTICALBOOKMARK 32 +#define SC_MARK_BAR 33 #define SC_MARK_CHARACTER 10000 +#define SC_MARKNUM_HISTORY_REVERTED_TO_ORIGIN 21 +#define SC_MARKNUM_HISTORY_SAVED 22 +#define SC_MARKNUM_HISTORY_MODIFIED 23 +#define SC_MARKNUM_HISTORY_REVERTED_TO_MODIFIED 24 #define SC_MARKNUM_FOLDEREND 25 #define SC_MARKNUM_FOLDEROPENMID 26 #define SC_MARKNUM_FOLDERMIDTAIL 27 @@ -162,6 +171,10 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_MARKERSETFORE 2041 #define SCI_MARKERSETBACK 2042 #define SCI_MARKERSETBACKSELECTED 2292 +#define SCI_MARKERSETFORETRANSLUCENT 2294 +#define SCI_MARKERSETBACKTRANSLUCENT 2295 +#define SCI_MARKERSETBACKSELECTEDTRANSLUCENT 2296 +#define SCI_MARKERSETSTROKEWIDTH 2297 #define SCI_MARKERENABLEHIGHLIGHT 2293 #define SCI_MARKERADD 2043 #define SCI_MARKERDELETE 2044 @@ -172,6 +185,8 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_MARKERDEFINEPIXMAP 2049 #define SCI_MARKERADDSET 2466 #define SCI_MARKERSETALPHA 2476 +#define SCI_MARKERGETLAYER 2734 +#define SCI_MARKERSETLAYER 2735 #define SC_MAX_MARGIN 4 #define SC_MARGIN_SYMBOL 0 #define SC_MARGIN_NUMBER 1 @@ -264,12 +279,52 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_STYLEGETWEIGHT 2064 #define SCI_STYLESETCHARACTERSET 2066 #define SCI_STYLESETHOTSPOT 2409 +#define SCI_STYLESETCHECKMONOSPACED 2254 +#define SCI_STYLEGETCHECKMONOSPACED 2255 +#define SCI_STYLESETINVISIBLEREPRESENTATION 2256 +#define SCI_STYLEGETINVISIBLEREPRESENTATION 2257 +#define SC_ELEMENT_LIST 0 +#define SC_ELEMENT_LIST_BACK 1 +#define SC_ELEMENT_LIST_SELECTED 2 +#define SC_ELEMENT_LIST_SELECTED_BACK 3 +#define SC_ELEMENT_SELECTION_TEXT 10 +#define SC_ELEMENT_SELECTION_BACK 11 +#define SC_ELEMENT_SELECTION_ADDITIONAL_TEXT 12 +#define SC_ELEMENT_SELECTION_ADDITIONAL_BACK 13 +#define SC_ELEMENT_SELECTION_SECONDARY_TEXT 14 +#define SC_ELEMENT_SELECTION_SECONDARY_BACK 15 +#define SC_ELEMENT_SELECTION_INACTIVE_TEXT 16 +#define SC_ELEMENT_SELECTION_INACTIVE_BACK 17 +#define SC_ELEMENT_CARET 40 +#define SC_ELEMENT_CARET_ADDITIONAL 41 +#define SC_ELEMENT_CARET_LINE_BACK 50 +#define SC_ELEMENT_WHITE_SPACE 60 +#define SC_ELEMENT_WHITE_SPACE_BACK 61 +#define SC_ELEMENT_HOT_SPOT_ACTIVE 70 +#define SC_ELEMENT_HOT_SPOT_ACTIVE_BACK 71 +#define SC_ELEMENT_FOLD_LINE 80 +#define SC_ELEMENT_HIDDEN_LINE 81 +#define SCI_SETELEMENTCOLOUR 2753 +#define SCI_GETELEMENTCOLOUR 2754 +#define SCI_RESETELEMENTCOLOUR 2755 +#define SCI_GETELEMENTISSET 2756 +#define SCI_GETELEMENTALLOWSTRANSLUCENT 2757 +#define SCI_GETELEMENTBASECOLOUR 2758 #define SCI_SETSELFORE 2067 #define SCI_SETSELBACK 2068 #define SCI_GETSELALPHA 2477 #define SCI_SETSELALPHA 2478 #define SCI_GETSELEOLFILLED 2479 #define SCI_SETSELEOLFILLED 2480 +#define SC_LAYER_BASE 0 +#define SC_LAYER_UNDER_TEXT 1 +#define SC_LAYER_OVER_TEXT 2 +#define SCI_GETSELECTIONLAYER 2762 +#define SCI_SETSELECTIONLAYER 2763 +#define SCI_GETCARETLINELAYER 2764 +#define SCI_SETCARETLINELAYER 2765 +#define SCI_GETCARETLINEHIGHLIGHTSUBLINE 2773 +#define SCI_SETCARETLINEHIGHLIGHTSUBLINE 2774 #define SCI_SETCARETFORE 2069 #define SCI_ASSIGNCMDKEY 2070 #define SCI_CLEARCMDKEY 2071 @@ -306,7 +361,8 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define INDIC_POINTCHARACTER 19 #define INDIC_GRADIENT 20 #define INDIC_GRADIENTCENTRE 21 -#define INDIC_EXPLORERLINK 22 +#define INDIC_POINT_TOP 22 +#define INDIC_EXPLORERLINK 23 #define INDIC_CONTAINER 8 #define INDIC_IME 32 #define INDIC_IME_MAX 35 @@ -314,7 +370,15 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define INDICATOR_CONTAINER 8 #define INDICATOR_IME 32 #define INDICATOR_IME_MAX 35 -#define INDICATOR_MAX 35 +#define INDICATOR_HISTORY_REVERTED_TO_ORIGIN_INSERTION 36 +#define INDICATOR_HISTORY_REVERTED_TO_ORIGIN_DELETION 37 +#define INDICATOR_HISTORY_SAVED_INSERTION 38 +#define INDICATOR_HISTORY_SAVED_DELETION 39 +#define INDICATOR_HISTORY_MODIFIED_INSERTION 40 +#define INDICATOR_HISTORY_MODIFIED_DELETION 41 +#define INDICATOR_HISTORY_REVERTED_TO_MODIFIED_INSERTION 42 +#define INDICATOR_HISTORY_REVERTED_TO_MODIFIED_DELETION 43 +#define INDICATOR_MAX 43 #define SCI_INDICSETSTYLE 2080 #define SCI_INDICGETSTYLE 2081 #define SCI_INDICSETFORE 2082 @@ -327,9 +391,12 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_INDICGETHOVERFORE 2683 #define SC_INDICVALUEBIT 0x1000000 #define SC_INDICVALUEMASK 0xFFFFFF +#define SC_INDICFLAG_NONE 0 #define SC_INDICFLAG_VALUEFORE 1 #define SCI_INDICSETFLAGS 2684 #define SCI_INDICGETFLAGS 2685 +#define SCI_INDICSETSTROKEWIDTH 2751 +#define SCI_INDICGETSTROKEWIDTH 2752 #define SCI_SETWHITESPACEFORE 2084 #define SCI_SETWHITESPACEBACK 2085 #define SCI_SETWHITESPACESIZE 2086 @@ -363,6 +430,10 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_USERLISTSHOW 2117 #define SCI_AUTOCSETAUTOHIDE 2118 #define SCI_AUTOCGETAUTOHIDE 2119 +#define SC_AUTOCOMPLETE_NORMAL 0 +#define SC_AUTOCOMPLETE_FIXED_SIZE 1 +#define SCI_AUTOCSETOPTIONS 2638 +#define SCI_AUTOCGETOPTIONS 2639 #define SCI_AUTOCSETDROPRESTOFWORD 2270 #define SCI_AUTOCGETDROPRESTOFWORD 2271 #define SCI_REGISTERIMAGE 2405 @@ -421,10 +492,19 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCFIND_POSIX 0x00400000 #define SCFIND_CXX11REGEX 0x00800000 #define SCI_FINDTEXT 2150 +#define SCI_FINDTEXTFULL 2196 #define SCI_FORMATRANGE 2151 +#define SCI_FORMATRANGEFULL 2777 +#define SC_CHANGE_HISTORY_DISABLED 0 +#define SC_CHANGE_HISTORY_ENABLED 1 +#define SC_CHANGE_HISTORY_MARKERS 2 +#define SC_CHANGE_HISTORY_INDICATORS 4 +#define SCI_SETCHANGEHISTORY 2780 +#define SCI_GETCHANGEHISTORY 2781 #define SCI_GETFIRSTVISIBLELINE 2152 #define SCI_GETLINE 2153 #define SCI_GETLINECOUNT 2154 +#define SCI_ALLOCATELINES 2089 #define SCI_SETMARGINLEFT 2155 #define SCI_GETMARGINLEFT 2156 #define SCI_SETMARGINRIGHT 2157 @@ -433,7 +513,9 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_SETSEL 2160 #define SCI_GETSELTEXT 2161 #define SCI_GETTEXTRANGE 2162 +#define SCI_GETTEXTRANGEFULL 2039 #define SCI_HIDESELECTION 2163 +#define SCI_GETSELECTIONHIDDEN 2088 #define SCI_POINTXFROMPOSITION 2164 #define SCI_POINTYFROMPOSITION 2165 #define SCI_LINEFROMPOSITION 2166 @@ -456,6 +538,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_GETTEXT 2182 #define SCI_GETTEXTLENGTH 2183 #define SCI_GETDIRECTFUNCTION 2184 +#define SCI_GETDIRECTSTATUSFUNCTION 2772 #define SCI_GETDIRECTPOINTER 2185 #define SCI_SETOVERTYPE 2186 #define SCI_GETOVERTYPE 2187 @@ -475,6 +558,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_TARGETWHOLEDOCUMENT 2690 #define SCI_REPLACETARGET 2194 #define SCI_REPLACETARGETRE 2195 +#define SCI_REPLACETARGETMINIMAL 2779 #define SCI_SEARCHINTARGET 2197 #define SCI_SETSEARCHFLAGS 2198 #define SCI_GETSEARCHFLAGS 2199 @@ -492,6 +576,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_VISIBLEFROMDOCLINE 2220 #define SCI_DOCLINEFROMVISIBLE 2221 #define SCI_WRAPCOUNT 2235 +#define SC_FOLDLEVELNONE 0x0 #define SC_FOLDLEVELBASE 0x400 #define SC_FOLDLEVELWHITEFLAG 0x1000 #define SC_FOLDLEVELHEADERFLAG 0x2000 @@ -518,16 +603,19 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SC_FOLDACTION_CONTRACT 0 #define SC_FOLDACTION_EXPAND 1 #define SC_FOLDACTION_TOGGLE 2 +#define SC_FOLDACTION_CONTRACT_EVERY_LEVEL 4 #define SCI_FOLDLINE 2237 #define SCI_FOLDCHILDREN 2238 #define SCI_EXPANDCHILDREN 2239 #define SCI_FOLDALL 2662 #define SCI_ENSUREVISIBLE 2232 +#define SC_AUTOMATICFOLD_NONE 0x0000 #define SC_AUTOMATICFOLD_SHOW 0x0001 #define SC_AUTOMATICFOLD_CLICK 0x0002 #define SC_AUTOMATICFOLD_CHANGE 0x0004 #define SCI_SETAUTOMATICFOLD 2663 #define SCI_GETAUTOMATICFOLD 2664 +#define SC_FOLDFLAG_NONE 0x0000 #define SC_FOLDFLAG_LINEBEFORE_EXPANDED 0x0002 #define SC_FOLDFLAG_LINEBEFORE_CONTRACTED 0x0004 #define SC_FOLDFLAG_LINEAFTER_EXPANDED 0x0008 @@ -841,6 +929,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_TOGGLECARETSTICKY 2459 #define SCI_SETPASTECONVERTENDINGS 2467 #define SCI_GETPASTECONVERTENDINGS 2468 +#define SCI_REPLACERECTANGULAR 2771 #define SCI_SELECTIONDUPLICATE 2469 #define SCI_SETCARETLINEBACKALPHA 2470 #define SCI_GETCARETLINEBACKALPHA 2471 @@ -849,6 +938,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define CARETSTYLE_BLOCK 2 #define CARETSTYLE_OVERSTRIKE_BAR 0 #define CARETSTYLE_OVERSTRIKE_BLOCK 0x10 +#define CARETSTYLE_CURSES 0x20 #define CARETSTYLE_INS_MASK 0xF #define CARETSTYLE_BLOCK_AFTER 0x100 #define SCI_SETCARETSTYLE 2512 @@ -865,6 +955,8 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_INDICATOREND 2509 #define SCI_SETPOSITIONCACHE 2514 #define SCI_GETPOSITIONCACHE 2515 +#define SCI_SETLAYOUTTHREADS 2775 +#define SCI_GETLAYOUTTHREADS 2776 #define SCI_COPYALLOWLINE 2519 #define SCI_GETCHARACTERPOINTER 2520 #define SCI_GETRANGEPOINTER 2643 @@ -1008,29 +1100,57 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_SETREPRESENTATION 2665 #define SCI_GETREPRESENTATION 2666 #define SCI_CLEARREPRESENTATION 2667 +#define SCI_CLEARALLREPRESENTATIONS 2770 +#define SC_REPRESENTATION_PLAIN 0 +#define SC_REPRESENTATION_BLOB 1 +#define SC_REPRESENTATION_COLOUR 0x10 +#define SCI_SETREPRESENTATIONAPPEARANCE 2766 +#define SCI_GETREPRESENTATIONAPPEARANCE 2767 +#define SCI_SETREPRESENTATIONCOLOUR 2768 +#define SCI_GETREPRESENTATIONCOLOUR 2769 #define SCI_EOLANNOTATIONSETTEXT 2740 #define SCI_EOLANNOTATIONGETTEXT 2741 #define SCI_EOLANNOTATIONSETSTYLE 2742 #define SCI_EOLANNOTATIONGETSTYLE 2743 #define SCI_EOLANNOTATIONCLEARALL 2744 -#define EOLANNOTATION_HIDDEN 0 -#define EOLANNOTATION_STANDARD 1 -#define EOLANNOTATION_BOXED 2 +#define EOLANNOTATION_HIDDEN 0x0 +#define EOLANNOTATION_STANDARD 0x1 +#define EOLANNOTATION_BOXED 0x2 +#define EOLANNOTATION_STADIUM 0x100 +#define EOLANNOTATION_FLAT_CIRCLE 0x101 +#define EOLANNOTATION_ANGLE_CIRCLE 0x102 +#define EOLANNOTATION_CIRCLE_FLAT 0x110 +#define EOLANNOTATION_FLATS 0x111 +#define EOLANNOTATION_ANGLE_FLAT 0x112 +#define EOLANNOTATION_CIRCLE_ANGLE 0x120 +#define EOLANNOTATION_FLAT_ANGLE 0x121 +#define EOLANNOTATION_ANGLES 0x122 #define SCI_EOLANNOTATIONSETVISIBLE 2745 #define SCI_EOLANNOTATIONGETVISIBLE 2746 #define SCI_EOLANNOTATIONSETSTYLEOFFSET 2747 #define SCI_EOLANNOTATIONGETSTYLEOFFSET 2748 +#define SC_SUPPORTS_LINE_DRAWS_FINAL 0 +#define SC_SUPPORTS_PIXEL_DIVISIONS 1 +#define SC_SUPPORTS_FRACTIONAL_STROKE_WIDTH 2 +#define SC_SUPPORTS_TRANSLUCENT_STROKE 3 +#define SC_SUPPORTS_PIXEL_MODIFICATION 4 +#define SC_SUPPORTS_THREAD_SAFE_MEASURE_WIDTHS 5 +#define SCI_SUPPORTSFEATURE 2750 +#define SC_LINECHARACTERINDEX_NONE 0 +#define SC_LINECHARACTERINDEX_UTF32 1 +#define SC_LINECHARACTERINDEX_UTF16 2 +#define SCI_GETLINECHARACTERINDEX 2710 +#define SCI_ALLOCATELINECHARACTERINDEX 2711 +#define SCI_RELEASELINECHARACTERINDEX 2712 +#define SCI_LINEFROMINDEXPOSITION 2713 +#define SCI_INDEXPOSITIONFROMLINE 2714 #define SCI_STARTRECORD 3001 #define SCI_STOPRECORD 3002 -#define SCI_SETLEXER 4001 #define SCI_GETLEXER 4002 #define SCI_COLOURISE 4003 #define SCI_SETPROPERTY 4004 -// #define KEYWORDSET_MAX 8 #define KEYWORDSET_MAX 30 #define SCI_SETKEYWORDS 4005 -#define SCI_SETLEXERLANGUAGE 4006 -#define SCI_LOADLEXERLIBRARY 4007 #define SCI_GETPROPERTY 4008 #define SCI_GETPROPERTYEXPANDED 4009 #define SCI_GETPROPERTYINT 4010 @@ -1083,7 +1203,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SC_MOD_CHANGETABSTOPS 0x200000 #define SC_MOD_CHANGEEOLANNOTATION 0x400000 #define SC_MODEVENTMASKALL 0x7FFFFF -#define SC_SEARCHRESULT_LINEBUFFERMAXLENGTH 2048 +#define SC_UPDATE_NONE 0x0 #define SC_UPDATE_CONTENT 0x1 #define SC_UPDATE_SELECTION 0x2 #define SC_UPDATE_V_SCROLL 0x4 @@ -1122,6 +1242,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SC_AC_TAB 3 #define SC_AC_NEWLINE 4 #define SC_AC_COMMAND 5 +#define SC_AC_SINGLE_CHOICE 6 #define SC_CHARACTERSOURCE_DIRECT_INPUT 0 #define SC_CHARACTERSOURCE_TENTATIVE_INPUT 1 #define SC_CHARACTERSOURCE_IME_RESULT 2 @@ -1163,21 +1284,11 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SC_BIDIRECTIONAL_R2L 2 #define SCI_GETBIDIRECTIONAL 2708 #define SCI_SETBIDIRECTIONAL 2709 -#define SC_LINECHARACTERINDEX_NONE 0 -#define SC_LINECHARACTERINDEX_UTF32 1 -#define SC_LINECHARACTERINDEX_UTF16 2 -#define SCI_GETLINECHARACTERINDEX 2710 -#define SCI_ALLOCATELINECHARACTERINDEX 2711 -#define SCI_RELEASELINECHARACTERINDEX 2712 -#define SCI_LINEFROMINDEXPOSITION 2713 -#define SCI_INDEXPOSITIONFROMLINE 2714 #endif +#define SC_SEARCHRESULT_LINEBUFFERMAXLENGTH 2048 #define SCI_GETBOOSTREGEXERRMSG 5000 - -#define SCN_SCROLLED 2080 #define SCN_FOLDINGSTATECHANGED 2081 - /* --Autogenerated -- end of section automatically generated from Scintilla.iface */ #endif @@ -1191,17 +1302,33 @@ struct Sci_CharacterRange { Sci_PositionCR cpMax; }; +struct Sci_CharacterRangeFull { + Sci_Position cpMin; + Sci_Position cpMax; +}; + struct Sci_TextRange { struct Sci_CharacterRange chrg; char *lpstrText; }; +struct Sci_TextRangeFull { + struct Sci_CharacterRangeFull chrg; + char *lpstrText; +}; + struct Sci_TextToFind { struct Sci_CharacterRange chrg; const char *lpstrText; struct Sci_CharacterRange chrgText; }; +struct Sci_TextToFindFull { + struct Sci_CharacterRangeFull chrg; + const char *lpstrText; + struct Sci_CharacterRangeFull chrgText; +}; + typedef void *Sci_SurfaceID; struct Sci_Rectangle { @@ -1222,6 +1349,14 @@ struct Sci_RangeToFormat { struct Sci_CharacterRange chrg; }; +struct Sci_RangeToFormatFull { + Sci_SurfaceID hdc; + Sci_SurfaceID hdcTarget; + struct Sci_Rectangle rc; + struct Sci_Rectangle rcPage; + struct Sci_CharacterRangeFull chrg; +}; + #ifndef __cplusplus /* For the GTK+ platform, g-ir-scanner needs to have these typedefs. This * is not required in C++ code and actually seems to break ScintillaEditPy */ @@ -1278,16 +1413,15 @@ struct SCNotification { int characterSource; /* SCN_CHARADDED */ }; -struct SearchResultMarking { - intptr_t _start; - intptr_t _end; +#include +struct SearchResultMarkingLine { // each line could have several segments if user want to see only 1 found line which contains several results + std::vector> _segmentPostions; // a vector of pair of start & end of occurrence for colourizing }; struct SearchResultMarkings { intptr_t _length; - SearchResultMarking *_markings; + SearchResultMarkingLine *_markings; }; - #ifdef INCLUDE_DEPRECATED_FEATURES #define SCI_SETKEYSUNICODE 2521 diff --git a/Common/Ccpp/StaticDialog.cpp b/Common/Ccpp/StaticDialog.cpp index 0707792..25d3cc8 100644 --- a/Common/Ccpp/StaticDialog.cpp +++ b/Common/Ccpp/StaticDialog.cpp @@ -36,12 +36,35 @@ void StaticDialog::destroy() ::DestroyWindow(_hSelf); } +void StaticDialog::getMappedChildRect(HWND hChild, RECT& rcChild) const +{ + ::GetClientRect(hChild, &rcChild); + ::MapWindowPoints(hChild, _hSelf, reinterpret_cast(&rcChild), 2); +} + +void StaticDialog::getMappedChildRect(int idChild, RECT& rcChild) const +{ + const HWND hChild = ::GetDlgItem(_hSelf, idChild); + getMappedChildRect(hChild, rcChild); +} + +void StaticDialog::redrawDlgItem(const int nIDDlgItem, bool forceUpdate) const +{ + RECT rcDlgItem{}; + const HWND hDlgItem = ::GetDlgItem(_hSelf, nIDDlgItem); + getMappedChildRect(hDlgItem, rcDlgItem); + ::InvalidateRect(_hSelf, &rcDlgItem, TRUE); + + if (forceUpdate) + ::UpdateWindow(hDlgItem); +} + POINT StaticDialog::getTopPoint(HWND hwnd, bool isLeft) const { - RECT rc; + RECT rc{}; ::GetWindowRect(hwnd, &rc); - POINT p; + POINT p{}; if (isLeft) p.x = rc.left; else @@ -52,11 +75,11 @@ POINT StaticDialog::getTopPoint(HWND hwnd, bool isLeft) const return p; } -void StaticDialog::goToCenter() +void StaticDialog::goToCenter(UINT swpFlags) { - RECT rc; + RECT rc{}; ::GetClientRect(_hParent, &rc); - POINT center; + POINT center{}; center.x = rc.left + (rc.right - rc.left)/2; center.y = rc.top + (rc.bottom - rc.top)/2; ::ClientToScreen(_hParent, ¢er); @@ -64,7 +87,7 @@ void StaticDialog::goToCenter() int x = center.x - (_rc.right - _rc.left)/2; int y = center.y - (_rc.bottom - _rc.top)/2; - ::SetWindowPos(_hSelf, HWND_TOP, x, y, _rc.right - _rc.left, _rc.bottom - _rc.top, SWP_SHOWWINDOW); + ::SetWindowPos(_hSelf, HWND_TOP, x, y, _rc.right - _rc.left, _rc.bottom - _rc.top, swpFlags); } void StaticDialog::display(bool toShow, bool enhancedPositioningCheckWhenShowing) const @@ -73,7 +96,7 @@ void StaticDialog::display(bool toShow, bool enhancedPositioningCheckWhenShowing { if (enhancedPositioningCheckWhenShowing) { - RECT testPositionRc, candidateRc; + RECT testPositionRc{}, candidateRc{}; getWindowRect(testPositionRc); @@ -89,8 +112,8 @@ void StaticDialog::display(bool toShow, bool enhancedPositioningCheckWhenShowing { // If the user has switched from a dual monitor to a single monitor since we last // displayed the dialog, then ensure that it's still visible on the single monitor. - RECT workAreaRect = { 0 }; - RECT rc = { 0 }; + RECT workAreaRect{}; + RECT rc{}; ::SystemParametersInfo(SPI_GETWORKAREA, 0, &workAreaRect, 0); ::GetWindowRect(_hSelf, &rc); int newLeft = rc.left; @@ -119,7 +142,7 @@ RECT StaticDialog::getViewablePositionRect(RECT testPositionRc) const { HMONITOR hMon = ::MonitorFromRect(&testPositionRc, MONITOR_DEFAULTTONULL); - MONITORINFO mi; + MONITORINFO mi{}; mi.cbSize = sizeof(MONITORINFO); bool rectPosViewableWithoutChange = false; diff --git a/Common/Ccpp/StaticDialog.h b/Common/Ccpp/StaticDialog.h index 9d89b09..aba41be 100644 --- a/Common/Ccpp/StaticDialog.h +++ b/Common/Ccpp/StaticDialog.h @@ -43,11 +43,15 @@ public : virtual void create(int dialogID, bool isRTL = false, bool msgDestParent = true); - virtual bool isCreated() const { - return (_hSelf != NULL); + virtual bool isCreated() const { + return (_hSelf != nullptr); } - void goToCenter(); + void getMappedChildRect(HWND hChild, RECT& rcChild) const; + void getMappedChildRect(int idChild, RECT& rcChild) const; + void redrawDlgItem(const int nIDDlgItem, bool forceUpdate = false) const; + + void goToCenter(UINT swpFlags = SWP_SHOWWINDOW); void display(bool toShow = true, bool enhancedPositioningCheckWhenShowing = false) const; @@ -65,10 +69,10 @@ public : ::SendDlgItemMessage(_hSelf, checkControlID, BM_SETCHECK, checkOrNot ? BST_CHECKED : BST_UNCHECKED, 0); } - virtual void destroy() override; + void destroy() override; protected: - RECT _rc = { 0 }; + RECT _rc{}; static intptr_t CALLBACK dlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); virtual intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) = 0; diff --git a/Common/Ccpp/Utf8.h b/Common/Ccpp/Utf8.h index 29a697e..83dbad5 100644 --- a/Common/Ccpp/Utf8.h +++ b/Common/Ccpp/Utf8.h @@ -51,4 +51,4 @@ namespace Utf8 { // could be a static class, instead of a namespace, if it needs ++charContinuationBytes; return startingIndex-charContinuationBytes; } -}; +} diff --git a/Common/Ccpp/menuCmdID.h b/Common/Ccpp/menuCmdID.h index 2ad7914..c864e91 100644 --- a/Common/Ccpp/menuCmdID.h +++ b/Common/Ccpp/menuCmdID.h @@ -68,7 +68,7 @@ //10 Rename... //11 Close //12 Close All -//13 Close More +//13 Close Multiple Documents //14 Move to Recycle Bin //15 -------- //16 Load Session... @@ -170,11 +170,14 @@ #define IDM_EDIT_INSERT_DATETIME_CUSTOMIZED (IDM_EDIT + 86) #define IDM_EDIT_COPY_ALL_NAMES (IDM_EDIT + 87) #define IDM_EDIT_COPY_ALL_PATHS (IDM_EDIT + 88) + #define IDM_EDIT_BEGINENDSELECT_COLUMNMODE (IDM_EDIT + 89) #define IDM_EDIT_AUTOCOMPLETE (50000 + 0) #define IDM_EDIT_AUTOCOMPLETE_CURRENTFILE (50000 + 1) #define IDM_EDIT_FUNCCALLTIP (50000 + 2) #define IDM_EDIT_AUTOCOMPLETE_PATH (50000 + 6) + #define IDM_EDIT_FUNCCALLTIP_PREVIOUS (50000 + 10) + #define IDM_EDIT_FUNCCALLTIP_NEXT (50000 + 11) #define IDM_SEARCH (IDM + 3000) @@ -248,6 +251,10 @@ #define IDM_SEARCH_MARKONEEXT4 (IDM_SEARCH + 65) #define IDM_SEARCH_MARKONEEXT5 (IDM_SEARCH + 66) + #define IDM_SEARCH_CHANGED_NEXT (IDM_SEARCH + 67) + #define IDM_SEARCH_CHANGED_PREV (IDM_SEARCH + 68) + #define IDM_SEARCH_CLEAR_CHANGE_HISTORY (IDM_SEARCH + 69) + #define IDM_MISC (IDM + 3500) #define IDM_DOCLIST_FILESCLOSE (IDM_MISC + 1) #define IDM_DOCLIST_FILESCLOSEOTHERS (IDM_MISC + 2) @@ -265,7 +272,7 @@ #define IDM_VIEW_DRAWTABBAR_TOPBAR (IDM_VIEW + 7) #define IDM_VIEW_DRAWTABBAR_INACIVETAB (IDM_VIEW + 8) #define IDM_VIEW_POSTIT (IDM_VIEW + 9) - #define IDM_VIEW_TOGGLE_FOLDALL (IDM_VIEW + 10) + #define IDM_VIEW_FOLDALL (IDM_VIEW + 10) #define IDM_VIEW_DISTRACTIONFREE (IDM_VIEW + 11) #define IDM_VIEW_LINENUMBER (IDM_VIEW + 12) #define IDM_VIEW_SYMBOLMARGIN (IDM_VIEW + 13) @@ -284,7 +291,7 @@ #define IDM_VIEW_EOL (IDM_VIEW + 26) #define IDM_VIEW_TOOLBAR_REDUCE_SET2 (IDM_VIEW + 27) #define IDM_VIEW_TOOLBAR_ENLARGE_SET2 (IDM_VIEW + 28) - #define IDM_VIEW_TOGGLE_UNFOLDALL (IDM_VIEW + 29) + #define IDM_VIEW_UNFOLDALL (IDM_VIEW + 29) #define IDM_VIEW_FOLD_CURRENT (IDM_VIEW + 30) #define IDM_VIEW_UNFOLD_CURRENT (IDM_VIEW + 31) #define IDM_VIEW_FULLSCREENTOGGLE (IDM_VIEW + 32) @@ -300,7 +307,7 @@ #define IDM_VIEW_HIDELINES (IDM_VIEW + 42) #define IDM_VIEW_DRAWTABBAR_VERTICAL (IDM_VIEW + 43) #define IDM_VIEW_DRAWTABBAR_MULTILINE (IDM_VIEW + 44) - #define IDM_VIEW_DOCCHANGEMARGIN (IDM_VIEW + 45) + //#define IDM_VIEW_DOCCHANGEMARGIN (IDM_VIEW + 45) #define IDM_VIEW_LWDEF (IDM_VIEW + 46) #define IDM_VIEW_LWALIGN (IDM_VIEW + 47) #define IDM_VIEW_LWINDENT (IDM_VIEW + 48) @@ -365,6 +372,16 @@ #define IDM_VIEW_SWITCHTO_FUNC_LIST (IDM_VIEW + 108) #define IDM_VIEW_SWITCHTO_DOCLIST (IDM_VIEW + 109) + #define IDM_VIEW_TAB_COLOUR_NONE (IDM_VIEW + 110) + #define IDM_VIEW_TAB_COLOUR_1 (IDM_VIEW + 111) + #define IDM_VIEW_TAB_COLOUR_2 (IDM_VIEW + 112) + #define IDM_VIEW_TAB_COLOUR_3 (IDM_VIEW + 113) + #define IDM_VIEW_TAB_COLOUR_4 (IDM_VIEW + 114) + #define IDM_VIEW_TAB_COLOUR_5 (IDM_VIEW + 115) + + #define IDM_VIEW_NPC (IDM_VIEW + 130) + #define IDM_VIEW_NPC_CCUNIEOL (IDM_VIEW + 131) + #define IDM_VIEW_GOTO_ANOTHER_VIEW 10001 #define IDM_VIEW_CLONE_TO_ANOTHER_VIEW 10002 #define IDM_VIEW_GOTO_NEW_INSTANCE 10003 @@ -525,7 +542,11 @@ #define IDM_LANG_TXT2TAGS (IDM_LANG + 82) #define IDM_LANG_VISUALPROLOG (IDM_LANG + 83) #define IDM_LANG_TYPESCRIPT (IDM_LANG + 84) - + #define IDM_LANG_JSON5 (IDM_LANG + 85) + #define IDM_LANG_MSSQL (IDM_LANG + 86) + #define IDM_LANG_GDSCRIPT (IDM_LANG + 87) + #define IDM_LANG_HOLLYWOOD (IDM_LANG + 88) + #define IDM_LANG_EXTERNAL (IDM_LANG + 165) #define IDM_LANG_EXTERNAL_LIMIT (IDM_LANG + 179) @@ -576,6 +597,12 @@ #define IDM_TOOL_SHA256_GENERATE (IDM_TOOL + 4) #define IDM_TOOL_SHA256_GENERATEFROMFILE (IDM_TOOL + 5) #define IDM_TOOL_SHA256_GENERATEINTOCLIPBOARD (IDM_TOOL + 6) + #define IDM_TOOL_SHA1_GENERATE (IDM_TOOL + 7) + #define IDM_TOOL_SHA1_GENERATEFROMFILE (IDM_TOOL + 8) + #define IDM_TOOL_SHA1_GENERATEINTOCLIPBOARD (IDM_TOOL + 9) + #define IDM_TOOL_SHA512_GENERATE (IDM_TOOL + 10) + #define IDM_TOOL_SHA512_GENERATEFROMFILE (IDM_TOOL + 11) + #define IDM_TOOL_SHA512_GENERATEINTOCLIPBOARD (IDM_TOOL + 12) #define IDM_EXECUTE (IDM + 9000) @@ -585,3 +612,22 @@ #define IDM_SYSTRAYPOPUP_NEW_AND_PASTE (IDM_SYSTRAYPOPUP + 3) #define IDM_SYSTRAYPOPUP_OPENFILE (IDM_SYSTRAYPOPUP + 4) #define IDM_SYSTRAYPOPUP_CLOSE (IDM_SYSTRAYPOPUP + 5) + +#define IDR_WINDOWS_MENU 11000 + #define IDM_WINDOW_WINDOWS (IDR_WINDOWS_MENU + 1) + #define IDM_WINDOW_SORT_FN_ASC (IDR_WINDOWS_MENU + 2) + #define IDM_WINDOW_SORT_FN_DSC (IDR_WINDOWS_MENU + 3) + #define IDM_WINDOW_SORT_FP_ASC (IDR_WINDOWS_MENU + 4) + #define IDM_WINDOW_SORT_FP_DSC (IDR_WINDOWS_MENU + 5) + #define IDM_WINDOW_SORT_FT_ASC (IDR_WINDOWS_MENU + 6) + #define IDM_WINDOW_SORT_FT_DSC (IDR_WINDOWS_MENU + 7) + #define IDM_WINDOW_SORT_FS_ASC (IDR_WINDOWS_MENU + 8) + #define IDM_WINDOW_SORT_FS_DSC (IDR_WINDOWS_MENU + 9) + #define IDM_WINDOW_MRU_FIRST (IDR_WINDOWS_MENU + 20) + #define IDM_WINDOW_MRU_LIMIT (IDR_WINDOWS_MENU + 59) + #define IDM_WINDOW_COPY_NAME (IDM_WINDOW_MRU_LIMIT + 1) + #define IDM_WINDOW_COPY_PATH (IDM_WINDOW_MRU_LIMIT + 2) + +#define IDR_DROPLIST_MENU 14000 + #define IDM_DROPLIST_LIST (IDR_DROPLIST_MENU + 1) + #define IDM_DROPLIST_MRU_FIRST (IDR_DROPLIST_MENU + 20) diff --git a/HexEditor/projects/2003/HexEditor.vcxproj b/HexEditor/projects/2003/HexEditor.vcxproj index 7580401..cb2f080 100644 --- a/HexEditor/projects/2003/HexEditor.vcxproj +++ b/HexEditor/projects/2003/HexEditor.vcxproj @@ -113,7 +113,7 @@ Disabled ../../src;../../src/HelpDlg;../../src/MISC;../../src/OptionDlg;../../src/UserDlg;../../../Common/Ccpp;../../../NativeLang/src;%(AdditionalIncludeDirectories) - WIN32;_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES;_CRT_SECURE_NO_WARNINGS;_DEBUG;_WINDOWS;_USRDLL;HEXEDITOR_EXPORTS;%(PreprocessorDefinitions) + WIN32;_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES;_CRT_SECURE_NO_WARNINGS;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;_DEBUG;_WINDOWS;_USRDLL;HEXEDITOR_EXPORTS;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebugDLL Level4 @@ -121,7 +121,7 @@ true true false - stdcpp14 + stdcpp17 stdc17 @@ -138,7 +138,7 @@ Disabled ../../src;../../src/HelpDlg;../../src/MISC;../../src/OptionDlg;../../src/UserDlg;../../../Common/Ccpp;../../../NativeLang/src;%(AdditionalIncludeDirectories) - WIN32;_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES;_CRT_SECURE_NO_WARNINGS;_DEBUG;_WINDOWS;_USRDLL;HEXEDITOR_EXPORTS;%(PreprocessorDefinitions) + WIN32;_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES;_CRT_SECURE_NO_WARNINGS;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;_DEBUG;_WINDOWS;_USRDLL;HEXEDITOR_EXPORTS;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebugDLL Level4 @@ -146,7 +146,7 @@ true true false - stdcpp14 + stdcpp17 stdc17 @@ -162,7 +162,7 @@ Disabled ../../src;../../src/HelpDlg;../../src/MISC;../../src/OptionDlg;../../src/UserDlg;../../../Common/Ccpp;../../../NativeLang/src;%(AdditionalIncludeDirectories) - WIN32;_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES;_CRT_SECURE_NO_WARNINGS;_DEBUG;_WINDOWS;_USRDLL;HEXEDITOR_EXPORTS;%(PreprocessorDefinitions) + WIN32;_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES;_CRT_SECURE_NO_WARNINGS;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;_DEBUG;_WINDOWS;_USRDLL;HEXEDITOR_EXPORTS;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebugDLL Level4 @@ -170,7 +170,7 @@ true true false - stdcpp14 + stdcpp17 stdc17 @@ -190,7 +190,7 @@ Neither true ../../src;../../src/HelpDlg;../../src/MISC;../../src/OptionDlg;../../src/UserDlg;../../../Common/Ccpp;../../../NativeLang/src;%(AdditionalIncludeDirectories) - WIN32;_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES;_CRT_SECURE_NO_WARNINGS;_WINDOWS;_USRDLL;HEXEDITOR_EXPORTS;%(PreprocessorDefinitions) + WIN32;_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES;_CRT_SECURE_NO_WARNINGS;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;_WINDOWS;_USRDLL;HEXEDITOR_EXPORTS;%(PreprocessorDefinitions) true MultiThreaded false @@ -199,7 +199,7 @@ true true Default - stdcpp14 + stdcpp17 stdc17 @@ -224,7 +224,7 @@ Neither true ../../src;../../src/HelpDlg;../../src/MISC;../../src/OptionDlg;../../src/UserDlg;../../../Common/Ccpp;../../../NativeLang/src;%(AdditionalIncludeDirectories) - WIN32;_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES;_CRT_SECURE_NO_WARNINGS;_WINDOWS;_USRDLL;HEXEDITOR_EXPORTS;%(PreprocessorDefinitions) + WIN32;_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES;_CRT_SECURE_NO_WARNINGS;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;_WINDOWS;_USRDLL;HEXEDITOR_EXPORTS;%(PreprocessorDefinitions) true MultiThreaded false @@ -233,7 +233,7 @@ true true Default - stdcpp14 + stdcpp17 stdc17 @@ -257,7 +257,7 @@ Neither true ../../src;../../src/HelpDlg;../../src/MISC;../../src/OptionDlg;../../src/UserDlg;../../../Common/Ccpp;../../../NativeLang/src;%(AdditionalIncludeDirectories) - WIN32;_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES;_CRT_SECURE_NO_WARNINGS;_WINDOWS;_USRDLL;HEXEDITOR_EXPORTS;%(PreprocessorDefinitions) + WIN32;_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES;_CRT_SECURE_NO_WARNINGS;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;_WINDOWS;_USRDLL;HEXEDITOR_EXPORTS;%(PreprocessorDefinitions) true MultiThreaded false @@ -266,7 +266,7 @@ true true Default - stdcpp14 + stdcpp17 stdc17 diff --git a/HexEditor/src/OptionDlg/OptionDialog.cpp b/HexEditor/src/OptionDlg/OptionDialog.cpp index 7bb7ae7..ced2ae1 100644 --- a/HexEditor/src/OptionDlg/OptionDialog.cpp +++ b/HexEditor/src/OptionDlg/OptionDialog.cpp @@ -80,7 +80,7 @@ INT_PTR CALLBACK OptionDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPar goToCenter(); - ETDTProc EnableDlgTheme = (ETDTProc)::SendMessage(_nppData._nppHandle, NPPM_GETENABLETHEMETEXTUREFUNC, 0, 0); + ETDTProc EnableDlgTheme = (ETDTProc)::SendMessage(_nppData._nppHandle, NPPM_GETENABLETHEMETEXTUREFUNC_DEPRECATED, 0, 0); if (EnableDlgTheme != NULL) EnableDlgTheme(_hSelf, ETDT_ENABLETAB); diff --git a/HexEditor/src/UserDlg/FindReplaceDialog.cpp b/HexEditor/src/UserDlg/FindReplaceDialog.cpp index e19c711..bbc181e 100644 --- a/HexEditor/src/UserDlg/FindReplaceDialog.cpp +++ b/HexEditor/src/UserDlg/FindReplaceDialog.cpp @@ -45,7 +45,7 @@ void FindReplaceDlg::doDialog(HWND hParent, BOOL findReplace) create(IDD_FINDREPLACE_DLG); ::SendMessage(_hParent, NPPM_MODELESSDIALOG, MODELESSDIALOGADD, (LPARAM)_hSelf); - ETDTProc EnableDlgTheme = (ETDTProc)::SendMessage(_nppData._nppHandle, NPPM_GETENABLETHEMETEXTUREFUNC, 0, 0); + ETDTProc EnableDlgTheme = (ETDTProc)::SendMessage(_nppData._nppHandle, NPPM_GETENABLETHEMETEXTUREFUNC_DEPRECATED, 0, 0); if (EnableDlgTheme != NULL) EnableDlgTheme(_hSelf, ETDT_ENABLETAB); } diff --git a/HexEditor/src/Utf8_16.h b/HexEditor/src/Utf8_16.h index eed9993..ea8348e 100644 --- a/HexEditor/src/Utf8_16.h +++ b/HexEditor/src/Utf8_16.h @@ -41,7 +41,7 @@ class Utf8_16 { eUtf8Plain, eLast }; - static const utf8 k_Boms[encodingType::eLast][3]; + static const utf8 k_Boms[static_cast(encodingType::eLast)][3]; }; // Reads UTF-16 and outputs UTF-8 diff --git a/HexEditor/src/misc/MultiTypeCombo.h b/HexEditor/src/misc/MultiTypeCombo.h index 735c2fc..ccc8477 100644 --- a/HexEditor/src/misc/MultiTypeCombo.h +++ b/HexEditor/src/misc/MultiTypeCombo.h @@ -33,7 +33,7 @@ typedef enum class eCodingType HEX_CODE_MAX } eCodingType; -const TCHAR strCode[eCodingType::HEX_CODE_MAX][16] = +const TCHAR strCode[static_cast(eCodingType::HEX_CODE_MAX)][16] = { _T("Hexadecimal"), _T("ANSI String"),