Skip to content

Commit 3177c9a

Browse files
authored
Scintilla 446 (N++ 8.2) (#220)
* - updated NppPlugin data from N++ version 8.2 with scintilla 4.4.6 - first adaptations to N++ changes - added project dependencies in sln - added some initializations * further updated npp files from pre N++ 8.2.1 * try to add msvc code analysis step instead of codeql which is not available on image 2022 * - adapted CreateWrapper.py for new enum - created new scintilla wrapper and docu for 4.4.6 via CreateWrapper.py from input Scintilla.iface * - correct some failing unittests - correct RegexTester.py as python 3 dict has no has_key() method * - fix test_reloadFile testcase by changing the setting IDC_CHECK_UPDATESILENTLY - started to try to fix test_disableAutoUpdate
1 parent 01ea9ea commit 3177c9a

38 files changed

+2266
-1074
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 0 additions & 76 deletions
This file was deleted.
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# This workflow uses actions that are not certified by GitHub.
2+
# They are provided by a third-party and are governed by
3+
# separate terms of service, privacy policy, and support
4+
# documentation.
5+
#
6+
# Find more information at:
7+
# https://github.com/microsoft/msvc-code-analysis-action
8+
9+
name: Microsoft C++ Code Analysis
10+
11+
on: [push, pull_request]
12+
13+
jobs:
14+
Analyze:
15+
runs-on: windows-2022
16+
17+
strategy:
18+
fail-fast: false
19+
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v2
23+
with:
24+
submodules: recursive
25+
26+
- name: Add msbuild to PATH
27+
uses: microsoft/setup-msbuild@v1
28+
29+
- name: "Use CI config files"
30+
run: |
31+
Write-Host "remove PythonSettings.props" -ForegroundColor Green
32+
Remove-Item '.\PythonScript\project\PythonSettings.props'
33+
Rename-Item -Path ".\PythonScript\project\PythonSettings_appveyor.props" -NewName "PythonSettings.props"
34+
Write-Host "remove packages.config" -ForegroundColor Green
35+
Remove-Item '.\PythonScript\project\packages.config'
36+
Rename-Item -Path ".\PythonScript\project\packages_appveyor.config" -NewName "packages.config"
37+
shell: pwsh
38+
working-directory: .
39+
40+
- name: Setup NuGet.exe
41+
uses: nuget/setup-nuget@v1
42+
43+
- name: Restore
44+
working-directory: .
45+
run: nuget restore PythonScript.sln
46+
47+
- name: Run MSVC Code Analysis
48+
working-directory: .
49+
run: msbuild PythonScript.sln /m /verbosity:minimal /p:configuration="Debug" /p:platform="x64" /p:RunCodeAnalysis=true
50+
51+
# Upload SARIF file to GitHub Code Scanning Alerts
52+
#- name: Upload SARIF to GitHub
53+
# uses: github/codeql-action/upload-sarif@v1
54+
# with:
55+
# sarif_file: ${{ steps.run-analysis.outputs.sarif }}
56+
57+
# Upload SARIF file as an Artifact to download and view
58+
# - name: Upload SARIF as an Artifact
59+
# uses: actions/upload-artifact@v2
60+
# with:
61+
# name: sarif-file
62+
# path: ${{ steps.run-analysis.outputs.sarif }}

NppPlugin/include/Common.h

Lines changed: 62 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,27 @@
11
// This file is part of Notepad++ project
2-
// Copyright (C)2003 Don HO <[email protected]>
3-
//
4-
// This program is free software; you can redistribute it and/or
5-
// modify it under the terms of the GNU General Public License
6-
// as published by the Free Software Foundation; either
7-
// version 2 of the License, or (at your option) any later version.
8-
//
9-
// Note that the GPL places important restrictions on "derived works", yet
10-
// it does not provide a detailed definition of that term. To avoid
11-
// misunderstandings, we consider an application to constitute a
12-
// "derivative work" for the purpose of this license if it does any of the
13-
// following:
14-
// 1. Integrates source code from Notepad++.
15-
// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable
16-
// installer, such as those produced by InstallShield.
17-
// 3. Links to a library or executes a program that does any of the above.
2+
// Copyright (C)2021 Don HO <[email protected]>
3+
4+
// This program is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// at your option any later version.
188
//
199
// This program is distributed in the hope that it will be useful,
2010
// but WITHOUT ANY WARRANTY; without even the implied warranty of
21-
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2212
// GNU General Public License for more details.
2313
//
2414
// You should have received a copy of the GNU General Public License
25-
// along with this program; if not, write to the Free Software
26-
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
15+
// along with this program. If not, see <https://www.gnu.org/licenses/>.
2716
#pragma once
2817
#include <vector>
2918
#include <string>
3019
#include <sstream>
3120
#include <windows.h>
3221
#include <iso646.h>
3322
#include <cstdint>
23+
#include <unordered_set>
24+
#include <algorithm>
3425

3526

3627
const bool dirUp = true;
@@ -92,12 +83,16 @@ std::string getFileContent(const TCHAR *file2read);
9283
generic_string relativeFilePathToFullFilePath(const TCHAR *relativeFilePath);
9384
void writeFileContent(const TCHAR *file2write, const char *content2write);
9485
bool matchInList(const TCHAR *fileName, const std::vector<generic_string> & patterns);
86+
bool matchInExcludeDirList(const TCHAR* dirName, const std::vector<generic_string>& patterns, size_t level);
87+
bool allPatternsAreExclusion(const std::vector<generic_string> patterns);
9588

9689
class WcharMbcsConvertor final
9790
{
9891
public:
99-
static WcharMbcsConvertor * getInstance() {return _pSelf;}
100-
static void destroyInstance() {delete _pSelf;}
92+
static WcharMbcsConvertor& getInstance() {
93+
static WcharMbcsConvertor instance;
94+
return instance;
95+
}
10196

10297
const wchar_t * char2wchar(const char *mbStr, UINT codepage, int lenIn=-1, int *pLenOut=NULL, int *pBytesNotProcessed=NULL);
10398
const wchar_t * char2wchar(const char *mbcs2Convert, UINT codepage, int *mstart, int *mend);
@@ -112,15 +107,17 @@ class WcharMbcsConvertor final
112107
}
113108

114109
protected:
115-
WcharMbcsConvertor() {}
116-
~WcharMbcsConvertor() {}
110+
WcharMbcsConvertor() = default;
111+
~WcharMbcsConvertor() = default;
117112

118113
// Since there's no public ctor, we need to void the default assignment operator and copy ctor.
119114
// Since these are marked as deleted does not matter under which access specifier are kept
120115
WcharMbcsConvertor(const WcharMbcsConvertor&) = delete;
121116
WcharMbcsConvertor& operator= (const WcharMbcsConvertor&) = delete;
122117

123-
static WcharMbcsConvertor* _pSelf;
118+
// No move ctor and assignment
119+
WcharMbcsConvertor(WcharMbcsConvertor&&) = delete;
120+
WcharMbcsConvertor& operator= (WcharMbcsConvertor&&) = delete;
124121

125122
template <class T>
126123
class StringBuffer final
@@ -169,26 +166,30 @@ class WcharMbcsConvertor final
169166
#define REBARBAND_SIZE sizeof(REBARBANDINFO)
170167

171168
generic_string PathRemoveFileSpec(generic_string & path);
172-
generic_string PathAppend(generic_string &strDest, const generic_string & str2append);
169+
generic_string pathAppend(generic_string &strDest, const generic_string & str2append);
173170
COLORREF getCtrlBgColor(HWND hWnd);
174171
generic_string stringToUpper(generic_string strToConvert);
175172
generic_string stringToLower(generic_string strToConvert);
176173
generic_string stringReplace(generic_string subject, const generic_string& search, const generic_string& replace);
177174
std::vector<generic_string> stringSplit(const generic_string& input, const generic_string& delimiter);
175+
bool str2numberVector(generic_string str2convert, std::vector<size_t>& numVect);
178176
generic_string stringJoin(const std::vector<generic_string>& strings, const generic_string& separator);
179177
generic_string stringTakeWhileAdmissable(const generic_string& input, const generic_string& admissable);
180178
double stodLocale(const generic_string& str, _locale_t loc, size_t* idx = NULL);
181179

182180
int OrdinalIgnoreCaseCompareStrings(LPCTSTR sz1, LPCTSTR sz2);
183181

184182
bool str2Clipboard(const generic_string &str2cpy, HWND hwnd);
183+
class Buffer;
184+
bool buf2Clipborad(const std::vector<Buffer*>& buffers, bool isFullPath, HWND hwnd);
185185

186186
generic_string GetLastErrorAsString(DWORD errorCode = 0);
187187

188188
generic_string intToString(int val);
189189
generic_string uintToString(unsigned int val);
190190

191-
HWND CreateToolTip(int toolID, HWND hDlg, HINSTANCE hInst, const PTSTR pszText);
191+
HWND CreateToolTip(int toolID, HWND hDlg, HINSTANCE hInst, const PTSTR pszText, bool isRTL);
192+
HWND CreateToolTipRect(int toolID, HWND hWnd, HINSTANCE hInst, const PTSTR pszText, const RECT rc);
192193

193194
bool isCertificateValidated(const generic_string & fullFilePath, const generic_string & subjectName2check);
194195
bool isAssoCommandExisting(LPCTSTR FullPathName);
@@ -199,3 +200,38 @@ std::string ws2s(const std::wstring& wstr);
199200
bool deleteFileOrFolder(const generic_string& f2delete);
200201

201202
void getFilesInFolder(std::vector<generic_string>& files, const generic_string& extTypeFilter, const generic_string& inFolder);
203+
204+
template<typename T> size_t vecRemoveDuplicates(std::vector<T>& vec, bool isSorted = false, bool canSort = false)
205+
{
206+
if (!isSorted && canSort)
207+
{
208+
std::sort(vec.begin(), vec.end());
209+
isSorted = true;
210+
}
211+
212+
if (isSorted)
213+
{
214+
typename std::vector<T>::iterator it;
215+
it = std::unique(vec.begin(), vec.end());
216+
vec.resize(distance(vec.begin(), it)); // unique() does not shrink the vector
217+
}
218+
else
219+
{
220+
std::unordered_set<T> seen;
221+
auto newEnd = std::remove_if(vec.begin(), vec.end(), [&seen](const T& value)
222+
{
223+
return !seen.insert(value).second;
224+
});
225+
vec.erase(newEnd, vec.end());
226+
}
227+
return vec.size();
228+
}
229+
230+
void trim(generic_string& str);
231+
bool endsWith(const generic_string& s, const generic_string& suffix);
232+
233+
int nbDigitsFromNbLines(size_t nbLines);
234+
235+
generic_string getDateTimeStrFrom(const generic_string& dateTimeFormat, const SYSTEMTIME& st);
236+
237+
HFONT createFont(const TCHAR* fontName, int fontSize, bool isBold, HWND hDestParent);

NppPlugin/include/Docking.h

Lines changed: 26 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,18 @@
1-
// this file is part of Notepad++
2-
// Copyright (C)2005 Jens Lorenz <[email protected]>
3-
//
4-
// This program is free software; you can redistribute it and/or
5-
// modify it under the terms of the GNU General Public License
6-
// as published by the Free Software Foundation; either
7-
// version 2 of the License, or (at your option) any later version.
8-
//
9-
// // Note that the GPL places important restrictions on "derived works", yet
10-
// it does not provide a detailed definition of that term. To avoid
11-
// misunderstandings, we consider an application to constitute a
12-
// "derivative work" for the purpose of this license if it does any of the
13-
// following:
14-
// 1. Integrates source code from Notepad++.
15-
// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable
16-
// installer, such as those produced by InstallShield.
17-
// 3. Links to a library or executes a program that does any of the above.
18-
//
1+
// This file is part of Notepad++ project
2+
// Copyright (C)2021 Don HO <[email protected]>
3+
4+
// This program is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// at your option any later version.
8+
//
199
// This program is distributed in the hope that it will be useful,
2010
// but WITHOUT ANY WARRANTY; without even the implied warranty of
21-
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2212
// GNU General Public License for more details.
23-
//
13+
//
2414
// You should have received a copy of the GNU General Public License
25-
// along with this program; if not, write to the Free Software
26-
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
15+
// along with this program. If not, see <https://www.gnu.org/licenses/>.
2716

2817

2918
#pragma once
@@ -57,27 +46,27 @@
5746
#define DWS_DF_FLOATING 0x80000000 // default state is floating
5847

5948

60-
typedef struct {
61-
HWND hClient; // client Window Handle
62-
const TCHAR *pszName; // name of plugin (shown in window)
63-
int dlgID; // a funcItem provides the function pointer to start a dialog. Please parse here these ID
49+
struct tTbData {
50+
HWND hClient = nullptr; // client Window Handle
51+
const TCHAR* pszName = nullptr; // name of plugin (shown in window)
52+
int dlgID = 0; // a funcItem provides the function pointer to start a dialog. Please parse here these ID
6453

6554
// user modifications
66-
UINT uMask; // mask params: look to above defines
67-
HICON hIconTab; // icon for tabs
68-
const TCHAR *pszAddInfo; // for plugin to display additional informations
55+
UINT uMask = 0; // mask params: look to above defines
56+
HICON hIconTab = nullptr; // icon for tabs
57+
const TCHAR* pszAddInfo = nullptr; // for plugin to display additional informations
6958

7059
// internal data, do not use !!!
71-
RECT rcFloat; // floating position
72-
int iPrevCont; // stores the privious container (toggling between float and dock)
73-
const TCHAR* pszModuleName; // it's the plugin file name. It's used to identify the plugin
74-
} tTbData;
60+
RECT rcFloat = {0}; // floating position
61+
int iPrevCont = 0; // stores the privious container (toggling between float and dock)
62+
const TCHAR* pszModuleName = nullptr; // it's the plugin file name. It's used to identify the plugin
63+
};
7564

7665

77-
typedef struct {
78-
HWND hWnd; // the docking manager wnd
79-
RECT rcRegion[DOCKCONT_MAX]; // position of docked dialogs
80-
} tDockMgr;
66+
struct tDockMgr {
67+
HWND hWnd = nullptr; // the docking manager wnd
68+
RECT rcRegion[DOCKCONT_MAX] = {{0}}; // position of docked dialogs
69+
};
8170

8271

8372
#define HIT_TEST_THICKNESS 20

0 commit comments

Comments
 (0)