Clean up NPPM_ALLOCATEMARKER API
parent
11884bd97f
commit
83ee8f09bf
|
@ -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 <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
|
||||
// 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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#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;
|
||||
}
|
||||
|
||||
|
|
@ -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); }
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -436,7 +436,6 @@ copy ..\src\contextMenu.xml ..\binarm64\contextMenu.xml
|
|||
<ClCompile Include="..\src\WinControls\FunctionList\functionParser.cpp" />
|
||||
<ClCompile Include="..\src\ScintillaComponent\GoToLineDlg.cpp" />
|
||||
<ClCompile Include="..\src\WinControls\DockingWnd\Gripper.cpp" />
|
||||
<ClCompile Include="..\src\MISC\PluginsManager\IDAllocator.cpp" />
|
||||
<ClCompile Include="..\src\WinControls\ImageListSet\ImageListSet.cpp" />
|
||||
<ClCompile Include="..\src\uchardet\JpCntx.cpp" />
|
||||
<ClCompile Include="..\src\uchardet\LangBulgarianModel.cpp" />
|
||||
|
|
Loading…
Reference in New Issue