From 83ee8f09bf84980809d7b58e008314b4672566e7 Mon Sep 17 00:00:00 2001 From: Don Ho Date: Mon, 3 Oct 2022 01:28:55 +0200 Subject: [PATCH] Clean up NPPM_ALLOCATEMARKER API --- .../src/MISC/PluginsManager/IDAllocator.cpp | 42 ------------------- .../src/MISC/PluginsManager/IDAllocator.h | 14 ++++++- .../MISC/PluginsManager/PluginsManager.cpp | 4 +- .../src/MISC/PluginsManager/PluginsManager.h | 2 +- .../ScintillaComponent/ScintillaEditView.h | 4 +- PowerEditor/src/resource.h | 4 +- PowerEditor/visual.net/notepadPlus.vcxproj | 1 - 7 files changed, 19 insertions(+), 52 deletions(-) delete mode 100644 PowerEditor/src/MISC/PluginsManager/IDAllocator.cpp diff --git a/PowerEditor/src/MISC/PluginsManager/IDAllocator.cpp b/PowerEditor/src/MISC/PluginsManager/IDAllocator.cpp deleted file mode 100644 index 34a14f740..000000000 --- a/PowerEditor/src/MISC/PluginsManager/IDAllocator.cpp +++ /dev/null @@ -1,42 +0,0 @@ -// IDAllocator.h code is copyrighted (C) 2010 by Dave Brotherstone - -// This file is part of Notepad++ project -// 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 -// 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 "IDAllocator.h" - -IDAllocator::IDAllocator(int start, int maximumID) - : _start(start), - _nextID(start), - _maximumID(maximumID) -{ -} - -int IDAllocator::allocate(int quantity) -{ - int retVal = -1; - - if (_nextID + quantity <= _maximumID && quantity > 0) - { - retVal = _nextID; - _nextID += quantity; - } - - return retVal; -} - - diff --git a/PowerEditor/src/MISC/PluginsManager/IDAllocator.h b/PowerEditor/src/MISC/PluginsManager/IDAllocator.h index d3e496690..1f1b76dfc 100644 --- a/PowerEditor/src/MISC/PluginsManager/IDAllocator.h +++ b/PowerEditor/src/MISC/PluginsManager/IDAllocator.h @@ -22,10 +22,20 @@ class IDAllocator { public: - IDAllocator(int start, int maximumID); + IDAllocator(int start, int maximumID) : _start(start), _nextID(start), _maximumID(maximumID) {}; /// Returns -1 if not enough available - int allocate(int quantity); + int allocate(int quantity) { + int retVal = -1; + + if (_nextID + quantity <= _maximumID && quantity > 0) + { + retVal = _nextID; + _nextID += quantity; + } + + return retVal; + }; bool isInRange(int id) { return (id >= _start && id < _nextID); } diff --git a/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp b/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp index 4117d835a..0f2356bde 100644 --- a/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp +++ b/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp @@ -808,11 +808,11 @@ bool PluginsManager::allocateCmdID(int numberRequired, int *start) return retVal; } -bool PluginsManager::allocateMarker(int numberRequired, int *start) +bool PluginsManager::allocateMarker(int numberRequired, int* start) { bool retVal = true; *start = _markerAlloc.allocate(numberRequired); - if (-1 == *start) + if (*start == -1) { *start = 0; retVal = false; diff --git a/PowerEditor/src/MISC/PluginsManager/PluginsManager.h b/PowerEditor/src/MISC/PluginsManager/PluginsManager.h index ba795763c..ed18e4546 100644 --- a/PowerEditor/src/MISC/PluginsManager/PluginsManager.h +++ b/PowerEditor/src/MISC/PluginsManager/PluginsManager.h @@ -116,7 +116,7 @@ public: bool allocateCmdID(int numberRequired, int *start); bool inDynamicRange(int id) { return _dynamicIDAlloc.isInRange(id); } - bool allocateMarker(int numberRequired, int *start); + bool allocateMarker(int numberRequired, int* start); generic_string getLoadedPluginNames() const; private: diff --git a/PowerEditor/src/ScintillaComponent/ScintillaEditView.h b/PowerEditor/src/ScintillaComponent/ScintillaEditView.h index 2962dff5c..4c5d4c10e 100644 --- a/PowerEditor/src/ScintillaComponent/ScintillaEditView.h +++ b/PowerEditor/src/ScintillaComponent/ScintillaEditView.h @@ -117,8 +117,8 @@ const int MARK_BOOKMARK = 20; const int MARK_HIDELINESBEGIN = 19; const int MARK_HIDELINESEND = 18; const int MARK_HIDELINESUNDERLINE = 17; -// 20 - 16 reserved for Notepad++ internal used -// 15 - 0 are free to use for plugins +// 20 - 17 reserved for Notepad++ internal used +// 16 - 0 are free to use for plugins int getNbDigits(int aNum, int base); diff --git a/PowerEditor/src/resource.h b/PowerEditor/src/resource.h index ac4f7d028..16d8bab65 100644 --- a/PowerEditor/src/resource.h +++ b/PowerEditor/src/resource.h @@ -415,8 +415,8 @@ #define ID_PLUGINS_CMD_DYNAMIC_LIMIT 24999 -#define MARKER_PLUGINS 3 -#define MARKER_PLUGINS_LIMIT 19 +#define MARKER_PLUGINS 1 +#define MARKER_PLUGINS_LIMIT 15 diff --git a/PowerEditor/visual.net/notepadPlus.vcxproj b/PowerEditor/visual.net/notepadPlus.vcxproj index f2d22e35c..924a94652 100755 --- a/PowerEditor/visual.net/notepadPlus.vcxproj +++ b/PowerEditor/visual.net/notepadPlus.vcxproj @@ -436,7 +436,6 @@ copy ..\src\contextMenu.xml ..\binarm64\contextMenu.xml -