diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..c380823a --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,23 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + - package-ecosystem: "nuget" # See documentation for possible values + directory: "/" # Location of package manifests + schedule: + interval: "monthly" + + # Maintain dependencies for GitHub Actions + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "monthly" + + # Maintain dependencies for submodules + - package-ecosystem: "gitsubmodule" + directory: "/" + schedule: + interval: "monthly" \ No newline at end of file diff --git a/.github/workflows/CI_build.yml b/.github/workflows/CI_build.yml new file mode 100644 index 00000000..d3f90465 --- /dev/null +++ b/.github/workflows/CI_build.yml @@ -0,0 +1,64 @@ +name: Continuous Integration + +on: [push, pull_request] + +jobs: + build: + + runs-on: windows-latest + strategy: + fail-fast: false + matrix: + build_configuration: [Release, Debug] + build_platform: [x64, Win32] + + steps: + + - name: Checkout repo + uses: actions/checkout@v4 + with: + submodules: 'true' + + - name: Add msbuild to PATH + uses: microsoft/setup-msbuild@v2 + + - name: "Use CI config files" + run: | + Write-Host "remove PythonSettings.props" -ForegroundColor Green + Remove-Item '.\PythonScript\project\PythonSettings.props' + Rename-Item -Path ".\PythonScript\project\PythonSettings_appveyor.props" -NewName "PythonSettings.props" + Write-Host "remove packages.config" -ForegroundColor Green + Remove-Item '.\PythonScript\project\packages.config' + Rename-Item -Path ".\PythonScript\project\packages_appveyor.config" -NewName "packages.config" + shell: pwsh + working-directory: . + + - name: Setup NuGet.exe + uses: nuget/setup-nuget@v2 + + - name: Restore + working-directory: . + run: nuget restore PythonScript.sln + + - name: MSBuild of solution + working-directory: . + run: msbuild PythonScript.sln /m /verbosity:minimal /p:configuration="${{ matrix.build_configuration }}" /p:platform="${{ matrix.build_platform }}" /p:PlatformToolset="v143" + + - name: Build docs + if: matrix.build_configuration == 'Release' + working-directory: docs + run: | + python -m pip install --upgrade pip + pip install -U sphinx + .\make.bat html + + - name: Build installer and release zips + if: matrix.build_configuration == 'Release' + working-directory: installer + run: | + $env:PYTHONBUILDDIR_X64='${{ github.workspace }}\packages\python2.2.7.18\tools' + $env:PYTHONBUILDDIR='${{ github.workspace }}\packages\python2x86.2.7.18\tools' + Rename-Item -Path ".\buildPaths.bat.orig" -NewName "buildPaths.bat" + $env:WIX_PATH="C:\Program Files (x86)\WiX Toolset v3.11\bin" + $env:PATH = $env:PATH + ';' + $env:WIX_PATH + .\buildAll.bat ${{ matrix.build_platform }} diff --git a/.github/workflows/msvc_analysis.yml b/.github/workflows/msvc_analysis.yml new file mode 100644 index 00000000..2759eadb --- /dev/null +++ b/.github/workflows/msvc_analysis.yml @@ -0,0 +1,62 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. +# +# Find more information at: +# https://github.com/microsoft/msvc-code-analysis-action + +name: Microsoft C++ Code Analysis + +on: [push, pull_request] + +jobs: + Analyze: + runs-on: windows-latest + + strategy: + fail-fast: false + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Add msbuild to PATH + uses: microsoft/setup-msbuild@v2 + + - name: "Use CI config files" + run: | + Write-Host "remove PythonSettings.props" -ForegroundColor Green + Remove-Item '.\PythonScript\project\PythonSettings.props' + Rename-Item -Path ".\PythonScript\project\PythonSettings_appveyor.props" -NewName "PythonSettings.props" + Write-Host "remove packages.config" -ForegroundColor Green + Remove-Item '.\PythonScript\project\packages.config' + Rename-Item -Path ".\PythonScript\project\packages_appveyor.config" -NewName "packages.config" + shell: pwsh + working-directory: . + + - name: Setup NuGet.exe + uses: nuget/setup-nuget@v2 + + - name: Restore + working-directory: . + run: nuget restore PythonScript.sln + + - name: Run MSVC Code Analysis + working-directory: . + run: msbuild PythonScript.sln /m /verbosity:minimal /p:configuration="Debug" /p:platform="x64" /p:PlatformToolset="v143" /p:RunCodeAnalysis=true + + # Upload SARIF file to GitHub Code Scanning Alerts + #- name: Upload SARIF to GitHub + # uses: github/codeql-action/upload-sarif@v1 + # with: + # sarif_file: ${{ steps.run-analysis.outputs.sarif }} + + # Upload SARIF file as an Artifact to download and view + # - name: Upload SARIF as an Artifact + # uses: actions/upload-artifact@v2 + # with: + # name: sarif-file + # path: ${{ steps.run-analysis.outputs.sarif }} diff --git a/.gitignore b/.gitignore index a3e7ea74..f3228bb3 100644 --- a/.gitignore +++ b/.gitignore @@ -17,12 +17,15 @@ *.vcxproj.user *.sdf *.opensdf +*.VC.db BuildLog.htm +packages/ bin/ obj/ Debug/ Release/ PythonDebug/ +x64/ ipch/ *.pyc _ReSharper.*/ @@ -35,4 +38,5 @@ Release_Archive/ installer/build/ installer/temp/ Thumbs.db -installer/buildPaths.bat \ No newline at end of file +installer/buildPaths.bat +.vs/ \ No newline at end of file diff --git a/NppPlugin/include/Common.h b/NppPlugin/include/Common.h index 97de03bf..3d354803 100644 --- a/NppPlugin/include/Common.h +++ b/NppPlugin/include/Common.h @@ -1,29 +1,19 @@ // This file is part of Notepad++ project -// Copyright (C)2003 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 the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// Note that the GPL places important restrictions on "derived works", yet -// it does not provide a detailed definition of that term. To avoid -// misunderstandings, we consider an application to constitute a -// "derivative work" for the purpose of this license if it does any of the -// following: -// 1. Integrates source code from Notepad++. -// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable -// installer, such as those produced by InstallShield. -// 3. Links to a library or executes a program that does any of the above. +// Copyright (C)2021 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 +// the Free Software Foundation, either version 3 of the License, or +// at your option any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +// along with this program. If not, see . + #pragma once #include #include @@ -31,6 +21,12 @@ #include #include #include +#include +#include +#include + +#pragma deprecated(PathFileExists) // Use doesFileExist, doesDirectoryExist or doesPathExist (for file or directory) instead. +#pragma deprecated(PathIsDirectory) // Use doesDirectoryExist instead. const bool dirUp = true; @@ -45,66 +41,58 @@ 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 -#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") - -typedef std::basic_string generic_string; -typedef std::basic_stringstream generic_stringstream; - -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); +#ifndef __MINGW32__ +#define WCSTOK wcstok +#else +#define WCSTOK wcstok_s +#endif + + +#define NPP_INTERNAL_FUCTION_STR L"Notepad++::InternalFunction" + + +std::wstring folderBrowser(HWND parent, const std::wstring & title = L"", int outputCtrlID = 0, const wchar_t *defaultStr = NULL); +std::wstring getFolderName(HWND parent, const wchar_t *defaultDir = NULL); void printInt(int int2print); -void printStr(const TCHAR *str2print); -generic_string commafyInt(size_t n); +void printStr(const wchar_t *str2print); +std::wstring commafyInt(size_t n); -void writeLog(const TCHAR *logFileName, const char *log2write); +void writeLog(const wchar_t* logFileName, const char* log2write); +void writeLog(const wchar_t* logFileName, const wchar_t* log2write); int filter(unsigned int code, struct _EXCEPTION_POINTERS *ep); -generic_string purgeMenuItemString(const TCHAR * menuItemStr, bool keepAmpersand = false); -std::vector tokenizeString(const generic_string & tokenString, const char delim); +std::wstring purgeMenuItemString(const wchar_t* menuItemStr, bool keepAmpersand = false); +std::vector tokenizeString(const std::wstring & tokenString, const char delim); void ClientRectToScreenRect(HWND hWnd, RECT* rect); 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); +bool isInList(const wchar_t *token, const wchar_t *list); +std::wstring BuildMenuFileName(int filenameLen, unsigned int pos, const std::wstring &filename, bool ordinalNumber = true); -std::string getFileContent(const TCHAR *file2read); -generic_string relativeFilePathToFullFilePath(const TCHAR *relativeFilePath); -void writeFileContent(const TCHAR *file2write, const char *content2write); -bool matchInList(const TCHAR *fileName, const std::vector & patterns); +std::string getFileContent(const wchar_t *file2read); +std::wstring relativeFilePathToFullFilePath(const wchar_t *relativeFilePath); +void writeFileContent(const wchar_t *file2write, const char *content2write); +bool matchInList(const wchar_t *fileName, const std::vector & patterns); +bool matchInExcludeDirList(const wchar_t* dirName, const std::vector& patterns, size_t level); +bool allPatternsAreExclusion(const std::vector& patterns); class WcharMbcsConvertor final { public: - static WcharMbcsConvertor * getInstance() {return _pSelf;} - static void destroyInstance() {delete _pSelf;} + static WcharMbcsConvertor& getInstance() { + static WcharMbcsConvertor instance; + return instance; + } - const wchar_t * char2wchar(const char *mbStr, UINT codepage, int lenIn=-1, int *pLenOut=NULL, int *pBytesNotProcessed=NULL); - const wchar_t * char2wchar(const char *mbcs2Convert, UINT codepage, int *mstart, int *mend); - const char * wchar2char(const wchar_t *wcStr, UINT codepage, int lenIn = -1, int *pLenOut = NULL); - const char * wchar2char(const wchar_t *wcStr, UINT codepage, long *mstart, long *mend); + const wchar_t * char2wchar(const char *mbStr, size_t codepage, int lenMbcs =-1, int* pLenOut=NULL, int* pBytesNotProcessed=NULL); + const wchar_t * char2wchar(const char *mbcs2Convert, size_t codepage, intptr_t* mstart, intptr_t* mend); + const char * wchar2char(const wchar_t *wcStr, size_t codepage, int lenIn = -1, int* pLenOut = NULL); + const char * wchar2char(const wchar_t *wcStr, size_t codepage, intptr_t* mstart, intptr_t* mend); - const char * encode(UINT fromCodepage, UINT toCodepage, const char *txt2Encode, int lenIn=-1, int *pLenOut=NULL, int *pBytesNotProcessed=NULL) + const char * encode(UINT fromCodepage, UINT toCodepage, const char *txt2Encode, int lenIn = -1, int* pLenOut=NULL, int* pBytesNotProcessed=NULL) { int lenWc = 0; const wchar_t * strW = char2wchar(txt2Encode, fromCodepage, lenIn, &lenWc, pBytesNotProcessed); @@ -112,15 +100,17 @@ class WcharMbcsConvertor final } protected: - WcharMbcsConvertor() {} - ~WcharMbcsConvertor() {} + WcharMbcsConvertor() = default; + ~WcharMbcsConvertor() = default; // Since there's no public ctor, we need to void the default assignment operator and copy ctor. // Since these are marked as deleted does not matter under which access specifier are kept WcharMbcsConvertor(const WcharMbcsConvertor&) = delete; WcharMbcsConvertor& operator= (const WcharMbcsConvertor&) = delete; - static WcharMbcsConvertor* _pSelf; + // No move ctor and assignment + WcharMbcsConvertor(WcharMbcsConvertor&&) = delete; + WcharMbcsConvertor& operator= (WcharMbcsConvertor&&) = delete; template class StringBuffer final @@ -134,7 +124,7 @@ class WcharMbcsConvertor final { if (_allocLen) delete[] _str; - _allocLen = max(size, initSize); + _allocLen = std::max(size, initSize); _str = new T[_allocLen]; } } @@ -162,40 +152,139 @@ 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); -generic_string PathAppend(generic_string &strDest, const generic_string & str2append); +std::wstring pathRemoveFileSpec(std::wstring & path); +std::wstring pathAppend(std::wstring &strDest, const std::wstring & str2append); 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); -generic_string stringJoin(const std::vector& strings, const generic_string& separator); -generic_string stringTakeWhileAdmissable(const generic_string& input, const generic_string& admissable); -double stodLocale(const generic_string& str, _locale_t loc, size_t* idx = NULL); - -int OrdinalIgnoreCaseCompareStrings(LPCTSTR sz1, LPCTSTR sz2); +std::wstring stringToUpper(std::wstring strToConvert); +std::wstring stringToLower(std::wstring strToConvert); +std::wstring stringReplace(std::wstring subject, const std::wstring& search, const std::wstring& replace); +void stringSplit(const std::wstring& input, const std::wstring& delimiter, std::vector& output); +bool str2numberVector(std::wstring str2convert, std::vector& numVect); +void stringJoin(const std::vector& strings, const std::wstring& separator, std::wstring& joinedString); +std::wstring stringTakeWhileAdmissable(const std::wstring& input, const std::wstring& admissable); +double stodLocale(const std::wstring& str, _locale_t loc, size_t* idx = NULL); -bool str2Clipboard(const generic_string &str2cpy, HWND hwnd); +bool str2Clipboard(const std::wstring &str2cpy, HWND hwnd); +class Buffer; +bool buf2Clipboard(const std::vector& buffers, bool isFullPath, HWND hwnd); -generic_string GetLastErrorAsString(DWORD errorCode = 0); +std::wstring GetLastErrorAsString(DWORD errorCode = 0); -generic_string intToString(int val); -generic_string uintToString(unsigned int val); +std::wstring intToString(int val); +std::wstring uintToString(unsigned int val); -HWND CreateToolTip(int toolID, HWND hDlg, HINSTANCE hInst, const PTSTR pszText); +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); -bool isCertificateValidated(const generic_string & fullFilePath, const generic_string & subjectName2check); +bool isCertificateValidated(const std::wstring & fullFilePath, const std::wstring & subjectName2check); bool isAssoCommandExisting(LPCTSTR FullPathName); -std::wstring s2ws(const std::string& str); -std::string ws2s(const std::wstring& wstr); +bool deleteFileOrFolder(const std::wstring& f2delete); + +void getFilesInFolder(std::vector& files, const std::wstring& extTypeFilter, const std::wstring& inFolder); + +template size_t vecRemoveDuplicates(std::vector& vec, bool isSorted = false, bool canSort = false) +{ + if (!isSorted && canSort) + { + std::sort(vec.begin(), vec.end()); + isSorted = true; + } + + if (isSorted) + { + typename std::vector::iterator it; + it = std::unique(vec.begin(), vec.end()); + vec.resize(distance(vec.begin(), it)); // unique() does not shrink the vector + } + else + { + std::unordered_set seen; + auto newEnd = std::remove_if(vec.begin(), vec.end(), [&seen](const T& value) + { + return !seen.insert(value).second; + }); + vec.erase(newEnd, vec.end()); + } + return vec.size(); +} + +void trim(std::wstring& str); + +int nbDigitsFromNbLines(size_t nbLines); + +std::wstring getDateTimeStrFrom(const std::wstring& dateTimeFormat, const SYSTEMTIME& st); + +HFONT createFont(const wchar_t* fontName, int fontSize, bool isBold, HWND hDestParent); +bool removeReadOnlyFlagFromFileAttributes(const wchar_t* fileFullPath); + +bool isWin32NamespacePrefixedFileName(const std::wstring& fileName); +bool isWin32NamespacePrefixedFileName(const wchar_t* szFileName); +bool isUnsupportedFileName(const std::wstring& fileName); +bool isUnsupportedFileName(const wchar_t* szFileName); + +class Version final +{ +public: + Version() = default; + Version(const std::wstring& versionStr); + + void setVersionFrom(const std::wstring& filePath); + std::wstring toString(); + bool isNumber(const std::wstring& s) const { + return !s.empty() && + find_if(s.begin(), s.end(), [](wchar_t 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; +}; + -bool deleteFileOrFolder(const generic_string& f2delete); +BOOL getDiskFreeSpaceWithTimeout(const wchar_t* dirPath, ULARGE_INTEGER* freeBytesForUser, + DWORD milliSec2wait = 0, bool* isTimeoutReached = nullptr); +BOOL getFileAttributesExWithTimeout(const wchar_t* filePath, WIN32_FILE_ATTRIBUTE_DATA* fileAttr, + DWORD milliSec2wait = 0, bool* isTimeoutReached = nullptr, DWORD* pdwWin32ApiError = nullptr); -void getFilesInFolder(std::vector& files, const generic_string& extTypeFilter, const generic_string& inFolder); +bool doesFileExist(const wchar_t* filePath, DWORD milliSec2wait = 0, bool* isTimeoutReached = nullptr); +bool doesDirectoryExist(const wchar_t* dirPath, DWORD milliSec2wait = 0, bool* isTimeoutReached = nullptr); +bool doesPathExist(const wchar_t* path, DWORD milliSec2wait = 0, bool* isTimeoutReached = nullptr); \ No newline at end of file diff --git a/NppPlugin/include/Docking.h b/NppPlugin/include/Docking.h index f4b2af49..ca9cd19d 100644 --- a/NppPlugin/include/Docking.h +++ b/NppPlugin/include/Docking.h @@ -1,29 +1,18 @@ -// this file is part of Notepad++ -// Copyright (C)2005 Jens Lorenz -// -// 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 the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// // Note that the GPL places important restrictions on "derived works", yet -// it does not provide a detailed definition of that term. To avoid -// misunderstandings, we consider an application to constitute a -// "derivative work" for the purpose of this license if it does any of the -// following: -// 1. Integrates source code from Notepad++. -// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable -// installer, such as those produced by InstallShield. -// 3. Links to a library or executes a program that does any of the above. -// +// This file is part of Notepad++ project +// Copyright (C)2024 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 +// the Free Software Foundation, either version 3 of the License, or +// at your option any later version. +// // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// +// // You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +// along with this program. If not, see . #pragma once @@ -47,6 +36,7 @@ #define DWS_ICONTAB 0x00000001 // Icon for tabs are available #define DWS_ICONBAR 0x00000002 // Icon for icon bar are available (currently not supported) #define DWS_ADDINFO 0x00000004 // Additional information are in use +#define DWS_USEOWNDARKMODE 0x00000008 // Use plugin's own dark mode #define DWS_PARAMSALL (DWS_ICONTAB|DWS_ICONBAR|DWS_ADDINFO) // default docking values for first call of plugin @@ -57,27 +47,27 @@ #define DWS_DF_FLOATING 0x80000000 // default state is floating -typedef struct { - HWND hClient; // client Window Handle - const TCHAR *pszName; // name of plugin (shown in window) - int dlgID; // a funcItem provides the function pointer to start a dialog. Please parse here these ID +struct tTbData { + HWND hClient = nullptr; // client Window Handle + const wchar_t* pszName = nullptr; // name of plugin (shown in window) + int dlgID = 0; // a funcItem provides the function pointer to start a dialog. Please parse here these ID // user modifications - UINT uMask; // mask params: look to above defines - HICON hIconTab; // icon for tabs - const TCHAR *pszAddInfo; // for plugin to display additional informations + UINT uMask = 0; // mask params: look to above defines + HICON hIconTab = nullptr; // icon for tabs + const wchar_t* pszAddInfo = nullptr; // for plugin to display additional informations // internal data, do not use !!! - RECT rcFloat; // floating position - int iPrevCont; // stores the privious container (toggling between float and dock) - const TCHAR* pszModuleName; // it's the plugin file name. It's used to identify the plugin -} tTbData; + RECT rcFloat = {}; // floating position + int iPrevCont = 0; // stores the privious container (toggling between float and dock) + const wchar_t* pszModuleName = nullptr; // it's the plugin file name. It's used to identify the plugin +}; -typedef struct { - HWND hWnd; // the docking manager wnd - RECT rcRegion[DOCKCONT_MAX]; // position of docked dialogs -} tDockMgr; +struct tDockMgr { + HWND hWnd = nullptr; // the docking manager wnd + RECT rcRegion[DOCKCONT_MAX] = {{}}; // position of docked dialogs +}; #define HIT_TEST_THICKNESS 20 diff --git a/NppPlugin/include/DockingDlgInterface.h b/NppPlugin/include/DockingDlgInterface.h index 249a4706..ffd4b3ed 100644 --- a/NppPlugin/include/DockingDlgInterface.h +++ b/NppPlugin/include/DockingDlgInterface.h @@ -1,28 +1,18 @@ -// this file is part of Function List Plugin for Notepad++ -// Copyright (C)2005 Jens Lorenz -// -// 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 the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// Note that the GPL places important restrictions on "derived works", yet -// it does not provide a detailed definition of that term. To avoid -// misunderstandings, we consider an application to constitute a -// "derivative work" for the purpose of this license if it does any of the -// following: -// 1. Integrates source code from Notepad++. -// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable -// installer, such as those produced by InstallShield. -// 3. Links to a library or executes a program that does any of the above. +// This file is part of Notepad++ project +// Copyright (C)2006 Jens Lorenz + +// 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 +// the Free Software Foundation, either version 3 of the License, or +// at your option any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// +// // You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software +// along with this program. If not, see . #pragma once @@ -34,6 +24,7 @@ #include #include "Common.h" #include "StaticDialog.h" +#include "NppDarkMode.h" @@ -43,44 +34,39 @@ class DockingDlgInterface : public StaticDialog DockingDlgInterface() = default; explicit DockingDlgInterface(int dlgID): _dlgID(dlgID) {} - virtual void init(HINSTANCE hInst, HWND parent) - { + void init(HINSTANCE hInst, HWND parent) override { StaticDialog::init(hInst, parent); - TCHAR temp[MAX_PATH]; - ::GetModuleFileName(reinterpret_cast(hInst), temp, MAX_PATH); + wchar_t temp[MAX_PATH]; + ::GetModuleFileName(hInst, temp, MAX_PATH); _moduleName = ::PathFindFileName(temp); } - void create(tTbData * data, bool isRTL = false) - { + void create(tTbData* data, bool isRTL = false) { assert(data != nullptr); StaticDialog::create(_dlgID, isRTL); - TCHAR temp[MAX_PATH]; + wchar_t temp[MAX_PATH]; ::GetWindowText(_hSelf, temp, MAX_PATH); _pluginName = temp; - // user information - data->hClient = _hSelf; - data->pszName = _pluginName.c_str(); + // user information + data->hClient = _hSelf; + data->pszName = _pluginName.c_str(); // supported features by plugin - data->uMask = 0; + data->uMask = 0; // additional info - data->pszAddInfo = NULL; + data->pszAddInfo = NULL; } - virtual void updateDockingDlg() - { + virtual void updateDockingDlg() { ::SendMessage(_hParent, NPPM_DMMUPDATEDISPINFO, 0, reinterpret_cast(_hSelf)); } - virtual void destroy() {} - virtual void setBackgroundColor(COLORREF) {} virtual void setForegroundColor(COLORREF) {} - virtual void display(bool toShow = true) const { + void display(bool toShow = true) const override { ::SendMessage(_hParent, toShow ? NPPM_DMMSHOW : NPPM_DMMHIDE, 0, reinterpret_cast(_hSelf)); } @@ -92,16 +78,33 @@ class DockingDlgInterface : public StaticDialog _isClosed = toClose; } - const TCHAR * getPluginFileName() const { + const wchar_t * getPluginFileName() const { return _moduleName.c_str(); } protected : - virtual INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM, LPARAM lParam) - { - switch (message) + int _dlgID = -1; + bool _isFloating = true; + int _iDockedPos = 0; + std::wstring _moduleName; + std::wstring _pluginName; + bool _isClosed = false; + + intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) override { + switch (message) { + case WM_ERASEBKGND: + { + if (!NppDarkMode::isEnabled()) + { + break; + } + RECT rc = {}; + getClientRect(rc); + ::FillRect(reinterpret_cast(wParam), &rc, NppDarkMode::getDarkerBackgroundBrush()); + return TRUE; + } case WM_NOTIFY: { LPNMHDR pnmh = reinterpret_cast(lParam); @@ -136,13 +139,4 @@ protected : } return FALSE; }; - - // Handles - HWND _HSource = NULL; - int _dlgID = -1; - bool _isFloating = true; - int _iDockedPos = 0; - generic_string _moduleName; - generic_string _pluginName; - bool _isClosed = false; }; diff --git a/NppPlugin/include/Notepad_plus_msgs.h b/NppPlugin/include/Notepad_plus_msgs.h index 306c109c..ee1e6a33 100644 --- a/NppPlugin/include/Notepad_plus_msgs.h +++ b/NppPlugin/include/Notepad_plus_msgs.h @@ -1,33 +1,26 @@ // This file is part of Notepad++ project -// Copyright (C)2003 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 the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// Note that the GPL places important restrictions on "derived works", yet -// it does not provide a detailed definition of that term. To avoid -// misunderstandings, we consider an application to constitute a -// "derivative work" for the purpose of this license if it does any of the -// following: -// 1. Integrates source code from Notepad++. -// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable -// installer, such as those produced by InstallShield. -// 3. Links to a library or executes a program that does any of the above. +// Copyright (C)2024 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 +// the Free Software Foundation, either version 3 of the License, or +// at your option any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +// along with this program. If not, see . + -#ifndef NOTEPAD_PLUS_MSGS_H -#define NOTEPAD_PLUS_MSGS_H +// For more comprehensive information on plugin communication, please refer to the following resource: +// https://npp-user-manual.org/docs/plugin-communication/ + + +#pragma once #include #include @@ -43,395 +36,977 @@ enum LangType {L_TEXT, L_PHP , L_C, L_CPP, L_CS, L_OBJC, L_JAVA, L_RC,\ L_IHEX, L_TEHEX, L_SWIFT,\ L_ASN1, L_AVS, L_BLITZBASIC, L_PUREBASIC, L_FREEBASIC, \ L_CSOUND, L_ERLANG, L_ESCRIPT, L_FORTH, L_LATEX, \ - L_MMIXAL, L_NIMROD, L_NNCRONTAB, L_OSCRIPT, L_REBOL, \ + L_MMIXAL, L_NIM, L_NNCRONTAB, L_OSCRIPT, L_REBOL, \ L_REGISTRY, L_RUST, L_SPICE, L_TXT2TAGS, L_VISUALPROLOG,\ + L_TYPESCRIPT, L_JSON5, L_MSSQL, L_GDSCRIPT, L_HOLLYWOOD,\ + L_GOLANG, L_RAKU, L_TOML,\ // 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 Platform { PF_UNKNOWN, PF_X86, PF_X64, PF_IA64 }; +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 }; -//Here you can find how to use these messages : http://docs.notepad-plus-plus.org/index.php/Messages_And_Notifications #define NPPMSG (WM_USER + 1000) - #define NPPM_GETCURRENTSCINTILLA (NPPMSG + 4) - #define NPPM_GETCURRENTLANGTYPE (NPPMSG + 5) - #define NPPM_SETCURRENTLANGTYPE (NPPMSG + 6) - - #define NPPM_GETNBOPENFILES (NPPMSG + 7) - #define ALL_OPEN_FILES 0 - #define PRIMARY_VIEW 1 - #define SECOND_VIEW 2 - - #define NPPM_GETOPENFILENAMES (NPPMSG + 8) - - - #define NPPM_MODELESSDIALOG (NPPMSG + 12) - #define MODELESSDIALOGADD 0 - #define MODELESSDIALOGREMOVE 1 + #define NPPM_GETCURRENTSCINTILLA (NPPMSG + 4) + // BOOL NPPM_GETCURRENTSCINTILLA(0, int* iScintillaView) + // Get current Scintilla view. + // wParam: 0 (not used) + // lParam[out]: iScintillaView could be 0 (Main View) or 1 (Sub View) + // return TRUE + + #define NPPM_GETCURRENTLANGTYPE (NPPMSG + 5) + // BOOL NPPM_GETCURRENTLANGTYPE(0, int* langType) + // Get the programming language type from the current used document. + // wParam: 0 (not used) + // lParam[out]: langType - see "enum LangType" for all valid values + // return TRUE + + #define NPPM_SETCURRENTLANGTYPE (NPPMSG + 6) + // BOOL NPPM_SETCURRENTLANGTYPE(0, int langType) + // Set a new programming language type to the current used document. + // wParam: 0 (not used) + // lParam[in]: langType - see "enum LangType" for all valid values + // return TRUE + + #define NPPM_GETNBOPENFILES (NPPMSG + 7) + #define ALL_OPEN_FILES 0 + #define PRIMARY_VIEW 1 + #define SECOND_VIEW 2 + // int NPPM_GETNBOPENFILES(0, int iViewType) + // Get the number of files currently open. + // wParam: 0 (not used) + // lParam[in]: iViewType - could be PRIMARY_VIEW (value 1), SECOND_VIEW (value 2) or ALL_OPEN_FILES (value 0) + // return the number of opened files + + #define NPPM_GETOPENFILENAMES (NPPMSG + 8) + // BOOL NPPM_GETOPENFILENAMES(wchar_t** fileNames, int nbFileNames) + // Get the open files full paths of both views. User is responsible to allocate an big enough fileNames array by using NPPM_GETNBOPENFILES. + // wParam[out]: fileNames - array of file path + // lParam[in]: nbFileNames is the number of file path. + // return value: The number of files copied into fileNames array + + #define NPPM_MODELESSDIALOG (NPPMSG + 12) + #define MODELESSDIALOGADD 0 + #define MODELESSDIALOGREMOVE 1 + // HWND NPPM_MODELESSDIALOG(int action, HWND hDlg) + // Register (or unregister) plugin's dialog handle. + // For each created dialog in your plugin, you should register it (and unregister while destroy it) to Notepad++ by using this message. + // If this message is ignored, then your dialog won't react with the key stroke messages such as TAB, Ctrl-C or Ctrl-V key. + // For the good functioning of your plugin dialog, you're recommended to not ignore this message. + // wParam[in]: action is MODELESSDIALOGADD (for registering your hDlg) or MODELESSDIALOGREMOVE (for unregistering your hDlg) + // lParam[in]: hDlg is the handle of dialog to register/unregister + // return hDlg (HWND) on success, NULL on failure #define NPPM_GETNBSESSIONFILES (NPPMSG + 13) + // int NPPM_GETNBSESSIONFILES (BOOL* pbIsValidXML, wchar_t* sessionFileName) + // Get the number of files to load in the session sessionFileName. sessionFileName should be a full path name of an xml file. + // wParam[out]: pbIsValidXML, if the lParam pointer is null, then this parameter will be ignored. TRUE if XML is valid, otherwise FALSE. + // lParam[in]: sessionFileName is XML session full path + // return value: The number of files in XML session file + #define NPPM_GETSESSIONFILES (NPPMSG + 14) - #define NPPM_SAVESESSION (NPPMSG + 15) - #define NPPM_SAVECURRENTSESSION (NPPMSG + 16) + // NPPM_GETSESSIONFILES (wchar_t** sessionFileArray, wchar_t* sessionFileName) + // the files' full path name from a session file. + // wParam[out]: sessionFileArray is the array in which the files' full path of the same group are written. To allocate the array with the proper size, send message NPPM_GETNBSESSIONFILES. + // lParam[in]: sessionFileName is XML session full path + // Return FALSE on failure, TRUE on success + #define NPPM_SAVESESSION (NPPMSG + 15) struct sessionInfo { - TCHAR* sessionFilePathName; - int nbFile; - TCHAR** files; + wchar_t* sessionFilePathName; // Full session file path name to be saved + int nbFile; // Size of "files" array - number of files to be saved in session + wchar_t** files; // Array of file name (full path) to be saved in session }; + // NPPM_SAVESESSION(0, sessionInfo* si) + // Creates an session file for a defined set of files. + // Contrary to NPPM_SAVECURRENTSESSION (see below), which saves the current opened files, this call can be used to freely define any file which should be part of a session. + // wParam: 0 (not used) + // lParam[in]: si is a pointer to sessionInfo structure + // Returns sessionFileName on success, NULL otherwise + + #define NPPM_SAVECURRENTSESSION (NPPMSG + 16) + // wchar_t* NPPM_SAVECURRENTSESSION(0, wchar_t* sessionFileName) + // Saves the current opened files in Notepad++ as a group of files (session) as an xml file. + // wParam: 0 (not used) + // lParam[in]: sessionFileName is the xml full path name + // Returns sessionFileName on success, NULL otherwise + #define NPPM_GETOPENFILENAMESPRIMARY (NPPMSG + 17) + // BOOL NPPM_GETOPENFILENAMESPRIMARY(wchar_t** fileNames, int nbFileNames) + // Get the open files full paths of main view. User is responsible to allocate an big enough fileNames array by using NPPM_GETNBOPENFILES. + // wParam[out]: fileNames - array of file path + // lParam[in]: nbFileNames is the number of file path. + // return value: The number of files copied into fileNames array + #define NPPM_GETOPENFILENAMESSECOND (NPPMSG + 18) + // BOOL NPPM_GETOPENFILENAMESSECOND(wchar_t** fileNames, int nbFileNames) + // Get the open files full paths of sub-view. User is responsible to allocate an big enough fileNames array by using NPPM_GETNBOPENFILES. + // wParam[out]: fileNames - array of file path + // lParam[in]: nbFileNames is the number of file path. + // return value: The number of files copied into fileNames array #define NPPM_CREATESCINTILLAHANDLE (NPPMSG + 20) - #define NPPM_DESTROYSCINTILLAHANDLE (NPPMSG + 21) + // HWND NPPM_CREATESCINTILLAHANDLE(0, HWND hParent) + // A plugin can create a Scintilla for its usage by sending this message to Notepad++. + // wParam: 0 (not used) + // lParam[in]: hParent - If set (non NULL), it will be the parent window of this created Scintilla handle, otherwise the parent window is Notepad++ + // return the handle of created Scintilla handle + + #define NPPM_DESTROYSCINTILLAHANDLE_DEPRECATED (NPPMSG + 21) + // BOOL NPPM_DESTROYSCINTILLAHANDLE_DEPRECATED(0, HWND hScintilla) - DEPRECATED: It is kept for the compatibility. + // Notepad++ will deallocate every createed Scintilla control on exit, this message returns TRUE but does nothing. + // wParam: 0 (not used) + // lParam[in]: hScintilla is Scintilla handle + // Return TRUE + #define NPPM_GETNBUSERLANG (NPPMSG + 22) + // int NPPM_GETNBUSERLANG(0, int* udlID) + // Get the number of user defined languages and, optionally, the starting menu id. + // wParam: 0 (not used) + // lParam[out]: udlID is optional, if not used set it to 0, otherwise an integer pointer is needed to retrieve the menu identifier. + // Return the number of user defined languages identified #define NPPM_GETCURRENTDOCINDEX (NPPMSG + 23) #define MAIN_VIEW 0 #define SUB_VIEW 1 + // int NPPM_GETCURRENTDOCINDEX(0, int inView) + // Get the current index of the given view. + // wParam: 0 (not used) + // lParam[in]: inView, should be 0 (main view) or 1 (sub-view) + // Return -1 if the view is invisible (hidden), otherwise is the current index. #define NPPM_SETSTATUSBAR (NPPMSG + 24) - #define STATUSBAR_DOC_TYPE 0 - #define STATUSBAR_DOC_SIZE 1 - #define STATUSBAR_CUR_POS 2 - #define STATUSBAR_EOF_FORMAT 3 + #define STATUSBAR_DOC_TYPE 0 + #define STATUSBAR_DOC_SIZE 1 + #define STATUSBAR_CUR_POS 2 + #define STATUSBAR_EOF_FORMAT 3 #define STATUSBAR_UNICODE_TYPE 4 - #define STATUSBAR_TYPING_MODE 5 + #define STATUSBAR_TYPING_MODE 5 + // BOOL NPPM_SETSTATUSBAR(int whichPart, wchar_t *str2set) + // Set string in the specified field of a statusbar. + // wParam[in]: whichPart for indicating the statusbar part you want to set. It can be only the above value (0 - 5) + // lParam[in]: str2set is the string you want to write to the part of statusbar. + // Return FALSE on failure, TRUE on success #define NPPM_GETMENUHANDLE (NPPMSG + 25) #define NPPPLUGINMENU 0 #define NPPMAINMENU 1 - // INT NPPM_GETMENUHANDLE(INT menuChoice, 0) + // int NPPM_GETMENUHANDLE(int menuChoice, 0) + // Get menu handle (HMENU) of choice. + // wParam[in]: menuChoice could be main menu (NPPMAINMENU) or Plugin menu (NPPPLUGINMENU) + // lParam: 0 (not used) // Return: menu handle (HMENU) of choice (plugin menu handle or Notepad++ main menu handle) #define NPPM_ENCODESCI (NPPMSG + 26) - //ascii file to unicode - //int NPPM_ENCODESCI(MAIN_VIEW/SUB_VIEW, 0) - //return new unicodeMode + // int NPPM_ENCODESCI(int inView, 0) + // Changes current buffer in view to UTF-8. + // wParam[in]: inView - main view (0) or sub-view (1) + // lParam: 0 (not used) + // return new UniMode, with the following value: + // 0: ANSI + // 1: UTF-8 with BOM + // 2: UTF-16 Big Ending with BOM + // 3: UTF-16 Little Ending with BOM + // 4: UTF-8 without BOM + // 5: uni7Bit + // 6: UTF-16 Big Ending without BOM + // 7: UTF-16 Little Ending without BOM #define NPPM_DECODESCI (NPPMSG + 27) - //unicode file to ascii - //int NPPM_DECODESCI(MAIN_VIEW/SUB_VIEW, 0) - //return old unicodeMode + // int NPPM_DECODESCI(int inView, 0) + // Changes current buffer in view to ANSI. + // wParam[in]: inView - main view (0) or sub-view (1) + // lParam: 0 (not used) + // return old UniMode - see above #define NPPM_ACTIVATEDOC (NPPMSG + 28) - //void NPPM_ACTIVATEDOC(int view, int index2Activate) + // BOOL NPPM_ACTIVATEDOC(int inView, int index2Activate) + // Switch to the document by the given view and index. + // wParam[in]: inView - main view (0) or sub-view (1) + // lParam[in]: index2Activate - index (in the view indicated above) where is the document to be activated + // Return TRUE #define NPPM_LAUNCHFINDINFILESDLG (NPPMSG + 29) - //void NPPM_LAUNCHFINDINFILESDLG(TCHAR * dir2Search, TCHAR * filtre) + // BOOL NPPM_LAUNCHFINDINFILESDLG(wchar_t * dir2Search, wchar_t * filtre) + // Launch Find in Files dialog and set "Find in" directory and filters with the given arguments. + // wParam[in]: if dir2Search is not NULL, it will be set as working directory in which Notepad++ will search + // lParam[in]: if filtre is not NULL, filtre string will be set into filter field + // Return TRUE #define NPPM_DMMSHOW (NPPMSG + 30) - //void NPPM_DMMSHOW(0, tTbData->hClient) + // BOOL NPPM_DMMSHOW(0, HWND hDlg) + // Show the dialog which was previously regeistered by NPPM_DMMREGASDCKDLG. + // wParam: 0 (not used) + // lParam[in]: hDlg is the handle of dialog to show + // Return TRUE #define NPPM_DMMHIDE (NPPMSG + 31) - //void NPPM_DMMHIDE(0, tTbData->hClient) + // BOOL NPPM_DMMHIDE(0, HWND hDlg) + // Hide the dialog which was previously regeistered by NPPM_DMMREGASDCKDLG. + // wParam: 0 (not used) + // lParam[in]: hDlg is the handle of dialog to hide + // Return TRUE #define NPPM_DMMUPDATEDISPINFO (NPPMSG + 32) - //void NPPM_DMMUPDATEDISPINFO(0, tTbData->hClient) + // BOOL NPPM_DMMUPDATEDISPINFO(0, HWND hDlg) + // Redraw the dialog. + // wParam: 0 (not used) + // lParam[in]: hDlg is the handle of dialog to redraw + // Return TRUE #define NPPM_DMMREGASDCKDLG (NPPMSG + 33) - //void NPPM_DMMREGASDCKDLG(0, &tTbData) + // BOOL NPPM_DMMREGASDCKDLG(0, tTbData* pData) + // Pass the necessary dockingData to Notepad++ in order to make your dialog dockable. + // wParam: 0 (not used) + // lParam[in]: pData is the pointer of tTbData. Please check tTbData structure in "Docking.h" + // Minimum informations which needs to be filled out are hClient, pszName, dlgID, uMask and pszModuleName. + // Notice that rcFloatand iPrevCont shouldn't be filled. They are used internally. + // Return TRUE #define NPPM_LOADSESSION (NPPMSG + 34) - //void NPPM_LOADSESSION(0, const TCHAR* file name) + // BOOL NPPM_LOADSESSION(0, wchar_t* sessionFileName) + // Open all files of same session in Notepad++ via a xml format session file sessionFileName. + // wParam: 0 (not used) + // lParam[in]: sessionFileName is the full file path of session file to reload + // Return TRUE #define NPPM_DMMVIEWOTHERTAB (NPPMSG + 35) - //void WM_DMM_VIEWOTHERTAB(0, tTbData->pszName) + // BOOL WM_DMM_VIEWOTHERTAB(0, wchar_t* name) + // Show the plugin dialog (switch to plugin tab) with the given name. + // wParam: 0 (not used) + // lParam[in]: name should be the same value as previously used to register the dialog (pszName of tTbData) + // Return TRUE #define NPPM_RELOADFILE (NPPMSG + 36) - //BOOL NPPM_RELOADFILE(BOOL withAlert, TCHAR *filePathName2Reload) + // BOOL NPPM_RELOADFILE(BOOL withAlert, wchar_t *filePathName2Reload) + // Reload the document which matches with the given filePathName2Reload. + // wParam: 0 (not used) + // lParam[in]: filePathName2Reload is the full file path of document to reload + // Return TRUE if reloading file succeeds, otherwise FALSE #define NPPM_SWITCHTOFILE (NPPMSG + 37) - //BOOL NPPM_SWITCHTOFILE(0, TCHAR *filePathName2switch) + // BOOL NPPM_SWITCHTOFILE(0, wchar_t* filePathName2switch) + // Switch to the document which matches with the given filePathName2switch. + // wParam: 0 (not used) + // lParam[in]: filePathName2switch is the full file path of document to switch + // Return TRUE #define NPPM_SAVECURRENTFILE (NPPMSG + 38) - //BOOL NPPM_SAVECURRENTFILE(0, 0) + // BOOL NPPM_SAVECURRENTFILE(0, 0) + // Save current activated document. + // wParam: 0 (not used) + // lParam: 0 (not used) + // Return TRUE if file is saved, otherwise FALSE (the file doesn't need to be saved, or other reasons). #define NPPM_SAVEALLFILES (NPPMSG + 39) - //BOOL NPPM_SAVEALLFILES(0, 0) + // BOOL NPPM_SAVEALLFILES(0, 0) + // Save all opened document. + // wParam: 0 (not used) + // lParam: 0 (not used) + // Return FALSE when no file needs to be saved, else TRUE if there is at least one file saved. #define NPPM_SETMENUITEMCHECK (NPPMSG + 40) - //void WM_PIMENU_CHECK(UINT funcItem[X]._cmdID, TRUE/FALSE) + // BOOL NPPM_SETMENUITEMCHECK(UINT pluginCmdID, BOOL doCheck) + // Set or remove the check on a item of plugin menu and tool bar (if any). + // wParam[in]: pluginCmdID is the plugin command ID which corresponds to the menu item: funcItem[X]._cmdID + // lParam[in]: if doCheck value is TRUE, item will be checked, FALSE makes item unchecked. + // Return TRUE - #define NPPM_ADDTOOLBARICON (NPPMSG + 41) - //void WM_ADDTOOLBARICON(UINT funcItem[X]._cmdID, toolbarIcons icon) + #define NPPM_ADDTOOLBARICON_DEPRECATED (NPPMSG + 41) struct toolbarIcons { HBITMAP hToolbarBmp; HICON hToolbarIcon; }; + // BOOL NPPM_ADDTOOLBARICON_DEPRECATED(UINT pluginCmdID, toolbarIcons* iconHandles) -- DEPRECATED: use NPPM_ADDTOOLBARICON_FORDARKMODE instead + // Add an icon to the toolbar. + // wParam[in]: pluginCmdID is the plugin command ID which corresponds to the menu item: funcItem[X]._cmdID + // lParam[in]: iconHandles of toolbarIcons structure. 2 formats ".ico" & ".bmp" are needed + // Both handles should be set so the icon will be displayed correctly if toolbar icon sets are changed by users + // Return TRUE + #define NPPM_GETWINDOWSVERSION (NPPMSG + 42) - //winVer NPPM_GETWINDOWSVERSION(0, 0) + // winVer NPPM_GETWINDOWSVERSION(0, 0) + // Get OS (Windows) version. + // wParam: 0 (not used) + // lParam: 0 (not used) + // Return enum winVer, which is defined at the begining of this file #define NPPM_DMMGETPLUGINHWNDBYNAME (NPPMSG + 43) - //HWND WM_DMM_GETPLUGINHWNDBYNAME(const TCHAR *windowName, const TCHAR *moduleName) - // if moduleName is NULL, then return value is NULL - // if windowName is NULL, then the first found window handle which matches with the moduleName will be returned + // HWND NPPM_DMMGETPLUGINHWNDBYNAME(const wchar_t *windowName, const wchar_t *moduleName) + // Retrieve the dialog handle corresponds to the windowName and moduleName. You may need this message if you want to communicate with another plugin "dockable" dialog. + // wParam[in]: windowName - if windowName is NULL, then the first found window handle which matches with the moduleName will be returned + // lParam[in] : moduleName - if moduleName is NULL, then return value is NULL + // Return NULL if moduleName is NULL. If windowName is NULL, then the first found window handle which matches with the moduleName will be returned. #define NPPM_MAKECURRENTBUFFERDIRTY (NPPMSG + 44) - //BOOL NPPM_MAKECURRENTBUFFERDIRTY(0, 0) - - #define NPPM_GETENABLETHEMETEXTUREFUNC (NPPMSG + 45) - //BOOL NPPM_GETENABLETHEMETEXTUREFUNC(0, 0) + // BOOL NPPM_MAKECURRENTBUFFERDIRTY(0, 0) + // Make the current document dirty, aka set the save state to unsaved. + // wParam: 0 (not used) + // lParam: 0 (not used) + // Return TRUE + + #define NPPM_GETENABLETHEMETEXTUREFUNC_DEPRECATED (NPPMSG + 45) + // THEMEAPI NPPM_GETENABLETHEMETEXTUREFUNC(0, 0) -- DEPRECATED: plugin can use EnableThemeDialogTexture directly from uxtheme.h instead + // Get "EnableThemeDialogTexture" function address. + // wParam: 0 (not used) + // lParam: 0 (not used) + // Return a proc address or NULL #define NPPM_GETPLUGINSCONFIGDIR (NPPMSG + 46) - //INT NPPM_GETPLUGINSCONFIGDIR(int strLen, TCHAR *str) + // int NPPM_GETPLUGINSCONFIGDIR(int strLen, wchar_t *str) // Get user's plugin config directory path. It's useful if plugins want to save/load parameters for the current user - // Returns the number of TCHAR copied/to copy. - // Users should call it with "str" be NULL to get the required number of TCHAR (not including the terminating nul character), - // allocate "str" buffer with the return value + 1, then call it again to get the path. + // wParam[in]: strLen is length of allocated buffer in which directory path is copied + // lParam[out] : str is the allocated buffere. User should call this message twice - + // The 1st call with "str" be NULL to get the required number of wchar_t (not including the terminating nul character) + // The 2nd call to allocate "str" buffer with the 1st call's return value + 1, then call it again to get the path + // Return value: The 1st call - the number of wchar_t to copy. + // The 2nd call - FALSE on failure, TRUE on success #define NPPM_MSGTOPLUGIN (NPPMSG + 47) - //BOOL NPPM_MSGTOPLUGIN(TCHAR *destModuleName, CommunicationInfo *info) - // return value is TRUE when the message arrive to the destination plugins. - // if destModule or info is NULL, then return value is FALSE struct CommunicationInfo { - long internalMsg; - const TCHAR * srcModuleName; - void * info; // defined by plugin + long internalMsg; // an integer defined by plugin Y, known by plugin X, identifying the message being sent. + const wchar_t * srcModuleName; // the complete module name (with the extesion .dll) of caller (plugin X). + void* info; // defined by plugin, the informations to be exchanged between X and Y. It's a void pointer so it should be defined by plugin Y and known by plugin X. }; + // BOOL NPPM_MSGTOPLUGIN(wchar_t *destModuleName, CommunicationInfo *info) + // Send a private information to a plugin with given plugin name. This message allows the communication between 2 plugins. + // For example, plugin X can execute a command of plugin Y if plugin X knows the command ID and the file name of plugin Y. + // wParam[in]: destModuleName is the destination complete module file name (with the file extension ".dll") + // lParam[in]: info - See above "CommunicationInfo" structure + // The returned value is TRUE if Notepad++ found the plugin by its module name (destModuleName), and pass the info (communicationInfo) to the module. + // The returned value is FALSE if no plugin with such name is found. #define NPPM_MENUCOMMAND (NPPMSG + 48) - //void NPPM_MENUCOMMAND(0, int cmdID) - // uncomment //#include "menuCmdID.h" - // in the beginning of this file then use the command symbols defined in "menuCmdID.h" file - // to access all the Notepad++ menu command items + // BOOL NPPM_MENUCOMMAND(0, int cmdID) + // Run Notepad++ command with the given command ID. + // wParam: 0 (not used) + // lParam[in]: cmdID - See "menuCmdID.h" for all the Notepad++ menu command items + // Return TRUE #define NPPM_TRIGGERTABBARCONTEXTMENU (NPPMSG + 49) - //void NPPM_TRIGGERTABBARCONTEXTMENU(int view, int index2Activate) + // BOOL NPPM_TRIGGERTABBARCONTEXTMENU(int inView, int index2Activate) + // Switch to the document by the given view and index and trigger the context menu + // wParam[in]: inView - main view (0) or sub-view (1) + // lParam[in]: index2Activate - index (in the view indicated above) where is the document to have the context menu + // Return TRUE #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. + // wParam[in]: ADD_ZERO_PADDING (see below) + // lParam: 0 (not used) + // return value: + // 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) - // if hideOrNot is set as TRUE then tab bar will be hidden - // otherwise it'll be shown. - // return value : the old status value + // Hide (or show) tab bar. + // wParam: 0 (not used) + // lParam[in]: if hideOrNot is set as TRUE then tab bar will be hidden, otherwise it'll be shown. + // return value: the old status value #define NPPM_ISTABBARHIDDEN (NPPMSG + 52) // BOOL NPPM_ISTABBARHIDDEN(0, 0) - // returned value : TRUE if tab bar is hidden, otherwise FALSE + // Get tab bar status. + // wParam: 0 (not used) + // lParam: 0 (not used) + // return value: TRUE if tool bar is hidden, otherwise FALSE #define NPPM_GETPOSFROMBUFFERID (NPPMSG + 57) - // INT NPPM_GETPOSFROMBUFFERID(UINT_PTR bufferID, INT priorityView) - // Return VIEW|INDEX from a buffer ID. -1 if the bufferID non existing - // if priorityView set to SUB_VIEW, then SUB_VIEW will be search firstly + // int NPPM_GETPOSFROMBUFFERID(UINT_PTR bufferID, int priorityView) + // Get document position (VIEW and INDEX) from a buffer ID, according priorityView. + // wParam[in]: BufferID of document + // lParam[in]: priorityView is the target VIEW. However, if the given bufferID cannot be found in the target VIEW, the other VIEW will be searched. + // Return -1 if the bufferID non existing, else return value contains VIEW & INDEX: // // VIEW takes 2 highest bits and INDEX (0 based) takes the rest (30 bits) - // Here's the values for the view : + // Here's the values for the view: // MAIN_VIEW 0 // SUB_VIEW 1 + // + // if priorityView set to SUB_VIEW, then SUB_VIEW will be search firstly #define NPPM_GETFULLPATHFROMBUFFERID (NPPMSG + 58) - // INT NPPM_GETFULLPATHFROMBUFFERID(UINT_PTR bufferID, TCHAR *fullFilePath) - // Get full path file name from a bufferID. - // Return -1 if the bufferID non existing, otherwise the number of TCHAR copied/to copy - // User should call it with fullFilePath be NULL to get the number of TCHAR (not including the nul character), - // allocate fullFilePath with the return values + 1, then call it again to get full path file name + // int NPPM_GETFULLPATHFROMBUFFERID(UINT_PTR bufferID, wchar_t* fullFilePath) + // Get full path file name from a bufferID (the pointer of buffer). + // wParam[in]: bufferID + // lParam[out]: fullFilePath - User should call it with fullFilePath be NULL to get the number of wchar_t (not including the nul character), + // allocate fullFilePath with the return values + 1, then call it again to get full path file name + // Return -1 if the bufferID non existing, otherwise the number of wchar_t copied/to copy #define NPPM_GETBUFFERIDFROMPOS (NPPMSG + 59) - // LRESULT NPPM_GETBUFFERIDFROMPOS(INT index, INT iView) - // wParam: Position of document - // lParam: View to use, 0 = Main, 1 = Secondary - // Returns 0 if invalid + // UINT_PTR NPPM_GETBUFFERIDFROMPOS(int index, int iView) + // Get the document bufferID from the given position (iView & index). + // wParam[in]: Position (0 based) of document + // lParam[in]: Main or sub View in which document is, 0 = Main, 1 = Sub + // Returns NULL if invalid, otherwise bufferID #define NPPM_GETCURRENTBUFFERID (NPPMSG + 60) - // LRESULT NPPM_GETCURRENTBUFFERID(0, 0) - // Returns active Buffer + // UINT_PTR NPPM_GETCURRENTBUFFERID(0, 0) + // Get active document BufferID. + // wParam: 0 (not used) + // lParam: 0 (not used) + // Return active document BufferID #define NPPM_RELOADBUFFERID (NPPMSG + 61) - // VOID NPPM_RELOADBUFFERID(UINT_PTR bufferID, BOOL alert) - // Reloads Buffer - // wParam: Buffer to reload - // lParam: 0 if no alert, else alert - + // BOOL NPPM_RELOADBUFFERID(UINT_PTR bufferID, BOOL alert) + // Reloads document with the given BufferID + // wParam[in]: BufferID of document to reload + // lParam[in]: set TRUE to let user confirm or reject the reload; setting FALSE will reload with no alert. + // Returns TRUE on success, FALSE otherwise #define NPPM_GETBUFFERLANGTYPE (NPPMSG + 64) - // INT NPPM_GETBUFFERLANGTYPE(UINT_PTR bufferID, 0) - // wParam: BufferID to get LangType from - // lParam: 0 + // int NPPM_GETBUFFERLANGTYPE(UINT_PTR bufferID, 0) + // Retrieves the language type of the document with the given bufferID. + // wParam[in]: BufferID of document to get LangType from + // lParam: 0 (not used) // Returns as int, see LangType. -1 on error #define NPPM_SETBUFFERLANGTYPE (NPPMSG + 65) - // BOOL NPPM_SETBUFFERLANGTYPE(UINT_PTR bufferID, INT langType) - // wParam: BufferID to set LangType of - // lParam: LangType + // BOOL NPPM_SETBUFFERLANGTYPE(UINT_PTR bufferID, int langType) + // Set the language type of the document based on the given bufferID. + // wParam[in]: BufferID to set LangType of + // lParam[in]: langType as int, enum LangType for valid values (L_USER and L_EXTERNAL are not supported) // Returns TRUE on success, FALSE otherwise - // use int, see LangType for possible values - // L_USER and L_EXTERNAL are not supported #define NPPM_GETBUFFERENCODING (NPPMSG + 66) - // INT NPPM_GETBUFFERENCODING(UINT_PTR bufferID, 0) - // wParam: BufferID to get encoding from - // lParam: 0 - // returns as int, see UniMode. -1 on error + // int NPPM_GETBUFFERENCODING(UINT_PTR bufferID, 0) + // Get encoding from the document with the given bufferID + // wParam[in]: BufferID to get encoding from + // lParam: 0 (not used) + // returns -1 on error, otherwise UniMode, with the following value: + // 0: ANSI + // 1: UTF-8 with BOM + // 2: UTF-16 Big Ending with BOM + // 3: UTF-16 Little Ending with BOM + // 4: UTF-8 without BOM + // 5: uni7Bit + // 6: UTF-16 Big Ending without BOM + // 7: UTF-16 Little Ending without BOM #define NPPM_SETBUFFERENCODING (NPPMSG + 67) - // BOOL NPPM_SETBUFFERENCODING(UINT_PTR bufferID, INT encoding) + // BOOL NPPM_SETBUFFERENCODING(UINT_PTR bufferID, int encoding) + // Set encoding to the document with the given bufferID // wParam: BufferID to set encoding of - // lParam: encoding + // lParam: encoding, see UniMode value in NPPM_GETBUFFERENCODING (above) // Returns TRUE on success, FALSE otherwise - // use int, see UniMode // Can only be done on new, unedited files #define NPPM_GETBUFFERFORMAT (NPPMSG + 68) - // INT NPPM_GETBUFFERFORMAT(UINT_PTR bufferID, 0) - // wParam: BufferID to get EolType format from - // lParam: 0 - // returns as int, see EolType format. -1 on error + // int NPPM_GETBUFFERFORMAT(UINT_PTR bufferID, 0) + // Get the EOL format of the document with given bufferID. + // wParam[in]: BufferID to get EolType format from + // lParam: 0 (not used) + // Returned value is -1 on error, otherwize EolType format: + // 0: Windows (CRLF) + // 1: Macos (CR) + // 2: Unix (LF) + // 3. Unknown #define NPPM_SETBUFFERFORMAT (NPPMSG + 69) - // BOOL NPPM_SETBUFFERFORMAT(UINT_PTR bufferID, INT format) - // wParam: BufferID to set EolType format of - // lParam: format + // BOOL NPPM_SETBUFFERFORMAT(UINT_PTR bufferID, int format) + // Set the EOL format to the document with given bufferID. + // wParam[in]: BufferID to set EolType format of + // lParam[in]: EolType format. For EolType format value, see NPPM_GETBUFFERFORMAT (above) // Returns TRUE on success, FALSE otherwise - // use int, see EolType format - #define NPPM_HIDETOOLBAR (NPPMSG + 70) // BOOL NPPM_HIDETOOLBAR(0, BOOL hideOrNot) - // if hideOrNot is set as TRUE then tool bar will be hidden - // otherwise it'll be shown. - // return value : the old status value + // Hide (or show) the toolbar. + // wParam: 0 (not used) + // lParam[in]: if hideOrNot is set as TRUE then tool bar will be hidden, otherwise it'll be shown. + // return value: the old status value #define NPPM_ISTOOLBARHIDDEN (NPPMSG + 71) // BOOL NPPM_ISTOOLBARHIDDEN(0, 0) - // returned value : TRUE if tool bar is hidden, otherwise FALSE + // Get toolbar status. + // wParam: 0 (not used) + // lParam: 0 (not used) + // return value: TRUE if tool bar is hidden, otherwise FALSE #define NPPM_HIDEMENU (NPPMSG + 72) // BOOL NPPM_HIDEMENU(0, BOOL hideOrNot) - // if hideOrNot is set as TRUE then menu will be hidden - // otherwise it'll be shown. - // return value : the old status value + // Hide (or show) menu bar. + // wParam: 0 (not used) + // lParam[in]: if hideOrNot is set as TRUE then menu will be hidden, otherwise it'll be shown. + // return value: the old status value #define NPPM_ISMENUHIDDEN (NPPMSG + 73) // BOOL NPPM_ISMENUHIDDEN(0, 0) - // returned value : TRUE if menu is hidden, otherwise FALSE + // Get menu bar status. + // wParam: 0 (not used) + // lParam: 0 (not used) + // return value: TRUE if menu bar is hidden, otherwise FALSE #define NPPM_HIDESTATUSBAR (NPPMSG + 74) // BOOL NPPM_HIDESTATUSBAR(0, BOOL hideOrNot) - // if hideOrNot is set as TRUE then STATUSBAR will be hidden - // otherwise it'll be shown. - // return value : the old status value + // Hide (or show) status bar. + // wParam: 0 (not used) + // lParam[in]: if hideOrNot is set as TRUE then status bar will be hidden, otherwise it'll be shown. + // return value: the old status value #define NPPM_ISSTATUSBARHIDDEN (NPPMSG + 75) // BOOL NPPM_ISSTATUSBARHIDDEN(0, 0) - // returned value : TRUE if STATUSBAR is hidden, otherwise FALSE + // Get status bar status. + // wParam: 0 (not used) + // lParam: 0 (not used) + // return value: TRUE if status bar is hidden, otherwise FALSE #define NPPM_GETSHORTCUTBYCMDID (NPPMSG + 76) - // BOOL NPPM_GETSHORTCUTBYCMDID(int cmdID, ShortcutKey *sk) - // get your plugin command current mapped shortcut into sk via cmdID - // You may need it after getting NPPN_READY notification - // returned value : TRUE if this function call is successful and shortcut is enable, otherwise FALSE + // BOOL NPPM_GETSHORTCUTBYCMDID(int cmdID, ShortcutKey* sk) + // Get your plugin command current mapped shortcut into sk via cmdID. + // wParam[in]: cmdID is your plugin command ID + // lParam[out]: sk is a pointer of ShortcutKey strcture which will receive the requested CMD shortcut. It should be allocated in the plugin before being used. + // For ShortcutKey strcture, see in "PluginInterface.h". You may need it after getting NPPN_READY notification. + // return value: TRUE if this function call is successful and shortcut is enable, otherwise FALSE #define NPPM_DOOPEN (NPPMSG + 77) - // BOOL NPPM_DOOPEN(0, const TCHAR *fullPathName2Open) - // fullPathName2Open indicates the full file path name to be opened. - // The return value is TRUE (1) if the operation is successful, otherwise FALSE (0). + // BOOL NPPM_DOOPEN(0, const wchar_t* fullPathName2Open) + // Open a file with given fullPathName2Open. + // If fullPathName2Open has been already opened in Notepad++, the it will be activated and becomes the current document. + // wParam: 0 (not used) + // lParam[in]: fullPathName2Open indicates the full file path name to be opened + // The return value is TRUE if the operation is successful, otherwise FALSE #define NPPM_SAVECURRENTFILEAS (NPPMSG + 78) - // BOOL NPPM_SAVECURRENTFILEAS (BOOL asCopy, const TCHAR* filename) + // BOOL NPPM_SAVECURRENTFILEAS (BOOL saveAsCopy, const wchar_t* filename) + // Save the current activated document. + // wParam[in]: saveAsCopy must be either FALSE to save, or TRUE to save a copy of the current filename ("Save a Copy As..." action) + // lParam[in]: filename indicates the full file path name to be saved + // The return value is TRUE if the operation is successful, otherwise FALSE #define NPPM_GETCURRENTNATIVELANGENCODING (NPPMSG + 79) - // INT NPPM_GETCURRENTNATIVELANGENCODING(0, 0) - // returned value : the current native language encoding + // int NPPM_GETCURRENTNATIVELANGENCODING(0, 0) + // Get the code page associated with the current localisation of Notepad++. + // wParam: 0 (not used) + // lParam: 0 (not used) + // return value: the current native language encoding + + #define NPPM_ALLOCATESUPPORTED_DEPRECATED (NPPMSG + 80) + // DEPRECATED: the message has been made (since 2010 AD) for checking if NPPM_ALLOCATECMDID is supported. This message is no more needed. + // BOOL NPPM_ALLOCATESUPPORTED_DEPRECATED(0, 0) + // Get NPPM_ALLOCATECMDID supported status. Use to identify if subclassing is necessary + // wParam: 0 (not used) + // lParam: 0 (not used) + // returns TRUE if NPPM_ALLOCATECMDID is supported - #define NPPM_ALLOCATESUPPORTED (NPPMSG + 80) - // returns TRUE if NPPM_ALLOCATECMDID is supported - // Use to identify if subclassing is necessary #define NPPM_ALLOCATECMDID (NPPMSG + 81) - // BOOL NPPM_ALLOCATECMDID(int numberRequested, int* startNumber) - // sets startNumber to the initial command ID if successful - // Returns: TRUE if successful, FALSE otherwise. startNumber will also be set to 0 if unsuccessful + // BOOL NPPM_ALLOCATECMDID(int numberRequested, int* startNumber) + // Obtain a number of consecutive menu item IDs for creating menus dynamically, with the guarantee of these IDs not clashing with any other plugins. + // wParam[in]: numberRequested is the number of ID you request for the reservation + // lParam[out]: startNumber will be set to the initial command ID if successful + // Returns: TRUE if successful, FALSE otherwise. startNumber will also be set to 0 if unsuccessful + // + // Example: If a plugin needs 4 menu item ID, the following code can be used: + // + // int idBegin; + // BOOL isAllocatedSuccessful = ::SendMessage(nppData._nppHandle, NPPM_ALLOCATECMDID, 4, &idBegin); + // + // if isAllocatedSuccessful is TRUE, and value of idBegin is 46581 + // then menu iten ID 46581, 46582, 46583 and 46584 are preserved by Notepad++, and they are safe to be used by the plugin. #define NPPM_ALLOCATEMARKER (NPPMSG + 82) // BOOL NPPM_ALLOCATEMARKER(int numberRequested, int* startNumber) - // sets startNumber to the initial command ID if successful - // Allocates a marker number to a plugin - // Returns: TRUE if successful, FALSE otherwise. startNumber will also be set to 0 if unsuccessful + // Allocate a number of consecutive marker IDs 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. + // wParam[in]: numberRequested is the number of ID you request for the reservation + // lParam[out]: startNumber will be set to the initial command ID if successful + // Return TRUE if successful, FALSE otherwise. startNumber will also be set to 0 if unsuccessful + // + // Example: If a plugin needs 3 marker ID, the following code can be used: + // + // int idBegin; + // BOOL isAllocatedSuccessful = ::SendMessage(nppData._nppHandle, NPPM_ALLOCATEMARKER, 3, &idBegin); + // + // if isAllocatedSuccessful is TRUE, and value of idBegin is 16 + // then marker ID 16, 17 and 18 are preserved by Notepad++, and they are safe to be used by the plugin. #define NPPM_GETLANGUAGENAME (NPPMSG + 83) - // INT NPPM_GETLANGUAGENAME(int langType, TCHAR *langName) - // Get programming language name from the given language type (LangType) + // int NPPM_GETLANGUAGENAME(LangType langType, wchar_t* langName) + // Get programming language name from the given language type (enum LangType). + // wParam[in]: langType is the number of LangType + // lParam[out]: langName is the buffer to recieve the language name string // Return value is the number of copied character / number of character to copy (\0 is not included) + // // You should call this function 2 times - the first time you pass langName as NULL to get the number of characters to copy. // You allocate a buffer of the length of (the number of characters + 1) then call NPPM_GETLANGUAGENAME function the 2nd time // by passing allocated buffer as argument langName #define NPPM_GETLANGUAGEDESC (NPPMSG + 84) - // INT NPPM_GETLANGUAGEDESC(int langType, TCHAR *langDesc) - // Get programming language short description from the given language type (LangType) + // INT NPPM_GETLANGUAGEDESC(int langType, wchar_t *langDesc) + // Get programming language short description from the given language type (enum LangType) + // wParam[in]: langType is the number of LangType + // lParam[out]: langDesc is the buffer to recieve the language description string // Return value is the number of copied character / number of character to copy (\0 is not included) + // // You should call this function 2 times - the first time you pass langDesc as NULL to get the number of characters to copy. // You allocate a buffer of the length of (the number of characters + 1) then call NPPM_GETLANGUAGEDESC function the 2nd time // by passing allocated buffer as argument langDesc - #define NPPM_SHOWDOCSWITCHER (NPPMSG + 85) - // VOID NPPM_ISDOCSWITCHERSHOWN(0, BOOL toShowOrNot) - // Send this message to show or hide doc switcher. - // if toShowOrNot is TRUE then show doc switcher, otherwise hide it. + #define NPPM_SHOWDOCLIST (NPPMSG + 85) + // BOOL NPPM_SHOWDOCLIST(0, BOOL toShowOrNot) + // Show or hide the Document List panel. + // wParam: 0 (not used) + // lParam[in]: toShowOrNot - if toShowOrNot is TRUE, the Document List panel is shown otherwise it is hidden. + // Return TRUE - #define NPPM_ISDOCSWITCHERSHOWN (NPPMSG + 86) - // BOOL NPPM_ISDOCSWITCHERSHOWN(0, 0) - // Check to see if doc switcher is shown. + #define NPPM_ISDOCLISTSHOWN (NPPMSG + 86) + // BOOL NPPM_ISDOCLISTSHOWN(0, 0) + // Checks the visibility of the Document List panel. + // wParam: 0 (not used) + // lParam: 0 (not used) + // return value: TRUE if the Document List panel is currently shown, FALSE otherwise #define NPPM_GETAPPDATAPLUGINSALLOWED (NPPMSG + 87) // BOOL NPPM_GETAPPDATAPLUGINSALLOWED(0, 0) // Check to see if loading plugins from "%APPDATA%\..\Local\Notepad++\plugins" is allowed. + // wParam: 0 (not used) + // lParam: 0 (not used) + // return value: TRUE if loading plugins from %APPDATA% is allowed, FALSE otherwise #define NPPM_GETCURRENTVIEW (NPPMSG + 88) - // INT NPPM_GETCURRENTVIEW(0, 0) + // int NPPM_GETCURRENTVIEW(0, 0) + // Get the current used view. + // wParam: 0 (not used) + // lParam: 0 (not used) // Return: current edit view of Notepad++. Only 2 possible values: 0 = Main, 1 = Secondary - #define NPPM_DOCSWITCHERDISABLECOLUMN (NPPMSG + 89) - // VOID NPPM_DOCSWITCHERDISABLECOLUMN(0, BOOL disableOrNot) - // Disable or enable extension column of doc switcher + #define NPPM_DOCLISTDISABLEEXTCOLUMN (NPPMSG + 89) + // BOOL NPPM_DOCLISTDISABLEEXTCOLUMN(0, BOOL disableOrNot) + // Disable or enable extension column of Document List + // wParam: 0 (not used) + // lParam[in]: disableOrNot - if disableOrNot is TRUE, extension column is hidden otherwise it is visible. + // Return TRUE + + #define NPPM_DOCLISTDISABLEPATHCOLUMN (NPPMSG + 102) + // BOOL NPPM_DOCLISTDISABLEPATHCOLUMN(0, BOOL disableOrNot) + // Disable or enable path column of Document List + // wParam: 0 (not used) + // lParam[in]: disableOrNot - if disableOrNot is TRUE, extension column is hidden otherwise it is visible. + // Return TRUE #define NPPM_GETEDITORDEFAULTFOREGROUNDCOLOR (NPPMSG + 90) - // INT NPPM_GETEDITORDEFAULTFOREGROUNDCOLOR(0, 0) - // Return: current editor default foreground color. You should convert the returned value in COLORREF + // int NPPM_GETEDITORDEFAULTFOREGROUNDCOLOR(0, 0) + // Get the current editor default foreground color. + // wParam: 0 (not used) + // lParam: 0 (not used) + // Return: the color as integer with hex format being 0x00bbggrr #define NPPM_GETEDITORDEFAULTBACKGROUNDCOLOR (NPPMSG + 91) - // INT NPPM_GETEDITORDEFAULTBACKGROUNDCOLOR(0, 0) - // Return: current editor default background color. You should convert the returned value in COLORREF + // int NPPM_GETEDITORDEFAULTBACKGROUNDCOLOR(0, 0) + // Get the current editor default background color. + // wParam: 0 (not used) + // lParam: 0 (not used) + // Return: the color as integer with hex format being 0x00bbggrr #define NPPM_SETSMOOTHFONT (NPPMSG + 92) - // VOID NPPM_SETSMOOTHFONT(0, BOOL setSmoothFontOrNot) + // BOOL NPPM_SETSMOOTHFONT(0, BOOL setSmoothFontOrNot) + // Set (or remove) smooth font. The API uses underlying Scintilla command SCI_SETFONTQUALITY to manage the font quality. + // wParam: 0 (not used) + // lParam[in]: setSmoothFontOrNot - if value is TRUE, this message sets SC_EFF_QUALITY_LCD_OPTIMIZED else SC_EFF_QUALITY_DEFAULT + // Return TRUE #define NPPM_SETEDITORBORDEREDGE (NPPMSG + 93) - // VOID NPPM_SETEDITORBORDEREDGE(0, BOOL withEditorBorderEdgeOrNot) + // BOOL NPPM_SETEDITORBORDEREDGE(0, BOOL withEditorBorderEdgeOrNot) + // Add (or remove) an additional sunken edge style to the Scintilla window else it removes the extended style from the window. + // wParam: 0 (not used) + // lParam[in]: withEditorBorderEdgeOrNot - TRUE for adding border edge on Scintilla window, FALSE for removing it + // Return TRUE #define NPPM_SAVEFILE (NPPMSG + 94) - // VOID NPPM_SAVEFILE(0, const TCHAR *fileNameToSave) + // BOOL NPPM_SAVEFILE(0, const wchar_t *fileNameToSave) + // Save the file (opened in Notepad++) with the given full file name path. + // wParam: 0 (not used) + // lParam[in]: fileNameToSave must be the full file path for the file to be saved. + // Return TRUE on success, FALSE on fileNameToSave is not found #define NPPM_DISABLEAUTOUPDATE (NPPMSG + 95) // 2119 in decimal - // VOID NPPM_DISABLEAUTOUPDATE(0, 0) + // BOOL NPPM_DISABLEAUTOUPDATE(0, 0) + // Disable Notepad++ auto-update. + // wParam: 0 (not used) + // lParam: 0 (not used) + // Return TRUE #define NPPM_REMOVESHORTCUTBYCMDID (NPPMSG + 96) // 2120 in decimal - // BOOL NPPM_REMOVESHORTCUTASSIGNMENT(int cmdID) - // removes the assigned shortcut mapped to cmdID - // returned value : TRUE if function call is successful, otherwise FALSE + // BOOL NPPM_REMOVESHORTCUTBYCMDID(int pluginCmdID, 0) + // Remove the assigned shortcut mapped to pluginCmdID + // wParam[in]: pluginCmdID + // lParam: 0 (not used) + // return value: TRUE if function call is successful, otherwise FALSE #define NPPM_GETPLUGINHOMEPATH (NPPMSG + 97) - // INT NPPM_GETPLUGINHOMEPATH(size_t strLen, TCHAR *pluginRootPath) - // Get plugin home root path. It's useful if plugins want to get its own path - // by appending which is the name of plugin without extension part. - // Returns the number of TCHAR copied/to copy. - // Users should call it with pluginRootPath be NULL to get the required number of TCHAR (not including the terminating nul character), - // allocate pluginRootPath buffer with the return value + 1, then call it again to get the path. - -#define RUNCOMMAND_USER (WM_USER + 3000) + // int NPPM_GETPLUGINHOMEPATH(size_t strLen, wchar_t* pluginRootPath) + // Get plugin home root path. It's useful if plugins want to get its own path by appending which is the name of plugin without extension part. + // wParam[in]: strLen - size of allocated buffer "pluginRootPath" + // lParam[out]: pluginRootPath - Users should call it with pluginRootPath be NULL to get the required number of wchar_t (not including the terminating nul character), + // allocate pluginRootPath buffer with the return value + 1, then call it again to get the path. + // Return the number of wchar_t copied/to copy, 0 on copy failed + + #define NPPM_GETSETTINGSONCLOUDPATH (NPPMSG + 98) + // int NPPM_GETSETTINGSCLOUDPATH(size_t strLen, wchar_t *settingsOnCloudPath) + // Get settings on cloud path. It's useful if plugins want to store its settings on Cloud, if this path is set. + // wParam[in]: strLen - size of allocated buffer "settingsOnCloudPath" + // lParam[out]: settingsOnCloudPath - Users should call it with settingsOnCloudPath be NULL to get the required number of wchar_t (not including the terminating nul character), + // allocate settingsOnCloudPath buffer with the return value + 1, then call it again to get the path. + // Returns the number of wchar_t copied/to copy. If the return value is 0, then this path is not set, or the "strLen" is not enough to copy the path. + + #define NPPM_SETLINENUMBERWIDTHMODE (NPPMSG + 99) + #define LINENUMWIDTH_DYNAMIC 0 + #define LINENUMWIDTH_CONSTANT 1 + // BOOL NPPM_SETLINENUMBERWIDTHMODE(0, int widthMode) + // Set line number margin width in dynamic width mode (LINENUMWIDTH_DYNAMIC) or constant width mode (LINENUMWIDTH_CONSTANT) + // It may help some plugins to disable non-dynamic line number margins width to have a smoothly visual effect while vertical scrolling the content in Notepad++ + // wParam: 0 (not used) + // lParam[in]: widthMode should be LINENUMWIDTH_DYNAMIC or LINENUMWIDTH_CONSTANT + // return TRUE if calling is successful, otherwise return FALSE + + #define NPPM_GETLINENUMBERWIDTHMODE (NPPMSG + 100) + // int NPPM_GETLINENUMBERWIDTHMODE(0, 0) + // Get line number margin width in dynamic width mode (LINENUMWIDTH_DYNAMIC) or constant width mode (LINENUMWIDTH_CONSTANT) + // wParam: 0 (not used) + // lParam: 0 (not used) + // Return current line number margin width mode (LINENUMWIDTH_DYNAMIC or LINENUMWIDTH_CONSTANT) + + #define NPPM_ADDTOOLBARICON_FORDARKMODE (NPPMSG + 101) + struct toolbarIconsWithDarkMode { + HBITMAP hToolbarBmp; + HICON hToolbarIcon; + HICON hToolbarIconDarkMode; + }; + // BOOL NPPM_ADDTOOLBARICON_FORDARKMODE(UINT pluginCmdID, toolbarIconsWithDarkMode* iconHandles) + // Use NPPM_ADDTOOLBARICON_FORDARKMODE instead obsolete NPPM_ADDTOOLBARICON (DEPRECATED) which doesn't support the dark mode + // wParam[in]: pluginCmdID + // lParam[in]: iconHandles is the pointer of toolbarIconsWithDarkMode structure + // All 3 handles below should be set so the icon will be displayed correctly if toolbar icon sets are changed by users, also in dark mode + // Return TRUE + + #define NPPM_GETEXTERNALLEXERAUTOINDENTMODE (NPPMSG + 103) + // BOOL NPPM_GETEXTERNALLEXERAUTOINDENTMODE(const wchar_t* languageName, ExternalLexerAutoIndentMode* autoIndentMode) + // Get ExternalLexerAutoIndentMode for an installed external programming language. + // wParam[in]: languageName is external language name to search + // lParam[out]: autoIndentMode could recieve one of three following values + // - Standard (0) means Notepad++ will keep the same TAB indentation between lines; + // - C_Like (1) means Notepad++ will perform a C-Language style indentation for the selected external language; + // - Custom (2) 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 wchar_t* languageName, ExternalLexerAutoIndentMode autoIndentMode) + // Set ExternalLexerAutoIndentMode for an installed external programming language. + // wParam[in]: languageName is external language name to set + // lParam[in]: autoIndentMode could recieve one of three following values + // - Standard (0) means Notepad++ will keep the same TAB indentation between lines; + // - C_Like (1) means Notepad++ will perform a C-Language style indentation for the selected external language; + // - Custom (2) means a Plugin will be controlling auto-indentation for the current language. + // return value: TRUE if function call was successful, otherwise FALSE. + + #define NPPM_ISAUTOINDENTON (NPPMSG + 105) + // BOOL NPPM_ISAUTOINDENTON(0, 0) + // Get the current use Auto-Indentation setting in Notepad++ Preferences. + // wParam: 0 (not used) + // lParam: 0 (not used) + // Return TRUE if Auto-Indentation is on, FALSE otherwise + + #define NPPM_GETCURRENTMACROSTATUS (NPPMSG + 106) + // MacroStatus NPPM_GETCURRENTMACROSTATUS(0, 0) + // Get current enum class MacroStatus { Idle, RecordInProgress, RecordingStopped, PlayingBack } + // wParam: 0 (not used) + // lParam: 0 (not used) + // Return MacroStatus as int: + // 0: Idle - macro is not in use and it's empty + // 1: RecordInProgress - macro is currently being recorded + // 2: RecordingStopped - macro recording has been stopped + // 3: PlayingBack - macro is currently being played back + + #define NPPM_ISDARKMODEENABLED (NPPMSG + 107) + // BOOL NPPM_ISDARKMODEENABLED(0, 0) + // Get Notepad++ Dark Mode status (ON or OFF). + // wParam: 0 (not used) + // lParam: 0 (not used) + // Return TRUE if Dark Mode is enable, otherwise FALSE + + #define NPPM_GETDARKMODECOLORS (NPPMSG + 108) + // BOOL NPPM_GETDARKMODECOLORS (size_t cbSize, NppDarkMode::Colors* returnColors) + // Get the colors used in Dark Mode. + // wParam[in]: cbSize must be filled with sizeof(NppDarkMode::Colors). + // lParam[out]: returnColors must be a pre-allocated NppDarkMode::Colors struct. + // Return 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, wchar_t *commandLineStr) + // Get the Current Command Line string. + // Users should call it with commandLineStr as NULL to get the required number of wchar_t (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. + // wParam[in]: strLen is "commandLineStr" buffer length + // lParam[out]: commandLineStr receives all copied command line string + // Return the number of wchar_t copied/to copy + + + #define NPPM_CREATELEXER (NPPMSG + 110) + // void* NPPM_CREATELEXER(0, const wchar_t* lexer_name) + // Get the ILexer pointer created by Lexilla. Call the lexilla "CreateLexer()" function to allow plugins to set the lexer for a Scintilla instance created by NPPM_CREATESCINTILLAHANDLE. + // wParam: 0 (not used) + // lParam[in]: lexer_name is the name of the lexer + // Return the ILexer pointer + + #define NPPM_GETBOOKMARKID (NPPMSG + 111) + // int NPPM_GETBOOKMARKID(0, 0) + // Get the bookmark ID - use this API to get bookmark ID dynamically that garantees you get always the right bookmark ID even it's been changed through the different versions. + // wParam: 0 (not used) + // lParam: 0 (not used) + // Return bookmark ID + + #define NPPM_DARKMODESUBCLASSANDTHEME (NPPMSG + 112) + 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; + }; + + // ULONG NPPM_DARKMODESUBCLASSANDTHEME(ULONG dmFlags, HWND hwnd) + // Add support for generic dark mode to plugin dialog. Subclassing is applied automatically unless DWS_USEOWNDARKMODE flag is used. + // Might not work properly in C# plugins. + // wParam[in]: dmFlags has 2 possible value dmfInit (0x0000000BUL) & dmfHandleChange (0x0000000CUL) - see above definition + // lParam[in]: hwnd is the dialog handle of plugin - Docking panels don't need to call NPPM_DARKMODESUBCLASSANDTHEME + // Returns succesful combinations of flags. + + // 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) + // 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. + // wParam[in]: numberRequested is the number of ID you request for the reservation + // lParam[out]: startNumber will be set to the initial command ID if successful + // Return TRUE if successful, FALSE otherwise. startNumber will also be set to 0 if unsuccessful + // + // Example: If a plugin needs 1 indicator ID, the following code can be used : + // + // int idBegin; + // BOOL isAllocatedSuccessful = ::SendMessage(nppData._nppHandle, NPPM_ALLOCATEINDICATOR, 1, &idBegin); + // + // if isAllocatedSuccessful is TRUE, and value of idBegin is 7 + // then indicator ID 7 is preserved by Notepad++, and it is safe to be used by the plugin. + + #define NPPM_GETTABCOLORID (NPPMSG + 114) + // int NPPM_GETTABCOLORID(int view, int tabIndex) + // Get the tab color ID with given tab index and view. + // wParam[in]: view - main view (0) or sub-view (1) or -1 (active view) + // lParam[in]: tabIndex - index (in the view indicated above). -1 for currently active tab + // Return tab color ID which contains the following values: 0 (yellow), 1 (green), 2 (blue), 3 (orange), 4 (pink) or -1 (no color) + // + // Note: there's no symetric command NPPM_SETTABCOLORID. Plugins can use NPPM_MENUCOMMAND to set current tab color with the desired tab color ID. + + #define NPPM_SETUNTITLEDNAME (NPPMSG + 115) + // int NPPM_SETUNTITLEDNAME(BufferID id, const wchar_t* newName) + // Rename the tab name for an untitled tab. + // wParam[in]: id - BufferID of the tab. -1 for currently active tab + // lParam[in]: newName - the desired new name of the tab + // Return TRUE upon success; FALSE upon failure + + #define NPPM_GETNATIVELANGFILENAME (NPPMSG + 116) + // int NPPM_GETNATIVELANGFILENAME(size_t strLen, char* nativeLangFileName) + // Get the Current native language file name string. Use it after getting NPPN_READY notification to find out which native language is used. + // Users should call it with nativeLangFileName as NULL to get the required number of char (not including the terminating nul character), + // allocate language file name string buffer with the return value + 1, then call it again to get the current native language file name string. + // If there's no localization file applied, the returned value is 0. + // wParam[in]: strLen is "language file name string" buffer length + // lParam[out]: language file name string receives all copied native language file name string + // Return the number of char copied/to copy + + // 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) @@ -439,45 +1014,41 @@ enum Platform { PF_UNKNOWN, PF_X86, PF_X64, PF_IA64 }; #define NPPM_GETEXTPART (RUNCOMMAND_USER + EXT_PART) #define NPPM_GETCURRENTWORD (RUNCOMMAND_USER + CURRENT_WORD) #define NPPM_GETNPPDIRECTORY (RUNCOMMAND_USER + NPP_DIRECTORY) + #define NPPM_GETNPPFULLFILEPATH (RUNCOMMAND_USER + NPP_FULL_FILE_PATH) #define NPPM_GETFILENAMEATCURSOR (RUNCOMMAND_USER + GETFILENAMEATCURSOR) - // BOOL NPPM_GETXXXXXXXXXXXXXXXX(size_t strLen, TCHAR *str) - // where str is the allocated TCHAR array, - // strLen is the allocated array size - // The return value is TRUE when get generic_string operation success - // Otherwise (allocated array size is too small) FALSE + #define NPPM_GETCURRENTLINESTR (RUNCOMMAND_USER + CURRENT_LINESTR) + // BOOL NPPM_GETXXXXXXXXXXXXXXXX(size_t strLen, wchar_t *str) + // Get XXX string operations. + // wParam[in]: strLen is the allocated array size + // lParam[out]: str is the allocated wchar_t array + // The return value is TRUE when get std::wstring operation success, otherwise FALSE (allocated array size is too small) + #define NPPM_GETCURRENTLINE (RUNCOMMAND_USER + CURRENT_LINE) - // INT NPPM_GETCURRENTLINE(0, 0) + // int NPPM_GETCURRENTLINE(0, 0) + // Get current line number. + // wParam: 0 (not used) + // lParam: 0 (not used) // return the caret current position line + #define NPPM_GETCURRENTCOLUMN (RUNCOMMAND_USER + CURRENT_COLUMN) - // INT NPPM_GETCURRENTCOLUMN(0, 0) + // int NPPM_GETCURRENTCOLUMN(0, 0) + // Get current column number. + // wParam: 0 (not used) + // lParam: 0 (not used) // return the caret current position column - #define NPPM_GETNPPFULLFILEPATH (RUNCOMMAND_USER + NPP_FULL_FILE_PATH) - - #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 // 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. + #define NPPN_READY (NPPN_FIRST + 1) // To notify plugins that all the initialization for launching Notepad++ is complete. //scnNotification->nmhdr.code = NPPN_READY; //scnNotification->nmhdr.hwndFrom = hwndNpp; //scnNotification->nmhdr.idFrom = 0; #define NPPN_TBMODIFICATION (NPPN_FIRST + 2) // To notify plugins that toolbar icons can be registered - //scnNotification->nmhdr.code = NPPN_TB_MODIFICATION; + //scnNotification->nmhdr.code = NPPN_TBMODIFICATION; //scnNotification->nmhdr.hwndFrom = hwndNpp; //scnNotification->nmhdr.idFrom = 0; @@ -502,7 +1073,7 @@ enum Platform { PF_UNKNOWN, PF_X86, PF_X64, PF_IA64 }; //scnNotification->nmhdr.idFrom = BufferID; #define NPPN_FILEBEFORESAVE (NPPN_FIRST + 7) // To notify plugins that the current file is about to be saved - //scnNotification->nmhdr.code = NPPN_FILEBEFOREOPEN; + //scnNotification->nmhdr.code = NPPN_FILEBEFORESAVE; //scnNotification->nmhdr.hwndFrom = hwndNpp; //scnNotification->nmhdr.idFrom = BufferID; @@ -532,7 +1103,7 @@ enum Platform { PF_UNKNOWN, PF_X86, PF_X64, PF_IA64 }; //scnNotification->nmhdr.idFrom = currentBufferID; #define NPPN_SHORTCUTREMAPPED (NPPN_FIRST + 13) // To notify plugins that plugin command shortcut is remapped. - //scnNotification->nmhdr.code = NPPN_SHORTCUTSREMAPPED; + //scnNotification->nmhdr.code = NPPN_SHORTCUTREMAPPED; //scnNotification->nmhdr.hwndFrom = ShortcutKeyStructurePointer; //scnNotification->nmhdr.idFrom = cmdID; //where ShortcutKeyStructurePointer is pointer of struct ShortcutKey: @@ -544,12 +1115,12 @@ enum Platform { PF_UNKNOWN, PF_X86, PF_X64, PF_IA64 }; //}; #define NPPN_FILEBEFORELOAD (NPPN_FIRST + 14) // To notify plugins that the current file is about to be loaded - //scnNotification->nmhdr.code = NPPN_FILEBEFOREOPEN; + //scnNotification->nmhdr.code = NPPN_FILEBEFORELOAD; //scnNotification->nmhdr.hwndFrom = hwndNpp; //scnNotification->nmhdr.idFrom = NULL; #define NPPN_FILELOADFAILED (NPPN_FIRST + 15) // To notify plugins that file open operation failed - //scnNotification->nmhdr.code = NPPN_FILEOPENFAILED; + //scnNotification->nmhdr.code = NPPN_FILELOADFAILED; //scnNotification->nmhdr.hwndFrom = hwndNpp; //scnNotification->nmhdr.idFrom = BufferID; @@ -613,4 +1184,32 @@ enum Platform { PF_UNKNOWN, PF_X86, PF_X64, PF_IA64 }; //scnNotification->nmhdr.hwndFrom = hwndNpp; //scnNotification->nmhdr.idFrom = BufferID; -#endif //NOTEPAD_PLUS_MSGS_H + #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 + + #define NPPN_GLOBALMODIFIED (NPPN_FIRST + 30) // To notify plugins that the current document is just modified by Replace All action. + // For solving the performance issue (from v8.6.4), Notepad++ doesn't trigger SCN_MODIFIED during Replace All action anymore. + // As a result, the plugins which monitor SCN_MODIFIED should also monitor NPPN_GLOBALMODIFIED. + // This notification is implemented in Notepad++ v8.6.5. + //scnNotification->nmhdr.code = NPPN_GLOBALMODIFIED; + //scnNotification->nmhdr.hwndFrom = BufferID; + //scnNotification->nmhdr.idFrom = 0; // preserved for the future use, must be zero + + #define NPPN_NATIVELANGCHANGED (NPPN_FIRST + 31) // To notify plugins that the current native language is just changed to another one. + // Use NPPM_GETNATIVELANGFILENAME to get current native language file name. + // Use NPPM_GETMENUHANDLE(NPPPLUGINMENU, 0) to get submenu "Plugins" handle (HMENU) + //scnNotification->nmhdr.code = NPPN_NATIVELANGCHANGED; + //scnNotification->nmhdr.hwndFrom = hwndNpp + //scnNotification->nmhdr.idFrom = 0; // preserved for the future use, must be zero diff --git a/NppPlugin/include/NppDarkMode.h b/NppPlugin/include/NppDarkMode.h new file mode 100644 index 00000000..497a95e3 --- /dev/null +++ b/NppPlugin/include/NppDarkMode.h @@ -0,0 +1,243 @@ +// This file is part of Notepad++ project +// Copyright (c) 2021 adzm / Adam D. Walling + +// 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 +// the Free Software Foundation, either version 3 of the License, or +// at your option any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +#pragma once + +#include +#include + + +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; + }; + + 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 + { + tooltip, + toolbar, + listview, + treeview, + tabbar + }; + + enum ColorTone { + blackTone = 0, + redTone = 1, + greenTone = 2, + blueTone = 3, + purpleTone = 4, + cyanTone = 5, + oliveTone = 6, + customizedTone = 32 + }; + + enum class TreeViewStyle + { + classic = 0, + light = 1, + dark = 2 + }; + + struct AdvOptDefaults + { + std::wstring _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 }; + }; + + constexpr UINT WM_SETBUTTONIDEALSIZE = (WM_USER + 4200); + + 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); + std::wstring getThemeName(); + void setThemeName(const std::wstring& 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); + double calculatePerceivedLightness(COLORREF c); + + void setDarkTone(ColorTone colorToneChoice); + + COLORREF getBackgroundColor(); + COLORREF getSofterBackgroundColor(); + COLORREF getHotBackgroundColor(); + COLORREF getDarkerBackgroundColor(); + COLORREF getErrorBackgroundColor(); + + COLORREF getTextColor(); + COLORREF getDarkerTextColor(); + COLORREF getDisabledTextColor(); + COLORREF getLinkTextColor(); + + COLORREF getEdgeColor(); + COLORREF getHotEdgeColor(); + COLORREF getDisabledEdgeColor(); + + HBRUSH getBackgroundBrush(); + HBRUSH getDarkerBackgroundBrush(); + HBRUSH getSofterBackgroundBrush(); + HBRUSH getHotBackgroundBrush(); + HBRUSH getErrorBackgroundBrush(); + + HBRUSH getEdgeBrush(); + HBRUSH getHotEdgeBrush(); + HBRUSH getDisabledEdgeBrush(); + + HPEN getDarkerTextPen(); + HPEN getEdgePen(); + HPEN getHotEdgePen(); + HPEN getDisabledEdgePen(); + + void setBackgroundColor(COLORREF c); + void setSofterBackgroundColor(COLORREF c); + void setHotBackgroundColor(COLORREF c); + void setDarkerBackgroundColor(COLORREF c); + void setErrorBackgroundColor(COLORREF c); + void setTextColor(COLORREF c); + void setDarkerTextColor(COLORREF c); + void setDisabledTextColor(COLORREF c); + void setLinkTextColor(COLORREF c); + void setEdgeColor(COLORREF c); + void setHotEdgeColor(COLORREF c); + void setDisabledEdgeColor(COLORREF c); + + Colors getDarkModeDefaultColors(ColorTone colorTone = ColorTone::blackTone); + void changeCustomTheme(const Colors& colors); + + // handle events + 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 + bool runUAHWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, LRESULT* lr); + void drawUAHMenuNCBottomLine(HWND hWnd); + + // from DarkMode.h + void initExperimentalDarkMode(); + void setDarkMode(bool useDark, bool fixDarkScrollbar); + void allowDarkModeForApp(bool allow); + bool allowDarkModeForWindow(HWND hWnd, bool allow); + void setTitleBarThemeColor(HWND hWnd); + + // 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); + + 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); + void setDarkTooltips(HWND hwnd, ToolTipsType type); + void setDarkLineAbovePanelToolbar(HWND hwnd); + void setDarkListView(HWND hwnd); + + void disableVisualStyle(HWND hwnd, bool doDisable); + void calculateTreeViewStyle(); + void updateTreeViewStylePrev(); + TreeViewStyle getTreeViewStyle(); + void setTreeViewStyle(HWND hWnd, bool force = false); + bool isThemeDark(); + void setBorder(HWND hwnd, bool border = true); + + 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/NppPlugin/include/PluginInterface.h b/NppPlugin/include/PluginInterface.h index 4ec81f37..3aa6c8c1 100644 --- a/NppPlugin/include/PluginInterface.h +++ b/NppPlugin/include/PluginInterface.h @@ -1,51 +1,37 @@ // This file is part of Notepad++ project -// Copyright (C)2003 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 the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// Note that the GPL places important restrictions on "derived works", yet -// it does not provide a detailed definition of that term. To avoid -// misunderstandings, we consider an application to constitute a -// "derivative work" for the purpose of this license if it does any of the -// following: -// 1. Integrates source code from Notepad++. -// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable -// installer, such as those produced by InstallShield. -// 3. Links to a library or executes a program that does any of the above. +// Copyright (C)2024 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 +// the Free Software Foundation, either version 3 of the License, or +// at your option any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +// along with this program. If not, see . -#ifndef PLUGININTERFACE_H -#define PLUGININTERFACE_H -#ifndef SCINTILLA_H -#include "Scintilla.h" -#endif //SCINTILLA_H +// For more comprehensive information on plugin communication, please refer to the following resource: +// https://npp-user-manual.org/docs/plugin-communication/ -#ifndef NOTEPAD_PLUS_MSGS_H +#pragma once + +#include "Scintilla.h" #include "Notepad_plus_msgs.h" -#endif //NOTEPAD_PLUS_MSGS_H -const int nbChar = 64; -typedef const TCHAR * (__cdecl * PFUNCGETNAME)(); +typedef const wchar_t * (__cdecl * PFUNCGETNAME)(); struct NppData { - HWND _nppHandle; - HWND _scintillaMainHandle; - HWND _scintillaSecondHandle; + HWND _nppHandle = nullptr; + HWND _scintillaMainHandle = nullptr; + HWND _scintillaSecondHandle = nullptr; }; typedef void (__cdecl * PFUNCSETINFO)(NppData); @@ -56,26 +42,28 @@ typedef LRESULT (__cdecl * PMESSAGEPROC)(UINT Message, WPARAM wParam, LPARAM lPa struct ShortcutKey { - bool _isCtrl; - bool _isAlt; - bool _isShift; - UCHAR _key; + bool _isCtrl = false; + bool _isAlt = false; + bool _isShift = false; + UCHAR _key = 0; }; +const int menuItemSize = 64; + struct FuncItem { - TCHAR _itemName[nbChar]; - PFUNCPLUGINCMD _pFunc; - int _cmdID; - bool _init2Check; - ShortcutKey *_pShKey; + wchar_t _itemName[menuItemSize] = { '\0' }; + PFUNCPLUGINCMD _pFunc = nullptr; + int _cmdID = 0; + bool _init2Check = false; + ShortcutKey *_pShKey = nullptr; }; typedef FuncItem * (__cdecl * PFUNCGETFUNCSARRAY)(int *); // You should implement (or define an empty function body) those functions which are called by Notepad++ plugin manager extern "C" __declspec(dllexport) void setInfo(NppData); -extern "C" __declspec(dllexport) const TCHAR * getName(); +extern "C" __declspec(dllexport) const wchar_t * getName(); extern "C" __declspec(dllexport) FuncItem * getFuncsArray(int *); extern "C" __declspec(dllexport) void beNotified(SCNotification *); extern "C" __declspec(dllexport) LRESULT messageProc(UINT Message, WPARAM wParam, LPARAM lParam); @@ -83,5 +71,3 @@ extern "C" __declspec(dllexport) LRESULT messageProc(UINT Message, WPARAM wParam // This API return always true now, since Notepad++ isn't compiled in ANSI mode anymore extern "C" __declspec(dllexport) BOOL isUnicode(); - -#endif //PLUGININTERFACE_H diff --git a/NppPlugin/include/SciLexer.h b/NppPlugin/include/SciLexer.h index 36552d15..92d2f624 100644 --- a/NppPlugin/include/SciLexer.h +++ b/NppPlugin/include/SciLexer.h @@ -142,121 +142,20 @@ #define SCLEX_CIL 127 #define SCLEX_X12 128 #define SCLEX_DATAFLEX 129 +#define SCLEX_HOLLYWOOD 130 +#define SCLEX_RAKU 131 +#define SCLEX_FSHARP 132 +#define SCLEX_JULIA 133 +#define SCLEX_ASCIIDOC 134 +#define SCLEX_GDSCRIPT 135 +#define SCLEX_TOML 136 +#define SCLEX_TROFF 137 +#define SCLEX_DART 138 +#define SCLEX_ZIG 139 #define SCLEX_SEARCHRESULT 150 #define SCLEX_OBJC 151 #define SCLEX_USER 152 #define SCLEX_AUTOMATIC 1000 - - -//For All lexer -#define SCE_UNIVERSAL_FOUND_STYLE 31 -#define SCE_UNIVERSAL_FOUND_STYLE_SMART 29 -#define SCE_UNIVERSAL_FOUND_STYLE_INC 28 -#define SCE_UNIVERSAL_TAGMATCH 27 -#define SCE_UNIVERSAL_TAGATTR 26 -#define SCE_UNIVERSAL_FOUND_STYLE_EXT1 25 -#define SCE_UNIVERSAL_FOUND_STYLE_EXT2 24 -#define SCE_UNIVERSAL_FOUND_STYLE_EXT3 23 -#define SCE_UNIVERSAL_FOUND_STYLE_EXT4 22 -#define SCE_UNIVERSAL_FOUND_STYLE_EXT5 21 - -#define SCE_UDL_VERSION_MAJOR 2 -#define SCE_UDL_VERSION_MINOR 1 -#define SCE_UDL_VERSION_BUILD 0 -#define SCE_UDL_VERSION_REVISION 12 - -#define SCE_USER_KWLIST_COMMENTS 0 -#define SCE_USER_KWLIST_NUMBER_PREFIX1 1 -#define SCE_USER_KWLIST_NUMBER_PREFIX2 2 -#define SCE_USER_KWLIST_NUMBER_EXTRAS1 3 -#define SCE_USER_KWLIST_NUMBER_EXTRAS2 4 -#define SCE_USER_KWLIST_NUMBER_SUFFIX1 5 -#define SCE_USER_KWLIST_NUMBER_SUFFIX2 6 -#define SCE_USER_KWLIST_NUMBER_RANGE 7 -#define SCE_USER_KWLIST_OPERATORS1 8 -#define SCE_USER_KWLIST_OPERATORS2 9 -#define SCE_USER_KWLIST_FOLDERS_IN_CODE1_OPEN 10 -#define SCE_USER_KWLIST_FOLDERS_IN_CODE1_MIDDLE 11 -#define SCE_USER_KWLIST_FOLDERS_IN_CODE1_CLOSE 12 -#define SCE_USER_KWLIST_FOLDERS_IN_CODE2_OPEN 13 -#define SCE_USER_KWLIST_FOLDERS_IN_CODE2_MIDDLE 14 -#define SCE_USER_KWLIST_FOLDERS_IN_CODE2_CLOSE 15 -#define SCE_USER_KWLIST_FOLDERS_IN_COMMENT_OPEN 16 -#define SCE_USER_KWLIST_FOLDERS_IN_COMMENT_MIDDLE 17 -#define SCE_USER_KWLIST_FOLDERS_IN_COMMENT_CLOSE 18 -#define SCE_USER_KWLIST_KEYWORDS1 19 -#define SCE_USER_KWLIST_KEYWORDS2 20 -#define SCE_USER_KWLIST_KEYWORDS3 21 -#define SCE_USER_KWLIST_KEYWORDS4 22 -#define SCE_USER_KWLIST_KEYWORDS5 23 -#define SCE_USER_KWLIST_KEYWORDS6 24 -#define SCE_USER_KWLIST_KEYWORDS7 25 -#define SCE_USER_KWLIST_KEYWORDS8 26 -#define SCE_USER_KWLIST_DELIMITERS 27 -#define SCE_USER_KWLIST_TOTAL 28 // must always be <= KEYWORDSET_MAX - -#define SCE_USER_TOTAL_DELIMITERS 8 -#define SCE_USER_TOTAL_KEYWORD_GROUPS 8 -#define SCE_USER_TOTAL_FOLDERS 6 - -#define SCE_USER_STYLE_DEFAULT 0 -#define SCE_USER_STYLE_COMMENT 1 -#define SCE_USER_STYLE_COMMENTLINE 2 -#define SCE_USER_STYLE_NUMBER 3 -#define SCE_USER_STYLE_KEYWORD1 4 -#define SCE_USER_STYLE_KEYWORD2 5 -#define SCE_USER_STYLE_KEYWORD3 6 -#define SCE_USER_STYLE_KEYWORD4 7 -#define SCE_USER_STYLE_KEYWORD5 8 -#define SCE_USER_STYLE_KEYWORD6 9 -#define SCE_USER_STYLE_KEYWORD7 10 -#define SCE_USER_STYLE_KEYWORD8 11 -#define SCE_USER_STYLE_OPERATOR 12 -#define SCE_USER_STYLE_FOLDER_IN_CODE1 13 -#define SCE_USER_STYLE_FOLDER_IN_CODE2 14 -#define SCE_USER_STYLE_FOLDER_IN_COMMENT 15 -#define SCE_USER_STYLE_DELIMITER1 16 -#define SCE_USER_STYLE_DELIMITER2 17 -#define SCE_USER_STYLE_DELIMITER3 18 -#define SCE_USER_STYLE_DELIMITER4 19 -#define SCE_USER_STYLE_DELIMITER5 20 -#define SCE_USER_STYLE_DELIMITER6 21 -#define SCE_USER_STYLE_DELIMITER7 22 -#define SCE_USER_STYLE_DELIMITER8 23 -#define SCE_USER_STYLE_IDENTIFIER 24 -#define SCE_USER_STYLE_TOTAL_STYLES SCE_USER_STYLE_IDENTIFIER -#define SCE_USER_STYLE_MAPPER_TOTAL 17 -#define SCE_STYLE_ARRAY_SIZE 30 // must cover sizes of NppParameters::_lexerStyler and NppParameters::_widgetStyle - -#define SCE_USER_MASK_NESTING_NONE 0 -#define SCE_USER_MASK_NESTING_DELIMITER1 0x1 -#define SCE_USER_MASK_NESTING_DELIMITER2 0x2 -#define SCE_USER_MASK_NESTING_DELIMITER3 0x4 -#define SCE_USER_MASK_NESTING_DELIMITER4 0x8 -#define SCE_USER_MASK_NESTING_DELIMITER5 0x10 -#define SCE_USER_MASK_NESTING_DELIMITER6 0x20 -#define SCE_USER_MASK_NESTING_DELIMITER7 0x40 -#define SCE_USER_MASK_NESTING_DELIMITER8 0x80 -#define SCE_USER_MASK_NESTING_COMMENT 0x100 -#define SCE_USER_MASK_NESTING_COMMENT_LINE 0x200 -#define SCE_USER_MASK_NESTING_KEYWORD1 0x400 -#define SCE_USER_MASK_NESTING_KEYWORD2 0x800 -#define SCE_USER_MASK_NESTING_KEYWORD3 0x1000 -#define SCE_USER_MASK_NESTING_KEYWORD4 0x2000 -#define SCE_USER_MASK_NESTING_KEYWORD5 0x4000 -#define SCE_USER_MASK_NESTING_KEYWORD6 0x8000 -#define SCE_USER_MASK_NESTING_KEYWORD7 0x10000 -#define SCE_USER_MASK_NESTING_KEYWORD8 0x20000 -#define SCE_USER_MASK_NESTING_FOLDERS_IN_CODE2_OPEN 0x40000 -#define SCE_USER_MASK_NESTING_FOLDERS_IN_CODE2_MIDDLE 0x80000 -#define SCE_USER_MASK_NESTING_FOLDERS_IN_CODE2_CLOSE 0x100000 -#define SCE_USER_MASK_NESTING_FOLDERS_IN_COMMENT_OPEN 0x200000 -#define SCE_USER_MASK_NESTING_FOLDERS_IN_COMMENT_MIDDLE 0x400000 -#define SCE_USER_MASK_NESTING_FOLDERS_IN_COMMENT_CLOSE 0x800000 -#define SCE_USER_MASK_NESTING_OPERATORS1 0x1000000 -#define SCE_USER_MASK_NESTING_OPERATORS2 0x2000000 -#define SCE_USER_MASK_NESTING_NUMBERS 0x4000000 - #define SCE_P_DEFAULT 0 #define SCE_P_COMMENTLINE 1 #define SCE_P_NUMBER 2 @@ -277,6 +176,7 @@ #define SCE_P_FCHARACTER 17 #define SCE_P_FTRIPLE 18 #define SCE_P_FTRIPLEDOUBLE 19 +#define SCE_P_ATTRIBUTE 20 #define SCE_C_DEFAULT 0 #define SCE_C_COMMENT 1 #define SCE_C_COMMENTLINE 2 @@ -328,17 +228,6 @@ #define SCE_D_WORD5 20 #define SCE_D_WORD6 21 #define SCE_D_WORD7 22 - -#define SCE_SEARCHRESULT_DEFAULT 0 -#define SCE_SEARCHRESULT_SEARCH_HEADER 1 -#define SCE_SEARCHRESULT_FILE_HEADER 2 -#define SCE_SEARCHRESULT_LINE_NUMBER 3 -#define SCE_SEARCHRESULT_WORD2SEARCH 4 -#define SCE_SEARCHRESULT_HIGHLIGHT_LINE 5 -#define SCE_SEARCHRESULT_CURRENT_LINE 6 -#define SCE_OBJC_DIRECTIVE 20 -#define SCE_OBJC_QUALIFIER 21 - #define SCE_TCL_DEFAULT 0 #define SCE_TCL_COMMENT 1 #define SCE_TCL_COMMENTLINE 2 @@ -406,6 +295,7 @@ #define SCE_HJ_SYMBOLS 50 #define SCE_HJ_STRINGEOL 51 #define SCE_HJ_REGEX 52 +#define SCE_HJ_TEMPLATELITERAL 53 #define SCE_HJA_START 55 #define SCE_HJA_DEFAULT 56 #define SCE_HJA_COMMENT 57 @@ -419,6 +309,7 @@ #define SCE_HJA_SYMBOLS 65 #define SCE_HJA_STRINGEOL 66 #define SCE_HJA_REGEX 67 +#define SCE_HJA_TEMPLATELITERAL 68 #define SCE_HB_START 70 #define SCE_HB_DEFAULT 71 #define SCE_HB_COMMENTLINE 72 @@ -550,7 +441,11 @@ #define SCE_RB_STDIN 30 #define SCE_RB_STDOUT 31 #define SCE_RB_STDERR 40 -#define SCE_RB_UPPER_BOUND 41 +#define SCE_RB_STRING_W 41 +#define SCE_RB_STRING_I 42 +#define SCE_RB_STRING_QI 43 +#define SCE_RB_STRING_QS 44 +#define SCE_RB_UPPER_BOUND 45 #define SCE_B_DEFAULT 0 #define SCE_B_COMMENT 1 #define SCE_B_NUMBER 2 @@ -639,6 +534,8 @@ #define SCE_ERR_GCC_INCLUDED_FROM 22 #define SCE_ERR_ESCSEQ 23 #define SCE_ERR_ESCSEQ_UNKNOWN 24 +#define SCE_ERR_GCC_EXCERPT 25 +#define SCE_ERR_BASH 26 #define SCE_ERR_ES_BLACK 40 #define SCE_ERR_ES_RED 41 #define SCE_ERR_ES_GREEN 42 @@ -663,6 +560,7 @@ #define SCE_BAT_COMMAND 5 #define SCE_BAT_IDENTIFIER 6 #define SCE_BAT_OPERATOR 7 +#define SCE_BAT_AFTER_LABEL 8 #define SCE_TCMD_DEFAULT 0 #define SCE_TCMD_COMMENT 1 #define SCE_TCMD_WORD 2 @@ -885,7 +783,7 @@ #define SCE_CSS_EXTENDED_IDENTIFIER 19 #define SCE_CSS_EXTENDED_PSEUDOCLASS 20 #define SCE_CSS_EXTENDED_PSEUDOELEMENT 21 -#define SCE_CSS_MEDIA 22 +#define SCE_CSS_GROUP_RULE 22 #define SCE_CSS_VARIABLE 23 #define SCE_POV_DEFAULT 0 #define SCE_POV_COMMENT 1 @@ -1053,6 +951,28 @@ #define SCE_ERLANG_MODULES 23 #define SCE_ERLANG_MODULES_ATT 24 #define SCE_ERLANG_UNKNOWN 31 +#define SCE_JULIA_DEFAULT 0 +#define SCE_JULIA_COMMENT 1 +#define SCE_JULIA_NUMBER 2 +#define SCE_JULIA_KEYWORD1 3 +#define SCE_JULIA_KEYWORD2 4 +#define SCE_JULIA_KEYWORD3 5 +#define SCE_JULIA_CHAR 6 +#define SCE_JULIA_OPERATOR 7 +#define SCE_JULIA_BRACKET 8 +#define SCE_JULIA_IDENTIFIER 9 +#define SCE_JULIA_STRING 10 +#define SCE_JULIA_SYMBOL 11 +#define SCE_JULIA_MACRO 12 +#define SCE_JULIA_STRINGINTERP 13 +#define SCE_JULIA_DOCSTRING 14 +#define SCE_JULIA_STRINGLITERAL 15 +#define SCE_JULIA_COMMAND 16 +#define SCE_JULIA_COMMANDLITERAL 17 +#define SCE_JULIA_TYPEANNOT 18 +#define SCE_JULIA_LEXERROR 19 +#define SCE_JULIA_KEYWORD4 20 +#define SCE_JULIA_TYPEOPERATOR 21 #define SCE_MSSQL_DEFAULT 0 #define SCE_MSSQL_COMMENT 1 #define SCE_MSSQL_LINE_COMMENT 2 @@ -1491,6 +1411,10 @@ #define SCE_R_IDENTIFIER 9 #define SCE_R_INFIX 10 #define SCE_R_INFIXEOL 11 +#define SCE_R_BACKTICKS 12 +#define SCE_R_RAWSTRING 13 +#define SCE_R_RAWSTRING2 14 +#define SCE_R_ESCAPESEQUENCE 15 #define SCE_MAGIK_DEFAULT 0 #define SCE_MAGIK_COMMENT 1 #define SCE_MAGIK_HYPER_COMMENT 16 @@ -1807,16 +1731,18 @@ #define SCE_VISUALPROLOG_ANONYMOUS 10 #define SCE_VISUALPROLOG_NUMBER 11 #define SCE_VISUALPROLOG_OPERATOR 12 -#define SCE_VISUALPROLOG_CHARACTER 13 -#define SCE_VISUALPROLOG_CHARACTER_TOO_MANY 14 -#define SCE_VISUALPROLOG_CHARACTER_ESCAPE_ERROR 15 -#define SCE_VISUALPROLOG_STRING 16 +#define SCE_VISUALPROLOG_UNUSED1 13 +#define SCE_VISUALPROLOG_UNUSED2 14 +#define SCE_VISUALPROLOG_UNUSED3 15 +#define SCE_VISUALPROLOG_STRING_QUOTE 16 #define SCE_VISUALPROLOG_STRING_ESCAPE 17 #define SCE_VISUALPROLOG_STRING_ESCAPE_ERROR 18 -#define SCE_VISUALPROLOG_STRING_EOL_OPEN 19 -#define SCE_VISUALPROLOG_STRING_VERBATIM 20 -#define SCE_VISUALPROLOG_STRING_VERBATIM_SPECIAL 21 -#define SCE_VISUALPROLOG_STRING_VERBATIM_EOL 22 +#define SCE_VISUALPROLOG_UNUSED4 19 +#define SCE_VISUALPROLOG_STRING 20 +#define SCE_VISUALPROLOG_UNUSED5 21 +#define SCE_VISUALPROLOG_STRING_EOL 22 +#define SCE_VISUALPROLOG_EMBEDDED 23 +#define SCE_VISUALPROLOG_PLACEHOLDER 24 #define SCE_STTXT_DEFAULT 0 #define SCE_STTXT_COMMENT 1 #define SCE_STTXT_COMMENTLINE 2 @@ -2036,6 +1962,321 @@ #define SCE_DF_SCOPEWORD 12 #define SCE_DF_OPERATOR 13 #define SCE_DF_ICODE 14 +#define SCE_HOLLYWOOD_DEFAULT 0 +#define SCE_HOLLYWOOD_COMMENT 1 +#define SCE_HOLLYWOOD_COMMENTBLOCK 2 +#define SCE_HOLLYWOOD_NUMBER 3 +#define SCE_HOLLYWOOD_KEYWORD 4 +#define SCE_HOLLYWOOD_STDAPI 5 +#define SCE_HOLLYWOOD_PLUGINAPI 6 +#define SCE_HOLLYWOOD_PLUGINMETHOD 7 +#define SCE_HOLLYWOOD_STRING 8 +#define SCE_HOLLYWOOD_STRINGBLOCK 9 +#define SCE_HOLLYWOOD_PREPROCESSOR 10 +#define SCE_HOLLYWOOD_OPERATOR 11 +#define SCE_HOLLYWOOD_IDENTIFIER 12 +#define SCE_HOLLYWOOD_CONSTANT 13 +#define SCE_HOLLYWOOD_HEXNUMBER 14 +#define SCE_RAKU_DEFAULT 0 +#define SCE_RAKU_ERROR 1 +#define SCE_RAKU_COMMENTLINE 2 +#define SCE_RAKU_COMMENTEMBED 3 +#define SCE_RAKU_POD 4 +#define SCE_RAKU_CHARACTER 5 +#define SCE_RAKU_HEREDOC_Q 6 +#define SCE_RAKU_HEREDOC_QQ 7 +#define SCE_RAKU_STRING 8 +#define SCE_RAKU_STRING_Q 9 +#define SCE_RAKU_STRING_QQ 10 +#define SCE_RAKU_STRING_Q_LANG 11 +#define SCE_RAKU_STRING_VAR 12 +#define SCE_RAKU_REGEX 13 +#define SCE_RAKU_REGEX_VAR 14 +#define SCE_RAKU_ADVERB 15 +#define SCE_RAKU_NUMBER 16 +#define SCE_RAKU_PREPROCESSOR 17 +#define SCE_RAKU_OPERATOR 18 +#define SCE_RAKU_WORD 19 +#define SCE_RAKU_FUNCTION 20 +#define SCE_RAKU_IDENTIFIER 21 +#define SCE_RAKU_TYPEDEF 22 +#define SCE_RAKU_MU 23 +#define SCE_RAKU_POSITIONAL 24 +#define SCE_RAKU_ASSOCIATIVE 25 +#define SCE_RAKU_CALLABLE 26 +#define SCE_RAKU_GRAMMAR 27 +#define SCE_RAKU_CLASS 28 +#define SCE_FSHARP_DEFAULT 0 +#define SCE_FSHARP_KEYWORD 1 +#define SCE_FSHARP_KEYWORD2 2 +#define SCE_FSHARP_KEYWORD3 3 +#define SCE_FSHARP_KEYWORD4 4 +#define SCE_FSHARP_KEYWORD5 5 +#define SCE_FSHARP_IDENTIFIER 6 +#define SCE_FSHARP_QUOT_IDENTIFIER 7 +#define SCE_FSHARP_COMMENT 8 +#define SCE_FSHARP_COMMENTLINE 9 +#define SCE_FSHARP_PREPROCESSOR 10 +#define SCE_FSHARP_LINENUM 11 +#define SCE_FSHARP_OPERATOR 12 +#define SCE_FSHARP_NUMBER 13 +#define SCE_FSHARP_CHARACTER 14 +#define SCE_FSHARP_STRING 15 +#define SCE_FSHARP_VERBATIM 16 +#define SCE_FSHARP_QUOTATION 17 +#define SCE_FSHARP_ATTRIBUTE 18 +#define SCE_FSHARP_FORMAT_SPEC 19 +#define SCE_ASCIIDOC_DEFAULT 0 +#define SCE_ASCIIDOC_STRONG1 1 +#define SCE_ASCIIDOC_STRONG2 2 +#define SCE_ASCIIDOC_EM1 3 +#define SCE_ASCIIDOC_EM2 4 +#define SCE_ASCIIDOC_HEADER1 5 +#define SCE_ASCIIDOC_HEADER2 6 +#define SCE_ASCIIDOC_HEADER3 7 +#define SCE_ASCIIDOC_HEADER4 8 +#define SCE_ASCIIDOC_HEADER5 9 +#define SCE_ASCIIDOC_HEADER6 10 +#define SCE_ASCIIDOC_ULIST_ITEM 11 +#define SCE_ASCIIDOC_OLIST_ITEM 12 +#define SCE_ASCIIDOC_BLOCKQUOTE 13 +#define SCE_ASCIIDOC_LINK 14 +#define SCE_ASCIIDOC_CODEBK 15 +#define SCE_ASCIIDOC_PASSBK 16 +#define SCE_ASCIIDOC_COMMENT 17 +#define SCE_ASCIIDOC_COMMENTBK 18 +#define SCE_ASCIIDOC_LITERAL 19 +#define SCE_ASCIIDOC_LITERALBK 20 +#define SCE_ASCIIDOC_ATTRIB 21 +#define SCE_ASCIIDOC_ATTRIBVAL 22 +#define SCE_ASCIIDOC_MACRO 23 +#define SCE_GD_DEFAULT 0 +#define SCE_GD_COMMENTLINE 1 +#define SCE_GD_NUMBER 2 +#define SCE_GD_STRING 3 +#define SCE_GD_CHARACTER 4 +#define SCE_GD_WORD 5 +#define SCE_GD_TRIPLE 6 +#define SCE_GD_TRIPLEDOUBLE 7 +#define SCE_GD_CLASSNAME 8 +#define SCE_GD_FUNCNAME 9 +#define SCE_GD_OPERATOR 10 +#define SCE_GD_IDENTIFIER 11 +#define SCE_GD_COMMENTBLOCK 12 +#define SCE_GD_STRINGEOL 13 +#define SCE_GD_WORD2 14 +#define SCE_GD_ANNOTATION 15 +#define SCE_GD_NODEPATH 16 +#define SCE_TOML_DEFAULT 0 +#define SCE_TOML_COMMENT 1 +#define SCE_TOML_IDENTIFIER 2 +#define SCE_TOML_KEYWORD 3 +#define SCE_TOML_NUMBER 4 +#define SCE_TOML_TABLE 5 +#define SCE_TOML_KEY 6 +#define SCE_TOML_ERROR 7 +#define SCE_TOML_OPERATOR 8 +#define SCE_TOML_STRING_SQ 9 +#define SCE_TOML_STRING_DQ 10 +#define SCE_TOML_TRIPLE_STRING_SQ 11 +#define SCE_TOML_TRIPLE_STRING_DQ 12 +#define SCE_TOML_ESCAPECHAR 13 +#define SCE_TOML_DATETIME 14 +#define SCE_TROFF_DEFAULT 0 +#define SCE_TROFF_REQUEST 1 +#define SCE_TROFF_COMMAND 2 +#define SCE_TROFF_NUMBER 3 +#define SCE_TROFF_OPERATOR 4 +#define SCE_TROFF_STRING 5 +#define SCE_TROFF_COMMENT 6 +#define SCE_TROFF_IGNORE 7 +#define SCE_TROFF_ESCAPE_STRING 8 +#define SCE_TROFF_ESCAPE_MACRO 9 +#define SCE_TROFF_ESCAPE_FONT 10 +#define SCE_TROFF_ESCAPE_NUMBER 11 +#define SCE_TROFF_ESCAPE_COLOUR 12 +#define SCE_TROFF_ESCAPE_GLYPH 13 +#define SCE_TROFF_ESCAPE_ENV 14 +#define SCE_TROFF_ESCAPE_SUPPRESSION 15 +#define SCE_TROFF_ESCAPE_SIZE 16 +#define SCE_TROFF_ESCAPE_TRANSPARENT 17 +#define SCE_TROFF_ESCAPE_ISVALID 18 +#define SCE_TROFF_ESCAPE_DRAW 19 +#define SCE_TROFF_ESCAPE_MOVE 20 +#define SCE_TROFF_ESCAPE_HEIGHT 21 +#define SCE_TROFF_ESCAPE_OVERSTRIKE 22 +#define SCE_TROFF_ESCAPE_SLANT 23 +#define SCE_TROFF_ESCAPE_WIDTH 24 +#define SCE_TROFF_ESCAPE_VSPACING 25 +#define SCE_TROFF_ESCAPE_DEVICE 26 +#define SCE_TROFF_ESCAPE_NOMOVE 27 +#define SCE_DART_DEFAULT 0 +#define SCE_DART_COMMENTLINE 1 +#define SCE_DART_COMMENTLINEDOC 2 +#define SCE_DART_COMMENTBLOCK 3 +#define SCE_DART_COMMENTBLOCKDOC 4 +#define SCE_DART_STRING_SQ 5 +#define SCE_DART_STRING_DQ 6 +#define SCE_DART_TRIPLE_STRING_SQ 7 +#define SCE_DART_TRIPLE_STRING_DQ 8 +#define SCE_DART_RAWSTRING_SQ 9 +#define SCE_DART_RAWSTRING_DQ 10 +#define SCE_DART_TRIPLE_RAWSTRING_SQ 11 +#define SCE_DART_TRIPLE_RAWSTRING_DQ 12 +#define SCE_DART_ESCAPECHAR 13 +#define SCE_DART_IDENTIFIER 14 +#define SCE_DART_IDENTIFIER_STRING 15 +#define SCE_DART_OPERATOR 16 +#define SCE_DART_OPERATOR_STRING 17 +#define SCE_DART_SYMBOL_IDENTIFIER 18 +#define SCE_DART_SYMBOL_OPERATOR 19 +#define SCE_DART_NUMBER 20 +#define SCE_DART_KEY 21 +#define SCE_DART_METADATA 22 +#define SCE_DART_KW_PRIMARY 23 +#define SCE_DART_KW_SECONDARY 24 +#define SCE_DART_KW_TERTIARY 25 +#define SCE_DART_KW_TYPE 26 +#define SCE_ZIG_DEFAULT 0 +#define SCE_ZIG_COMMENTLINE 1 +#define SCE_ZIG_COMMENTLINEDOC 2 +#define SCE_ZIG_COMMENTLINETOP 3 +#define SCE_ZIG_NUMBER 4 +#define SCE_ZIG_OPERATOR 5 +#define SCE_ZIG_CHARACTER 6 +#define SCE_ZIG_STRING 7 +#define SCE_ZIG_MULTISTRING 8 +#define SCE_ZIG_ESCAPECHAR 9 +#define SCE_ZIG_IDENTIFIER 10 +#define SCE_ZIG_FUNCTION 11 +#define SCE_ZIG_BUILTIN_FUNCTION 12 +#define SCE_ZIG_KW_PRIMARY 13 +#define SCE_ZIG_KW_SECONDARY 14 +#define SCE_ZIG_KW_TERTIARY 15 +#define SCE_ZIG_KW_TYPE 16 /* --Autogenerated -- end of section automatically generated from Scintilla.iface */ + + + +//For All lexer +#define SCE_UNIVERSAL_FOUND_STYLE 31 +#define SCE_UNIVERSAL_FOUND_STYLE_SMART 29 +#define SCE_UNIVERSAL_FOUND_STYLE_INC 28 +#define SCE_UNIVERSAL_TAGMATCH 27 +#define SCE_UNIVERSAL_TAGATTR 26 +#define SCE_UNIVERSAL_FOUND_STYLE_EXT1 25 +#define SCE_UNIVERSAL_FOUND_STYLE_EXT2 24 +#define SCE_UNIVERSAL_FOUND_STYLE_EXT3 23 +#define SCE_UNIVERSAL_FOUND_STYLE_EXT4 22 +#define SCE_UNIVERSAL_FOUND_STYLE_EXT5 21 + +#define SCE_UDL_VERSION_MAJOR 2 +#define SCE_UDL_VERSION_MINOR 1 +#define SCE_UDL_VERSION_BUILD 0 +#define SCE_UDL_VERSION_REVISION 12 + +#define SCE_USER_KWLIST_COMMENTS 0 +#define SCE_USER_KWLIST_NUMBER_PREFIX1 1 +#define SCE_USER_KWLIST_NUMBER_PREFIX2 2 +#define SCE_USER_KWLIST_NUMBER_EXTRAS1 3 +#define SCE_USER_KWLIST_NUMBER_EXTRAS2 4 +#define SCE_USER_KWLIST_NUMBER_SUFFIX1 5 +#define SCE_USER_KWLIST_NUMBER_SUFFIX2 6 +#define SCE_USER_KWLIST_NUMBER_RANGE 7 +#define SCE_USER_KWLIST_OPERATORS1 8 +#define SCE_USER_KWLIST_OPERATORS2 9 +#define SCE_USER_KWLIST_FOLDERS_IN_CODE1_OPEN 10 +#define SCE_USER_KWLIST_FOLDERS_IN_CODE1_MIDDLE 11 +#define SCE_USER_KWLIST_FOLDERS_IN_CODE1_CLOSE 12 +#define SCE_USER_KWLIST_FOLDERS_IN_CODE2_OPEN 13 +#define SCE_USER_KWLIST_FOLDERS_IN_CODE2_MIDDLE 14 +#define SCE_USER_KWLIST_FOLDERS_IN_CODE2_CLOSE 15 +#define SCE_USER_KWLIST_FOLDERS_IN_COMMENT_OPEN 16 +#define SCE_USER_KWLIST_FOLDERS_IN_COMMENT_MIDDLE 17 +#define SCE_USER_KWLIST_FOLDERS_IN_COMMENT_CLOSE 18 +#define SCE_USER_KWLIST_KEYWORDS1 19 +#define SCE_USER_KWLIST_KEYWORDS2 20 +#define SCE_USER_KWLIST_KEYWORDS3 21 +#define SCE_USER_KWLIST_KEYWORDS4 22 +#define SCE_USER_KWLIST_KEYWORDS5 23 +#define SCE_USER_KWLIST_KEYWORDS6 24 +#define SCE_USER_KWLIST_KEYWORDS7 25 +#define SCE_USER_KWLIST_KEYWORDS8 26 +#define SCE_USER_KWLIST_DELIMITERS 27 +#define SCE_USER_KWLIST_TOTAL 28 // must always be <= KEYWORDSET_MAX + +#define SCE_USER_TOTAL_DELIMITERS 8 +#define SCE_USER_TOTAL_KEYWORD_GROUPS 8 +#define SCE_USER_TOTAL_FOLDERS 6 + +#define SCE_USER_STYLE_DEFAULT 0 +#define SCE_USER_STYLE_COMMENT 1 +#define SCE_USER_STYLE_COMMENTLINE 2 +#define SCE_USER_STYLE_NUMBER 3 +#define SCE_USER_STYLE_KEYWORD1 4 +#define SCE_USER_STYLE_KEYWORD2 5 +#define SCE_USER_STYLE_KEYWORD3 6 +#define SCE_USER_STYLE_KEYWORD4 7 +#define SCE_USER_STYLE_KEYWORD5 8 +#define SCE_USER_STYLE_KEYWORD6 9 +#define SCE_USER_STYLE_KEYWORD7 10 +#define SCE_USER_STYLE_KEYWORD8 11 +#define SCE_USER_STYLE_OPERATOR 12 +#define SCE_USER_STYLE_FOLDER_IN_CODE1 13 +#define SCE_USER_STYLE_FOLDER_IN_CODE2 14 +#define SCE_USER_STYLE_FOLDER_IN_COMMENT 15 +#define SCE_USER_STYLE_DELIMITER1 16 +#define SCE_USER_STYLE_DELIMITER2 17 +#define SCE_USER_STYLE_DELIMITER3 18 +#define SCE_USER_STYLE_DELIMITER4 19 +#define SCE_USER_STYLE_DELIMITER5 20 +#define SCE_USER_STYLE_DELIMITER6 21 +#define SCE_USER_STYLE_DELIMITER7 22 +#define SCE_USER_STYLE_DELIMITER8 23 +#define SCE_USER_STYLE_IDENTIFIER 24 +#define SCE_USER_STYLE_TOTAL_STYLES SCE_USER_STYLE_IDENTIFIER +#define SCE_USER_STYLE_MAPPER_TOTAL 17 + +#define SCE_USER_MASK_NESTING_NONE 0 +#define SCE_USER_MASK_NESTING_DELIMITER1 0x1 +#define SCE_USER_MASK_NESTING_DELIMITER2 0x2 +#define SCE_USER_MASK_NESTING_DELIMITER3 0x4 +#define SCE_USER_MASK_NESTING_DELIMITER4 0x8 +#define SCE_USER_MASK_NESTING_DELIMITER5 0x10 +#define SCE_USER_MASK_NESTING_DELIMITER6 0x20 +#define SCE_USER_MASK_NESTING_DELIMITER7 0x40 +#define SCE_USER_MASK_NESTING_DELIMITER8 0x80 +#define SCE_USER_MASK_NESTING_COMMENT 0x100 +#define SCE_USER_MASK_NESTING_COMMENT_LINE 0x200 +#define SCE_USER_MASK_NESTING_KEYWORD1 0x400 +#define SCE_USER_MASK_NESTING_KEYWORD2 0x800 +#define SCE_USER_MASK_NESTING_KEYWORD3 0x1000 +#define SCE_USER_MASK_NESTING_KEYWORD4 0x2000 +#define SCE_USER_MASK_NESTING_KEYWORD5 0x4000 +#define SCE_USER_MASK_NESTING_KEYWORD6 0x8000 +#define SCE_USER_MASK_NESTING_KEYWORD7 0x10000 +#define SCE_USER_MASK_NESTING_KEYWORD8 0x20000 +#define SCE_USER_MASK_NESTING_FOLDERS_IN_CODE2_OPEN 0x40000 +#define SCE_USER_MASK_NESTING_FOLDERS_IN_CODE2_MIDDLE 0x80000 +#define SCE_USER_MASK_NESTING_FOLDERS_IN_CODE2_CLOSE 0x100000 +#define SCE_USER_MASK_NESTING_FOLDERS_IN_COMMENT_OPEN 0x200000 +#define SCE_USER_MASK_NESTING_FOLDERS_IN_COMMENT_MIDDLE 0x400000 +#define SCE_USER_MASK_NESTING_FOLDERS_IN_COMMENT_CLOSE 0x800000 +#define SCE_USER_MASK_NESTING_OPERATORS1 0x1000000 +#define SCE_USER_MASK_NESTING_OPERATORS2 0x2000000 +#define SCE_USER_MASK_NESTING_NUMBERS 0x4000000 + + +#define SCE_SEARCHRESULT_DEFAULT 0 +#define SCE_SEARCHRESULT_SEARCH_HEADER 1 +#define SCE_SEARCHRESULT_FILE_HEADER 2 +#define SCE_SEARCHRESULT_LINE_NUMBER 3 +#define SCE_SEARCHRESULT_WORD2SEARCH 4 +//#define SCE_SEARCHRESULT_HIGHLIGHT_LINE 5 // (no use anymore) +#define SCE_SEARCHRESULT_CURRENT_LINE 6 +#define SCE_OBJC_DIRECTIVE 20 +#define SCE_OBJC_QUALIFIER 21 + + #endif diff --git a/NppPlugin/include/Sci_Position.h b/NppPlugin/include/Sci_Position.h index abd0f340..88ad5132 100644 --- a/NppPlugin/include/Sci_Position.h +++ b/NppPlugin/include/Sci_Position.h @@ -18,7 +18,7 @@ typedef ptrdiff_t Sci_Position; typedef size_t Sci_PositionU; // For Sci_CharacterRange which is defined as long to be compatible with Win32 CHARRANGE -typedef long Sci_PositionCR; +typedef intptr_t Sci_PositionCR; #ifdef _WIN32 #define SCI_METHOD __stdcall diff --git a/NppPlugin/include/Scintilla.h b/NppPlugin/include/Scintilla.h index a292dc37..50467ef7 100644 --- a/NppPlugin/include/Scintilla.h +++ b/NppPlugin/include/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,9 @@ 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 /* ++Autogenerated -- start of section automatically generated from Scintilla.iface */ #define INVALID_POSITION -1 @@ -55,14 +57,18 @@ 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 +#define SCI_MARKERHANDLEFROMLINE 2732 +#define SCI_MARKERNUMBERFROMLINE 2733 #define SCI_GETUNDOCOLLECTION 2019 #define SCWS_INVISIBLE 0 #define SCWS_VISIBLEALWAYS 1 @@ -93,15 +99,26 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_SETBUFFEREDDRAW 2035 #define SCI_SETTABWIDTH 2036 #define SCI_GETTABWIDTH 2121 +#define SCI_SETTABMINIMUMWIDTH 2724 +#define SCI_GETTABMINIMUMWIDTH 2725 #define SCI_CLEARTABSTOPS 2675 #define SCI_ADDTABSTOP 2676 #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 #define SCI_SETIMEINTERACTION 2679 +#define SC_ALPHA_TRANSPARENT 0 +#define SC_ALPHA_OPAQUE 255 +#define SC_ALPHA_NOALPHA 256 +#define SC_CURSORNORMAL -1 +#define SC_CURSORARROW 2 +#define SC_CURSORWAIT 4 +#define SC_CURSORREVERSEARROW 7 #define MARKER_MAX 31 #define SC_MARK_CIRCLE 0 #define SC_MARK_ROUNDRECT 1 @@ -136,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 @@ -144,11 +166,16 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SC_MARKNUM_FOLDERSUB 29 #define SC_MARKNUM_FOLDER 30 #define SC_MARKNUM_FOLDEROPEN 31 +#define SC_MASK_HISTORY 0x01E00000 #define SC_MASK_FOLDERS 0xFE000000 #define SCI_MARKERDEFINE 2040 #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 @@ -159,6 +186,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 @@ -251,12 +280,65 @@ 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 SC_STRETCH_ULTRA_CONDENSED 1 +#define SC_STRETCH_EXTRA_CONDENSED 2 +#define SC_STRETCH_CONDENSED 3 +#define SC_STRETCH_SEMI_CONDENSED 4 +#define SC_STRETCH_NORMAL 5 +#define SC_STRETCH_SEMI_EXPANDED 6 +#define SC_STRETCH_EXPANDED 7 +#define SC_STRETCH_EXTRA_EXPANDED 8 +#define SC_STRETCH_ULTRA_EXPANDED 9 +#define SCI_STYLESETSTRETCH 2258 +#define SCI_STYLEGETSTRETCH 2259 +#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_SELECTION_INACTIVE_ADDITIONAL_TEXT 18 +#define SC_ELEMENT_SELECTION_INACTIVE_ADDITIONAL_BACK 19 +#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 @@ -271,6 +353,21 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_GETCHARACTERCATEGORYOPTIMIZATION 2721 #define SCI_BEGINUNDOACTION 2078 #define SCI_ENDUNDOACTION 2079 +#define SCI_GETUNDOSEQUENCE 2799 +#define SCI_GETUNDOACTIONS 2790 +#define SCI_SETUNDOSAVEPOINT 2791 +#define SCI_GETUNDOSAVEPOINT 2792 +#define SCI_SETUNDODETACH 2793 +#define SCI_GETUNDODETACH 2794 +#define SCI_SETUNDOTENTATIVE 2795 +#define SCI_GETUNDOTENTATIVE 2796 +#define SCI_SETUNDOCURRENT 2797 +#define SCI_GETUNDOCURRENT 2798 +#define SCI_PUSHUNDOACTIONTYPE 2800 +#define SCI_CHANGELASTUNDOACTIONTEXT 2801 +#define SCI_GETUNDOACTIONTYPE 2802 +#define SCI_GETUNDOACTIONPOSITION 2803 +#define SCI_GETUNDOACTIONTEXT 2804 #define INDIC_PLAIN 0 #define INDIC_SQUIGGLE 1 #define INDIC_TT 2 @@ -293,6 +390,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_POINT_TOP 22 +#define INDIC_EXPLORERLINK 23 #define INDIC_CONTAINER 8 #define INDIC_IME 32 #define INDIC_IME_MAX 35 @@ -300,7 +399,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 @@ -313,9 +420,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 @@ -349,6 +459,11 @@ 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 SC_AUTOCOMPLETE_SELECT_FIRST_ITEM 2 +#define SCI_AUTOCSETOPTIONS 2638 +#define SCI_AUTOCGETOPTIONS 2639 #define SCI_AUTOCSETDROPRESTOFWORD 2270 #define SCI_AUTOCGETDROPRESTOFWORD 2271 #define SCI_REGISTERIMAGE 2405 @@ -359,6 +474,8 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_AUTOCGETMAXWIDTH 2209 #define SCI_AUTOCSETMAXHEIGHT 2210 #define SCI_AUTOCGETMAXHEIGHT 2211 +#define SCI_AUTOCSETSTYLE 2109 +#define SCI_AUTOCGETSTYLE 2120 #define SCI_SETINDENT 2122 #define SCI_GETINDENT 2123 #define SCI_SETUSETABS 2124 @@ -407,10 +524,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 @@ -419,7 +545,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 @@ -442,6 +570,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 @@ -449,14 +578,19 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_GETCARETWIDTH 2189 #define SCI_SETTARGETSTART 2190 #define SCI_GETTARGETSTART 2191 +#define SCI_SETTARGETSTARTVIRTUALSPACE 2728 +#define SCI_GETTARGETSTARTVIRTUALSPACE 2729 #define SCI_SETTARGETEND 2192 #define SCI_GETTARGETEND 2193 +#define SCI_SETTARGETENDVIRTUALSPACE 2730 +#define SCI_GETTARGETENDVIRTUALSPACE 2731 #define SCI_SETTARGETRANGE 2686 #define SCI_GETTARGETTEXT 2687 #define SCI_TARGETFROMSELECTION 2287 #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 @@ -474,6 +608,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 @@ -500,16 +635,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 @@ -630,7 +768,9 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_CANCEL 2325 #define SCI_DELETEBACK 2326 #define SCI_TAB 2327 +#define SCI_LINEINDENT 2813 #define SCI_BACKTAB 2328 +#define SCI_LINEDEDENT 2814 #define SCI_NEWLINE 2329 #define SCI_FORMFEED 2330 #define SCI_VCHOME 2331 @@ -668,6 +808,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_BRACEBADLIGHT 2352 #define SCI_BRACEBADLIGHTINDICATOR 2499 #define SCI_BRACEMATCH 2353 +#define SCI_BRACEMATCHNEXT 2369 #define SCI_GETVIEWEOL 2355 #define SCI_SETVIEWEOL 2356 #define SCI_GETDOCPOINTER 2357 @@ -685,6 +826,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_SETEDGECOLOUR 2365 #define SCI_MULTIEDGEADDLINE 2694 #define SCI_MULTIEDGECLEARALL 2695 +#define SCI_GETMULTIEDGECOLUMN 2749 #define SCI_SEARCHANCHOR 2366 #define SCI_SEARCHNEXT 2367 #define SCI_SEARCHPREV 2368 @@ -719,10 +861,6 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_GETMOUSEDOWNCAPTURES 2385 #define SCI_SETMOUSEWHEELCAPTURES 2696 #define SCI_GETMOUSEWHEELCAPTURES 2697 -#define SC_CURSORNORMAL -1 -#define SC_CURSORARROW 2 -#define SC_CURSORWAIT 4 -#define SC_CURSORREVERSEARROW 7 #define SCI_SETCURSOR 2386 #define SCI_GETCURSOR 2387 #define SCI_SETCONTROLCHARSYMBOL 2388 @@ -771,7 +909,9 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SC_SEL_LINES 2 #define SC_SEL_THIN 3 #define SCI_SETSELECTIONMODE 2422 +#define SCI_CHANGESELECTIONMODE 2659 #define SCI_GETSELECTIONMODE 2423 +#define SCI_SETMOVEEXTENDSSELECTION 2719 #define SCI_GETMOVEEXTENDSSELECTION 2706 #define SCI_GETLINESELSTARTPOSITION 2424 #define SCI_GETLINESELENDPOSITION 2425 @@ -817,18 +957,16 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_SETLENGTHFORENCODE 2448 #define SCI_ENCODEDFROMUTF8 2449 #define SCI_FINDCOLUMN 2456 -#define SCI_GETCARETSTICKY 2457 -#define SCI_SETCARETSTICKY 2458 #define SC_CARETSTICKY_OFF 0 #define SC_CARETSTICKY_ON 1 #define SC_CARETSTICKY_WHITESPACE 2 +#define SCI_GETCARETSTICKY 2457 +#define SCI_SETCARETSTICKY 2458 #define SCI_TOGGLECARETSTICKY 2459 #define SCI_SETPASTECONVERTENDINGS 2467 #define SCI_GETPASTECONVERTENDINGS 2468 +#define SCI_REPLACERECTANGULAR 2771 #define SCI_SELECTIONDUPLICATE 2469 -#define SC_ALPHA_TRANSPARENT 0 -#define SC_ALPHA_OPAQUE 255 -#define SC_ALPHA_NOALPHA 256 #define SCI_SETCARETLINEBACKALPHA 2470 #define SCI_GETCARETLINEBACKALPHA 2471 #define CARETSTYLE_INVISIBLE 0 @@ -836,6 +974,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 @@ -852,7 +991,12 @@ 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_CUTALLOWLINE 2810 +#define SCI_SETCOPYSEPARATOR 2811 +#define SCI_GETCOPYSEPARATOR 2812 #define SCI_GETCHARACTERPOINTER 2520 #define SCI_GETRANGEPOINTER 2643 #define SCI_GETGAPPOSITION 2644 @@ -916,6 +1060,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_CLEARSELECTIONS 2571 #define SCI_SETSELECTION 2572 #define SCI_ADDSELECTION 2573 +#define SCI_SELECTIONFROMPOINT 2474 #define SCI_DROPSELECTIONN 2671 #define SCI_SETMAINSELECTION 2574 #define SCI_GETMAINSELECTION 2575 @@ -929,7 +1074,9 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_GETSELECTIONNANCHORVIRTUALSPACE 2583 #define SCI_SETSELECTIONNSTART 2584 #define SCI_GETSELECTIONNSTART 2585 +#define SCI_GETSELECTIONNSTARTVIRTUALSPACE 2726 #define SCI_SETSELECTIONNEND 2586 +#define SCI_GETSELECTIONNENDVIRTUALSPACE 2727 #define SCI_GETSELECTIONNEND 2587 #define SCI_SETRECTANGULARSELECTIONCARET 2588 #define SCI_GETRECTANGULARSELECTIONCARET 2589 @@ -993,17 +1140,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 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 @@ -1030,6 +1217,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_NAMEOFSTYLE 4030 #define SCI_TAGSOFSTYLE 4031 #define SCI_DESCRIPTIONOFSTYLE 4032 +#define SCI_SETILEXER 4033 #define SC_MOD_NONE 0x0 #define SC_MOD_INSERTTEXT 0x1 #define SC_MOD_DELETETEXT 0x2 @@ -1053,8 +1241,9 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SC_MOD_LEXERSTATE 0x80000 #define SC_MOD_INSERTCHECK 0x100000 #define SC_MOD_CHANGETABSTOPS 0x200000 -#define SC_MODEVENTMASKALL 0x3FFFFF -#define SC_SEARCHRESULT_LINEBUFFERMAXLENGTH 1024 +#define SC_MOD_CHANGEEOLANNOTATION 0x400000 +#define SC_MODEVENTMASKALL 0x7FFFFF +#define SC_UPDATE_NONE 0x0 #define SC_UPDATE_CONTENT 0x1 #define SC_UPDATE_SELECTION 0x2 #define SC_UPDATE_V_SCROLL 0x4 @@ -1093,6 +1282,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 @@ -1134,21 +1324,15 @@ 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 SCN_SCROLLED 2080 +#define SC_SEARCHRESULT_LINEBUFFERMAXLENGTH 2048 +#define SCI_GETBOOSTREGEXERRMSG 5000 #define SCN_FOLDINGSTATECHANGED 2081 - /* --Autogenerated -- end of section automatically generated from Scintilla.iface */ +#endif + /* These structures are defined to be exactly the same shape as the Win32 * CHARRANGE, TEXTRANGE, FINDTEXTEX, FORMATRANGE, and NMHDR structs. * So older code that treats Scintilla as a RichEdit will work. */ @@ -1158,17 +1342,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 { @@ -1189,6 +1389,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 */ @@ -1245,16 +1453,15 @@ struct SCNotification { int characterSource; /* SCN_CHARADDED */ }; -struct SearchResultMarking { - long _start; - long _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 { - long _length; - SearchResultMarking *_markings; + intptr_t _length; + SearchResultMarkingLine *_markings; }; - #ifdef INCLUDE_DEPRECATED_FEATURES #define SCI_SETKEYSUNICODE 2521 diff --git a/NppPlugin/include/StaticDialog.h b/NppPlugin/include/StaticDialog.h index 7e912f0b..b475bdbb 100644 --- a/NppPlugin/include/StaticDialog.h +++ b/NppPlugin/include/StaticDialog.h @@ -1,30 +1,21 @@ // This file is part of Notepad++ project -// Copyright (C)2003 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 the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// Note that the GPL places important restrictions on "derived works", yet -// it does not provide a detailed definition of that term. To avoid -// misunderstandings, we consider an application to constitute a -// "derivative work" for the purpose of this license if it does any of the -// following: -// 1. Integrates source code from Notepad++. -// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable -// installer, such as those produced by InstallShield. -// 3. Links to a library or executes a program that does any of the above. +// Copyright (C)2024 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 +// the Free Software Foundation, either version 3 of the License, or +// at your option any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +// along with this program. If not, see . + #pragma once +#include "dpiManagerV2.h" #include "Notepad_plus_msgs.h" #include "Window.h" @@ -34,16 +25,16 @@ enum class PosAlign { left, right, top, bottom }; struct DLGTEMPLATEEX { - WORD dlgVer; - WORD signature; - DWORD helpID; - DWORD exStyle; - DWORD style; - WORD cDlgItems; - short x; - short y; - short cx; - short cy; + WORD dlgVer = 0; + WORD signature = 0; + DWORD helpID = 0; + DWORD exStyle = 0; + DWORD style = 0; + WORD cDlgItems = 0; + short x = 0; + short y = 0; + short cx = 0; + short cy = 0; // The structure has more fields but are variable length }; @@ -54,13 +45,20 @@ 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 display(bool toShow = true) const; + void goToCenter(UINT swpFlags = SWP_SHOWWINDOW); + bool moveForDpiChange(); + + void display(bool toShow = true, bool enhancedPositioningCheckWhenShowing = false) const; + + RECT getViewablePositionRect(RECT testRc) const; POINT getTopPoint(HWND hwnd, bool isLeft = true) const; @@ -69,13 +67,29 @@ public : return (BST_CHECKED == ::SendMessage(::GetDlgItem(_hSelf, checkControlID), BM_GETCHECK, 0, 0)); } - virtual void destroy() override; + void setChecked(int checkControlID, bool checkOrNot = true) const + { + ::SendDlgItemMessage(_hSelf, checkControlID, BM_SETCHECK, checkOrNot ? BST_CHECKED : BST_UNCHECKED, 0); + } + + void setDpi() { + _dpiManager.setDpi(_hSelf); + } + + void setPositionDpi(LPARAM lParam, UINT flags = SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE) { + DPIManagerV2::setPositionDpi(lParam, _hSelf, flags); + } + + void destroy() override; + + DPIManagerV2& dpiManager() { return _dpiManager; } protected: - RECT _rc; - static INT_PTR CALLBACK dlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); - virtual INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) = 0; + RECT _rc{}; + DPIManagerV2 _dpiManager; + + 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; - void alignWith(HWND handle, HWND handle2Align, PosAlign pos, POINT & point); HGLOBAL makeRTLResource(int dialogID, DLGTEMPLATE **ppMyDlgTemplate); }; diff --git a/NppPlugin/include/SysMsg.h b/NppPlugin/include/SysMsg.h deleted file mode 100644 index d217c45b..00000000 --- a/NppPlugin/include/SysMsg.h +++ /dev/null @@ -1,27 +0,0 @@ -//this file is part of notepad++ -//Copyright (C)2003 Don HO ( donho@altern.org ) -// -//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 the Free Software Foundation; either -//version 2 of the License, or (at your option) any later version. -// -//This program is distributed in the hope that it will be useful, -//but WITHOUT ANY WARRANTY; without even the implied warranty of -//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//GNU General Public License for more details. -// -//You should have received a copy of the GNU General Public License -//along with this program; if not, write to the Free Software -//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -#ifndef M30_IDE_COMMUN_H -#define M30_IDE_COMMUN_H - -#include - - -void systemMessage(const char *title); -DWORD ShortToLongPathName(LPCTSTR lpszShortPath, LPTSTR lpszLongPath, DWORD cchBuffer); - -#endif //M30_IDE_COMMUN_H diff --git a/NppPlugin/include/Window.h b/NppPlugin/include/Window.h index e69e02f8..79a7fa34 100644 --- a/NppPlugin/include/Window.h +++ b/NppPlugin/include/Window.h @@ -1,29 +1,18 @@ // This file is part of Notepad++ project -// Copyright (C)2003 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 the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// Note that the GPL places important restrictions on "derived works", yet -// it does not provide a detailed definition of that term. To avoid -// misunderstandings, we consider an application to constitute a -// "derivative work" for the purpose of this license if it does any of the -// following: -// 1. Integrates source code from Notepad++. -// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable -// installer, such as those produced by InstallShield. -// 3. Links to a library or executes a program that does any of the above. +// Copyright (C)2024 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 +// the Free Software Foundation, either version 3 of the License, or +// at your option any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +// along with this program. If not, see . #pragma once @@ -40,61 +29,52 @@ class Window //@} - virtual void init(HINSTANCE hInst, HWND parent) - { + virtual void init(HINSTANCE hInst, HWND parent) { _hInst = hInst; _hParent = parent; } virtual void destroy() = 0; - virtual void display(bool toShow = true) const - { + virtual void display(bool toShow = true) const { ::ShowWindow(_hSelf, toShow ? SW_SHOW : SW_HIDE); } - virtual void reSizeTo(RECT & rc) // should NEVER be const !!! - { + virtual void reSizeTo(RECT & rc) { // should NEVER be const !!! ::MoveWindow(_hSelf, rc.left, rc.top, rc.right, rc.bottom, TRUE); redraw(); } - virtual void reSizeToWH(RECT& rc) // should NEVER be const !!! - { + virtual void reSizeToWH(RECT& rc) { // should NEVER be const !!! ::MoveWindow(_hSelf, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, TRUE); redraw(); } - virtual void redraw(bool forceUpdate = false) const - { + virtual void redraw(bool forceUpdate = false) const { ::InvalidateRect(_hSelf, nullptr, TRUE); if (forceUpdate) ::UpdateWindow(_hSelf); } - virtual void getClientRect(RECT & rc) const - { + virtual void getClientRect(RECT & rc) const { ::GetClientRect(_hSelf, &rc); } - virtual void getWindowRect(RECT & rc) const - { + virtual void getWindowRect(RECT & rc) const { ::GetWindowRect(_hSelf, &rc); } - virtual int getWidth() const - { + virtual int getWidth() const { RECT rc; ::GetClientRect(_hSelf, &rc); return (rc.right - rc.left); } - virtual int getHeight() const - { + virtual int getHeight() const { RECT rc; ::GetClientRect(_hSelf, &rc); if (::IsWindowVisible(_hSelf) == TRUE) @@ -107,8 +87,7 @@ class Window return (::IsWindowVisible(_hSelf)?true:false); } - HWND getHSelf() const - { + HWND getHSelf() const { return _hSelf; } @@ -116,13 +95,11 @@ class Window return _hParent; } - void getFocus() const { + void grabFocus() const { ::SetFocus(_hSelf); } - HINSTANCE getHinst() const - { - //assert(_hInst != 0); + HINSTANCE getHinst() const { return _hInst; } diff --git a/NppPlugin/include/dockingResource.h b/NppPlugin/include/dockingResource.h index 8b83f912..3c92767c 100644 --- a/NppPlugin/include/dockingResource.h +++ b/NppPlugin/include/dockingResource.h @@ -1,35 +1,23 @@ -// this file is part of docking functionality for Notepad++ +// This file is part of Notepad++ project // Copyright (C)2006 Jens Lorenz -// -// 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 the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// Note that the GPL places important restrictions on "derived works", yet -// it does not provide a detailed definition of that term. To avoid -// misunderstandings, we consider an application to constitute a -// "derivative work" for the purpose of this license if it does any of the -// following: -// 1. Integrates source code from Notepad++. -// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable -// installer, such as those produced by InstallShield. -// 3. Links to a library or executes a program that does any of the above. + +// 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 +// the Free Software Foundation, either version 3 of the License, or +// at your option any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// +// // You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +// along with this program. If not, see . -#ifndef DOCKING_RESOURCE_H -#define DOCKING_RESOURCE_H +#pragma once -#define DM_NOFOCUSWHILECLICKINGCAPTION TEXT("NOFOCUSWHILECLICKINGCAPTION") +#define DM_NOFOCUSWHILECLICKINGCAPTION L"NOFOCUSWHILECLICKINGCAPTION" #define IDD_PLUGIN_DLG 103 #define IDC_EDIT1 1000 @@ -51,8 +39,8 @@ #define DMM_FLOATALL (DMM_MSG + 5) #define DMM_MOVE (DMM_MSG + 6) #define DMM_UPDATEDISPINFO (DMM_MSG + 7) - #define DMM_GETIMAGELIST (DMM_MSG + 8) - #define DMM_GETICONPOS (DMM_MSG + 9) + //#define DMM_GETIMAGELIST (DMM_MSG + 8) + //#define DMM_GETICONPOS (DMM_MSG + 9) #define DMM_DROPDATA (DMM_MSG + 10) #define DMM_MOVE_SPLITTER (DMM_MSG + 11) #define DMM_CANCEL_MOVE (DMM_MSG + 12) @@ -77,5 +65,3 @@ //nmhdr.hwndFrom = DockingCont::_hself; //nmhdr.idFrom = 0; -#endif //DOCKING_RESOURCE_H - diff --git a/NppPlugin/include/dpiManagerV2.h b/NppPlugin/include/dpiManagerV2.h new file mode 100644 index 00000000..3b868299 --- /dev/null +++ b/NppPlugin/include/dpiManagerV2.h @@ -0,0 +1,150 @@ +// This file is part of Notepad++ project +// Copyright (c) 2024 ozone10 and Notepad++ team + +// 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 +// the Free Software Foundation, either version 3 of the License, or +// at your option any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + + +#pragma once +#include "NppDarkMode.h" + +#ifndef WM_DPICHANGED +#define WM_DPICHANGED 0x02E0 +#endif + +#ifndef WM_DPICHANGED_BEFOREPARENT +#define WM_DPICHANGED_BEFOREPARENT 0x02E2 +#endif + +#ifndef WM_DPICHANGED_AFTERPARENT +#define WM_DPICHANGED_AFTERPARENT 0x02E3 +#endif + +#ifndef WM_GETDPISCALEDSIZE +#define WM_GETDPISCALEDSIZE 0x02E4 +#endif + +#ifndef USER_DEFAULT_SCREEN_DPI +#define USER_DEFAULT_SCREEN_DPI 96 +#endif + +#ifndef DPI_AWARENESS_CONTEXT +#define DPI_AWARENESS_CONTEXT HANDLE +#endif + +class DPIManagerV2 +{ +public: + DPIManagerV2() { + setDpiWithSystem(); + } + virtual ~DPIManagerV2() = default; + + enum class FontType { menu, status, message, caption, smcaption }; + + static void initDpiAPI(); + + static int getSystemMetricsForDpi(int nIndex, UINT dpi); + int getSystemMetricsForDpi(int nIndex) const { + return getSystemMetricsForDpi(nIndex, _dpi); + } + static DPI_AWARENESS_CONTEXT setThreadDpiAwarenessContext(DPI_AWARENESS_CONTEXT dpiContext); + static BOOL adjustWindowRectExForDpi(LPRECT lpRect, DWORD dwStyle, BOOL bMenu, DWORD dwExStyle, UINT dpi); + + + static UINT getDpiForSystem(); + static UINT getDpiForWindow(HWND hWnd); + static UINT getDpiForParent(HWND hWnd) { + return getDpiForWindow(::GetParent(hWnd)); + } + + void setDpiWithSystem() { + _dpi = getDpiForSystem(); + } + + // parameter is WPARAM + void setDpiWP(WPARAM wParam) { + _dpi = LOWORD(wParam); + } + + void setDpi(UINT newDpi) { + _dpi = newDpi; + } + + void setDpi(HWND hWnd) { + setDpi(getDpiForWindow(hWnd)); + } + + void setDpiWithParent(HWND hWnd) { + setDpi(::GetParent(hWnd)); + } + + UINT getDpi() const { + return _dpi; + } + + static void setPositionDpi(LPARAM lParam, HWND hWnd, UINT flags = SWP_NOZORDER | SWP_NOACTIVATE); + + static int scale(int x, UINT toDpi, UINT fromDpi) { + return MulDiv(x, toDpi, fromDpi); + } + + static int scale(int x, UINT dpi) { + return scale(x, dpi, USER_DEFAULT_SCREEN_DPI); + } + + static int unscale(int x, UINT dpi) { + return scale(x, USER_DEFAULT_SCREEN_DPI, dpi); + } + + static int scale(int x, HWND hWnd) { + return scale(x, getDpiForWindow(hWnd), USER_DEFAULT_SCREEN_DPI); + } + + static int unscale(int x, HWND hWnd) { + return scale(x, USER_DEFAULT_SCREEN_DPI, getDpiForWindow(hWnd)); + } + + int scale(int x) const { + return scale(x, _dpi); + } + + int unscale(int x) const { + return unscale(x, _dpi); + } + + static int scaleFont(int pt, UINT dpi) { + return -(scale(pt, dpi, 72)); + } + + static int scaleFont(int pt, HWND hWnd) { + return -(scale(pt, getDpiForWindow(hWnd), 72)); + } + + int scaleFont(int pt) const { + return scaleFont(pt, _dpi); + } + + static LOGFONT getDefaultGUIFontForDpi(UINT dpi, FontType type = FontType::message); + static LOGFONT getDefaultGUIFontForDpi(HWND hWnd, FontType type = FontType::message) { + return getDefaultGUIFontForDpi(getDpiForWindow(hWnd), type); + } + LOGFONT getDefaultGUIFontForDpi(FontType type = FontType::message) const { + return getDefaultGUIFontForDpi(_dpi, type); + } + + static void loadIcon(HINSTANCE hinst, const wchar_t* pszName, int cx, int cy, HICON* phico, UINT fuLoad = LR_DEFAULTCOLOR); + +private: + UINT _dpi = USER_DEFAULT_SCREEN_DPI; +}; diff --git a/NppPlugin/include/keys.h b/NppPlugin/include/keys.h index 9fc3abd7..10f5517a 100644 --- a/NppPlugin/include/keys.h +++ b/NppPlugin/include/keys.h @@ -1,82 +1,28 @@ // This file is part of Notepad++ project -// Copyright (C)2003 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 the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// Note that the GPL places important restrictions on "derived works", yet -// it does not provide a detailed definition of that term. To avoid -// misunderstandings, we consider an application to constitute a -// "derivative work" for the purpose of this license if it does any of the -// following: -// 1. Integrates source code from Notepad++. -// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable -// installer, such as those produced by InstallShield. -// 3. Links to a library or executes a program that does any of the above. +// 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 +// the Free Software Foundation, either version 3 of the License, or +// at your option any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +// along with this program. If not, see . +#include /* See winuser.h -Altered list to support VK_0-9 and VK_A-Z +Altered list to support VK_0-9 and VK_A-Z, plus VK_NULL */ #define VK_NULL 0x00 -#define VK_CANCEL 0x03 - -#define VK_BACK 0x08 -#define VK_TAB 0x09 - -#define VK_CLEAR 0x0C -#define VK_RETURN 0x0D - -#define VK_SHIFT 0x10 -#define VK_CONTROL 0x11 -#define VK_MENU 0x12 -#define VK_PAUSE 0x13 -#define VK_CAPITAL 0x14 - -#define VK_KANA 0x15 -#define VK_HANGUL 0x15 -#define VK_JUNJA 0x17 -#define VK_FINAL 0x18 -#define VK_HANJA 0x19 -#define VK_KANJI 0x19 - -#define VK_ESCAPE 0x1B - -#define VK_CONVERT 0x1C -#define VK_NONCONVERT 0x1D -#define VK_ACCEPT 0x1E -#define VK_MODECHANGE 0x1F - -#define VK_SPACE 0x20 -#define VK_PRIOR 0x21 -#define VK_NEXT 0x22 -#define VK_END 0x23 -#define VK_HOME 0x24 -#define VK_LEFT 0x25 -#define VK_UP 0x26 -#define VK_RIGHT 0x27 -#define VK_DOWN 0x28 -#define VK_SELECT 0x29 -#define VK_PRINT 0x2A -#define VK_EXECUTE 0x2B -#define VK_SNAPSHOT 0x2C -#define VK_INSERT 0x2D -#define VK_DELETE 0x2E -#define VK_HELP 0x2F #define VK_0 0x30 #define VK_1 0x31 @@ -114,93 +60,3 @@ Altered list to support VK_0-9 and VK_A-Z #define VK_X 0x58 #define VK_Y 0x59 #define VK_Z 0x5A - -#define VK_LWIN 0x5B -#define VK_RWIN 0x5C -#define VK_APPS 0x5D - - -#define VK_SLEEP 0x5F - -#define VK_NUMPAD0 0x60 -#define VK_NUMPAD1 0x61 -#define VK_NUMPAD2 0x62 -#define VK_NUMPAD3 0x63 -#define VK_NUMPAD4 0x64 -#define VK_NUMPAD5 0x65 -#define VK_NUMPAD6 0x66 -#define VK_NUMPAD7 0x67 -#define VK_NUMPAD8 0x68 -#define VK_NUMPAD9 0x69 -#define VK_MULTIPLY 0x6A -#define VK_ADD 0x6B -#define VK_SEPARATOR 0x6C -#define VK_SUBTRACT 0x6D -#define VK_DECIMAL 0x6E -#define VK_DIVIDE 0x6F -#define VK_F1 0x70 -#define VK_F2 0x71 -#define VK_F3 0x72 -#define VK_F4 0x73 -#define VK_F5 0x74 -#define VK_F6 0x75 -#define VK_F7 0x76 -#define VK_F8 0x77 -#define VK_F9 0x78 -#define VK_F10 0x79 -#define VK_F11 0x7A -#define VK_F12 0x7B -#define VK_F13 0x7C -#define VK_F14 0x7D -#define VK_F15 0x7E -#define VK_F16 0x7F -#define VK_F17 0x80 -#define VK_F18 0x81 -#define VK_F19 0x82 -#define VK_F20 0x83 -#define VK_F21 0x84 -#define VK_F22 0x85 -#define VK_F23 0x86 -#define VK_F24 0x87 - -#define VK_NUMLOCK 0x90 -#define VK_SCROLL 0x91 - -#define VK_OEM_1 0xBA // ';:' for US -#define VK_OEM_PLUS 0xBB // '+' any country -#define VK_OEM_COMMA 0xBC // ',' any country -#define VK_OEM_MINUS 0xBD // '-' any country -#define VK_OEM_PERIOD 0xBE // '.' any country -#define VK_OEM_2 0xBF // '/?' for US -#define VK_OEM_3 0xC0 // '`~' for US - -#define VK_OEM_4 0xDB // '[{' for US -#define VK_OEM_5 0xDC // '\|' for US -#define VK_OEM_6 0xDD // ']}' for US -#define VK_OEM_7 0xDE // ''"' for US -#define VK_OEM_8 0xDF - -#define VK_OEM_102 0xE2 // "<>" or "\|" on RT 102-key kbd. - -#define VK_OEM_RESET 0xE9 -#define VK_OEM_JUMP 0xEA -#define VK_OEM_PA1 0xEB -#define VK_OEM_PA2 0xEC -#define VK_OEM_PA3 0xED -#define VK_OEM_WSCTRL 0xEE -#define VK_OEM_CUSEL 0xEF -#define VK_OEM_ATTN 0xF0 -#define VK_OEM_FINISH 0xF1 -#define VK_OEM_COPY 0xF2 -#define VK_OEM_AUTO 0xF3 -#define VK_OEM_ENLW 0xF4 -#define VK_OEM_BACKTAB 0xF5 -#define VK_ATTN 0xF6 -#define VK_CRSEL 0xF7 -#define VK_EXSEL 0xF8 -#define VK_EREOF 0xF9 -#define VK_PLAY 0xFA -#define VK_ZOOM 0xFB -#define VK_NONAME 0xFC -#define VK_PA1 0xFD -#define VK_OEM_CLEAR 0xFE \ No newline at end of file diff --git a/NppPlugin/include/menuCmdID.h b/NppPlugin/include/menuCmdID.h index b1d7667f..eac1411e 100644 --- a/NppPlugin/include/menuCmdID.h +++ b/NppPlugin/include/menuCmdID.h @@ -1,67 +1,57 @@ // This file is part of Notepad++ project -// Copyright (C)2003 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 the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// Note that the GPL places important restrictions on "derived works", yet -// it does not provide a detailed definition of that term. To avoid -// misunderstandings, we consider an application to constitute a -// "derivative work" for the purpose of this license if it does any of the -// following: -// 1. Integrates source code from Notepad++. -// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable -// installer, such as those produced by InstallShield. -// 3. Links to a library or executes a program that does any of the above. +// Copyright (C)2024 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 +// the Free Software Foundation, either version 3 of the License, or +// at your option any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +// along with this program. If not, see . -#ifndef MENUCMDID_H -#define MENUCMDID_H +#pragma once #define IDM 40000 #define IDM_FILE (IDM + 1000) // IMPORTANT: If list below is modified, you have to change the value of IDM_FILEMENU_LASTONE and IDM_FILEMENU_EXISTCMDPOSITION - #define IDM_FILE_NEW (IDM_FILE + 1) - #define IDM_FILE_OPEN (IDM_FILE + 2) - #define IDM_FILE_CLOSE (IDM_FILE + 3) - #define IDM_FILE_CLOSEALL (IDM_FILE + 4) - #define IDM_FILE_CLOSEALL_BUT_CURRENT (IDM_FILE + 5) - #define IDM_FILE_SAVE (IDM_FILE + 6) - #define IDM_FILE_SAVEALL (IDM_FILE + 7) - #define IDM_FILE_SAVEAS (IDM_FILE + 8) - #define IDM_FILE_CLOSEALL_TOLEFT (IDM_FILE + 9) - #define IDM_FILE_PRINT (IDM_FILE + 10) - #define IDM_FILE_PRINTNOW 1001 - #define IDM_FILE_EXIT (IDM_FILE + 11) - #define IDM_FILE_LOADSESSION (IDM_FILE + 12) - #define IDM_FILE_SAVESESSION (IDM_FILE + 13) - #define IDM_FILE_RELOAD (IDM_FILE + 14) - #define IDM_FILE_SAVECOPYAS (IDM_FILE + 15) - #define IDM_FILE_DELETE (IDM_FILE + 16) - #define IDM_FILE_RENAME (IDM_FILE + 17) - #define IDM_FILE_CLOSEALL_TORIGHT (IDM_FILE + 18) - #define IDM_FILE_OPEN_FOLDER (IDM_FILE + 19) - #define IDM_FILE_OPEN_CMD (IDM_FILE + 20) - #define IDM_FILE_RESTORELASTCLOSEDFILE (IDM_FILE + 21) - #define IDM_FILE_OPENFOLDERASWORSPACE (IDM_FILE + 22) - #define IDM_FILE_OPEN_DEFAULT_VIEWER (IDM_FILE + 23) - #define IDM_FILE_CLOSEALL_UNCHANGED (IDM_FILE + 24) + #define IDM_FILE_NEW (IDM_FILE + 1) + #define IDM_FILE_OPEN (IDM_FILE + 2) + #define IDM_FILE_CLOSE (IDM_FILE + 3) + #define IDM_FILE_CLOSEALL (IDM_FILE + 4) + #define IDM_FILE_CLOSEALL_BUT_CURRENT (IDM_FILE + 5) + #define IDM_FILE_SAVE (IDM_FILE + 6) + #define IDM_FILE_SAVEALL (IDM_FILE + 7) + #define IDM_FILE_SAVEAS (IDM_FILE + 8) + #define IDM_FILE_CLOSEALL_TOLEFT (IDM_FILE + 9) + #define IDM_FILE_PRINT (IDM_FILE + 10) + #define IDM_FILE_PRINTNOW 1001 + #define IDM_FILE_EXIT (IDM_FILE + 11) + #define IDM_FILE_LOADSESSION (IDM_FILE + 12) + #define IDM_FILE_SAVESESSION (IDM_FILE + 13) + #define IDM_FILE_RELOAD (IDM_FILE + 14) + #define IDM_FILE_SAVECOPYAS (IDM_FILE + 15) + #define IDM_FILE_DELETE (IDM_FILE + 16) + #define IDM_FILE_RENAME (IDM_FILE + 17) + #define IDM_FILE_CLOSEALL_TORIGHT (IDM_FILE + 18) + #define IDM_FILE_OPEN_FOLDER (IDM_FILE + 19) + #define IDM_FILE_OPEN_CMD (IDM_FILE + 20) + #define IDM_FILE_RESTORELASTCLOSEDFILE (IDM_FILE + 21) + #define IDM_FILE_OPENFOLDERASWORSPACE (IDM_FILE + 22) + #define IDM_FILE_OPEN_DEFAULT_VIEWER (IDM_FILE + 23) + #define IDM_FILE_CLOSEALL_UNCHANGED (IDM_FILE + 24) + #define IDM_FILE_CONTAININGFOLDERASWORKSPACE (IDM_FILE + 25) + #define IDM_FILE_CLOSEALL_BUT_PINNED (IDM_FILE + 26) // IMPORTANT: If list above is modified, you have to change the following values: // To be updated if new menu item(s) is (are) added in menu "File" - #define IDM_FILEMENU_LASTONE IDM_FILE_CLOSEALL_UNCHANGED + #define IDM_FILEMENU_LASTONE IDM_FILE_CLOSEALL_BUT_PINNED // 0 based position of command "Exit" including the bars in the file menu // and without counting "Recent files history" items @@ -79,7 +69,7 @@ //10 Rename... //11 Close //12 Close All -//13 Close More +//13 Close Multiple Documents //14 Move to Recycle Bin //15 -------- //16 Load Session... @@ -93,104 +83,113 @@ #define IDM_EDIT (IDM + 2000) - #define IDM_EDIT_CUT (IDM_EDIT + 1) - #define IDM_EDIT_COPY (IDM_EDIT + 2) - #define IDM_EDIT_UNDO (IDM_EDIT + 3) - #define IDM_EDIT_REDO (IDM_EDIT + 4) - #define IDM_EDIT_PASTE (IDM_EDIT + 5) - #define IDM_EDIT_DELETE (IDM_EDIT + 6) - #define IDM_EDIT_SELECTALL (IDM_EDIT + 7) - #define IDM_EDIT_BEGINENDSELECT (IDM_EDIT + 20) - - #define IDM_EDIT_INS_TAB (IDM_EDIT + 8) - #define IDM_EDIT_RMV_TAB (IDM_EDIT + 9) - #define IDM_EDIT_DUP_LINE (IDM_EDIT + 10) - #define IDM_EDIT_REMOVE_DUP_LINES (IDM_EDIT + 77) - #define IDM_EDIT_TRANSPOSE_LINE (IDM_EDIT + 11) - #define IDM_EDIT_SPLIT_LINES (IDM_EDIT + 12) - #define IDM_EDIT_JOIN_LINES (IDM_EDIT + 13) - #define IDM_EDIT_LINE_UP (IDM_EDIT + 14) - #define IDM_EDIT_LINE_DOWN (IDM_EDIT + 15) - #define IDM_EDIT_UPPERCASE (IDM_EDIT + 16) - #define IDM_EDIT_LOWERCASE (IDM_EDIT + 17) - #define IDM_EDIT_PROPERCASE_FORCE (IDM_EDIT + 67) - #define IDM_EDIT_PROPERCASE_BLEND (IDM_EDIT + 68) - #define IDM_EDIT_SENTENCECASE_FORCE (IDM_EDIT + 69) - #define IDM_EDIT_SENTENCECASE_BLEND (IDM_EDIT + 70) - #define IDM_EDIT_INVERTCASE (IDM_EDIT + 71) - #define IDM_EDIT_RANDOMCASE (IDM_EDIT + 72) - #define IDM_EDIT_REMOVEEMPTYLINES (IDM_EDIT + 55) - #define IDM_EDIT_REMOVEEMPTYLINESWITHBLANK (IDM_EDIT + 56) - #define IDM_EDIT_BLANKLINEABOVECURRENT (IDM_EDIT + 57) - #define IDM_EDIT_BLANKLINEBELOWCURRENT (IDM_EDIT + 58) - #define IDM_EDIT_SORTLINES_LEXICOGRAPHIC_ASCENDING (IDM_EDIT + 59) - #define IDM_EDIT_SORTLINES_LEXICOGRAPHIC_DESCENDING (IDM_EDIT + 60) - #define IDM_EDIT_SORTLINES_INTEGER_ASCENDING (IDM_EDIT + 61) - #define IDM_EDIT_SORTLINES_INTEGER_DESCENDING (IDM_EDIT + 62) - #define IDM_EDIT_SORTLINES_DECIMALCOMMA_ASCENDING (IDM_EDIT + 63) - #define IDM_EDIT_SORTLINES_DECIMALCOMMA_DESCENDING (IDM_EDIT + 64) - #define IDM_EDIT_SORTLINES_DECIMALDOT_ASCENDING (IDM_EDIT + 65) - #define IDM_EDIT_SORTLINES_DECIMALDOT_DESCENDING (IDM_EDIT + 66) - - #define IDM_EDIT_OPENASFILE (IDM_EDIT + 73) - #define IDM_EDIT_OPENINFOLDER (IDM_EDIT + 74) - #define IDM_EDIT_SEARCHONINTERNET (IDM_EDIT + 75) - #define IDM_EDIT_CHANGESEARCHENGINE (IDM_EDIT + 76) - -// Menu macro - #define IDM_MACRO_STARTRECORDINGMACRO (IDM_EDIT + 18) - #define IDM_MACRO_STOPRECORDINGMACRO (IDM_EDIT + 19) - #define IDM_MACRO_PLAYBACKRECORDEDMACRO (IDM_EDIT + 21) -//----------- - - #define IDM_EDIT_BLOCK_COMMENT (IDM_EDIT + 22) - #define IDM_EDIT_STREAM_COMMENT (IDM_EDIT + 23) - #define IDM_EDIT_TRIMTRAILING (IDM_EDIT + 24) - #define IDM_EDIT_TRIMLINEHEAD (IDM_EDIT + 42) - #define IDM_EDIT_TRIM_BOTH (IDM_EDIT + 43) - #define IDM_EDIT_EOL2WS (IDM_EDIT + 44) - #define IDM_EDIT_TRIMALL (IDM_EDIT + 45) - #define IDM_EDIT_TAB2SW (IDM_EDIT + 46) - #define IDM_EDIT_SW2TAB_LEADING (IDM_EDIT + 53) - #define IDM_EDIT_SW2TAB_ALL (IDM_EDIT + 54) - #define IDM_EDIT_STREAM_UNCOMMENT (IDM_EDIT + 47) - -// Menu macro - #define IDM_MACRO_SAVECURRENTMACRO (IDM_EDIT + 25) -//----------- - - #define IDM_EDIT_RTL (IDM_EDIT + 26) - #define IDM_EDIT_LTR (IDM_EDIT + 27) - #define IDM_EDIT_SETREADONLY (IDM_EDIT + 28) - #define IDM_EDIT_FULLPATHTOCLIP (IDM_EDIT + 29) - #define IDM_EDIT_FILENAMETOCLIP (IDM_EDIT + 30) - #define IDM_EDIT_CURRENTDIRTOCLIP (IDM_EDIT + 31) - -// Menu macro - #define IDM_MACRO_RUNMULTIMACRODLG (IDM_EDIT + 32) -//----------- - - #define IDM_EDIT_CLEARREADONLY (IDM_EDIT + 33) - #define IDM_EDIT_COLUMNMODE (IDM_EDIT + 34) - #define IDM_EDIT_BLOCK_COMMENT_SET (IDM_EDIT + 35) - #define IDM_EDIT_BLOCK_UNCOMMENT (IDM_EDIT + 36) - #define IDM_EDIT_COLUMNMODETIP (IDM_EDIT + 37) - #define IDM_EDIT_PASTE_AS_HTML (IDM_EDIT + 38) - #define IDM_EDIT_PASTE_AS_RTF (IDM_EDIT + 39) - #define IDM_EDIT_COPY_BINARY (IDM_EDIT + 48) - #define IDM_EDIT_CUT_BINARY (IDM_EDIT + 49) - #define IDM_EDIT_PASTE_BINARY (IDM_EDIT + 50) - #define IDM_EDIT_CHAR_PANEL (IDM_EDIT + 51) - #define IDM_EDIT_CLIPBOARDHISTORY_PANEL (IDM_EDIT + 52) - - #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) - - //Belong to MENU FILE - #define IDM_OPEN_ALL_RECENT_FILE (IDM_EDIT + 40) - #define IDM_CLEAN_RECENT_FILE_LIST (IDM_EDIT + 41) + #define IDM_EDIT_CUT (IDM_EDIT + 1) + #define IDM_EDIT_COPY (IDM_EDIT + 2) + #define IDM_EDIT_UNDO (IDM_EDIT + 3) + #define IDM_EDIT_REDO (IDM_EDIT + 4) + #define IDM_EDIT_PASTE (IDM_EDIT + 5) + #define IDM_EDIT_DELETE (IDM_EDIT + 6) + #define IDM_EDIT_SELECTALL (IDM_EDIT + 7) + #define IDM_EDIT_INS_TAB (IDM_EDIT + 8) + #define IDM_EDIT_RMV_TAB (IDM_EDIT + 9) + #define IDM_EDIT_DUP_LINE (IDM_EDIT + 10) + #define IDM_EDIT_TRANSPOSE_LINE (IDM_EDIT + 11) + #define IDM_EDIT_SPLIT_LINES (IDM_EDIT + 12) + #define IDM_EDIT_JOIN_LINES (IDM_EDIT + 13) + #define IDM_EDIT_LINE_UP (IDM_EDIT + 14) + #define IDM_EDIT_LINE_DOWN (IDM_EDIT + 15) + #define IDM_EDIT_UPPERCASE (IDM_EDIT + 16) + #define IDM_EDIT_LOWERCASE (IDM_EDIT + 17) + #define IDM_MACRO_STARTRECORDINGMACRO (IDM_EDIT + 18) + #define IDM_MACRO_STOPRECORDINGMACRO (IDM_EDIT + 19) + #define IDM_EDIT_BEGINENDSELECT (IDM_EDIT + 20) + #define IDM_MACRO_PLAYBACKRECORDEDMACRO (IDM_EDIT + 21) + #define IDM_EDIT_BLOCK_COMMENT (IDM_EDIT + 22) + #define IDM_EDIT_STREAM_COMMENT (IDM_EDIT + 23) + #define IDM_EDIT_TRIMTRAILING (IDM_EDIT + 24) + #define IDM_MACRO_SAVECURRENTMACRO (IDM_EDIT + 25) + #define IDM_EDIT_RTL (IDM_EDIT + 26) + #define IDM_EDIT_LTR (IDM_EDIT + 27) + #define IDM_EDIT_SETREADONLY (IDM_EDIT + 28) + #define IDM_EDIT_FULLPATHTOCLIP (IDM_EDIT + 29) + #define IDM_EDIT_FILENAMETOCLIP (IDM_EDIT + 30) + #define IDM_EDIT_CURRENTDIRTOCLIP (IDM_EDIT + 31) + #define IDM_MACRO_RUNMULTIMACRODLG (IDM_EDIT + 32) + #define IDM_EDIT_CLEARREADONLY (IDM_EDIT + 33) + #define IDM_EDIT_COLUMNMODE (IDM_EDIT + 34) + #define IDM_EDIT_BLOCK_COMMENT_SET (IDM_EDIT + 35) + #define IDM_EDIT_BLOCK_UNCOMMENT (IDM_EDIT + 36) + #define IDM_EDIT_COLUMNMODETIP (IDM_EDIT + 37) + #define IDM_EDIT_PASTE_AS_HTML (IDM_EDIT + 38) + #define IDM_EDIT_PASTE_AS_RTF (IDM_EDIT + 39) + #define IDM_OPEN_ALL_RECENT_FILE (IDM_EDIT + 40) + #define IDM_CLEAN_RECENT_FILE_LIST (IDM_EDIT + 41) + #define IDM_EDIT_TRIMLINEHEAD (IDM_EDIT + 42) + #define IDM_EDIT_TRIM_BOTH (IDM_EDIT + 43) + #define IDM_EDIT_EOL2WS (IDM_EDIT + 44) + #define IDM_EDIT_TRIMALL (IDM_EDIT + 45) + #define IDM_EDIT_TAB2SW (IDM_EDIT + 46) + #define IDM_EDIT_STREAM_UNCOMMENT (IDM_EDIT + 47) + #define IDM_EDIT_COPY_BINARY (IDM_EDIT + 48) + #define IDM_EDIT_CUT_BINARY (IDM_EDIT + 49) + #define IDM_EDIT_PASTE_BINARY (IDM_EDIT + 50) + #define IDM_EDIT_CHAR_PANEL (IDM_EDIT + 51) + #define IDM_EDIT_CLIPBOARDHISTORY_PANEL (IDM_EDIT + 52) + #define IDM_EDIT_SW2TAB_LEADING (IDM_EDIT + 53) + #define IDM_EDIT_SW2TAB_ALL (IDM_EDIT + 54) + #define IDM_EDIT_REMOVEEMPTYLINES (IDM_EDIT + 55) + #define IDM_EDIT_REMOVEEMPTYLINESWITHBLANK (IDM_EDIT + 56) + #define IDM_EDIT_BLANKLINEABOVECURRENT (IDM_EDIT + 57) + #define IDM_EDIT_BLANKLINEBELOWCURRENT (IDM_EDIT + 58) + #define IDM_EDIT_SORTLINES_LEXICOGRAPHIC_ASCENDING (IDM_EDIT + 59) + #define IDM_EDIT_SORTLINES_LEXICOGRAPHIC_DESCENDING (IDM_EDIT + 60) + #define IDM_EDIT_SORTLINES_INTEGER_ASCENDING (IDM_EDIT + 61) + #define IDM_EDIT_SORTLINES_INTEGER_DESCENDING (IDM_EDIT + 62) + #define IDM_EDIT_SORTLINES_DECIMALCOMMA_ASCENDING (IDM_EDIT + 63) + #define IDM_EDIT_SORTLINES_DECIMALCOMMA_DESCENDING (IDM_EDIT + 64) + #define IDM_EDIT_SORTLINES_DECIMALDOT_ASCENDING (IDM_EDIT + 65) + #define IDM_EDIT_SORTLINES_DECIMALDOT_DESCENDING (IDM_EDIT + 66) + #define IDM_EDIT_PROPERCASE_FORCE (IDM_EDIT + 67) + #define IDM_EDIT_PROPERCASE_BLEND (IDM_EDIT + 68) + #define IDM_EDIT_SENTENCECASE_FORCE (IDM_EDIT + 69) + #define IDM_EDIT_SENTENCECASE_BLEND (IDM_EDIT + 70) + #define IDM_EDIT_INVERTCASE (IDM_EDIT + 71) + #define IDM_EDIT_RANDOMCASE (IDM_EDIT + 72) + #define IDM_EDIT_OPENASFILE (IDM_EDIT + 73) + #define IDM_EDIT_OPENINFOLDER (IDM_EDIT + 74) + #define IDM_EDIT_SEARCHONINTERNET (IDM_EDIT + 75) + #define IDM_EDIT_CHANGESEARCHENGINE (IDM_EDIT + 76) + #define IDM_EDIT_REMOVE_CONSECUTIVE_DUP_LINES (IDM_EDIT + 77) + #define IDM_EDIT_SORTLINES_RANDOMLY (IDM_EDIT + 78) + #define IDM_EDIT_REMOVE_ANY_DUP_LINES (IDM_EDIT + 79) + #define IDM_EDIT_SORTLINES_LEXICO_CASE_INSENS_ASCENDING (IDM_EDIT + 80) + #define IDM_EDIT_SORTLINES_LEXICO_CASE_INSENS_DESCENDING (IDM_EDIT + 81) + #define IDM_EDIT_COPY_LINK (IDM_EDIT + 82) + #define IDM_EDIT_SORTLINES_REVERSE_ORDER (IDM_EDIT + 83) + #define IDM_EDIT_INSERT_DATETIME_SHORT (IDM_EDIT + 84) + #define IDM_EDIT_INSERT_DATETIME_LONG (IDM_EDIT + 85) + #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_MULTISELECTALL (IDM_EDIT + 90) + #define IDM_EDIT_MULTISELECTALLMATCHCASE (IDM_EDIT + 91) + #define IDM_EDIT_MULTISELECTALLWHOLEWORD (IDM_EDIT + 92) + #define IDM_EDIT_MULTISELECTALLMATCHCASEWHOLEWORD (IDM_EDIT + 93) + #define IDM_EDIT_MULTISELECTNEXT (IDM_EDIT + 94) + #define IDM_EDIT_MULTISELECTNEXTMATCHCASE (IDM_EDIT + 95) + #define IDM_EDIT_MULTISELECTNEXTWHOLEWORD (IDM_EDIT + 96) + #define IDM_EDIT_MULTISELECTNEXTMATCHCASEWHOLEWORD (IDM_EDIT + 97) + #define IDM_EDIT_MULTISELECTUNDO (IDM_EDIT + 98) + #define IDM_EDIT_MULTISELECTSSKIP (IDM_EDIT + 99) + + #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) #define IDM_SEARCH_FIND (IDM_SEARCH + 1) @@ -238,52 +237,72 @@ #define IDM_SEARCH_GONEXTMARKER_DEF (IDM_SEARCH + 44) #define IDM_FOCUS_ON_FOUND_RESULTS (IDM_SEARCH + 45) - #define IDM_SEARCH_GOTONEXTFOUND (IDM_SEARCH + 46) - #define IDM_SEARCH_GOTOPREVFOUND (IDM_SEARCH + 47) + #define IDM_SEARCH_GOTONEXTFOUND (IDM_SEARCH + 46) + #define IDM_SEARCH_GOTOPREVFOUND (IDM_SEARCH + 47) #define IDM_SEARCH_SETANDFINDNEXT (IDM_SEARCH + 48) #define IDM_SEARCH_SETANDFINDPREV (IDM_SEARCH + 49) #define IDM_SEARCH_INVERSEMARKS (IDM_SEARCH + 50) - #define IDM_SEARCH_DELETEUNMARKEDLINES (IDM_SEARCH + 51) - #define IDM_SEARCH_FINDCHARINRANGE (IDM_SEARCH + 52) - #define IDM_SEARCH_SELECTMATCHINGBRACES (IDM_SEARCH + 53) - #define IDM_SEARCH_MARK (IDM_SEARCH + 54) - + #define IDM_SEARCH_DELETEUNMARKEDLINES (IDM_SEARCH + 51) + #define IDM_SEARCH_FINDCHARINRANGE (IDM_SEARCH + 52) + #define IDM_SEARCH_SELECTMATCHINGBRACES (IDM_SEARCH + 53) + #define IDM_SEARCH_MARK (IDM_SEARCH + 54) + + #define IDM_SEARCH_STYLE1TOCLIP (IDM_SEARCH + 55) + #define IDM_SEARCH_STYLE2TOCLIP (IDM_SEARCH + 56) + #define IDM_SEARCH_STYLE3TOCLIP (IDM_SEARCH + 57) + #define IDM_SEARCH_STYLE4TOCLIP (IDM_SEARCH + 58) + #define IDM_SEARCH_STYLE5TOCLIP (IDM_SEARCH + 59) + #define IDM_SEARCH_ALLSTYLESTOCLIP (IDM_SEARCH + 60) + #define IDM_SEARCH_MARKEDTOCLIP (IDM_SEARCH + 61) + + #define IDM_SEARCH_MARKONEEXT1 (IDM_SEARCH + 62) + #define IDM_SEARCH_MARKONEEXT2 (IDM_SEARCH + 63) + #define IDM_SEARCH_MARKONEEXT3 (IDM_SEARCH + 64) + #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_FILESWITCHER_FILESCLOSE (IDM_MISC + 1) - #define IDM_FILESWITCHER_FILESCLOSEOTHERS (IDM_MISC + 2) + #define IDM_DOCLIST_FILESCLOSE (IDM_MISC + 1) + #define IDM_DOCLIST_FILESCLOSEOTHERS (IDM_MISC + 2) + #define IDM_DOCLIST_COPYNAMES (IDM_MISC + 3) + #define IDM_DOCLIST_COPYPATHS (IDM_MISC + 4) #define IDM_VIEW (IDM + 4000) //#define IDM_VIEW_TOOLBAR_HIDE (IDM_VIEW + 1) - #define IDM_VIEW_TOOLBAR_REDUCE (IDM_VIEW + 2) - #define IDM_VIEW_TOOLBAR_ENLARGE (IDM_VIEW + 3) - #define IDM_VIEW_TOOLBAR_STANDARD (IDM_VIEW + 4) - #define IDM_VIEW_REDUCETABBAR (IDM_VIEW + 5) - #define IDM_VIEW_LOCKTABBAR (IDM_VIEW + 6) - #define IDM_VIEW_DRAWTABBAR_TOPBAR (IDM_VIEW + 7) - #define IDM_VIEW_DRAWTABBAR_INACIVETAB (IDM_VIEW + 8) + //#define IDM_VIEW_TOOLBAR_REDUCE (IDM_VIEW + 2) + //#define IDM_VIEW_TOOLBAR_ENLARGE (IDM_VIEW + 3) + //#define IDM_VIEW_TOOLBAR_STANDARD (IDM_VIEW + 4) + //#define IDM_VIEW_REDUCETABBAR (IDM_VIEW + 5) + //#define IDM_VIEW_LOCKTABBAR (IDM_VIEW + 6) + //#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_USER_DLG (IDM_VIEW + 11) - #define IDM_VIEW_LINENUMBER (IDM_VIEW + 12) - #define IDM_VIEW_SYMBOLMARGIN (IDM_VIEW + 13) - #define IDM_VIEW_FOLDERMAGIN (IDM_VIEW + 14) - #define IDM_VIEW_FOLDERMAGIN_SIMPLE (IDM_VIEW + 15) - #define IDM_VIEW_FOLDERMAGIN_ARROW (IDM_VIEW + 16) - #define IDM_VIEW_FOLDERMAGIN_CIRCLE (IDM_VIEW + 17) - #define IDM_VIEW_FOLDERMAGIN_BOX (IDM_VIEW + 18) + #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) + //#define IDM_VIEW_FOLDERMAGIN (IDM_VIEW + 14) + //#define IDM_VIEW_FOLDERMAGIN_SIMPLE (IDM_VIEW + 15) + //#define IDM_VIEW_FOLDERMAGIN_ARROW (IDM_VIEW + 16) + //#define IDM_VIEW_FOLDERMAGIN_CIRCLE (IDM_VIEW + 17) + //#define IDM_VIEW_FOLDERMAGIN_BOX (IDM_VIEW + 18) #define IDM_VIEW_ALL_CHARACTERS (IDM_VIEW + 19) #define IDM_VIEW_INDENT_GUIDE (IDM_VIEW + 20) - #define IDM_VIEW_CURLINE_HILITING (IDM_VIEW + 21) + //#define IDM_VIEW_CURLINE_HILITING (IDM_VIEW + 21) #define IDM_VIEW_WRAP (IDM_VIEW + 22) #define IDM_VIEW_ZOOMIN (IDM_VIEW + 23) #define IDM_VIEW_ZOOMOUT (IDM_VIEW + 24) #define IDM_VIEW_TAB_SPACE (IDM_VIEW + 25) #define IDM_VIEW_EOL (IDM_VIEW + 26) - #define IDM_VIEW_EDGELINE (IDM_VIEW + 27) - #define IDM_VIEW_EDGEBACKGROUND (IDM_VIEW + 28) - #define IDM_VIEW_TOGGLE_UNFOLDALL (IDM_VIEW + 29) + //#define IDM_VIEW_TOOLBAR_REDUCE_SET2 (IDM_VIEW + 27) + //#define IDM_VIEW_TOOLBAR_ENLARGE_SET2 (IDM_VIEW + 28) + #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) @@ -291,19 +310,19 @@ #define IDM_VIEW_ALWAYSONTOP (IDM_VIEW + 34) #define IDM_VIEW_SYNSCROLLV (IDM_VIEW + 35) #define IDM_VIEW_SYNSCROLLH (IDM_VIEW + 36) - #define IDM_VIEW_EDGENONE (IDM_VIEW + 37) - #define IDM_VIEW_DRAWTABBAR_CLOSEBOTTUN (IDM_VIEW + 38) - #define IDM_VIEW_DRAWTABBAR_DBCLK2CLOSE (IDM_VIEW + 39) - #define IDM_VIEW_REFRESHTABAR (IDM_VIEW + 40) + //#define IDM_VIEW_EDGENONE (IDM_VIEW + 37) + //#define IDM_VIEW_DRAWTABBAR_CLOSEBOTTUN (IDM_VIEW + 38) + //#define IDM_VIEW_DRAWTABBAR_DBCLK2CLOSE (IDM_VIEW + 39) + //#define IDM_VIEW_REFRESHTABAR (IDM_VIEW + 40) #define IDM_VIEW_WRAP_SYMBOL (IDM_VIEW + 41) #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_LWDEF (IDM_VIEW + 46) - #define IDM_VIEW_LWALIGN (IDM_VIEW + 47) - #define IDM_VIEW_LWINDENT (IDM_VIEW + 48) - #define IDM_VIEW_SUMMARY (IDM_VIEW + 49) + //#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_LWDEF (IDM_VIEW + 46) + //#define IDM_VIEW_LWALIGN (IDM_VIEW + 47) + #define IDM_PINTAB (IDM_VIEW + 48) + #define IDM_VIEW_SUMMARY (IDM_VIEW + 49) #define IDM_VIEW_FOLD (IDM_VIEW + 50) #define IDM_VIEW_FOLD_1 (IDM_VIEW_FOLD + 1) @@ -325,43 +344,63 @@ #define IDM_VIEW_UNFOLD_7 (IDM_VIEW_UNFOLD + 7) #define IDM_VIEW_UNFOLD_8 (IDM_VIEW_UNFOLD + 8) - #define IDM_VIEW_FILESWITCHER_PANEL (IDM_VIEW + 70) - #define IDM_VIEW_SWITCHTO_OTHER_VIEW (IDM_VIEW + 72) - #define IDM_EXPORT_FUNC_LIST_AND_QUIT (IDM_VIEW + 73) - - #define IDM_VIEW_DOC_MAP (IDM_VIEW + 80) - - #define IDM_VIEW_PROJECT_PANEL_1 (IDM_VIEW + 81) - #define IDM_VIEW_PROJECT_PANEL_2 (IDM_VIEW + 82) - #define IDM_VIEW_PROJECT_PANEL_3 (IDM_VIEW + 83) - - #define IDM_VIEW_FUNC_LIST (IDM_VIEW + 84) - #define IDM_VIEW_FILEBROWSER (IDM_VIEW + 85) - - #define IDM_VIEW_TAB1 (IDM_VIEW + 86) - #define IDM_VIEW_TAB2 (IDM_VIEW + 87) - #define IDM_VIEW_TAB3 (IDM_VIEW + 88) - #define IDM_VIEW_TAB4 (IDM_VIEW + 89) - #define IDM_VIEW_TAB5 (IDM_VIEW + 90) - #define IDM_VIEW_TAB6 (IDM_VIEW + 91) - #define IDM_VIEW_TAB7 (IDM_VIEW + 92) - #define IDM_VIEW_TAB8 (IDM_VIEW + 93) - #define IDM_VIEW_TAB9 (IDM_VIEW + 94) - #define IDM_VIEW_TAB_NEXT (IDM_VIEW + 95) - #define IDM_VIEW_TAB_PREV (IDM_VIEW + 96) + #define IDM_VIEW_DOCLIST (IDM_VIEW + 70) + #define IDM_VIEW_SWITCHTO_OTHER_VIEW (IDM_VIEW + 72) + #define IDM_EXPORT_FUNC_LIST_AND_QUIT (IDM_VIEW + 73) + + #define IDM_VIEW_DOC_MAP (IDM_VIEW + 80) + + #define IDM_VIEW_PROJECT_PANEL_1 (IDM_VIEW + 81) + #define IDM_VIEW_PROJECT_PANEL_2 (IDM_VIEW + 82) + #define IDM_VIEW_PROJECT_PANEL_3 (IDM_VIEW + 83) + + #define IDM_VIEW_FUNC_LIST (IDM_VIEW + 84) + #define IDM_VIEW_FILEBROWSER (IDM_VIEW + 85) + + #define IDM_VIEW_TAB1 (IDM_VIEW + 86) + #define IDM_VIEW_TAB2 (IDM_VIEW + 87) + #define IDM_VIEW_TAB3 (IDM_VIEW + 88) + #define IDM_VIEW_TAB4 (IDM_VIEW + 89) + #define IDM_VIEW_TAB5 (IDM_VIEW + 90) + #define IDM_VIEW_TAB6 (IDM_VIEW + 91) + #define IDM_VIEW_TAB7 (IDM_VIEW + 92) + #define IDM_VIEW_TAB8 (IDM_VIEW + 93) + #define IDM_VIEW_TAB9 (IDM_VIEW + 94) + #define IDM_VIEW_TAB_NEXT (IDM_VIEW + 95) + #define IDM_VIEW_TAB_PREV (IDM_VIEW + 96) #define IDM_VIEW_MONITORING (IDM_VIEW + 97) - #define IDM_VIEW_TAB_MOVEFORWARD (IDM_VIEW + 98) - #define IDM_VIEW_TAB_MOVEBACKWARD (IDM_VIEW + 99) - #define IDM_VIEW_IN_FIREFOX (IDM_VIEW + 100) - #define IDM_VIEW_IN_CHROME (IDM_VIEW + 101) - #define IDM_VIEW_IN_EDGE (IDM_VIEW + 102) - #define IDM_VIEW_IN_IE (IDM_VIEW + 103) + #define IDM_VIEW_TAB_MOVEFORWARD (IDM_VIEW + 98) + #define IDM_VIEW_TAB_MOVEBACKWARD (IDM_VIEW + 99) + #define IDM_VIEW_IN_FIREFOX (IDM_VIEW + 100) + #define IDM_VIEW_IN_CHROME (IDM_VIEW + 101) + #define IDM_VIEW_IN_EDGE (IDM_VIEW + 102) + #define IDM_VIEW_IN_IE (IDM_VIEW + 103) + + #define IDM_VIEW_SWITCHTO_PROJECT_PANEL_1 (IDM_VIEW + 104) + #define IDM_VIEW_SWITCHTO_PROJECT_PANEL_2 (IDM_VIEW + 105) + #define IDM_VIEW_SWITCHTO_PROJECT_PANEL_3 (IDM_VIEW + 106) + #define IDM_VIEW_SWITCHTO_FILEBROWSER (IDM_VIEW + 107) + #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_TAB_START (IDM_VIEW + 116) + #define IDM_VIEW_TAB_END (IDM_VIEW + 117) + + #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 #define IDM_VIEW_LOAD_IN_NEW_INSTANCE 10004 - + #define IDM_VIEW_GOTO_START 10005 + #define IDM_VIEW_GOTO_END 10006 #define IDM_FORMAT (IDM + 5000) #define IDM_FORMAT_TODOS (IDM_FORMAT + 1) @@ -369,14 +408,14 @@ #define IDM_FORMAT_TOMAC (IDM_FORMAT + 3) #define IDM_FORMAT_ANSI (IDM_FORMAT + 4) #define IDM_FORMAT_UTF_8 (IDM_FORMAT + 5) - #define IDM_FORMAT_UCS_2BE (IDM_FORMAT + 6) - #define IDM_FORMAT_UCS_2LE (IDM_FORMAT + 7) + #define IDM_FORMAT_UTF_16BE (IDM_FORMAT + 6) + #define IDM_FORMAT_UTF_16LE (IDM_FORMAT + 7) #define IDM_FORMAT_AS_UTF_8 (IDM_FORMAT + 8) #define IDM_FORMAT_CONV2_ANSI (IDM_FORMAT + 9) #define IDM_FORMAT_CONV2_AS_UTF_8 (IDM_FORMAT + 10) #define IDM_FORMAT_CONV2_UTF_8 (IDM_FORMAT + 11) - #define IDM_FORMAT_CONV2_UCS_2BE (IDM_FORMAT + 12) - #define IDM_FORMAT_CONV2_UCS_2LE (IDM_FORMAT + 13) + #define IDM_FORMAT_CONV2_UTF_16BE (IDM_FORMAT + 12) + #define IDM_FORMAT_CONV2_UTF_16LE (IDM_FORMAT + 13) #define IDM_FORMAT_ENCODE (IDM_FORMAT + 20) #define IDM_FORMAT_WIN_1250 (IDM_FORMAT_ENCODE + 0) @@ -403,8 +442,8 @@ #define IDM_FORMAT_ISO_8859_14 (IDM_FORMAT_ENCODE + 21) #define IDM_FORMAT_ISO_8859_15 (IDM_FORMAT_ENCODE + 22) //#define IDM_FORMAT_ISO_8859_16 (IDM_FORMAT_ENCODE + 23) - #define IDM_FORMAT_DOS_437 (IDM_FORMAT_ENCODE + 24) - #define IDM_FORMAT_DOS_720 (IDM_FORMAT_ENCODE + 25) + #define IDM_FORMAT_DOS_437 (IDM_FORMAT_ENCODE + 24) + #define IDM_FORMAT_DOS_720 (IDM_FORMAT_ENCODE + 25) #define IDM_FORMAT_DOS_737 (IDM_FORMAT_ENCODE + 26) #define IDM_FORMAT_DOS_775 (IDM_FORMAT_ENCODE + 27) #define IDM_FORMAT_DOS_850 (IDM_FORMAT_ENCODE + 28) @@ -488,10 +527,10 @@ #define IDM_LANG_POWERSHELL (IDM_LANG + 53) #define IDM_LANG_R (IDM_LANG + 54) #define IDM_LANG_JSP (IDM_LANG + 55) - #define IDM_LANG_COFFEESCRIPT (IDM_LANG + 56) - #define IDM_LANG_JSON (IDM_LANG + 57) + #define IDM_LANG_COFFEESCRIPT (IDM_LANG + 56) + #define IDM_LANG_JSON (IDM_LANG + 57) #define IDM_LANG_FORTRAN_77 (IDM_LANG + 58) - #define IDM_LANG_BAANC (IDM_LANG + 59) + #define IDM_LANG_BAANC (IDM_LANG + 59) #define IDM_LANG_SREC (IDM_LANG + 60) #define IDM_LANG_IHEX (IDM_LANG + 61) #define IDM_LANG_TEHEX (IDM_LANG + 62) @@ -507,7 +546,7 @@ #define IDM_LANG_FORTH (IDM_LANG + 72) #define IDM_LANG_LATEX (IDM_LANG + 73) #define IDM_LANG_MMIXAL (IDM_LANG + 74) - #define IDM_LANG_NIMROD (IDM_LANG + 75) + #define IDM_LANG_NIM (IDM_LANG + 75) #define IDM_LANG_NNCRONTAB (IDM_LANG + 76) #define IDM_LANG_OSCRIPT (IDM_LANG + 77) #define IDM_LANG_REBOL (IDM_LANG + 78) @@ -516,30 +555,39 @@ #define IDM_LANG_SPICE (IDM_LANG + 81) #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_GOLANG (IDM_LANG + 89) + #define IDM_LANG_RAKU (IDM_LANG + 90) + #define IDM_LANG_TOML (IDM_LANG + 91) + #define IDM_LANG_EXTERNAL (IDM_LANG + 165) #define IDM_LANG_EXTERNAL_LIMIT (IDM_LANG + 179) #define IDM_LANG_USER (IDM_LANG + 180) //46180: Used for translation #define IDM_LANG_USER_LIMIT (IDM_LANG + 210) //46210: Ajust with IDM_LANG_USER - #define IDM_LANG_USER_DLG (IDM_LANG + 250) //46250: Used for translation + #define IDM_LANG_USER_DLG (IDM_LANG + 250) //46250: Used for translation + #define IDM_LANG_OPENUDLDIR (IDM_LANG + 300) + #define IDM_LANG_UDLCOLLECTION_PROJECT_SITE (IDM_LANG + 301) + - - #define IDM_ABOUT (IDM + 7000) #define IDM_HOMESWEETHOME (IDM_ABOUT + 1) #define IDM_PROJECTPAGE (IDM_ABOUT + 2) - #define IDM_ONLINEHELP (IDM_ABOUT + 3) + #define IDM_ONLINEDOCUMENT (IDM_ABOUT + 3) #define IDM_FORUM (IDM_ABOUT + 4) //#define IDM_PLUGINSHOME (IDM_ABOUT + 5) #define IDM_UPDATE_NPP (IDM_ABOUT + 6) #define IDM_WIKIFAQ (IDM_ABOUT + 7) - #define IDM_HELP (IDM_ABOUT + 8) - #define IDM_CONFUPDATERPROXY (IDM_ABOUT + 9) - #define IDM_CMDLINEARGUMENTS (IDM_ABOUT + 10) - #define IDM_ONLINESUPPORT (IDM_ABOUT + 11) - #define IDM_DEBUGINFO (IDM_ABOUT + 12) + //#define IDM_HELP (IDM_ABOUT + 8) + #define IDM_CONFUPDATERPROXY (IDM_ABOUT + 9) + #define IDM_CMDLINEARGUMENTS (IDM_ABOUT + 10) + //#define IDM_ONLINESUPPORT (IDM_ABOUT + 11) + #define IDM_DEBUGINFO (IDM_ABOUT + 12) #define IDM_SETTING (IDM + 8000) @@ -548,24 +596,30 @@ // #define IDM_SETTING_HISTORY_SIZE (IDM_SETTING + 3) // #define IDM_SETTING_EDGE_SIZE (IDM_SETTING + 4) #define IDM_SETTING_IMPORTPLUGIN (IDM_SETTING + 5) - #define IDM_SETTING_IMPORTSTYLETHEMS (IDM_SETTING + 6) + #define IDM_SETTING_IMPORTSTYLETHEMES (IDM_SETTING + 6) #define IDM_SETTING_TRAYICON (IDM_SETTING + 8) #define IDM_SETTING_SHORTCUT_MAPPER (IDM_SETTING + 9) #define IDM_SETTING_REMEMBER_LAST_SESSION (IDM_SETTING + 10) #define IDM_SETTING_PREFERENCE (IDM_SETTING + 11) #define IDM_SETTING_OPENPLUGINSDIR (IDM_SETTING + 14) #define IDM_SETTING_PLUGINADM (IDM_SETTING + 15) - #define IDM_SETTING_SHORTCUT_MAPPER_MACRO (IDM_SETTING + 16) - #define IDM_SETTING_SHORTCUT_MAPPER_RUN (IDM_SETTING + 17) - #define IDM_SETTING_EDITCONTEXTMENU (IDM_SETTING + 18) + #define IDM_SETTING_SHORTCUT_MAPPER_MACRO (IDM_SETTING + 16) + #define IDM_SETTING_SHORTCUT_MAPPER_RUN (IDM_SETTING + 17) + #define IDM_SETTING_EDITCONTEXTMENU (IDM_SETTING + 18) #define IDM_TOOL (IDM + 8500) - #define IDM_TOOL_MD5_GENERATE (IDM_TOOL + 1) - #define IDM_TOOL_MD5_GENERATEFROMFILE (IDM_TOOL + 2) - #define IDM_TOOL_MD5_GENERATEINTOCLIPBOARD (IDM_TOOL + 3) - #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_MD5_GENERATE (IDM_TOOL + 1) + #define IDM_TOOL_MD5_GENERATEFROMFILE (IDM_TOOL + 2) + #define IDM_TOOL_MD5_GENERATEINTOCLIPBOARD (IDM_TOOL + 3) + #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) @@ -576,4 +630,21 @@ #define IDM_SYSTRAYPOPUP_OPENFILE (IDM_SYSTRAYPOPUP + 4) #define IDM_SYSTRAYPOPUP_CLOSE (IDM_SYSTRAYPOPUP + 5) -#endif //MENUCMDID_H +#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/NppPlugin/project/NppPlugin.vcxproj b/NppPlugin/project/NppPlugin.vcxproj index 13291b79..6c851163 100644 --- a/NppPlugin/project/NppPlugin.vcxproj +++ b/NppPlugin/project/NppPlugin.vcxproj @@ -179,6 +179,8 @@ + + Create @@ -194,11 +196,16 @@ + + + + + + - diff --git a/NppPlugin/project/NppPlugin.vcxproj.filters b/NppPlugin/project/NppPlugin.vcxproj.filters index f6253f6c..50d4a305 100644 --- a/NppPlugin/project/NppPlugin.vcxproj.filters +++ b/NppPlugin/project/NppPlugin.vcxproj.filters @@ -21,6 +21,12 @@ Source Files + + Source Files + + + Source Files + @@ -38,9 +44,6 @@ Header Files - - Header Files - Header Files @@ -56,6 +59,24 @@ Header Files + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + diff --git a/NppPlugin/src/NppDarkModeDummy.cpp b/NppPlugin/src/NppDarkModeDummy.cpp new file mode 100644 index 00000000..4bb7f7f8 --- /dev/null +++ b/NppPlugin/src/NppDarkModeDummy.cpp @@ -0,0 +1,24 @@ +#include "stdafx.h" //ADDED BY PYTHONSCRIPT +#include "NppDarkMode.h" + +namespace NppDarkMode +{ + bool isEnabled() + { + return false; + } + + HBRUSH getDarkerBackgroundBrush() + { + return 0; + } + + void setDarkTitleBar(HWND /*hwnd*/) + { + } + + bool isWindows10() + { + return true; + } +} diff --git a/NppPlugin/src/StaticDialog.cpp b/NppPlugin/src/StaticDialog.cpp index b18ce0ce..028fdf27 100644 --- a/NppPlugin/src/StaticDialog.cpp +++ b/NppPlugin/src/StaticDialog.cpp @@ -1,42 +1,32 @@ // This file is part of Notepad++ project -// Copyright (C)2003 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 the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// Note that the GPL places important restrictions on "derived works", yet -// it does not provide a detailed definition of that term. To avoid -// misunderstandings, we consider an application to constitute a -// "derivative work" for the purpose of this license if it does any of the -// following: -// 1. Integrates source code from Notepad++. -// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable -// installer, such as those produced by InstallShield. -// 3. Links to a library or executes a program that does any of the above. +// Copyright (C)2024 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 +// the Free Software Foundation, either version 3 of the License, or +// at your option any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +// along with this program. If not, see . -#include "stdafx.h" +#include "stdafx.h" //ADDED BY PYTHONSCRIPT #include #include #include "StaticDialog.h" #include "Common.h" +//#include "NppDarkMode.h" StaticDialog::~StaticDialog() { if (isCreated()) { // Prevent run_dlgProc from doing anything, since its virtual - ::SetWindowLongPtr(_hSelf, GWLP_USERDATA, NULL); + ::SetWindowLongPtr(_hSelf, GWLP_USERDATA, 0); destroy(); } } @@ -47,12 +37,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 @@ -63,52 +76,144 @@ 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; + if ((rc.left == rc.right) || (rc.top == rc.bottom)) + swpFlags |= SWP_NOSIZE; // sizing has no sense here + + POINT center{}; center.x = rc.left + (rc.right - rc.left)/2; center.y = rc.top + (rc.bottom - rc.top)/2; ::ClientToScreen(_hParent, ¢er); + if ((center.x == -32000) && (center.y == -32000)) // https://devblogs.microsoft.com/oldnewthing/20041028-00/?p=37453 + swpFlags |= SWP_NOMOVE; // moving has no sense here (owner wnd is minimized) 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); + if (((swpFlags & SWP_NOMOVE) != SWP_NOMOVE) && ((swpFlags & SWP_SHOWWINDOW) == SWP_SHOWWINDOW)) + ::SendMessageW(_hSelf, DM_REPOSITION, 0, 0); +} + +bool StaticDialog::moveForDpiChange() +{ + if (_dpiManager.getDpi() != _dpiManager.getDpiForWindow(_hParent)) + { + goToCenter(SWP_HIDEWINDOW | SWP_NOSIZE | SWP_NOACTIVATE); + return true; + } + return false; } -void StaticDialog::display(bool toShow) const +void StaticDialog::display(bool toShow, bool enhancedPositioningCheckWhenShowing) const { if (toShow) { - // 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}; - ::SystemParametersInfo(SPI_GETWORKAREA, 0, &workAreaRect, 0); - ::GetWindowRect(_hSelf, &rc); - int newLeft = rc.left; - int newTop = rc.top; - int margin = ::GetSystemMetrics(SM_CYSMCAPTION); - - if (newLeft > ::GetSystemMetrics(SM_CXVIRTUALSCREEN)-margin) - newLeft -= rc.right - workAreaRect.right; - if (newLeft + (rc.right - rc.left) < ::GetSystemMetrics(SM_XVIRTUALSCREEN)+margin) - newLeft = workAreaRect.left; - if (newTop > ::GetSystemMetrics(SM_CYVIRTUALSCREEN)-margin) - newTop -= rc.bottom - workAreaRect.bottom; - if (newTop + (rc.bottom - rc.top) < ::GetSystemMetrics(SM_YVIRTUALSCREEN)+margin) - newTop = workAreaRect.top; - - if ((newLeft != rc.left) || (newTop != rc.top)) // then the virtual screen size has shrunk - // Remember that MoveWindow wants width/height. - ::MoveWindow(_hSelf, newLeft, newTop, rc.right - rc.left, rc.bottom - rc.top, TRUE); + if (enhancedPositioningCheckWhenShowing) + { + RECT testPositionRc{}, candidateRc{}; + + getWindowRect(testPositionRc); + + candidateRc = getViewablePositionRect(testPositionRc); + + if ((testPositionRc.left != candidateRc.left) || (testPositionRc.top != candidateRc.top)) + { + ::MoveWindow(_hSelf, candidateRc.left, candidateRc.top, + candidateRc.right - candidateRc.left, candidateRc.bottom - candidateRc.top, TRUE); + } + } + else + { + // 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{}; + RECT rc{}; + ::SystemParametersInfo(SPI_GETWORKAREA, 0, &workAreaRect, 0); + ::GetWindowRect(_hSelf, &rc); + int newLeft = rc.left; + int newTop = rc.top; + int margin = ::GetSystemMetrics(SM_CYSMCAPTION); + + if (newLeft > ::GetSystemMetrics(SM_CXVIRTUALSCREEN) - margin) + newLeft -= rc.right - workAreaRect.right; + if (newLeft + (rc.right - rc.left) < ::GetSystemMetrics(SM_XVIRTUALSCREEN) + margin) + newLeft = workAreaRect.left; + if (newTop > ::GetSystemMetrics(SM_CYVIRTUALSCREEN) - margin) + newTop -= rc.bottom - workAreaRect.bottom; + if (newTop + (rc.bottom - rc.top) < ::GetSystemMetrics(SM_YVIRTUALSCREEN) + margin) + newTop = workAreaRect.top; + + if ((newLeft != rc.left) || (newTop != rc.top)) // then the virtual screen size has shrunk + ::SetWindowPos(_hSelf, nullptr, newLeft, newTop, 0, 0, SWP_NOSIZE | SWP_NOZORDER); + else + ::SendMessageW(_hSelf, DM_REPOSITION, 0, 0); + } } Window::display(toShow); } +RECT StaticDialog::getViewablePositionRect(RECT testPositionRc) const +{ + HMONITOR hMon = ::MonitorFromRect(&testPositionRc, MONITOR_DEFAULTTONULL); + + MONITORINFO mi{}; + mi.cbSize = sizeof(MONITORINFO); + + bool rectPosViewableWithoutChange = false; + + if (hMon != NULL) + { + // rect would be at least partially visible on a monitor + + ::GetMonitorInfo(hMon, &mi); + + int margin = ::GetSystemMetrics(SM_CYBORDER) + ::GetSystemMetrics(SM_CYSIZEFRAME) + ::GetSystemMetrics(SM_CYCAPTION); + + // require that the title bar of the window be in a viewable place so the user can see it to grab it with the mouse + if ((testPositionRc.top >= mi.rcWork.top) && (testPositionRc.top + margin <= mi.rcWork.bottom) && + // require that some reasonable amount of width of the title bar be in the viewable area: + (testPositionRc.right - (margin * 2) > mi.rcWork.left) && (testPositionRc.left + (margin * 2) < mi.rcWork.right)) + { + rectPosViewableWithoutChange = true; + } + } + else + { + // rect would not have been visible on a monitor; get info about the nearest monitor to it + + hMon = ::MonitorFromRect(&testPositionRc, MONITOR_DEFAULTTONEAREST); + + ::GetMonitorInfo(hMon, &mi); + } + + RECT returnRc = testPositionRc; + + if (!rectPosViewableWithoutChange) + { + // reposition rect so that it would be viewable on current/nearest monitor, centering if reasonable + + LONG testRectWidth = testPositionRc.right - testPositionRc.left; + LONG testRectHeight = testPositionRc.bottom - testPositionRc.top; + LONG monWidth = mi.rcWork.right - mi.rcWork.left; + LONG monHeight = mi.rcWork.bottom - mi.rcWork.top; + + returnRc.left = mi.rcWork.left; + if (testRectWidth < monWidth) returnRc.left += (monWidth - testRectWidth) / 2; + returnRc.right = returnRc.left + testRectWidth; + + returnRc.top = mi.rcWork.top; + if (testRectHeight < monHeight) returnRc.top += (monHeight - testRectHeight) / 2; + returnRc.bottom = returnRc.top + testRectHeight; + } + + return returnRc; +} + HGLOBAL StaticDialog::makeRTLResource(int dialogID, DLGTEMPLATE **ppMyDlgTemplate) { // Get Dlg Template resource @@ -120,18 +225,23 @@ HGLOBAL StaticDialog::makeRTLResource(int dialogID, DLGTEMPLATE **ppMyDlgTemplat if (!hDlgTemplate) return NULL; - DLGTEMPLATE *pDlgTemplate = static_cast(::LockResource(hDlgTemplate)); + const DLGTEMPLATE *pDlgTemplate = static_cast(::LockResource(hDlgTemplate)); if (!pDlgTemplate) return NULL; // Duplicate Dlg Template resource unsigned long sizeDlg = ::SizeofResource(_hInst, hDialogRC); HGLOBAL hMyDlgTemplate = ::GlobalAlloc(GPTR, sizeDlg); + if (!hMyDlgTemplate) return nullptr; + *ppMyDlgTemplate = static_cast(::GlobalLock(hMyDlgTemplate)); + if (!*ppMyDlgTemplate) return nullptr; ::memcpy(*ppMyDlgTemplate, pDlgTemplate, sizeDlg); - DLGTEMPLATEEX *pMyDlgTemplateEx = reinterpret_cast(*ppMyDlgTemplate); + DLGTEMPLATEEX* pMyDlgTemplateEx = reinterpret_cast(*ppMyDlgTemplate); + if (!pMyDlgTemplateEx) return nullptr; + if (pMyDlgTemplateEx->signature == 0xFFFF) pMyDlgTemplateEx->exStyle |= WS_EX_LAYOUTRTL; else @@ -154,22 +264,27 @@ void StaticDialog::create(int dialogID, bool isRTL, bool msgDestParent) if (!_hSelf) { - generic_string errMsg = TEXT("CreateDialogParam() return NULL.\rGetLastError(): "); + std::wstring errMsg = L"CreateDialogParam() return NULL.\rGetLastError(): "; errMsg += GetLastErrorAsString(); - ::MessageBox(NULL, errMsg.c_str(), TEXT("In StaticDialog::create()"), MB_OK); + ::MessageBox(NULL, errMsg.c_str(), L"In StaticDialog::create()", MB_OK); return; } + NppDarkMode::setDarkTitleBar(_hSelf); + setDpi(); + // if the destination of message NPPM_MODELESSDIALOG is not its parent, then it's the grand-parent ::SendMessage(msgDestParent ? _hParent : (::GetParent(_hParent)), NPPM_MODELESSDIALOG, MODELESSDIALOGADD, reinterpret_cast(_hSelf)); } -INT_PTR CALLBACK StaticDialog::dlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +intptr_t CALLBACK StaticDialog::dlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_INITDIALOG: { + NppDarkMode::setDarkTitleBar(hwnd); + StaticDialog *pStaticDlg = reinterpret_cast(lParam); pStaticDlg->_hSelf = hwnd; ::SetWindowLongPtr(hwnd, GWLP_USERDATA, static_cast(lParam)); @@ -189,41 +304,3 @@ INT_PTR CALLBACK StaticDialog::dlgProc(HWND hwnd, UINT message, WPARAM wParam, L } } -void StaticDialog::alignWith(HWND handle, HWND handle2Align, PosAlign pos, POINT & point) -{ - RECT rc, rc2; - ::GetWindowRect(handle, &rc); - - point.x = rc.left; - point.y = rc.top; - - switch (pos) - { - case PosAlign::left: - { - ::GetWindowRect(handle2Align, &rc2); - point.x -= rc2.right - rc2.left; - break; - } - case PosAlign::right: - { - ::GetWindowRect(handle, &rc2); - point.x += rc2.right - rc2.left; - break; - } - case PosAlign::top: - { - ::GetWindowRect(handle2Align, &rc2); - point.y -= rc2.bottom - rc2.top; - break; - } - case PosAlign::bottom: - { - ::GetWindowRect(handle, &rc2); - point.y += rc2.bottom - rc2.top; - break; - } - } - - ::ScreenToClient(_hSelf, &point); -} diff --git a/NppPlugin/src/dpiManagerV2.cpp b/NppPlugin/src/dpiManagerV2.cpp new file mode 100644 index 00000000..d5d8fd22 --- /dev/null +++ b/NppPlugin/src/dpiManagerV2.cpp @@ -0,0 +1,218 @@ +// This file is part of Notepad++ project +// Copyright (c) 2024 ozone10 and Notepad++ team + +// 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 +// the Free Software Foundation, either version 3 of the License, or +// at your option any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +#include "stdafx.h" //ADDED BY PYTHONSCRIPT +#include "dpiManagerV2.h" + +#include + + +#if defined(__GNUC__) && __GNUC__ > 8 +#define WINAPI_LAMBDA_RETURN(return_t) -> return_t WINAPI +#elif defined(__GNUC__) +#define WINAPI_LAMBDA_RETURN(return_t) WINAPI -> return_t +#else +#define WINAPI_LAMBDA_RETURN(return_t) -> return_t +#endif + +template +bool ptrFn(HMODULE handle, P& pointer, const char* name) +{ + auto p = reinterpret_cast

(::GetProcAddress(handle, name)); + if (p != nullptr) + { + pointer = p; + return true; + } + return false; +} + +using fnGetDpiForSystem = UINT (WINAPI*)(VOID); +using fnGetDpiForWindow = UINT (WINAPI*)(HWND hwnd); +using fnGetSystemMetricsForDpi = int (WINAPI*)(int nIndex, UINT dpi); +using fnSystemParametersInfoForDpi = BOOL (WINAPI*)(UINT uiAction, UINT uiParam, PVOID pvParam, UINT fWinIni, UINT dpi); +using fnSetThreadDpiAwarenessContext = DPI_AWARENESS_CONTEXT (WINAPI*)(DPI_AWARENESS_CONTEXT dpiContext); +using fnAdjustWindowRectExForDpi = BOOL (WINAPI*)(LPRECT lpRect, DWORD dwStyle, BOOL bMenu, DWORD dwExStyle, UINT dpi); + + +fnGetDpiForSystem _fnGetDpiForSystem = nullptr; +fnGetDpiForWindow _fnGetDpiForWindow = nullptr; +fnGetSystemMetricsForDpi _fnGetSystemMetricsForDpi = nullptr; +fnSystemParametersInfoForDpi _fnSystemParametersInfoForDpi = nullptr; +fnSetThreadDpiAwarenessContext _fnSetThreadDpiAwarenessContext = nullptr; +fnAdjustWindowRectExForDpi _fnAdjustWindowRectExForDpi = nullptr; + + +void DPIManagerV2::initDpiAPI() +{ + if (NppDarkMode::isWindows10()) + { + HMODULE hUser32 = ::GetModuleHandleW(L"user32.dll"); + if (hUser32 != nullptr) + { + ptrFn(hUser32, _fnGetDpiForSystem, "GetDpiForSystem"); + ptrFn(hUser32, _fnGetDpiForWindow, "GetDpiForWindow"); + ptrFn(hUser32, _fnGetSystemMetricsForDpi, "GetSystemMetricsForDpi"); + ptrFn(hUser32, _fnSystemParametersInfoForDpi, "SystemParametersInfoForDpi"); + ptrFn(hUser32, _fnSetThreadDpiAwarenessContext, "SetThreadDpiAwarenessContext"); + ptrFn(hUser32, _fnAdjustWindowRectExForDpi, "AdjustWindowRectExForDpi"); + + } + } +} + +int DPIManagerV2::getSystemMetricsForDpi(int nIndex, UINT dpi) +{ + if (_fnGetSystemMetricsForDpi != nullptr) + { + return _fnGetSystemMetricsForDpi(nIndex, dpi); + } + return DPIManagerV2::scale(::GetSystemMetrics(nIndex), dpi); +} + +DPI_AWARENESS_CONTEXT DPIManagerV2::setThreadDpiAwarenessContext(DPI_AWARENESS_CONTEXT dpiContext) +{ + if (_fnSetThreadDpiAwarenessContext != nullptr) + { + return _fnSetThreadDpiAwarenessContext(dpiContext); + } + return NULL; +} + +BOOL DPIManagerV2::adjustWindowRectExForDpi(LPRECT lpRect, DWORD dwStyle, BOOL bMenu, DWORD dwExStyle, UINT dpi) +{ + if (_fnAdjustWindowRectExForDpi != nullptr) + { + return _fnAdjustWindowRectExForDpi(lpRect, dwStyle, bMenu, dwExStyle, dpi); + } + return FALSE; +} + +UINT DPIManagerV2::getDpiForSystem() +{ + if (_fnGetDpiForSystem != nullptr) + { + return _fnGetDpiForSystem(); + } + + UINT dpi = USER_DEFAULT_SCREEN_DPI; + HDC hdc = ::GetDC(nullptr); + if (hdc != nullptr) + { + dpi = ::GetDeviceCaps(hdc, LOGPIXELSX); + ::ReleaseDC(nullptr, hdc); + } + return dpi; +} + +UINT DPIManagerV2::getDpiForWindow(HWND hWnd) +{ + if (_fnGetDpiForWindow != nullptr) + { + const auto dpi = _fnGetDpiForWindow(hWnd); + if (dpi > 0) + { + return dpi; + } + } + return getDpiForSystem(); +} + +void DPIManagerV2::setPositionDpi(LPARAM lParam, HWND hWnd, UINT flags) +{ + const auto prcNewWindow = reinterpret_cast(lParam); + + ::SetWindowPos(hWnd, + nullptr, + prcNewWindow->left, + prcNewWindow->top, + prcNewWindow->right - prcNewWindow->left, + prcNewWindow->bottom - prcNewWindow->top, + flags); +} + +LOGFONT DPIManagerV2::getDefaultGUIFontForDpi(UINT dpi, FontType type) +{ + int result = 0; + LOGFONT lf{}; + NONCLIENTMETRICS ncm{}; + ncm.cbSize = sizeof(NONCLIENTMETRICS); + if (_fnSystemParametersInfoForDpi != nullptr + && (_fnSystemParametersInfoForDpi(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, 0, dpi) != FALSE)) + { + result = 2; + } + else if (::SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, 0) != FALSE) + { + result = 1; + } + + if (result > 0) + { + switch (type) + { + case FontType::menu: + { + lf = ncm.lfMenuFont; + break; + } + + case FontType::status: + { + lf = ncm.lfStatusFont; + break; + } + + case FontType::caption: + { + lf = ncm.lfCaptionFont; + break; + } + + case FontType::smcaption: + { + lf = ncm.lfSmCaptionFont; + break; + } + //case FontType::message: + default: + { + lf = ncm.lfMessageFont; + break; + } + } + } + else // should not happen, fallback + { + auto hf = static_cast(::GetStockObject(DEFAULT_GUI_FONT)); + ::GetObject(hf, sizeof(LOGFONT), &lf); + } + + if (result < 2) + { + lf.lfHeight = scaleFont(lf.lfHeight, dpi); + } + + return lf; +} + +void DPIManagerV2::loadIcon(HINSTANCE hinst, const wchar_t* pszName, int cx, int cy, HICON* phico, UINT fuLoad) +{ + if (::LoadIconWithScaleDown(hinst, pszName, cx, cy, phico) != S_OK) + { + *phico = static_cast(::LoadImage(hinst, pszName, IMAGE_ICON, cx, cy, fuLoad)); + } +} diff --git a/NppPlugin/stdafx.cpp b/NppPlugin/stdafx.cpp index c0acfbdd..acb27776 100644 --- a/NppPlugin/stdafx.cpp +++ b/NppPlugin/stdafx.cpp @@ -4,9 +4,9 @@ #include "Common.h" #include "tchar.h" -generic_string GetLastErrorAsString(DWORD errorCode) +std::wstring GetLastErrorAsString(DWORD errorCode) { - generic_string errorMsg(_T("")); + std::wstring errorMsg(_T("")); // Get the error message, if any. // If both error codes (passed error n GetLastError) are 0, then return empty if (errorCode == 0) diff --git a/NppPlugin/stdafx.h b/NppPlugin/stdafx.h index d82a230c..fd87e9d6 100644 --- a/NppPlugin/stdafx.h +++ b/NppPlugin/stdafx.h @@ -3,11 +3,11 @@ // Modify the following defines if you have to target a platform prior to the ones specified below. // Refer to MSDN for the latest info on corresponding values for different platforms. #ifndef WINVER // Allow use of features specific to Windows XP or later. -#define WINVER 0x0501 // Change this to the appropriate value to target other versions of Windows. +#define WINVER 0x0A00 // Change this to the appropriate value to target other versions of Windows. #endif #ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later. -#define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows. +#define _WIN32_WINNT 0x0A00 // Change this to the appropriate value to target other versions of Windows. #endif #ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later. @@ -22,6 +22,8 @@ // Windows Header Files: #include #include +#include +#include #include typedef std::basic_string tstring; diff --git a/NppPluginIface_DocTabMap.cpp b/NppPluginIface_DocTabMap.cpp deleted file mode 100644 index 77ac08af..00000000 --- a/NppPluginIface_DocTabMap.cpp +++ /dev/null @@ -1,166 +0,0 @@ -/* NppPluginIface_DocTabMap.h - * - * This file is part of the Notepad++ Plugin Interface Lib. - * Copyright 2008 - 2009 Thell Fowler (thell@almostautomated.com) - * - * 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 the Free Software Foundation; either version - * 2 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with this program; - * if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -/* - * Notepad++ Plugin Interface Lib extension providing mapping of Notepad++ tab bufferID and - * visibility to Scintilla Document pointers, as well as tracking the currently open files - * by docID and a docId to bufferID map. - * - * For an example of using this see NppPluginIface_ActionIndex. - * - */ - - -#include "NppPluginIface_DocTabMap.h" - -#include -#include - -// <--- Notepad++ Scintilla Components for BufferID to pDoc ---> -#define TIXMLA_USE_STL -#include "Buffer.h" - -// <--- Boost ---> -#include -#include -#include -#include - - -namespace npp_plugin { - - -namespace doctabmap { - -// The main class for storing the document to buffer state information. -struct DocTab { - HWND _view; - int _tab; - BufferID _bufferID; - Document _pDoc; - bool _isVisible; - - DocTab( HWND view, int tab, BufferID bufferID, Document pDoc, bool isVisible) - :_view(view), _tab(tab), _bufferID(bufferID), _pDoc(pDoc), _isVisible(isVisible){}; -}; - - -// Boost mulit_index_container setup for tracking tab visibility states. -using boost::multi_index::multi_index_container; -using namespace boost::multi_index; - -// Namespace for the DocTab multi_index_container. -namespace doctabmap_mic { - -// DocTab_set index key for comp_visible_key. -struct dt_visible_key{}; - -// DocTab_set composite index key for unique view/visible combination. -struct comp_visible_key:composite_key< - DocTab, - BOOST_MULTI_INDEX_MEMBER(DocTab, HWND, _view), - BOOST_MULTI_INDEX_MEMBER(DocTab, bool, _isVisible) ->{}; - -// Multi Index Container for indexing N++ Doc Tab state data. -typedef multi_index_container< - DocTab, - indexed_by< - ordered_unique< tag, comp_visible_key > - > -> DocTab_set; - -// Index definition type for the DocTab_set container. -typedef DocTab_set::index::type dts_by_visibleTab; - -// The one and only DocTab_set container. -DocTab_set dts; - -// A set for storing active and ready open documents -std::set open_docs; - -// A map for storing buffer id to doc id. Usefull for doc open/close operations. -std::map< int, int > buff2doc_map; - -} // End namespace doctabmap_mic - -using namespace doctabmap_mic; - -// Public index to the DocTab_set. -dts_by_visibleTab& visibleTab_index = dts.get(); - -// Update the tab mapping between bufferIDs and pDocs for message filtering. -void update_DocTabMap() -{ - // Since there isn't a buffer-deactivate message to remove an entry we empty the set and - // rebuild on buffer activated messages. - if ( dts.size() > 0 ) { - dts.clear(); - open_docs.clear(); - } - - // Populate the DocTab_set - // The tab and buffer ID aren't really needed, yet I believe there may be some other - // uses for that information so they've been left in there. - bool isVisible = false; - for ( int view = MAIN_VIEW; view <= SUB_VIEW; view++ ) { - HWND targetView = hViewByInt(view); - Document viewDocID = (Document)::SendMessage( targetView, SCI_GETDOCPOINTER, 0, 0); - int nb_openfiles_view = ( view == MAIN_VIEW ) ? ( PRIMARY_VIEW ) : ( SECOND_VIEW ); - int nb_Tabs = ::SendMessage( hNpp(), NPPM_GETNBOPENFILES, 0, nb_openfiles_view ); - for ( int tab = 0; tab < nb_Tabs; tab++ ) { - int tabBuffID = ::SendMessage( hNpp(), NPPM_GETBUFFERIDFROMPOS, tab, view); - if ( tabBuffID > 0 ) { - BufferID pBuff = (BufferID)tabBuffID;; - Document pDoc = pBuff->getDocument(); - isVisible = ( pDoc == viewDocID ) ? ( true ) : ( false ); - dts.insert( - DocTab( targetView, tab, pBuff, pDoc, isVisible) - ); - open_docs.insert( (int)pDoc ); - if ( buff2doc_map.find( (int)pBuff ) == buff2doc_map.end() ) { - buff2doc_map[ (int)pBuff ] = (int)pDoc; - } - } - } - } -} - -// Returns the Scintilla Document ID for the visible document in the specified view. -// ( MAIN_VIEW = 0, SUB_VIEW = 1 ) -int getVisibleDocId_by_View( int view ) -{ - // The tuple is composed of the HWND for the view and a bool for 'is visible' to lookup - // the Doc ID based on the composite key from the index. - DocTab _DocTab = *(visibleTab_index.find( boost::make_tuple( hViewByInt( view ), true ) ) ); - - return ( _DocTab._pDoc ); -} - -// Returns the Scintilla Document ID matching a buffer ID. -int getDocIdFromBufferId( int bufferID ) { return ( buff2doc_map[bufferID] ); } - -// Returns true if a document is currently open and ready. -bool fileIsOpen( int pDoc ) -{ - if ( open_docs.find( pDoc ) != open_docs.end() ) return ( true ); - else return ( false ); -} - -} // End namespace: doctabmap - -} // End namespace: npp_plugin diff --git a/NppPluginIface_DocTabMap.h b/NppPluginIface_DocTabMap.h deleted file mode 100644 index 106d9ea8..00000000 --- a/NppPluginIface_DocTabMap.h +++ /dev/null @@ -1,48 +0,0 @@ -/* NppPluginIface_DocTabMap.h - * - * This file is part of the Notepad++ Plugin Interface Lib. - * Copyright 2008 - 2009 Thell Fowler (thell@almostautomated.com) - * - * 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 the Free Software Foundation; either version - * 2 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with this program; - * if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -/* - * Notepad++ Plugin Interface Lib extension providing mapping of Notepad++ tab bufferID and - * visibility to Scintilla Document pointers, as well as tracking the currently open files - * by docID and a docId to bufferID map. - * - * For an example of using this see NppPluginIface_ActionIndex. - * - */ - - -#ifndef NPP_PLUGININTERFACE_DOCTABMAP_EXTENSION_H -#define NPP_PLUGININTERFACE_DOCTABMAP_EXTENSION_H - -#include "NppPluginIface.h" - -namespace npp_plugin { - -namespace doctabmap { - - -void update_DocTabMap(); -int getVisibleDocId_by_View( int view ); -int getDocIdFromBufferId( int bufferID ); -bool fileIsOpen( int pDoc ); - - -} // End namespace: doctabmap - -} // End namespace: npp_plugin - -#endif // End include guard: NPP_PLUGININTERFACE_ACTIONINDEX_EXTENSION_H diff --git a/PythonLib/full/_sendkeys.py b/PythonLib/full/_sendkeys.py new file mode 100644 index 00000000..1c170860 --- /dev/null +++ b/PythonLib/full/_sendkeys.py @@ -0,0 +1,96 @@ +''' + +Sendkeys module moved back to ctypes. +For x64 systems, for example. + +(c) 2009 Igor S. Mandrigin, Agnitum Ltd. + +''' + +from ctypes import windll + +# from the internet +KEYEVENTF_KEYUP = 2 +VK_NUMLOCK = 144 +KEYEVENTF_EXTENDEDKEY = 1 +KEYEVENTF_KEYUP = 2 + + +def _key_down( vk ) : + + scan = windll.user32.MapVirtualKeyA( vk, 0 ) + windll.user32.keybd_event( vk, scan, 0, 0 ) + + + +def _key_up( vk ) : + + scan = windll.user32.MapVirtualKeyA( vk, 0 ) + windll.user32.keybd_event( vk, scan, KEYEVENTF_KEYUP, 0 ) + + + + +def toggle_numlock( turn_on ) : + ''' + toggle_numlock(int) -> int + + Turns NUMLOCK on or off and returns whether + it was originally on or off. + ''' + + is_on = 0 + keys = []; + + is_on = windll.user32.GetKeyState( VK_NUMLOCK ) & 1 + + if is_on != turn_on : + windll.user32.keybd_event(VK_NUMLOCK, + 69, + KEYEVENTF_EXTENDEDKEY | 0, + 0); + windll.user32.keybd_event(VK_NUMLOCK, + 69, + KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, + 0); + + + + return is_on + + +def char2keycode( char ) : + ''' + char2keycode(char) -> int + + Converts character to virtual key code + ''' + vk = windll.user32.VkKeyScanA( ord( char ) ) + return vk + + + +def key_down( key ) : + ''' + key_down(int) -> None + + Generates a key pressed event. Takes a + virtual key code. + ''' + vk = key + # XXX exception if >= 256 + _key_down( vk ) + + + +def key_up( key ) : + ''' + key_up(int) -> None + + Generates a key released event. Takes a + virtual key code. + ''' + + vk = key + # XXX exception if >= 256 + _key_up( vk ) diff --git a/PythonLib/full_dll/_sendkeys.pyd b/PythonLib/full_dll/_sendkeys.pyd deleted file mode 100644 index db3672e7..00000000 Binary files a/PythonLib/full_dll/_sendkeys.pyd and /dev/null differ diff --git a/PythonLib/min/_sendkeys.py b/PythonLib/min/_sendkeys.py new file mode 100644 index 00000000..1c170860 --- /dev/null +++ b/PythonLib/min/_sendkeys.py @@ -0,0 +1,96 @@ +''' + +Sendkeys module moved back to ctypes. +For x64 systems, for example. + +(c) 2009 Igor S. Mandrigin, Agnitum Ltd. + +''' + +from ctypes import windll + +# from the internet +KEYEVENTF_KEYUP = 2 +VK_NUMLOCK = 144 +KEYEVENTF_EXTENDEDKEY = 1 +KEYEVENTF_KEYUP = 2 + + +def _key_down( vk ) : + + scan = windll.user32.MapVirtualKeyA( vk, 0 ) + windll.user32.keybd_event( vk, scan, 0, 0 ) + + + +def _key_up( vk ) : + + scan = windll.user32.MapVirtualKeyA( vk, 0 ) + windll.user32.keybd_event( vk, scan, KEYEVENTF_KEYUP, 0 ) + + + + +def toggle_numlock( turn_on ) : + ''' + toggle_numlock(int) -> int + + Turns NUMLOCK on or off and returns whether + it was originally on or off. + ''' + + is_on = 0 + keys = []; + + is_on = windll.user32.GetKeyState( VK_NUMLOCK ) & 1 + + if is_on != turn_on : + windll.user32.keybd_event(VK_NUMLOCK, + 69, + KEYEVENTF_EXTENDEDKEY | 0, + 0); + windll.user32.keybd_event(VK_NUMLOCK, + 69, + KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, + 0); + + + + return is_on + + +def char2keycode( char ) : + ''' + char2keycode(char) -> int + + Converts character to virtual key code + ''' + vk = windll.user32.VkKeyScanA( ord( char ) ) + return vk + + + +def key_down( key ) : + ''' + key_down(int) -> None + + Generates a key pressed event. Takes a + virtual key code. + ''' + vk = key + # XXX exception if >= 256 + _key_down( vk ) + + + +def key_up( key ) : + ''' + key_up(int) -> None + + Generates a key released event. Takes a + virtual key code. + ''' + + vk = key + # XXX exception if >= 256 + _key_up( vk ) diff --git a/PythonScript.Tests/PythonScript.Tests.vcxproj b/PythonScript.Tests/PythonScript.Tests.vcxproj index c5447e8f..ae8f7ce1 100644 --- a/PythonScript.Tests/PythonScript.Tests.vcxproj +++ b/PythonScript.Tests/PythonScript.Tests.vcxproj @@ -133,7 +133,7 @@ Use Level3 Disabled - WIN32;_DEBUG;_CONSOLE;BOOST_PYTHON_STATIC_LIB;%(PreprocessorDefinitions) + WIN32;NOMINMAX;_DEBUG;_CONSOLE;BOOST_PYTHON_STATIC_LIB;%(PreprocessorDefinitions) gtest\googletest\include;..\PythonScript\src;$(BoostBase);%(AdditionalIncludeDirectories) MultiThreadedDebug true @@ -147,7 +147,9 @@ - $(TargetDir)$(TargetFileName) + copy $(PythonBase)\python27.dll $(TargetDir) + $(TargetDir)$(TargetFileName) + @@ -155,7 +157,7 @@ Use Level3 Disabled - WIN32;_DEBUG;_CONSOLE;BOOST_PYTHON_STATIC_LIB;%(PreprocessorDefinitions) + WIN32;NOMINMAX;_DEBUG;_CONSOLE;BOOST_PYTHON_STATIC_LIB;%(PreprocessorDefinitions) gtest\googletest\include;..\PythonScript\src;$(BoostBase);%(AdditionalIncludeDirectories) MultiThreadedDebug true @@ -169,7 +171,9 @@ - $(TargetDir)$(TargetFileName) + copy $(PythonBaseX64)\python27.dll $(TargetDir) + $(TargetDir)$(TargetFileName) + @@ -177,7 +181,7 @@ Use Level3 Disabled - WIN32;BOOST_DEBUG_PYTHON;BOOST_LINKING_PYTHON;_DEBUG;_CONSOLE;BOOST_PYTHON_STATIC_LIB;%(PreprocessorDefinitions) + WIN32;NOMINMAX;BOOST_DEBUG_PYTHON;BOOST_LINKING_PYTHON;_DEBUG;_CONSOLE;BOOST_PYTHON_STATIC_LIB;%(PreprocessorDefinitions) gtest\googletest\include;..\PythonScript\src;$(BoostBase);%(AdditionalIncludeDirectories) MultiThreadedDebug true @@ -191,7 +195,9 @@ - $(TargetDir)$(TargetFileName) + copy $(PythonBase)\python27.dll $(TargetDir) + $(TargetDir)$(TargetFileName) + @@ -199,7 +205,7 @@ Use Level3 Disabled - WIN32;BOOST_DEBUG_PYTHON;BOOST_LINKING_PYTHON;_DEBUG;_CONSOLE;BOOST_PYTHON_STATIC_LIB;%(PreprocessorDefinitions) + WIN32;NOMINMAX;BOOST_DEBUG_PYTHON;BOOST_LINKING_PYTHON;_DEBUG;_CONSOLE;BOOST_PYTHON_STATIC_LIB;%(PreprocessorDefinitions) gtest\googletest\include;..\PythonScript\src;$(BoostBase);%(AdditionalIncludeDirectories) MultiThreadedDebug true @@ -213,7 +219,9 @@ - $(TargetDir)$(TargetFileName) + copy $(PythonBaseX64)\python27.dll $(TargetDir) + $(TargetDir)$(TargetFileName) + @@ -223,7 +231,7 @@ MaxSpeed true true - WIN32;NDEBUG;_CONSOLE;BOOST_PYTHON_STATIC_LIB;%(PreprocessorDefinitions) + WIN32;NOMINMAX;NDEBUG;_CONSOLE;BOOST_PYTHON_STATIC_LIB;%(PreprocessorDefinitions) MultiThreaded gtest\googletest\include;..\PythonScript\src;$(BoostBase);%(AdditionalIncludeDirectories) true @@ -243,7 +251,7 @@ MaxSpeed true true - WIN32;NDEBUG;_CONSOLE;BOOST_PYTHON_STATIC_LIB;%(PreprocessorDefinitions) + WIN32;NOMINMAX;NDEBUG;_CONSOLE;BOOST_PYTHON_STATIC_LIB;%(PreprocessorDefinitions) MultiThreaded gtest\googletest\include;..\PythonScript\src;$(BoostBase);%(AdditionalIncludeDirectories) true @@ -275,6 +283,7 @@ + Create @@ -296,7 +305,7 @@ - Dieses Projekt verweist auf mindestens ein NuGet-Paket, das auf diesem Computer fehlt. Verwenden Sie die Wiederherstellung von NuGet-Paketen, um die fehlenden Dateien herunterzuladen. Weitere Informationen finden Sie unter "http://go.microsoft.com/fwlink/?LinkID=322105". Die fehlende Datei ist "{0}". + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. diff --git a/PythonScript.Tests/TestRunner.cpp b/PythonScript.Tests/TestRunner.cpp index a2284f78..ed6d6f9d 100644 --- a/PythonScript.Tests/TestRunner.cpp +++ b/PythonScript.Tests/TestRunner.cpp @@ -13,8 +13,7 @@ void deleteEntry(NppPythonScript::ReplaceEntry* entry) void runReplace() { - - NppPythonScript::Replacer replacer; + NppPythonScript::Replacer replacer; std::list entries; bool moreEntries = replacer.startReplace("aaabbbaaabb", 12, 0, 0, "(b+)", "x$1x", NppPythonScript::python_re_flag_normal, entries); ASSERT_EQ(2, entries.size()); @@ -26,26 +25,26 @@ void runReplace() int main(int argc, char* argv[]) { #ifdef _DEBUG - _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); -_CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_FILE ); -_CrtSetReportFile( _CRT_WARN, _CRTDBG_FILE_STDOUT ); -_CrtSetReportMode( _CRT_ERROR, _CRTDBG_MODE_FILE ); -_CrtSetReportFile( _CRT_ERROR, _CRTDBG_FILE_STDOUT ); -_CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_FILE ); -_CrtSetReportFile( _CRT_ASSERT, _CRTDBG_FILE_STDOUT ); + _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); + _CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_FILE ); + _CrtSetReportFile( _CRT_WARN, _CRTDBG_FILE_STDOUT ); + _CrtSetReportMode( _CRT_ERROR, _CRTDBG_MODE_FILE ); + _CrtSetReportFile( _CRT_ERROR, _CRTDBG_FILE_STDOUT ); + _CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_FILE ); + _CrtSetReportFile( _CRT_ASSERT, _CRTDBG_FILE_STDOUT ); _CrtMemState state; _CrtMemCheckpoint(&state); #endif - + ::testing::InitGoogleTest(&argc, argv); RUN_ALL_TESTS(); - + // This function call is used to check if we've created memory leaks using startReplace // Gtest creates various static objects, so it can be a bit tricky to identify leaks with Gtest running - // It's left commented out as it normally serves no purpose. If it looks like there's leaks, then remove the + // It's left commented out as it normally serves no purpose. If it looks like there's leaks, then remove the // test code above, and uncomment this runReplace() call to try to identify the source of the leak. - // runReplace(); + // runReplace(); #ifdef _DEBUG _CrtMemDumpAllObjectsSince(&state); diff --git a/PythonScript.Tests/gtest b/PythonScript.Tests/gtest index de5be0eb..b3a9ba2b 160000 --- a/PythonScript.Tests/gtest +++ b/PythonScript.Tests/gtest @@ -1 +1 @@ -Subproject commit de5be0eb28b74ecd6335e3bd61d9dc8914ce0e57 +Subproject commit b3a9ba2b8e975550799838332803d468797ae2e1 diff --git a/PythonScript.Tests/stdafx.h b/PythonScript.Tests/stdafx.h index 755dfdad..14738486 100644 --- a/PythonScript.Tests/stdafx.h +++ b/PythonScript.Tests/stdafx.h @@ -19,6 +19,7 @@ #include #include +#include #include #include @@ -29,9 +30,9 @@ #define WINVER 0x0501 // Change this to the appropriate value to target other versions of Windows. #endif -#ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later. +#ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later. #define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows. -#endif +#endif #ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later. #define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. @@ -42,7 +43,9 @@ #endif #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +#ifndef NOMINMAX #define NOMINMAX +#endif // Windows Header Files: #include #include @@ -52,10 +55,10 @@ #ifdef _DEBUG #define _CRTDBG_MAP_ALLOC #include - #ifndef DBG_NEW - #define DBG_NEW new ( _NORMAL_BLOCK , __FILE__ , __LINE__ ) - #define new DBG_NEW - #endif + #ifndef DBG_NEW + #define DBG_NEW new ( _NORMAL_BLOCK , __FILE__ , __LINE__ ) + #define new DBG_NEW + #endif #endif diff --git a/PythonScript.Tests/tests/TestMenuManager.cpp b/PythonScript.Tests/tests/TestMenuManager.cpp index 4fdbf080..bb58b19e 100644 --- a/PythonScript.Tests/tests/TestMenuManager.cpp +++ b/PythonScript.Tests/tests/TestMenuManager.cpp @@ -218,7 +218,7 @@ TEST_P(MenuManagerFindMenuCommandTest, testFindOptionFindsCorrectOption) { } -INSTANTIATE_TEST_CASE_P(findMenuCommand, MenuManagerFindMenuCommandTest, +INSTANTIATE_TEST_SUITE_P(findMenuCommand, MenuManagerFindMenuCommandTest, ::testing::Values(MenuTestCase(L"File", L"Open", MENUID_FILE_OPEN), // First option MenuTestCase(L"File", L"Close", MENUID_FILE_CLOSE), // First menu, middle option MenuTestCase(L"Edit", L"Copy", MENUID_EDIT_COPY), // Mid menu, first option @@ -245,7 +245,7 @@ TEST_P(MenuManagerFindPluginCommandTest, testFindPluginCommand) { } -INSTANTIATE_TEST_CASE_P(findPluginMenuCommand, MenuManagerFindPluginCommandTest, +INSTANTIATE_TEST_SUITE_P(findPluginMenuCommand, MenuManagerFindPluginCommandTest, ::testing::Values(MenuTestCase(L"XML Tools", L"About", MENUID_XMLTOOLS_ABOUT), // First plugin, last option MenuTestCase(L"Second Plugin", L"About", MENUID_SECONDPLUGIN_ABOUT), // Second plugin, repeated option name from other plugin MenuTestCase(L"XML Tools", L"Recent 1", MENUID_XMLTOOLS_RECENT_1), // First plugin, repeated option name from main menu diff --git a/PythonScript.sln b/PythonScript.sln index 343ddaf7..ff415a73 100644 --- a/PythonScript.sln +++ b/PythonScript.sln @@ -1,10 +1,13 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 +Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 VisualStudioVersion = 15.0.27130.2036 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NppPlugin", "NppPlugin\project\NppPlugin.vcxproj", "{69CC76EB-0183-4622-929C-02E860A66A23}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PythonScript", "PythonScript\project\PythonScript2010.vcxproj", "{8ACDC1F7-75BD-44CA-9F35-6521DEDC5DF6}" + ProjectSection(ProjectDependencies) = postProject + {69CC76EB-0183-4622-929C-02E860A66A23} = {69CC76EB-0183-4622-929C-02E860A66A23} + EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PythonScript.Tests", "PythonScript.Tests\PythonScript.Tests.vcxproj", "{141C090A-DF76-456E-8B54-1E2C9E5AE75A}" ProjectSection(ProjectDependencies) = postProject diff --git a/PythonScript/project/PythonScript2010.sln b/PythonScript/project/PythonScript2010.sln deleted file mode 100644 index 413541b5..00000000 --- a/PythonScript/project/PythonScript2010.sln +++ /dev/null @@ -1,41 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PythonScript", "PythonScript2010.vcxproj", "{8ACDC1F7-75BD-44CA-9F35-6521DEDC5DF6}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NppPlugin", "..\..\NppPlugin\project\NppPlugin.vcxproj", "{69CC76EB-0183-4622-929C-02E860A66A23}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug-ANSI|Win32 = Debug-ANSI|Win32 - DebugStartup|Win32 = DebugStartup|Win32 - Release|Win32 = Release|Win32 - Release-ANSI|Win32 = Release-ANSI|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {8ACDC1F7-75BD-44CA-9F35-6521DEDC5DF6}.Debug|Win32.ActiveCfg = Debug|Win32 - {8ACDC1F7-75BD-44CA-9F35-6521DEDC5DF6}.Debug|Win32.Build.0 = Debug|Win32 - {8ACDC1F7-75BD-44CA-9F35-6521DEDC5DF6}.Debug-ANSI|Win32.ActiveCfg = Debug-ANSI|Win32 - {8ACDC1F7-75BD-44CA-9F35-6521DEDC5DF6}.Debug-ANSI|Win32.Build.0 = Debug-ANSI|Win32 - {8ACDC1F7-75BD-44CA-9F35-6521DEDC5DF6}.DebugStartup|Win32.ActiveCfg = DebugStartup|Win32 - {8ACDC1F7-75BD-44CA-9F35-6521DEDC5DF6}.DebugStartup|Win32.Build.0 = DebugStartup|Win32 - {8ACDC1F7-75BD-44CA-9F35-6521DEDC5DF6}.Release|Win32.ActiveCfg = Release|Win32 - {8ACDC1F7-75BD-44CA-9F35-6521DEDC5DF6}.Release|Win32.Build.0 = Release|Win32 - {8ACDC1F7-75BD-44CA-9F35-6521DEDC5DF6}.Release-ANSI|Win32.ActiveCfg = Release-ANSI|Win32 - {8ACDC1F7-75BD-44CA-9F35-6521DEDC5DF6}.Release-ANSI|Win32.Build.0 = Release-ANSI|Win32 - {69CC76EB-0183-4622-929C-02E860A66A23}.Debug|Win32.ActiveCfg = Debug|Win32 - {69CC76EB-0183-4622-929C-02E860A66A23}.Debug|Win32.Build.0 = Debug|Win32 - {69CC76EB-0183-4622-929C-02E860A66A23}.Debug-ANSI|Win32.ActiveCfg = Debug-ANSI|Win32 - {69CC76EB-0183-4622-929C-02E860A66A23}.Debug-ANSI|Win32.Build.0 = Debug-ANSI|Win32 - {69CC76EB-0183-4622-929C-02E860A66A23}.DebugStartup|Win32.ActiveCfg = Debug|Win32 - {69CC76EB-0183-4622-929C-02E860A66A23}.DebugStartup|Win32.Build.0 = Debug|Win32 - {69CC76EB-0183-4622-929C-02E860A66A23}.Release|Win32.ActiveCfg = Release|Win32 - {69CC76EB-0183-4622-929C-02E860A66A23}.Release|Win32.Build.0 = Release|Win32 - {69CC76EB-0183-4622-929C-02E860A66A23}.Release-ANSI|Win32.ActiveCfg = Release-ANSI|Win32 - {69CC76EB-0183-4622-929C-02E860A66A23}.Release-ANSI|Win32.Build.0 = Release-ANSI|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/PythonScript/project/PythonScript2010.vcxproj b/PythonScript/project/PythonScript2010.vcxproj index 4386c130..4ffd5bc5 100644 --- a/PythonScript/project/PythonScript2010.vcxproj +++ b/PythonScript/project/PythonScript2010.vcxproj @@ -179,7 +179,7 @@ Use Level4 Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;PYTHONSCRIPT2010_EXPORTS;BOOST_PYTHON_STATIC_LIB;%(PreprocessorDefinitions) + NOMINMAX;WIN32;_DEBUG;_WINDOWS;_USRDLL;PYTHONSCRIPT2010_EXPORTS;BOOST_PYTHON_STATIC_LIB;%(PreprocessorDefinitions) MultiThreadedDebug ../include;../res;%(AdditionalIncludeDirectories) true @@ -202,7 +202,7 @@ xcopy $(ProjectDir)..\python_tests\*.* "e:\notepadtest\unicode\plugins\config\py Use Level4 Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;PYTHONSCRIPT2010_EXPORTS;BOOST_PYTHON_STATIC_LIB;%(PreprocessorDefinitions) + NOMINMAX;WIN32;_DEBUG;_WINDOWS;_USRDLL;PYTHONSCRIPT2010_EXPORTS;BOOST_PYTHON_STATIC_LIB;%(PreprocessorDefinitions) MultiThreadedDebug ../include;../res;%(AdditionalIncludeDirectories) true @@ -225,7 +225,7 @@ xcopy $(ProjectDir)..\python_tests\*.* "e:\notepadtest\unicode\plugins\config\py Use Level4 Disabled - WIN32;BOOST_DEBUG_PYTHON;BOOST_LINKING_PYTHON;_DEBUG;_WINDOWS;_USRDLL;PYTHONSCRIPT2010_EXPORTS;BOOST_PYTHON_STATIC_LIB;%(PreprocessorDefinitions) + NOMINMAX;WIN32;BOOST_DEBUG_PYTHON;BOOST_LINKING_PYTHON;_DEBUG;_WINDOWS;_USRDLL;PYTHONSCRIPT2010_EXPORTS;BOOST_PYTHON_STATIC_LIB;%(PreprocessorDefinitions) MultiThreadedDebug ../include;../res;%(AdditionalIncludeDirectories) true @@ -249,7 +249,7 @@ xcopy $(ProjectDir)..\python_tests\*.* "e:\notepadtest\unicode\plugins\config\py Use Level4 Disabled - WIN32;BOOST_DEBUG_PYTHON;BOOST_LINKING_PYTHON;_DEBUG;_WINDOWS;_USRDLL;PYTHONSCRIPT2010_EXPORTS;BOOST_PYTHON_STATIC_LIB;%(PreprocessorDefinitions) + NOMINMAX;WIN32;BOOST_DEBUG_PYTHON;BOOST_LINKING_PYTHON;_DEBUG;_WINDOWS;_USRDLL;PYTHONSCRIPT2010_EXPORTS;BOOST_PYTHON_STATIC_LIB;%(PreprocessorDefinitions) MultiThreadedDebug ../include;../res;%(AdditionalIncludeDirectories) true @@ -273,7 +273,7 @@ xcopy $(ProjectDir)..\python_tests\*.* "e:\notepadtest\unicode\plugins\config\py Use Level4 Disabled - DEBUG_STARTUP;WIN32;_DEBUG;_WINDOWS;_USRDLL;PYTHONSCRIPT2010_EXPORTS;BOOST_PYTHON_STATIC_LIB;%(PreprocessorDefinitions) + NOMINMAX;DEBUG_STARTUP;WIN32;_DEBUG;_WINDOWS;_USRDLL;PYTHONSCRIPT2010_EXPORTS;BOOST_PYTHON_STATIC_LIB;%(PreprocessorDefinitions) MultiThreadedDebug ../include;%(AdditionalIncludeDirectories) true @@ -294,7 +294,7 @@ xcopy $(ProjectDir)..\python_tests\*.* "e:\notepadtest\unicode\plugins\config\py Use Level4 Disabled - DEBUG_STARTUP;WIN32;_DEBUG;_WINDOWS;_USRDLL;PYTHONSCRIPT2010_EXPORTS;BOOST_PYTHON_STATIC_LIB;%(PreprocessorDefinitions) + NOMINMAX;DEBUG_STARTUP;WIN32;_DEBUG;_WINDOWS;_USRDLL;PYTHONSCRIPT2010_EXPORTS;BOOST_PYTHON_STATIC_LIB;%(PreprocessorDefinitions) MultiThreadedDebug ../include;%(AdditionalIncludeDirectories) true @@ -317,7 +317,7 @@ xcopy $(ProjectDir)..\python_tests\*.* "e:\notepadtest\unicode\plugins\config\py MaxSpeed true true - WIN32;NDEBUG;_WINDOWS;_USRDLL;PYTHONSCRIPT2010_EXPORTS;BOOST_PYTHON_STATIC_LIB;%(PreprocessorDefinitions) + NOMINMAX;WIN32;NDEBUG;_WINDOWS;_USRDLL;PYTHONSCRIPT2010_EXPORTS;BOOST_PYTHON_STATIC_LIB;%(PreprocessorDefinitions) MultiThreaded ../include;../res;%(AdditionalIncludeDirectories) true @@ -338,7 +338,7 @@ xcopy $(ProjectDir)..\python_tests\*.* "e:\notepadtest\unicode\plugins\config\py MaxSpeed true true - WIN32;NDEBUG;_WINDOWS;_USRDLL;PYTHONSCRIPT2010_EXPORTS;BOOST_PYTHON_STATIC_LIB;%(PreprocessorDefinitions) + NOMINMAX;WIN32;NDEBUG;_WINDOWS;_USRDLL;PYTHONSCRIPT2010_EXPORTS;BOOST_PYTHON_STATIC_LIB;%(PreprocessorDefinitions) MultiThreaded ../include;../res;%(AdditionalIncludeDirectories) true @@ -464,6 +464,7 @@ xcopy $(ProjectDir)..\python_tests\*.* "e:\notepadtest\unicode\plugins\config\py + @@ -518,6 +519,7 @@ xcopy $(ProjectDir)..\python_tests\*.* "e:\notepadtest\unicode\plugins\config\py + @@ -532,7 +534,7 @@ xcopy $(ProjectDir)..\python_tests\*.* "e:\notepadtest\unicode\plugins\config\py - Dieses Projekt verweist auf mindestens ein NuGet-Paket, das auf diesem Computer fehlt. Verwenden Sie die Wiederherstellung von NuGet-Paketen, um die fehlenden Dateien herunterzuladen. Weitere Informationen finden Sie unter "http://go.microsoft.com/fwlink/?LinkID=322105". Die fehlende Datei ist "{0}". + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. diff --git a/PythonScript/project/PythonScript2010.vcxproj.filters b/PythonScript/project/PythonScript2010.vcxproj.filters index e7456807..31499198 100644 --- a/PythonScript/project/PythonScript2010.vcxproj.filters +++ b/PythonScript/project/PythonScript2010.vcxproj.filters @@ -175,6 +175,9 @@ Source Files + + Source Files + @@ -384,6 +387,9 @@ Header Files + + Header Files + diff --git a/PythonScript/project/PythonSettings_appveyor.props b/PythonScript/project/PythonSettings_appveyor.props index db2aeffa..33c3bbcd 100644 --- a/PythonScript/project/PythonSettings_appveyor.props +++ b/PythonScript/project/PythonSettings_appveyor.props @@ -4,8 +4,8 @@ - $(SolutionDir)/packages/python2x86.2.7.18/tools - $(SolutionDir)/packages/python2.2.7.18/tools + $(SolutionDir)packages\python2x86.2.7.18\tools + $(SolutionDir)packages\python2.2.7.18\tools $(PythonBase)\libs $(PythonBaseX64)\libs C:\Program Files (x86)\HTML Help Workshop diff --git a/PythonScript/python_tests/RunTests.py b/PythonScript/python_tests/RunTests.py index d8b20396..39632db4 100644 --- a/PythonScript/python_tests/RunTests.py +++ b/PythonScript/python_tests/RunTests.py @@ -20,7 +20,7 @@ if hasattr(test_suite, 'suite'): test_suites.append(test_suite.suite) - + alltests = unittest.TestSuite(test_suites) console.show() @@ -41,7 +41,7 @@ def writeTestFailure(error): if results.errors: for error in results.errors: writeTestFailure(error) - + if results.failures: for error in results.failures: writeTestFailure(error) diff --git a/PythonScript/python_tests/tests/CP1252FileCase.py b/PythonScript/python_tests/tests/CP1252FileCase.py new file mode 100644 index 00000000..e36565df --- /dev/null +++ b/PythonScript/python_tests/tests/CP1252FileCase.py @@ -0,0 +1,18 @@ +# -*- coding: windows-1252 -*- +import unittest +from Npp import notepad, editor + +class CP1252FileCase(unittest.TestCase): + def setUp(self): + notepad.new() + + def tearDown(self): + editor.setSavePoint() + notepad.close() + + def test_simple_text_output(self): + editor.write('test123äöüß') + text = editor.getText() + self.assertEqual(text, 'test123äöüß') + +suite = unittest.TestLoader().loadTestsFromTestCase(CP1252FileCase) diff --git a/PythonScript/python_tests/tests/ConsoleTestCase.py b/PythonScript/python_tests/tests/ConsoleTestCase.py index 40bdc9e5..409951e1 100644 --- a/PythonScript/python_tests/tests/ConsoleTestCase.py +++ b/PythonScript/python_tests/tests/ConsoleTestCase.py @@ -1,6 +1,6 @@ -# -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- import unittest -from Npp import * +from Npp import console class ConsoleTestCase(unittest.TestCase): def setUp(self): @@ -17,4 +17,4 @@ def test_print_utf8_to_console(self): console.clear() -suite = unittest.TestLoader().loadTestsFromTestCase(ConsoleTestCase) \ No newline at end of file +suite = unittest.TestLoader().loadTestsFromTestCase(ConsoleTestCase) diff --git a/PythonScript/python_tests/tests/LineEndingMacTestCase.py b/PythonScript/python_tests/tests/LineEndingMacTestCase.py new file mode 100644 index 00000000..599923c9 --- /dev/null +++ b/PythonScript/python_tests/tests/LineEndingMacTestCase.py @@ -0,0 +1 @@ +# -*- coding: utf-8 -*- import unittest from Npp import notepad, editor class LineEndingMacTestCase(unittest.TestCase): def setUp(self): notepad.new() def tearDown(self): editor.setSavePoint() notepad.close() def test_simple_text_output(self): editor.write('test123äöüß') text = editor.getText() self.assertEqual(text, 'test123äöüß') suite = unittest.TestLoader().loadTestsFromTestCase(LineEndingMacTestCase) \ No newline at end of file diff --git a/PythonScript/python_tests/tests/LineEndingUnixTestCase.py b/PythonScript/python_tests/tests/LineEndingUnixTestCase.py new file mode 100644 index 00000000..973d6a74 --- /dev/null +++ b/PythonScript/python_tests/tests/LineEndingUnixTestCase.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +import unittest +from Npp import notepad, editor + +class LineEndingUnixTestCase(unittest.TestCase): + def setUp(self): + notepad.new() + + def tearDown(self): + editor.setSavePoint() + notepad.close() + + def test_simple_text_output(self): + editor.write('test123äöüß') + text = editor.getText() + self.assertEqual(text, 'test123äöüß') + +suite = unittest.TestLoader().loadTestsFromTestCase(LineEndingUnixTestCase) diff --git a/PythonScript/python_tests/tests/MathTestCase.py b/PythonScript/python_tests/tests/MathTestCase.py index 2b1661b9..853db995 100644 --- a/PythonScript/python_tests/tests/MathTestCase.py +++ b/PythonScript/python_tests/tests/MathTestCase.py @@ -10,6 +10,6 @@ def tearDown(self): def test_complex_abs(self): cplx = complex(-2, -1) - self.assertAlmostEqual(abs(cplx), 2.236067977, places = 6) + self.assertAlmostEqual(abs(cplx), 2.236067977, places = 6) -suite = unittest.TestLoader().loadTestsFromTestCase(MathTestCase) \ No newline at end of file +suite = unittest.TestLoader().loadTestsFromTestCase(MathTestCase) diff --git a/PythonScript/python_tests/tests/NotepadCallbackTestCase.py b/PythonScript/python_tests/tests/NotepadCallbackTestCase.py index 2159b7c3..5301aa42 100644 --- a/PythonScript/python_tests/tests/NotepadCallbackTestCase.py +++ b/PythonScript/python_tests/tests/NotepadCallbackTestCase.py @@ -1,19 +1,20 @@ +# -*- coding: utf-8 -*- import unittest import time import tempfile import os -from Npp import * +from Npp import notepad, editor, NOTIFICATION, LANGTYPE, SCINTILLANOTIFICATION globalCallbackCalled = False def dummy_callback(args): - global callbackCalled + global globalCallbackCalled editor.write('Dummy Callback called in error') globalCallbackCalled = True def global_poll_for_callback(timeout = 0.5, interval = 0.1): global globalCallbackCalled - while globalCallbackCalled == False and timeout > 0: + while (not globalCallbackCalled) and (timeout > 0): time.sleep(interval) timeout -= interval @@ -38,7 +39,7 @@ def get_temp_filename(self): return filename def poll_for_callback(self, timeout = 0.5, interval = 0.1): - while self.callbackCalled == False and timeout > 0: + while (not self.callbackCalled) and (timeout > 0): time.sleep(interval) timeout -= interval @@ -57,7 +58,7 @@ def callback_nested(self, args): if langType == LANGTYPE.PHP: # first call notepad.setLangType(LANGTYPE.PYTHON) elif langType == LANGTYPE.PYTHON: # second call - notepad.setLangType(LANGTYPE.XML) + notepad.setLangType(LANGTYPE.XML) elif langType == LANGTYPE.XML: self.callbackCalled = True @@ -162,13 +163,13 @@ def test_notepad_callback_from_editor_callback(self): def test_notepad_callback_with_disallowed_sync_method(self): - """This checks calling a method in a n++ callback, that is not allowed in - a synchronous Scintilla callback - specifically because N++ callbacks are synchronous, but + """This checks calling a method in a n++ callback, that is not allowed in + a synchronous Scintilla callback - specifically because N++ callbacks are synchronous, but allow all methods""" editor.write('File 1') notepad.saveAs(self.get_temp_filename()) - self.oldBufferID = notepad.getCurrentBufferID() + self.oldBufferID = notepad.getCurrentBufferID() notepad.new() editor.write('File 2') notepad.saveAs(self.get_temp_filename()) @@ -182,10 +183,10 @@ def test_notepad_callback_with_disallowed_sync_method(self): self.assertTrue(self.callbackCalled) self.assertEqual(self.oldBufferID, currentBufferID) - + def callback_with_disallowed_sync_method(self, args): notepad.activateBufferID(self.oldBufferID) self.callbackCalled = True -suite = unittest.TestLoader().loadTestsFromTestCase(NotepadCallbackTestCase) \ No newline at end of file +suite = unittest.TestLoader().loadTestsFromTestCase(NotepadCallbackTestCase) diff --git a/PythonScript/python_tests/tests/NotepadTestCase.py b/PythonScript/python_tests/tests/NotepadTestCase.py index a21721c0..9a0ca339 100644 --- a/PythonScript/python_tests/tests/NotepadTestCase.py +++ b/PythonScript/python_tests/tests/NotepadTestCase.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- import unittest -from Npp import * +from Npp import notepad, BUFFERENCODING, LANGTYPE class NotepadTestCase(unittest.TestCase): def setUp(self): @@ -28,7 +28,7 @@ def test_setLangType(self): notepad.new() buffer2 = notepad.getCurrentBufferID() notepad.setLangType(LANGTYPE.PHP) - + notepad.activateBufferID(buffer1) newBuffer1Lang = notepad.getLangType() notepad.activateBufferID(buffer2) @@ -37,10 +37,10 @@ def test_setLangType(self): notepad.close() notepad.activateBufferID(buffer1) notepad.close() - + self.assertEqual(newBuffer1Lang, LANGTYPE.C) self.assertEqual(newBuffer2Lang, LANGTYPE.PHP) -suite = unittest.TestLoader().loadTestsFromTestCase(NotepadTestCase) \ No newline at end of file +suite = unittest.TestLoader().loadTestsFromTestCase(NotepadTestCase) diff --git a/PythonScript/python_tests/tests/NotepadWrapperTestCase.py b/PythonScript/python_tests/tests/NotepadWrapperTestCase.py index e0a9c7c1..db3ddaf9 100644 --- a/PythonScript/python_tests/tests/NotepadWrapperTestCase.py +++ b/PythonScript/python_tests/tests/NotepadWrapperTestCase.py @@ -4,13 +4,14 @@ import os import shlex import tempfile -import ctypes, ctypes.wintypes +import ctypes +import ctypes.wintypes import xml.etree.ElementTree as et import time from threading import Timer import subprocess -from Npp import notepad, editor, console, WINVER, LANGTYPE, MENUCOMMAND, BUFFERENCODING +from Npp import notepad, editor, console, WINVER, LANGTYPE, MENUCOMMAND, BUFFERENCODING, LINENUMWIDTHMODE EnumWindowsProc = ctypes.WINFUNCTYPE(ctypes.c_bool, ctypes.wintypes.HWND, @@ -30,6 +31,7 @@ def setUp(self): def tearDown(self): for file in self.files_to_delete: os.remove(file) + notepad.showDocSwitcher(False) # helper functions @@ -63,7 +65,15 @@ def _get_config_directory(self): def _get_active_styler_xml(self): npp_config_file = os.path.join(self._get_config_directory(), r'config.xml') xml_doc = et.parse(npp_config_file) - return xml_doc.find('GUIConfigs/GUIConfig[@name="stylerTheme"]').get('path') + darkmode_enabled = xml_doc.find('GUIConfigs/GUIConfig[@name="DarkMode"]').get('enable') + darkThemeName = xml_doc.find('GUIConfigs/GUIConfig[@name="DarkMode"]').get('darkThemeName') + lightThemeName = xml_doc.find('GUIConfigs/GUIConfig[@name="DarkMode"]').get('lightThemeName') + themepath = os.path.join(self._get_config_directory(), r'stylers.xml') + if(darkmode_enabled != 'no'): + themepath = os.path.join(self._get_config_directory(), r'themes', darkThemeName) + elif(lightThemeName != ''): + themepath = os.path.join(self._get_config_directory(), r'themes', lightThemeName) + return themepath def _get_current_lang_xml(self): @@ -87,12 +97,12 @@ def _invalid_parameter_passed(self, method, *args): try: method(*args) except Exception as e: - if 'did not match C++ signature' in e.message: + if 'did not match C++ signature' in str(e): raise ArgumentError - elif 'invalid aka unknown bufferID provided' in e.message: + elif 'invalid aka unknown bufferID provided' in str(e): raise ArgumentError else: - raise Exception('args:{} - message:{}'.format(args, e.message)) + raise Exception('args:{} - message:{}'.format(args, str(e))) def __test_invalid_parameter_passed(self, notepad_method): @@ -112,6 +122,7 @@ def __test_invalid_parameter_passed(self, notepad_method): self._invalid_parameter_passed(notepad_method, -1,-1,-1) + doc_switcher_found = False @staticmethod def foreach_window(hwnd, lParam): if ctypes.windll.user32.IsWindowVisible(hwnd): @@ -120,24 +131,27 @@ def foreach_window(hwnd, lParam): buffer = ctypes.create_unicode_buffer(length) ctypes.windll.user32.GetWindowTextW(hwnd, buffer, length) if buffer.value == ctypes.wstring_at(lParam): + NotepadTestCase.doc_switcher_found = True return False return True def find_child_window(self, caption): - return not ctypes.windll.user32.EnumChildWindows(NPP_HANDLE, + NotepadTestCase.doc_switcher_found = False + ctypes.windll.user32.EnumChildWindows(NPP_HANDLE, EnumWindowsProc(self.foreach_window), ctypes.create_unicode_buffer(caption)) + return NotepadTestCase.doc_switcher_found # old tests - + def test_setEncoding(self): notepad.new() - notepad.setEncoding(BUFFERENCODING.UTF8) + self.assertTrue(notepad.setEncoding(BUFFERENCODING.UTF8)) encoding = notepad.getEncoding() self.assertEqual(encoding, BUFFERENCODING.UTF8) - notepad.setEncoding(BUFFERENCODING.ANSI) + self.assertTrue(notepad.setEncoding(BUFFERENCODING.ANSI)) encoding = notepad.getEncoding() self.assertEqual(encoding, BUFFERENCODING.ANSI) notepad.close() @@ -177,22 +191,22 @@ def test_save(self): def test_saveAs(self): notepad.new() - notepad.setEncoding(BUFFERENCODING.ANSI) + self.assertTrue(notepad.setEncoding(BUFFERENCODING.ANSI)) editor.write('Hello world - saveAs') filename = self.get_temp_filename() - notepad.saveAs(filename) + self.assertTrue(notepad.saveAs(filename)) notepad.close() self.check_file_contents(filename, 'Hello world - saveAs') def test_saveAsCopy(self): notepad.new() - notepad.setEncoding(BUFFERENCODING.ANSI) + self.assertTrue(notepad.setEncoding(BUFFERENCODING.ANSI)) editor.write('Hello world - saveAsCopy') realFilename = self.get_temp_filename() copyFilename = self.get_temp_filename() - notepad.saveAs(realFilename) - notepad.saveAsCopy(copyFilename) + self.assertTrue(notepad.saveAs(realFilename)) + self.assertTrue(notepad.saveAsCopy(copyFilename)) editor.appendText('-OriginalChanged') notepad.save() notepad.close() @@ -205,7 +219,7 @@ def test_open(self): f = open(filename, "w") f.write('Test - open') f.close() - notepad.open(filename) + self.assertTrue(notepad.open(filename)) text = editor.getText() notepad.close() @@ -254,13 +268,13 @@ def test_getFiles(self): notepad.new() editor.write('File 1') file1 = self.get_temp_filename() - notepad.saveAs(file1) + self.assertTrue(notepad.saveAs(file1)) bufferID1 = notepad.getCurrentBufferID() index1 = notepad.getCurrentDocIndex(0) notepad.new() editor.write('File 2') file2 = self.get_temp_filename() - notepad.saveAs(file2) + self.assertTrue(notepad.saveAs(file2)) bufferID2 = notepad.getCurrentBufferID() index2 = notepad.getCurrentDocIndex(0) @@ -290,10 +304,10 @@ def test_saveLoadSession(self): # Create and open two files file1 = self.get_temp_filename() file2 = self.get_temp_filename() - notepad.open(file1) + self.assertTrue(notepad.open(file1)) editor.write('File 1 session') notepad.save() - notepad.open(file2) + self.assertTrue(notepad.open(file2)) editor.write('File 2 session') notepad.save() @@ -302,19 +316,19 @@ def test_saveLoadSession(self): notepad.saveSession(sessionFile, [file1, file2]) # Close the files - notepad.activateFile(file1) + self.assertTrue(notepad.activateFile(file1)) notepad.close() - notepad.activateFile(file2) + self.assertTrue(notepad.activateFile(file2)) notepad.close() # Load the session back notepad.loadSession(sessionFile) # Check the files are there again - notepad.activateFile(file1) + self.assertTrue(notepad.activateFile(file1)) file1Content = editor.getText() notepad.close() - notepad.activateFile(file2) + self.assertTrue(notepad.activateFile(file2)) file2Content = editor.getText() notepad.close() @@ -329,7 +343,7 @@ def test_getSessionFiles(self): notepad.open(file1) editor.write('File 1 session') notepad.save() - notepad.open(file2) + self.assertTrue(notepad.open(file2)) editor.write('File 2 session') notepad.save() @@ -338,9 +352,9 @@ def test_getSessionFiles(self): notepad.saveSession(sessionFile, [file1, file2]) sessionFiles = notepad.getSessionFiles(sessionFile) - notepad.activateFile(file1) + self.assertTrue(notepad.activateFile(file1)) notepad.close() - notepad.activateFile(file2) + self.assertTrue(notepad.activateFile(file2)) notepad.close() normalisedSessionFiles = [self.normalise_filename(f) for f in sessionFiles] self.assertEqual(normalisedSessionFiles, [self.normalise_filename(file1), self.normalise_filename(file2)]) @@ -354,16 +368,16 @@ def test_saveCurrentSession(self): notepad.open(file1) editor.write('File 1 session') notepad.save() - notepad.open(file2) + self.assertTrue(notepad.open(file2)) editor.write('File 2 session') notepad.save() sessionFile = self.get_temp_filename() notepad.saveCurrentSession(sessionFile) - notepad.activateFile(file1) + self.assertTrue(notepad.activateFile(file1)) notepad.close() - notepad.activateFile(file2) + self.assertTrue(notepad.activateFile(file2)) notepad.close() sessionFiles = notepad.getSessionFiles(sessionFile) @@ -374,15 +388,62 @@ def test_saveCurrentSession(self): def test_reloadFile(self): + + WM_CLOSE = 0x010 + WM_COMMAND = 0x0111 + IDC_CHECK_UPDATESILENTLY = 0x18A9 # decimal 6313 + def prepare_silent_file_updates(): + def set_silent_updates(hwnd, lParam): + curr_class = ctypes.create_unicode_buffer(256) + ctypes.windll.user32.GetClassNameW(hwnd, curr_class, 256) + + length = ctypes.windll.user32.GetWindowTextLengthW(hwnd) + buff = ctypes.create_unicode_buffer(length + 1) + ctypes.windll.user32.GetWindowTextW(hwnd, buff, length + 1) + + if curr_class.value.lower() == u'button' and buff.value == u'Update silently': + BM_SETCHECK = 0xF1 + # BST_UNCHECKED = 0 + BST_CHECKED = 1 + + ctypes.windll.user32.SendMessageW(hwnd,BM_SETCHECK, BST_CHECKED, None) + return False + + return True # let enumeration continue + + def store_silent_updates(hwnd, lParam): + curr_class = ctypes.create_unicode_buffer(256) + ctypes.windll.user32.GetClassNameW(hwnd, curr_class, 256) + + length = ctypes.windll.user32.GetWindowTextLengthW(hwnd) + buff = ctypes.create_unicode_buffer(length + 1) + ctypes.windll.user32.GetWindowTextW(hwnd, buff, length + 1) + + if curr_class.value == u'#32770': + #FOR_DEBUGGING print(curr_class.value) + ctypes.windll.user32.SendMessageW(hwnd,WM_COMMAND, IDC_CHECK_UPDATESILENTLY, 0) + return True # let enumeration continue as it is unclear if the right sub dlg was found + + return True # let enumeration continue + + notepad.menuCommand(MENUCOMMAND.SETTING_PREFERENCE) + preferences_dialog = ctypes.windll.user32.FindWindowW(None, u'Preferences') + ctypes.windll.user32.EnumChildWindows(preferences_dialog, EnumWindowsProc(set_silent_updates), 0) + ctypes.windll.user32.EnumChildWindows(preferences_dialog, EnumWindowsProc(store_silent_updates), 0) + ctypes.windll.user32.SendMessageW(preferences_dialog, WM_CLOSE, 0, 0) + + prepare_silent_file_updates() + notepad.new() editor.write('Reload test') filename = self.get_temp_filename() - notepad.saveAs(filename) + self.assertTrue(notepad.saveAs(filename)) f = open(filename, "w") f.write('Updated outside') f.close() beforeReload = editor.getText() - notepad.reloadFile(filename, False) + # TODO: See https://github.com/notepad-plus-plus/notepad-plus-plus/issues/12418 + self.assertTrue(notepad.reloadFile(filename, False)) afterReload = editor.getText() notepad.close() @@ -390,18 +451,21 @@ def test_reloadFile(self): self.assertEqual(afterReload, 'Updated outside') def test_getPluginConfigDir(self): - dir = notepad.getPluginConfigDir() - self.assertTrue(dir.lower().endswith('plugins\\config')) + cur_dir = notepad.getPluginConfigDir() + self.assertTrue(cur_dir.lower().endswith('plugins\\config')) def test_nppCommandLineDir(self): - dir = notepad.getNppDir() + cur_dir = notepad.getNppDir() commandLine = notepad.getCommandLine() - nppExe = shlex.split(commandLine)[0] + commandLine = commandLine.lstrip('\"') + nppExe = shlex.split(commandLine, posix=False)[0] nppDirOfExe = os.path.dirname(nppExe) - - self.assertEqual(dir, nppDirOfExe) + if nppDirOfExe: + self.assertEqual(cur_dir, nppDirOfExe, msg="Expected same value, got: {} vs. {}".format(cur_dir, nppDirOfExe)) + else: + self.assertTrue(len(commandLine) != 0) # new tests @@ -464,6 +528,21 @@ def test_allocateMarker(self): # test functionality + def test_allocateIndicator(self): + ''' ''' + notepad_method = notepad.allocateIndicator + with self.assertRaises(ArgumentError): + self._invalid_parameter_passed(notepad_method) + with self.assertRaises(ArgumentError): + self._invalid_parameter_passed(notepad_method, '') + with self.assertRaises(ArgumentError): + self._invalid_parameter_passed(notepad_method, -1,-1) + with self.assertRaises(ArgumentError): + self._invalid_parameter_passed(notepad_method, 0,0) + # test return code + # test functionality + + def test_allocateSupported(self): ''' ''' self.__test_invalid_parameter_passed(notepad.allocateSupported) @@ -502,8 +581,8 @@ def test_closeAllButCurrent(self): # test return code # test functionality - # TODO: NPP BUG - Crash - # + # TODO: NPP BUG - Crash + # # def test_createScintilla(self): # ''' ''' # self.__test_invalid_parameter_passed(notepad.createScintilla) @@ -528,7 +607,7 @@ def test_decodeSci(self): self.assertEqual(editor.getCodePage(), 0) notepad.close() - # TODO: NPP BUG - Crash + # TODO: NPP BUG - Crash @unittest.skipUnless(notepad.getVersion() > (7,5,8), "NPP BUG STILL EXISTS") def test_destroyScintilla(self): ''' ''' @@ -548,6 +627,9 @@ def test_destroyScintilla(self): def test_disableAutoUpdate(self): ''' ''' WM_CLOSE = 0x010 + WM_COMMAND = 0x0111 + IDC_CHECK_AUTOUPDATE = 0x18B3 # decimal 6323 + def start_and_immediately_stop_new_npp_instance(): process = subprocess.Popen([r'notepad++.exe', '-multiInst']) process_id = ctypes.windll.kernel32.GetProcessId(int(process._handle)) @@ -568,7 +650,7 @@ def find_newly_created_npp_instance(hwnd, lparam): ctypes.windll.user32.EnumWindows(EnumWindowsProc(find_newly_created_npp_instance), process_id) def prepare_auto_updater(): - def reset_auto_updater(hwnd, lParam): + def set_auto_updater(hwnd, lParam): curr_class = ctypes.create_unicode_buffer(256) ctypes.windll.user32.GetClassNameW(hwnd, curr_class, 256) @@ -578,23 +660,39 @@ def reset_auto_updater(hwnd, lParam): if curr_class.value.lower() == u'button' and buff.value == u'Enable Notepad++ auto-updater': BM_SETCHECK = 0xF1 - BST_UNCHECKED = 0 + # BST_UNCHECKED = 0 BST_CHECKED = 1 - ctypes.windll.user32.SendMessageW(hwnd,BM_SETCHECK, BST_UNCHECKED, None) ctypes.windll.user32.SendMessageW(hwnd,BM_SETCHECK, BST_CHECKED, None) return False return True # let enumeration continue + def store_auto_updater(hwnd, lParam): + curr_class = ctypes.create_unicode_buffer(256) + ctypes.windll.user32.GetClassNameW(hwnd, curr_class, 256) + + length = ctypes.windll.user32.GetWindowTextLengthW(hwnd) + buff = ctypes.create_unicode_buffer(length + 1) + ctypes.windll.user32.GetWindowTextW(hwnd, buff, length + 1) + + if curr_class.value == u'#32770': + #FOR_DEBUGGING print(curr_class.value) + ctypes.windll.user32.SendMessageW(hwnd,WM_COMMAND, IDC_CHECK_AUTOUPDATE, 0) + return True # let enumeration continue as it is unclear if the right sub dlg was found + + return True # let enumeration continue + + notepad.menuCommand(MENUCOMMAND.SETTING_PREFERENCE) - prefernces_dialog = ctypes.windll.user32.FindWindowW(None, u'Preferences') - ctypes.windll.user32.EnumChildWindows(prefernces_dialog, EnumWindowsProc(reset_auto_updater), 0) - ctypes.windll.user32.SendMessageW(prefernces_dialog, WM_CLOSE, 0, 0) + preferences_dialog = ctypes.windll.user32.FindWindowW(None, u'Preferences') + ctypes.windll.user32.EnumChildWindows(preferences_dialog, EnumWindowsProc(set_auto_updater), 0) + ctypes.windll.user32.EnumChildWindows(preferences_dialog, EnumWindowsProc(store_auto_updater), 0) + ctypes.windll.user32.SendMessageW(preferences_dialog, WM_CLOSE, 0, 0) self.__test_invalid_parameter_passed(notepad.disableAutoUpdate) - updater_exe = os.path.join(notepad.getNppDir(), u'updater\gup.exe') + updater_exe = os.path.join(notepad.getNppDir(), u'updater\\gup.exe') self.assertTrue(os.path.exists(updater_exe), msg=('Wrong test setup!!\n' 'It is needed to have a file called gup.exe under updater directory\n' 'Create one and restart npp and the test')) @@ -609,7 +707,9 @@ def reset_auto_updater(hwnd, lParam): self.assertEqual(self._get_disable_update_xml(), 'no') prepare_auto_updater() - def test_docSwitcherDisableColumn(self): + + doc_switcher_control_value_found = False + def test_docSwitcherDisableExtColumn(self): ''' ''' def search_for_doc_switcher(hwnd, lParam): if ctypes.windll.user32.IsWindowVisible(hwnd): @@ -627,11 +727,13 @@ def search_for_doc_switcher_controls(hwnd, lParam): ctypes.windll.user32.GetClassNameW(hwnd, curr_class, 256) if curr_class.value == 'SysHeader32': - if ctypes.windll.user32.SendMessageW(hwnd, 0x1200, 0, 0) == lParam: + HDM_GETITEMCOUNT = 0x1200 + if ctypes.windll.user32.SendMessageW(hwnd, HDM_GETITEMCOUNT, 0, 0) == lParam: + self.doc_switcher_control_value_found = True return False return True - notepad_method = notepad.docSwitcherDisableColumn + notepad_method = notepad.docSwitcherDisableExtColumn with self.assertRaises(ArgumentError): self._invalid_parameter_passed(notepad_method) with self.assertRaises(ArgumentError): @@ -642,28 +744,30 @@ def search_for_doc_switcher_controls(hwnd, lParam): self._invalid_parameter_passed(notepad_method, False,False) control_dict = {} - self.assertIsNone(notepad.docSwitcherDisableColumn(False)) + self.assertIsNone(notepad.docSwitcherDisableExtColumn(False)) notepad.showDocSwitcher(True) ctypes.windll.user32.EnumChildWindows(NPP_HANDLE, EnumWindowsProc(search_for_doc_switcher), - ctypes.create_unicode_buffer(u'Doc Switcher')) + ctypes.create_unicode_buffer(u'Document List')) - return_code = ctypes.windll.user32.EnumChildWindows(control_dict.get(u'Doc Switcher'), + self.doc_switcher_control_value_found = False + ctypes.windll.user32.EnumChildWindows(control_dict.get(u'Document List'), EnumWindowsProc(search_for_doc_switcher_controls), 2) - self.assertEqual(return_code, 0) + self.assertTrue(self.doc_switcher_control_value_found) - self.assertIsNone(notepad.docSwitcherDisableColumn(True)) + self.assertIsNone(notepad.docSwitcherDisableExtColumn(True)) ctypes.windll.user32.EnumChildWindows(NPP_HANDLE, EnumWindowsProc(search_for_doc_switcher), - ctypes.create_unicode_buffer(u'Doc Switcher')) + ctypes.create_unicode_buffer(u'Document List')) - return_code = ctypes.windll.user32.EnumChildWindows(control_dict.get(u'Doc Switcher'), + self.doc_switcher_control_value_found = False + ctypes.windll.user32.EnumChildWindows(control_dict.get(u'Document List'), EnumWindowsProc(search_for_doc_switcher_controls), 1) - self.assertEqual(return_code, 0) + self.assertTrue(self.doc_switcher_control_value_found) notepad.showDocSwitcher(False) @@ -948,7 +1052,7 @@ def test_hideTabBar(self): with self.assertRaises(ArgumentError): self._invalid_parameter_passed(notepad_method, '') hidden_tab_bar = notepad.hideTabBar() - self.assertIsNone(hidden_tab_bar) + self.assertFalse(hidden_tab_bar) self.assertTrue(notepad.isTabBarHidden()) @@ -977,12 +1081,12 @@ def test_isDocSwitcherShown(self): doc_switcher_shown = notepad.isDocSwitcherShown() self.assertIsInstance(doc_switcher_shown, bool) - res = self.find_child_window(u'Doc Switcher') + res = self.find_child_window(u'Document List') self.assertEqual(doc_switcher_shown, res) notepad.showDocSwitcher(True) doc_switcher_shown = notepad.isDocSwitcherShown() - res = self.find_child_window(u'Doc Switcher') + res = self.find_child_window(u'Document List') self.assertEqual(doc_switcher_shown, res) notepad.showDocSwitcher(False) @@ -1047,9 +1151,9 @@ def foreach_window(hwnd, lParam): ctypes.windll.user32.GetWindowTextW(hwnd, buff, length + 1) if curr_class.value.lower() == 'static': - if buff.value == 'Filter&s :': + if buff.value == 'Filter&s:': control_dict['filter'] = '' - elif buff.value == 'Dir&ectory :': + elif buff.value == 'Dir&ectory:': control_dict['directory'] = '' elif curr_class.value.lower() == 'edit': if control_dict.get('filter', None) == '': @@ -1256,22 +1360,18 @@ def test_saveAllFiles(self): def test_saveFile(self): ''' ''' self.__test_invalid_parameter_passed(notepad.saveFile) - self.assertIsNone(notepad.saveFile('')) + self.assertFalse(notepad.saveFile('')) tmpfile = self.get_temp_filename() - notepad.open(tmpfile) + self.assertTrue(notepad.open(tmpfile)) text_to_be_saved = 'example_text' editor.addText(text_to_be_saved) - with open(tmpfile, 'r') as f: - _content = f.read() + self.check_file_contents(tmpfile, '') - self.assertEqual(_content, '') + self.assertTrue(notepad.saveFile(tmpfile)) - notepad.saveFile(tmpfile) - with open(tmpfile, 'r') as f: - _content = f.read() + self.check_file_contents(tmpfile, text_to_be_saved) - self.assertEqual(_content, text_to_be_saved) notepad.close() @@ -1351,11 +1451,11 @@ def test_showDocSwitcher(self): self._invalid_parameter_passed(notepad_method, -1,-1,-1) self.assertIsNone(notepad.showDocSwitcher(True)) - res = self.find_child_window(u'Doc Switcher') + res = self.find_child_window(u'Document List') self.assertTrue(res) self.assertIsNone(notepad.showDocSwitcher(False)) - res = self.find_child_window(u'Doc Switcher') + res = self.find_child_window(u'Document List') self.assertFalse(res) @@ -1400,7 +1500,8 @@ def start_monitor(): menu_handle = ctypes.windll.user32.SendMessageW(tabbar_context_menu_hwnd, MN_GETHMENU, 0, 0) item_count = ctypes.windll.user32.GetMenuItemCount(menu_handle) - self.assertEqual(item_count, 28, msg=u'Expected 28 menu items but received:{}'.format(item_count)) + # TODO: a hard-coded value is quite bad + self.assertEqual(item_count, 17, msg=u'Expected 17 menu items but received:{}'.format(item_count)) ctypes.windll.user32.SendMessageW(tabbar_context_menu_hwnd, WM_CLOSE, 0, 0) timer = Timer(1, start_monitor) @@ -1415,8 +1516,144 @@ def test_getPluginHomePath(self): self.assertTrue('plugins' == plugin_dir) + def test_getSettingsOnCloudPath(self): + ''' Check if cloud path last part has default empty ''' + self.__test_invalid_parameter_passed(notepad.getSettingsOnCloudPath) + _, _, cloud_dir = notepad.getSettingsOnCloudPath().rpartition('\\') + self.assertTrue('' == cloud_dir) + + + def test_setUntitledName(self): + ''' ''' + notepad_method = notepad.setUntitledName + with self.assertRaises(ArgumentError): + self._invalid_parameter_passed(notepad_method) + with self.assertRaises(ArgumentError): + self._invalid_parameter_passed(notepad_method, None,None) + with self.assertRaises(ArgumentError): + self._invalid_parameter_passed(notepad_method, None,None,None) + with self.assertRaises(ArgumentError): + self._invalid_parameter_passed(notepad_method, -1) + with self.assertRaises(ArgumentError): + self._invalid_parameter_passed(notepad_method, -1,-1,-1) + with self.assertRaises(ArgumentError): + self._invalid_parameter_passed(notepad_method, '','') + + + def test_getTabColorID(self): + ''' ''' + notepad_method = notepad.getTabColorID + with self.assertRaises(ArgumentError): + self._invalid_parameter_passed(notepad_method, None) + with self.assertRaises(ArgumentError): + self._invalid_parameter_passed(notepad_method, None,None) + with self.assertRaises(ArgumentError): + self._invalid_parameter_passed(notepad_method, None,None,None) + with self.assertRaises(ArgumentError): + self._invalid_parameter_passed(notepad_method, -1,-1,-1) + with self.assertRaises(ArgumentError): + self._invalid_parameter_passed(notepad_method, '','') + with self.assertRaises(ArgumentError): + self._invalid_parameter_passed(notepad_method, '42','42') + + # first get the configured colors + notepad.menuCommand(MENUCOMMAND.VIEW_TAB_COLOUR_NONE) + tab_colour_none = notepad.getTabColorID() + notepad.menuCommand(MENUCOMMAND.VIEW_TAB_COLOUR_1) + tab_color_1 = notepad.getTabColorID() + notepad.menuCommand(MENUCOMMAND.VIEW_TAB_COLOUR_2) + tab_color_2 = notepad.getTabColorID() + notepad.menuCommand(MENUCOMMAND.VIEW_TAB_COLOUR_3) + tab_color_3 = notepad.getTabColorID() + notepad.menuCommand(MENUCOMMAND.VIEW_TAB_COLOUR_4) + tab_color_4 = notepad.getTabColorID() + notepad.menuCommand(MENUCOMMAND.VIEW_TAB_COLOUR_5) + tab_color_5 = notepad.getTabColorID() + + # test + notepad.menuCommand(MENUCOMMAND.VIEW_TAB_COLOUR_NONE) + self.assertTrue(tab_colour_none == notepad.getTabColorID()) + notepad.menuCommand(MENUCOMMAND.VIEW_TAB_COLOUR_1) + self.assertTrue(tab_color_1== notepad.getTabColorID()) + notepad.menuCommand(MENUCOMMAND.VIEW_TAB_COLOUR_2) + self.assertTrue(tab_color_2== notepad.getTabColorID()) + notepad.menuCommand(MENUCOMMAND.VIEW_TAB_COLOUR_3) + self.assertTrue(tab_color_3== notepad.getTabColorID()) + notepad.menuCommand(MENUCOMMAND.VIEW_TAB_COLOUR_4) + self.assertTrue(tab_color_4== notepad.getTabColorID()) + notepad.menuCommand(MENUCOMMAND.VIEW_TAB_COLOUR_5) + self.assertTrue(tab_color_5== notepad.getTabColorID()) + + + def test_getNativeLangFileName(self): + ''' ''' + self.__test_invalid_parameter_passed(notepad.getNativeLangFileName) + + + def test_lineNumberWidthMode(self): + ''' ''' + self.__test_invalid_parameter_passed(notepad.getLineNumberWidthMode) + self.__test_invalid_parameter_passed(notepad.setLineNumberWidthMode) + + mode = notepad.getLineNumberWidthMode() + if notepad.setLineNumberWidthMode(LINENUMWIDTHMODE.CONSTANT if mode == LINENUMWIDTHMODE.DYNAMIC else LINENUMWIDTHMODE.DYNAMIC): + changed_mode = notepad.getLineNumberWidthMode() + self.assertTrue(changed_mode != mode, msg="Expected different modes, got {} and {}".format(mode, changed_mode)) + if notepad.setLineNumberWidthMode(LINENUMWIDTHMODE.CONSTANT if mode == LINENUMWIDTHMODE.CONSTANT else LINENUMWIDTHMODE.DYNAMIC): + revert_changed_mode = notepad.getLineNumberWidthMode() + self.assertTrue(revert_changed_mode == mode, msg="Expected same modes, got {} and {}".format(mode, changed_mode)) + + # TODO: How can this be tested in a meaningful way? + def test_getExternalLexerAutoIndentMode(self): + ''' ''' + notepad_method = notepad.getExternalLexerAutoIndentMode + with self.assertRaises(ArgumentError): + self._invalid_parameter_passed(notepad_method, None,None) + with self.assertRaises(ArgumentError): + self._invalid_parameter_passed(notepad_method, None,None,None) + with self.assertRaises(ArgumentError): + self._invalid_parameter_passed(notepad_method, -1) + with self.assertRaises(ArgumentError): + self._invalid_parameter_passed(notepad_method, -1,-1,-1) + with self.assertRaises(ArgumentError): + self._invalid_parameter_passed(notepad_method, '','') + + # TODO: How can this be tested in a meaningful way? + def test_setExternalLexerAutoIndentMode(self): + ''' ''' + self.__test_invalid_parameter_passed(notepad.setExternalLexerAutoIndentMode) + + # TODO: How can this be tested in a meaningful way? + def test_isAutoIndention(self): + ''' ''' + self.__test_invalid_parameter_passed(notepad.isAutoIndention) + + def test_activateFile(self): + # Create and open two files + file1 = self.get_temp_filename() + file2 = self.get_temp_filename() + self.assertTrue(notepad.open(file1)) + self.assertTrue(notepad.open(file2)) + + # open two temp files + notepad.new() + temp_1 = notepad.getCurrentFilename() + notepad.new() + temp_2 = notepad.getCurrentFilename() + + self.assertTrue(notepad.activateFile(file1)) + notepad.close() + self.assertTrue(notepad.activateFile(temp_1)) + notepad.close() + self.assertTrue(notepad.activateFile(file2)) + notepad.close() + self.assertTrue(notepad.activateFile(temp_2)) + notepad.close() + + +suite = unittest.TestLoader().loadTestsFromTestCase(NotepadTestCase) + if __name__ == '__main__': - suite = unittest.TestLoader().loadTestsFromTestCase(NotepadTestCase) alltests = unittest.TestSuite(suite) results = unittest.TestResult() @@ -1439,10 +1676,7 @@ def writeTestFailure(error): console.writeError('Tests Run: {}\n Errors : {}\n Failures: {}\n'.format(results.testsRun, len(results.errors), len(results.failures))) else: console.write('Tests Run: {}\n Errors : {}\n Failures: {}\n'.format(results.testsRun, len(results.errors), len(results.failures))) - if results.skipped: - console.write('Skipped: {}\n'.format(len(results.skipped))) - for skipped_test in results.skipped: - console.write(' {} - {}\n'.format(skipped_test[0], skipped_test[1])) - console.show() -else: - suite = unittest.TestLoader().loadTestsFromTestCase(NotepadTestCase) \ No newline at end of file + if results.skipped: + console.write('Skipped: {}\n'.format(len(results.skipped))) + for skipped_test in results.skipped: + console.write(' {} - {}\n'.format(skipped_test[0], skipped_test[1])) diff --git a/PythonScript/python_tests/tests/ReplaceAnsiPythonFunction.py b/PythonScript/python_tests/tests/ReplaceAnsiPythonFunction.py index 39366648..9e4f3f0f 100644 --- a/PythonScript/python_tests/tests/ReplaceAnsiPythonFunction.py +++ b/PythonScript/python_tests/tests/ReplaceAnsiPythonFunction.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- import unittest from Npp import notepad, editor @@ -19,7 +19,7 @@ def group1_with_counter(m): - + class ReplaceAnsiPythonFunctionTestCase(unittest.TestCase): def setUp(self): @@ -28,25 +28,27 @@ def setUp(self): notepad.new() notepad.runMenuCommand("Encoding", "Convert to ANSI") editor.write(u'abc123 def5432 gh98\r\näbc123 üef5432 öh98\r\n'.encode('windows-1252')) - + def tearDown(self): editor.setSavePoint() notepad.close() - + + @unittest.skipIf(notepad.getPluginVersion()[0] == '3', "not yet py3-compatible") def test_replace_function(self): editor.rereplace(r'([a-z]+)([0-9]+)'.encode('windows-1252'), group2_with_counter) text = editor.getText() self.assertEqual(text, u'1231 54322 983\r\nä1234 ü54325 ö986\r\n'.encode('windows-1252')) - + + @unittest.skipIf(notepad.getPluginVersion()[0] == '3', "not yet py3-compatible") def test_unicode_replace_function(self): editor.rereplace(ur'([a-zäöü]+)([0-9]+)', group1_with_counter) text = editor.getText() self.assertEqual(text, u'abc1 def2 gh3\r\näbc4 üef5 öh6\r\n'.encode('windows-1252')) - + def groups_check(self, m): global counter counter += 1 - groups_data_correct = { 1 : ('abc', '123'), + groups_data_correct = { 1 : ('abc', '123'), 2 : ('def', '5432'), 3 : ('gh', '98'), 4 : (u'äbc'.encode('windows-1252'), '123'), @@ -55,22 +57,25 @@ def groups_check(self, m): self.assertEqual(m.groups(), groups_data_correct[counter]) return counter + @unittest.skipIf(notepad.getPluginVersion()[0] == '3', "not yet py3-compatible") def test_groups(self): editor.rereplace(ur'([a-zäöü]+)([0-9]+)', lambda m: self.groups_check(m)) text = editor.getText() self.assertEqual(text, '1 2 3\r\n4 5 6\r\n') - + @unittest.skipIf(notepad.getPluginVersion()[0] == '3', "not yet py3-compatible") def test_groups_with_named_groups(self): editor.rereplace(ur'(?[a-zäöü]+)(?[0-9]+)', lambda m: self.groups_check(m)) text = editor.getText() self.assertEqual(text, '1 2 3\r\n4 5 6\r\n') + @unittest.skipIf(notepad.getPluginVersion()[0] == '3', "not yet py3-compatible") def test_named_groups(self): editor.rereplace(ur'(?[a-zäöü]+)(?[0-9]+)', lambda m: m.group('letters')) text = editor.getText() self.assertEqual(text, u'abc def gh\r\näbc üef öh\r\n'.encode('windows-1252')) + @unittest.skipIf(notepad.getPluginVersion()[0] == '3', "not yet py3-compatible") def test_named_groups_2(self): editor.rereplace(ur'(?[a-zäöü]+)(?[0-9]+)', lambda m: m.group('numbers')) text = editor.getText() @@ -80,7 +85,7 @@ def test_named_groups_2(self): def group_tuples_check(self, m): global counter counter += 1 - groups_data_correct = { 1 : ('123', 'abc', '123'), + groups_data_correct = { 1 : ('123', 'abc', '123'), 2 : ('5432', 'def', '5432'), 3 : ('98', 'gh', '98'), 4 : ('123', '\xe4bc', '123'), @@ -88,7 +93,8 @@ def group_tuples_check(self, m): 6 : ('98', u'öh'.encode('windows-1252'), '98') } self.assertEqual(m.group(2, 'letters', 'numbers'), groups_data_correct[counter]) return counter - + + @unittest.skipIf(notepad.getPluginVersion()[0] == '3', "not yet py3-compatible") def test_group_tuples(self): editor.rereplace(ur'(?[a-zäöü]+)(?[0-9]+)', lambda m: self.group_tuples_check(m)) text = editor.getText() diff --git a/PythonScript/python_tests/tests/ReplaceAnsiTestCase.py b/PythonScript/python_tests/tests/ReplaceAnsiTestCase.py index ed520b7b..1e0fcdbf 100644 --- a/PythonScript/python_tests/tests/ReplaceAnsiTestCase.py +++ b/PythonScript/python_tests/tests/ReplaceAnsiTestCase.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- import unittest from Npp import notepad, editor @@ -6,27 +6,32 @@ class ReplaceAnsiTestCase(unittest.TestCase): def setUp(self): notepad.new() notepad.runMenuCommand("Encoding", "Convert to ANSI") - editor.write(u'Here is some text\r\nWith some umlauts XäXüXö\r\n'.encode('windows-1252')); - + editor.write(u'Here is some text\r\nWith some umlauts XäXüXö\r\n'.encode('windows-1252')) + + def tearDown(self): editor.setSavePoint() notepad.close() - + + @unittest.skipIf(notepad.getPluginVersion()[0] == '3', "not yet py3-compatible") def test_simple_replace(self): - editor.rereplace(r'some\s([a-z]+)', 'TEST'); + editor.rereplace(r'some\s([a-z]+)', 'TEST') text = editor.getText() - self.assertEqual(text, u'Here is TEST\r\nWith TEST XäXüXö\r\n'.encode('windows-1252')); - + self.assertEqual(text, u'Here is TEST\r\nWith TEST XäXüXö\r\n'.encode('windows-1252')) + + @unittest.skipIf(notepad.getPluginVersion()[0] == '3', "not yet py3-compatible") def test_ansi_replace(self): - editor.rereplace(u'X[äö]'.encode('windows-1252'), 'YY'); + editor.rereplace(u'X[äö]'.encode('windows-1252'), 'YY') text = editor.getText() - self.assertEqual(text, u'Here is some text\r\nWith some umlauts YYXüYY\r\n'.encode('windows-1252')); + self.assertEqual(text, u'Here is some text\r\nWith some umlauts YYXüYY\r\n'.encode('windows-1252')) + @unittest.skipIf(notepad.getPluginVersion()[0] == '3', "not yet py3-compatible") def test_unicode_replace(self): - editor.rereplace(u'X[äö]', 'PP'); + editor.rereplace(u'X[äö]', 'PP') text = editor.getText() - self.assertEqual(text, u'Here is some text\r\nWith some umlauts PPXüPP\r\n'.encode('windows-1252')); + self.assertEqual(text, u'Here is some text\r\nWith some umlauts PPXüPP\r\n'.encode('windows-1252')) + @unittest.skipIf(notepad.getPluginVersion()[0] == '3', "not yet py3-compatible") def test_replace_with_unicode(self): editor.rereplace('Here|With', u'XäöüY') text = editor.getText() diff --git a/PythonScript/python_tests/tests/ReplaceCountTestCase.py b/PythonScript/python_tests/tests/ReplaceCountTestCase.py index a58072a8..66a761f9 100644 --- a/PythonScript/python_tests/tests/ReplaceCountTestCase.py +++ b/PythonScript/python_tests/tests/ReplaceCountTestCase.py @@ -1,31 +1,31 @@ # -*- coding: utf-8 -*- import unittest import re -from Npp import * +from Npp import notepad, editor class ReplaceStartEndTestCase(unittest.TestCase): def setUp(self): notepad.new() notepad.runMenuCommand("Encoding", "Encode in UTF-8") editor.write(u'Abc123DEF4567 ghi8910\r\nAbc123\r\n') - + def tearDown(self): editor.setSavePoint() notepad.close() - + def test_replace_limit_3(self): - editor.rereplace(r'([A-Z]{3})', 'TEST', re.IGNORECASE, 0, 0, 3) + editor.rereplace(r'([A-Z]{3})', 'TEST', re.IGNORECASE, 0, -1, 3) text = editor.getText() self.assertEqual(text, u'TEST123TEST4567 TEST8910\r\nAbc123\r\n') - + def test_replace_limit_2(self): - editor.rereplace(r'([A-Z]{3})', 'TEST', re.IGNORECASE, 0, 0, 2) + editor.rereplace(r'([A-Z]{3})', 'TEST', re.IGNORECASE, 0, -1, 2) text = editor.getText() self.assertEqual(text, u'TEST123TEST4567 ghi8910\r\nAbc123\r\n') - + def test_replace_literal_count_1(self): - editor.replace(r'Abc', 'TEST', re.IGNORECASE, 0, 0, 1) + editor.replace(r'Abc', 'TEST', re.IGNORECASE, 0, -1, 1) text = editor.getText() self.assertEqual(text, u'TEST123DEF4567 ghi8910\r\nAbc123\r\n') diff --git a/PythonScript/python_tests/tests/ReplaceFlagsTestCase.py b/PythonScript/python_tests/tests/ReplaceFlagsTestCase.py index 1c83195a..aa7c7370 100644 --- a/PythonScript/python_tests/tests/ReplaceFlagsTestCase.py +++ b/PythonScript/python_tests/tests/ReplaceFlagsTestCase.py @@ -1,23 +1,23 @@ -# -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- import unittest import re -from Npp import * +from Npp import notepad, editor class ReplaceFlagsTestCase(unittest.TestCase): def setUp(self): notepad.new() notepad.runMenuCommand("Encoding", "Encode in UTF-8") editor.write(u'Abc123DEF4567 ghi8910\r\nAbc123\r\n') - + def tearDown(self): editor.setSavePoint() notepad.close() - + def test_replace_is_case_sensitive(self): editor.rereplace(r'([A-Z]{3})', 'TEST') text = editor.getText() self.assertEqual(text, u'Abc123TEST4567 ghi8910\r\nAbc123\r\n') - + def test_replace_case_insensitive(self): editor.rereplace(r'([A-Z]{3})', 'TEST', re.IGNORECASE) text = editor.getText() diff --git a/PythonScript/python_tests/tests/ReplacePlainTestCase.py b/PythonScript/python_tests/tests/ReplacePlainTestCase.py index c7d11cbd..616ad783 100644 --- a/PythonScript/python_tests/tests/ReplacePlainTestCase.py +++ b/PythonScript/python_tests/tests/ReplacePlainTestCase.py @@ -1,27 +1,26 @@ # -*- coding: utf-8 -*- import unittest -from Npp import * -import re +from Npp import notepad, editor class ReplacePlainTestCase(unittest.TestCase): def setUp(self): notepad.new() notepad.runMenuCommand("Encoding", "Encode in UTF-8") - editor.write('Some text with ([abc]+) embedded regex\r\n'); - + editor.write('Some text with ([abc]+) embedded regex\r\n') + def tearDown(self): editor.setSavePoint() notepad.close() - + def test_plain_replace(self): - editor.replace(r'([abc]+)', 'TEST'); + editor.replace(r'([abc]+)', 'TEST') text = editor.getText() - self.assertEqual(text, 'Some text with TEST embedded regex\r\n'); + self.assertEqual(text, 'Some text with TEST embedded regex\r\n') def check_plain_search(self, m): self.called = True self.assertEqual('([abc]+)', m.group()) - + def test_plain_search(self): self.called = False editor.search(r'([abc]+)', lambda m: self.check_plain_search(m)) diff --git a/PythonScript/python_tests/tests/ReplaceStartEndTestCase.py b/PythonScript/python_tests/tests/ReplaceStartEndTestCase.py index 7f7a2587..09d60eb3 100644 --- a/PythonScript/python_tests/tests/ReplaceStartEndTestCase.py +++ b/PythonScript/python_tests/tests/ReplaceStartEndTestCase.py @@ -1,29 +1,29 @@ # -*- coding: utf-8 -*- import unittest import re -from Npp import * +from Npp import notepad, editor class ReplaceStartEndTestCase(unittest.TestCase): def setUp(self): notepad.new() notepad.runMenuCommand("Encoding", "Encode in UTF-8") editor.write(u'Abc123DEF4567 ghi8910\r\nAbc123\r\n') - + def tearDown(self): editor.setSavePoint() notepad.close() - + def test_replace_start_later(self): editor.rereplace(r'([A-Z]{3})', 'TEST', re.IGNORECASE, 3) text = editor.getText() self.assertEqual(text, u'Abc123TEST4567 TEST8910\r\nTEST123\r\n') - + def test_replace_start_later_end_sooner(self): editor.rereplace(r'([A-Z]{3})', 'TEST', re.IGNORECASE, 3, 18) text = editor.getText() self.assertEqual(text, u'Abc123TEST4567 TEST8910\r\nAbc123\r\n') - + def test_replace_literal_start_later(self): editor.rereplace(r'Abc', 'TEST', re.IGNORECASE, 3) text = editor.getText() @@ -39,7 +39,7 @@ def test_replace_literal_start_later_end_sooner_2(self): text = editor.getText() self.assertEqual(text, u'AbcTESTDEF4567 ghi8910\r\nAbc123\r\n') - def test_replace_literal_start_later_end_sooner_2(self): + def test_replace_literal_start_later_end_sooner_3(self): editor.replace('123', 'TEST', re.IGNORECASE, 4, 18) text = editor.getText() self.assertEqual(text, u'Abc123DEF4567 ghi8910\r\nAbc123\r\n') diff --git a/PythonScript/python_tests/tests/ReplaceTestLastIndex.py b/PythonScript/python_tests/tests/ReplaceTestLastIndex.py index c87bb609..9ee5b479 100644 --- a/PythonScript/python_tests/tests/ReplaceTestLastIndex.py +++ b/PythonScript/python_tests/tests/ReplaceTestLastIndex.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- import unittest -from Npp import * +from Npp import notepad, editor class ReplaceLastIndex(unittest.TestCase): @@ -9,21 +9,21 @@ def setUp(self): counter = 0 notepad.new() notepad.runMenuCommand("Encoding", "Encode in UTF-8") - + def tearDown(self): editor.setSavePoint() notepad.close() - + def test_lastindex_normal(self): editor.write('abcX123') - editor.rereplace('(abc)(X)([0-9]+)', lambda m: self.assertEquals(m.lastindex, 3)) - + editor.rereplace('(abc)(X)([0-9]+)', lambda m: self.assertEqual(m.lastindex, 3)) + def test_lastindex_empty(self): editor.write('abcX') - editor.rereplace('(abc)(X)([0-9]*)', lambda m: self.assertEquals(m.lastindex, 3)) - + editor.rereplace('(abc)(X)([0-9]*)', lambda m: self.assertEqual(m.lastindex, 3)) + def test_lastindex_notmatched(self): editor.write('abcX') - editor.rereplace('(abc)(X)([0-9]+)?', lambda m: self.assertEquals(m.lastindex, 2)) + editor.rereplace('(abc)(X)([0-9]+)?', lambda m: self.assertEqual(m.lastindex, 2)) suite = unittest.TestLoader().loadTestsFromTestCase(ReplaceLastIndex) diff --git a/PythonScript/python_tests/tests/ReplaceUTF8PythonFunction.py b/PythonScript/python_tests/tests/ReplaceUTF8PythonFunction.py index b56e9c77..9e648bfb 100644 --- a/PythonScript/python_tests/tests/ReplaceUTF8PythonFunction.py +++ b/PythonScript/python_tests/tests/ReplaceUTF8PythonFunction.py @@ -1,6 +1,6 @@ -# -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- import unittest -from Npp import * +from Npp import notepad, editor counter = 0 @@ -19,7 +19,7 @@ def group1_with_counter(m): - + class ReplaceUTF8PythonFunctionTestCase(unittest.TestCase): def setUp(self): @@ -28,25 +28,25 @@ def setUp(self): notepad.new() notepad.runMenuCommand("Encoding", "Encode in UTF-8") editor.write('abc123 def5432 gh98\r\näbc123 üef5432 öh98\r\n') - + def tearDown(self): editor.setSavePoint() notepad.close() - + def test_replace_function(self): editor.rereplace(r'([a-z]+)([0-9]+)', group2_with_counter) text = editor.getText() self.assertEqual(text, '1231 54322 983\r\nä1234 ü54325 ö986\r\n') - + def test_utf8_replace_function(self): editor.rereplace(r'([a-zäöü]+)([0-9]+)', group1_with_counter) text = editor.getText() self.assertEqual(text, 'abc1 def2 gh3\r\näbc4 üef5 öh6\r\n') - + def groups_check(self, m): global counter counter += 1 - groups_data_correct = { 1 : ('abc', '123'), + groups_data_correct = { 1 : ('abc', '123'), 2 : ('def', '5432'), 3 : ('gh', '98'), 4 : ('äbc', '123'), @@ -80,7 +80,7 @@ def test_named_groups_2(self): def group_tuples_check(self, m): global counter counter += 1 - groups_data_correct = { 1 : ('123', 'abc', '123'), + groups_data_correct = { 1 : ('123', 'abc', '123'), 2 : ('5432', 'def', '5432'), 3 : ('98', 'gh', '98'), 4 : ('123', 'äbc', '123'), @@ -88,7 +88,7 @@ def group_tuples_check(self, m): 6 : ('98', 'öh', '98') } self.assertEqual(m.group(2, 'letters', 'numbers'), groups_data_correct[counter]) return counter - + def test_group_tuples(self): editor.rereplace(r'(?[a-zäöü]+)(?[0-9]+)', lambda m: self.group_tuples_check(m)) text = editor.getText() @@ -146,7 +146,7 @@ def test_span(self): editor.rereplace(r'([a-z]+)([0-9]+)', lambda m: self.span_check(m)) text = editor.getText() self.assertEqual(text, '1 2 3\r\nä4 ü5 ö6\r\n') - + def test_not_supported_groupdict(self): with self.assertRaisesRegexp(RuntimeError, r"not supported under Notepad\+\+"): editor.rereplace(r'([a-z]+)', lambda m: m.groupdict()[0]) @@ -172,5 +172,5 @@ def test_group_index_invalid(self): def test_group_name_invalid(self): with self.assertRaisesRegexp(IndexError, "no such group"): editor.rereplace(r'(?[a-z]+)(?[0-9]+)', lambda m: m.group('somethingelse')) - + suite = unittest.TestLoader().loadTestsFromTestCase(ReplaceUTF8PythonFunctionTestCase) diff --git a/PythonScript/python_tests/tests/ReplaceUTF8TestCase.py b/PythonScript/python_tests/tests/ReplaceUTF8TestCase.py index 3358e8c2..2c27249c 100644 --- a/PythonScript/python_tests/tests/ReplaceUTF8TestCase.py +++ b/PythonScript/python_tests/tests/ReplaceUTF8TestCase.py @@ -1,27 +1,27 @@ -# -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- import unittest -from Npp import * +from Npp import notepad, editor class ReplaceUTF8TestCase(unittest.TestCase): def setUp(self): notepad.new() notepad.runMenuCommand("Encoding", "Encode in UTF-8") - editor.write('Here is some text\r\nWith some umlauts XäXüXö\r\n'); - + editor.write('Here is some text\r\nWith some umlauts XäXüXö\r\n') + def tearDown(self): editor.setSavePoint() notepad.close() - + def test_simple_replace(self): - editor.rereplace(r'some\s([a-z]+)', 'TEST'); + editor.rereplace(r'some\s([a-z]+)', 'TEST') text = editor.getText() - self.assertEqual(text, 'Here is TEST\r\nWith TEST XäXüXö\r\n'); - + self.assertEqual(text, 'Here is TEST\r\nWith TEST XäXüXö\r\n') + def test_utf8_replace(self): - editor.rereplace(r'X[äö]', 'YY'); + editor.rereplace(r'X[äö]', 'YY') text = editor.getText() - self.assertEqual(text, 'Here is some text\r\nWith some umlauts YYXüYY\r\n'); - + self.assertEqual(text, 'Here is some text\r\nWith some umlauts YYXüYY\r\n') + def test_replace_condition(self): editor.rereplace('(Here)|(Xä)', '(?1Cheese)(?2Y)') text = editor.getText() diff --git a/PythonScript/python_tests/tests/ScintillaCallbackTestCase.py b/PythonScript/python_tests/tests/ScintillaCallbackTestCase.py index b2723162..5a523170 100644 --- a/PythonScript/python_tests/tests/ScintillaCallbackTestCase.py +++ b/PythonScript/python_tests/tests/ScintillaCallbackTestCase.py @@ -1,17 +1,18 @@ +# -*- coding: utf-8 -*- import unittest import time -from Npp import * +from Npp import notepad, editor, SCINTILLANOTIFICATION, MODIFICATIONFLAGS globalCallbackCalled = False def dummy_callback(args): - global callbackCalled + global globalCallbackCalled editor.write('Dummy Callback called in error') globalCallbackCalled = True def global_poll_for_callback(timeout = 0.5, interval = 0.1): global globalCallbackCalled - while globalCallbackCalled == False and timeout > 0: + while (not globalCallbackCalled) and (timeout > 0): time.sleep(interval) timeout -= interval @@ -39,10 +40,10 @@ def disabled_test_callback_updateui(self): editor.write('test update ui') self.poll_for_callback() self.assertEqual(self.called, True) - + def modified_callback(self, args): - pass + pass def test_modified_callback(self): # Although the callback doesn't do anything, this checks that when lots of callbacks are generated in succession @@ -76,7 +77,7 @@ def test_nested_callbacks(self): text = editor.getText() self.assertEqual(self.callbackCalled, True) # Check the callbacks were called one after another in the right order - self.assertEqual(text, "rootchange1change2") + self.assertEqual(text, "rootchange1change2") def callback_register_2(self, args): if args['modificationType'] & 1 == 0: # ignore modifications that aren't SC_MOD_INSERTTEXT @@ -85,7 +86,7 @@ def callback_register_2(self, args): editor.write('change3') elif args['text'] == 'change3': self.callbackCalled = True - + def callback_register_in_callback(self, args): # Order: # 1. test_register_callback_in_callback writes 'root', triggers the callback @@ -112,7 +113,7 @@ def test_register_callback_in_callback(self): text = editor.getText() self.assertEqual(text, 'rootchange1change2change3') - + def callback_for_remove(self, args): self.callbackCalled = True @@ -155,7 +156,7 @@ def test_remove_callback_via_method_and_notification(self): self.assertFalse(globalCallbackCalled) self.assertTrue(self.callbackCalled) # the second callback should still have been called - + def test_sync_modified_callback(self): editor.write('start\r\n') @@ -167,7 +168,7 @@ def test_sync_modified_callback(self): self.assertEqual(self.callbackResults['modifiedText'], 'change\r\n') self.assertEqual(text, 'start\r\nchange\r\n') self.assertEqual(calledDirectly, True) - + def callback_sync_modified(self, args): if args['modificationType'] & 1 == 0: # ignore modifications that aren't SC_MOD_INSERTTEXT return @@ -184,7 +185,7 @@ def test_sync_setsavepoint(self): def callback_sync_setsavepoint(self, args): editor.write('in change\r\n') self.callbackResults['text'] = editor.getText() - + def test_sync_disallowed_scintilla_method(self): editor.write('Hello world') editor.callbackSync(lambda a: self.callback_sync_disallowed_scintilla_method(a), [SCINTILLANOTIFICATION.SAVEPOINTREACHED]) @@ -195,18 +196,18 @@ def test_sync_disallowed_scintilla_method(self): def callback_sync_disallowed_scintilla_method(self, args): self.callbackCalled = True with self.assertRaisesRegexp(RuntimeError, "not allowed in a synchronous"): - found = editor.findText(0, 0, editor.getLength(), 'Hello') + _ = editor.findText(0, 0, editor.getLength(), 'Hello') def test_sync_disallowed_notepad_method(self): editor.write('Hello world') editor.callbackSync(lambda a: self.callback_sync_disallowed_notepad_method(a), [SCINTILLANOTIFICATION.SAVEPOINTREACHED]) editor.setSavePoint() self.assertTrue(self.callbackCalled) - + def callback_sync_disallowed_notepad_method(self, args): self.callbackCalled = True with self.assertRaisesRegexp(RuntimeError, "not allowed in a synchronous"): - scintilla = notepad.createScintilla() + _ = notepad.createScintilla() def test_callback_with_replace(self): editor.callback(lambda a: self.callback_with_replace(a), [SCINTILLANOTIFICATION.MODIFIED]) @@ -222,7 +223,7 @@ def callback_with_replace(self, args): def poll_for_callback(self, timeout = 0.5, interval = 0.1): - while self.callbackCalled == False and timeout > 0: + while (not self.callbackCalled) and (timeout > 0): time.sleep(interval) timeout -= interval diff --git a/PythonScript/python_tests/tests/ScintillaWrapperTestCase.py b/PythonScript/python_tests/tests/ScintillaWrapperTestCase.py index 314bb9db..7da3adc2 100644 --- a/PythonScript/python_tests/tests/ScintillaWrapperTestCase.py +++ b/PythonScript/python_tests/tests/ScintillaWrapperTestCase.py @@ -1,10 +1,10 @@ -# -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- import unittest import time from Npp import ( editor, notepad, SCINTILLANOTIFICATION, FINDOPTION, KEYMOD, - SCINTILLAMESSAGE, LEXER, MODIFICATIONFLAGS, LANGTYPE, Cell + SCINTILLAMESSAGE, MODIFICATIONFLAGS, LANGTYPE, Cell ) @@ -24,7 +24,7 @@ def tearDown(self): notepad.close() def poll_for_callback(self, timeout = 0.5, interval = 0.1): - while self.callbackCalled == False and timeout > 0: + while (not self.callbackCalled) and (timeout > 0): time.sleep(interval) timeout -= interval @@ -33,7 +33,7 @@ def poll_for_callback(self, timeout = 0.5, interval = 0.1): def test_scintillawrapper_int_void_textrange(self): notepad.setLangType(LANGTYPE.XML) editor.write('') - time.sleep(0.1) # let the lexer do it's thang. The getStyledText appears to fail occassionally, returns a bunch of zeroes for the styles + time.sleep(0.1) # let the lexer do it's thing. The getStyledText appears to fail occassionally, returns a bunch of zeroes for the styles # I'm assuming it's a timing bug, as it "normally" works. Added the sleep to see if it makes a difference. result = editor.getStyledText(0, 19) self.assertEqual(('

Change log:

+2.0.0.0 +
    +
  • support N++ 8.3 with scintilla 4.4.6
  • +
  • Notepad++ 8.3 builds change Sci_position leading to crash #218
  • +
  • editor.getTextRange crash notepad++ #224
  • +
  • findText do not find text #223
  • +
  • Support for SendKeys module #183
  • +
  • used plain python 2.7.18, without the modifications from fork https://github.com/bruderstein/python, reintroducing dependency to MSVCR90.dll
  • +
+
1.5.4.0
  • Fix issue docs intro.rst: invalid FILESAVING notification vs valid FILEBEFORESAVE #148