-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
backport changes from master for support of n++ 8.3
expected to fix: - editor.getTextRange crash notepad++ #224 - findText do not find text #223 - Notepad++ 8.3 builds change Sci_position leading to crash #218
- Loading branch information
Showing
41 changed files
with
2,460 additions
and
1,766 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,27 @@ | ||
// This file is part of Notepad++ project | ||
// Copyright (C)2003 Don HO <[email protected]> | ||
// | ||
// 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 <[email protected]> | ||
|
||
// 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 <https://www.gnu.org/licenses/>. | ||
#pragma once | ||
#include <vector> | ||
#include <string> | ||
#include <sstream> | ||
#include <windows.h> | ||
#include <iso646.h> | ||
#include <cstdint> | ||
#include <unordered_set> | ||
#include <algorithm> | ||
|
||
|
||
const bool dirUp = true; | ||
|
@@ -92,35 +83,41 @@ 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<generic_string> & patterns); | ||
bool matchInExcludeDirList(const TCHAR* dirName, const std::vector<generic_string>& patterns, size_t level); | ||
bool allPatternsAreExclusion(const std::vector<generic_string> 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); | ||
return wchar2char(strW, toCodepage, lenWc, pLenOut); | ||
} | ||
|
||
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 T> | ||
class StringBuffer final | ||
|
@@ -169,26 +166,30 @@ class WcharMbcsConvertor final | |
#define REBARBAND_SIZE sizeof(REBARBANDINFO) | ||
|
||
generic_string PathRemoveFileSpec(generic_string & path); | ||
generic_string PathAppend(generic_string &strDest, const generic_string & str2append); | ||
generic_string pathAppend(generic_string &strDest, const generic_string & 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<generic_string> stringSplit(const generic_string& input, const generic_string& delimiter); | ||
bool str2numberVector(generic_string str2convert, std::vector<size_t>& numVect); | ||
generic_string stringJoin(const std::vector<generic_string>& 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); | ||
|
||
bool str2Clipboard(const generic_string &str2cpy, HWND hwnd); | ||
class Buffer; | ||
bool buf2Clipborad(const std::vector<Buffer*>& buffers, bool isFullPath, HWND hwnd); | ||
|
||
generic_string GetLastErrorAsString(DWORD errorCode = 0); | ||
|
||
generic_string intToString(int val); | ||
generic_string 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 isAssoCommandExisting(LPCTSTR FullPathName); | ||
|
@@ -199,3 +200,38 @@ std::string ws2s(const std::wstring& wstr); | |
bool deleteFileOrFolder(const generic_string& f2delete); | ||
|
||
void getFilesInFolder(std::vector<generic_string>& files, const generic_string& extTypeFilter, const generic_string& inFolder); | ||
|
||
template<typename T> size_t vecRemoveDuplicates(std::vector<T>& vec, bool isSorted = false, bool canSort = false) | ||
{ | ||
if (!isSorted && canSort) | ||
{ | ||
std::sort(vec.begin(), vec.end()); | ||
isSorted = true; | ||
} | ||
|
||
if (isSorted) | ||
{ | ||
typename std::vector<T>::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<T> 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(generic_string& str); | ||
bool endsWith(const generic_string& s, const generic_string& suffix); | ||
|
||
int nbDigitsFromNbLines(size_t nbLines); | ||
|
||
generic_string getDateTimeStrFrom(const generic_string& dateTimeFormat, const SYSTEMTIME& st); | ||
|
||
HFONT createFont(const TCHAR* fontName, int fontSize, bool isBold, HWND hDestParent); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,18 @@ | ||
// this file is part of Notepad++ | ||
// Copyright (C)2005 Jens Lorenz <[email protected]> | ||
// | ||
// 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)2021 Don HO <[email protected]> | ||
|
||
// 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 <https://www.gnu.org/licenses/>. | ||
|
||
|
||
#pragma once | ||
|
@@ -57,27 +46,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 TCHAR* 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 TCHAR* 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 = {0}; // floating position | ||
int iPrevCont = 0; // stores the privious container (toggling between float and dock) | ||
const TCHAR* 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] = {{0}}; // position of docked dialogs | ||
}; | ||
|
||
|
||
#define HIT_TEST_THICKNESS 20 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,18 @@ | ||
// this file is part of Function List Plugin for Notepad++ | ||
// Copyright (C)2005 Jens Lorenz <[email protected]> | ||
// | ||
// 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 <[email protected]> | ||
|
||
// 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 <https://www.gnu.org/licenses/>. | ||
|
||
|
||
#pragma once | ||
|
@@ -34,6 +24,7 @@ | |
#include <shlwapi.h> | ||
#include "Common.h" | ||
#include "StaticDialog.h" | ||
#include "NppDarkMode.h" | ||
|
||
|
||
|
||
|
@@ -43,39 +34,38 @@ class DockingDlgInterface : public StaticDialog | |
DockingDlgInterface() = default; | ||
explicit DockingDlgInterface(int dlgID): _dlgID(dlgID) {} | ||
|
||
virtual void init(HINSTANCE hInst, HWND parent) | ||
{ | ||
virtual void init(HINSTANCE hInst, HWND parent) { | ||
StaticDialog::init(hInst, parent); | ||
TCHAR temp[MAX_PATH]; | ||
::GetModuleFileName(reinterpret_cast<HMODULE>(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]; | ||
::GetWindowText(_hSelf, temp, MAX_PATH); | ||
_pluginName = temp; | ||
|
||
// user information | ||
data->hClient = _hSelf; | ||
data->pszName = _pluginName.c_str(); | ||
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<LPARAM>(_hSelf)); | ||
} | ||
|
||
virtual void destroy() {} | ||
virtual void destroy() { | ||
StaticDialog::destroy(); | ||
} | ||
|
||
virtual void setBackgroundColor(COLORREF) {} | ||
virtual void setForegroundColor(COLORREF) {} | ||
|
@@ -97,11 +87,28 @@ class DockingDlgInterface : public StaticDialog | |
} | ||
|
||
protected : | ||
virtual INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM, LPARAM lParam) | ||
{ | ||
switch (message) | ||
int _dlgID = -1; | ||
bool _isFloating = true; | ||
int _iDockedPos = 0; | ||
generic_string _moduleName; | ||
generic_string _pluginName; | ||
bool _isClosed = false; | ||
|
||
virtual intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) { | ||
switch (message) | ||
{ | ||
case WM_ERASEBKGND: | ||
{ | ||
if (!NppDarkMode::isEnabled()) | ||
{ | ||
break; | ||
} | ||
|
||
RECT rc = { 0 }; | ||
getClientRect(rc); | ||
::FillRect(reinterpret_cast<HDC>(wParam), &rc, NppDarkMode::getDarkerBackgroundBrush()); | ||
return TRUE; | ||
} | ||
case WM_NOTIFY: | ||
{ | ||
LPNMHDR pnmh = reinterpret_cast<LPNMHDR>(lParam); | ||
|
@@ -136,13 +143,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; | ||
}; |
Oops, something went wrong.