Skip to content

Commit

Permalink
Scintilla 446 (N++ 8.2) (#220)
Browse files Browse the repository at this point in the history
* - 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
  • Loading branch information
chcg committed Feb 5, 2022
1 parent 01ea9ea commit 3177c9a
Show file tree
Hide file tree
Showing 38 changed files with 2,266 additions and 1,074 deletions.
76 changes: 0 additions & 76 deletions .github/workflows/codeql-analysis.yml

This file was deleted.

62 changes: 62 additions & 0 deletions .github/workflows/msvc_analysis.yml
Original file line number Diff line number Diff line change
@@ -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-2022

strategy:
fail-fast: false

steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: recursive

- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1

- 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@v1

- 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: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 }}
88 changes: 62 additions & 26 deletions NppPlugin/include/Common.h
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 <don.h@free.fr>
//
// 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 <don.h@free.fr>

// 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;
Expand Down Expand Up @@ -92,12 +83,16 @@ 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);
Expand All @@ -112,15 +107,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 T>
class StringBuffer final
Expand Down Expand Up @@ -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);
Expand All @@ -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);
63 changes: 26 additions & 37 deletions NppPlugin/include/Docking.h
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 <jens.plugin.npp@gmx.de>
//
// 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 <don.h@free.fr>

// 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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 3177c9a

Please sign in to comment.