Skip to content

Commit 0c7e163

Browse files
committed
add support for notepad.allocateIndicator function available with N++ 8.5.6 and therefore updated N++ files
1 parent 1631950 commit 0c7e163

5 files changed

Lines changed: 45 additions & 2 deletions

File tree

NppPlugin/include/Notepad_plus_msgs.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ enum Platform { PF_UNKNOWN, PF_X86, PF_X64, PF_IA64, PF_ARM64 };
368368

369369
#define NPPM_ALLOCATEMARKER (NPPMSG + 82)
370370
// BOOL NPPM_ALLOCATEMARKER(int numberRequested, int* startNumber)
371-
// sets startNumber to the initial command ID if successful
371+
// sets startNumber to the initial marker ID if successful
372372
// Allocates a marker number to a plugin: if a plugin need to add a marker on Notepad++'s Scintilla marker margin,
373373
// it has to use this message to get marker number, in order to prevent from the conflict with the other plugins.
374374
// Returns: TRUE if successful, FALSE otherwise. startNumber will also be set to 0 if unsuccessful
@@ -591,6 +591,12 @@ enum Platform { PF_UNKNOWN, PF_X86, PF_X64, PF_IA64, PF_ARM64 };
591591
// }
592592
//}
593593

594+
#define NPPM_ALLOCATEINDICATOR (NPPMSG + 113)
595+
// BOOL NPPM_ALLOCATEINDICATOR(int numberRequested, int* startNumber)
596+
// sets startNumber to the initial indicator ID if successful
597+
// Allocates an indicator number to a plugin: if a plugin needs to add an indicator,
598+
// it has to use this message to get the indicator number, in order to prevent a conflict with the other plugins.
599+
// Returns: TRUE if successful, FALSE otherwise.
594600

595601
// For RUNCOMMAND_USER
596602
#define VAR_NOT_RECOGNIZED 0

PythonScript/python_tests/tests/NotepadWrapperTestCase.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,21 @@ def test_allocateMarker(self):
518518
# test functionality
519519

520520

521+
def test_allocateIndicator(self):
522+
''' '''
523+
notepad_method = notepad.allocateIndicator
524+
with self.assertRaises(ArgumentError):
525+
self._invalid_parameter_passed(notepad_method)
526+
with self.assertRaises(ArgumentError):
527+
self._invalid_parameter_passed(notepad_method, '')
528+
with self.assertRaises(ArgumentError):
529+
self._invalid_parameter_passed(notepad_method, -1,-1)
530+
with self.assertRaises(ArgumentError):
531+
self._invalid_parameter_passed(notepad_method, 0,0)
532+
# test return code
533+
# test functionality
534+
535+
521536
def test_allocateSupported(self):
522537
''' '''
523538
self.__test_invalid_parameter_passed(notepad.allocateSupported)

PythonScript/src/NotepadPlusWrapper.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -889,6 +889,20 @@ boost::python::object NotepadPlusWrapper::allocateMarker(int quantity)
889889
}
890890
}
891891

892+
boost::python::object NotepadPlusWrapper::allocateIndicator(int quantity)
893+
{
894+
int startID = 0;
895+
bool result = static_cast<bool>(callNotepad(NPPM_ALLOCATEINDICATOR, static_cast<WPARAM>(quantity), reinterpret_cast<LPARAM>(&startID)));
896+
if (result)
897+
{
898+
return boost::python::object(startID);
899+
}
900+
else
901+
{
902+
return boost::python::object();
903+
}
904+
}
905+
892906
intptr_t NotepadPlusWrapper::getMenuHandle(int menu = 0)
893907
{
894908
return callNotepad(NPPM_GETMENUHANDLE, static_cast<WPARAM>(menu), 0);

PythonScript/src/NotepadPlusWrapper.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -845,6 +845,7 @@ class NotepadPlusWrapper
845845
bool allocateSupported();
846846
boost::python::object allocateCmdID(int quantity);
847847
boost::python::object allocateMarker(int quantity);
848+
boost::python::object allocateIndicator(int quantity);
848849

849850
typedef std::multimap<idx_t, boost::python::object> callbackT;
850851

docs/source/notepad.rst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,18 @@ Notepad++ Object
3838

3939
.. method:: notepad.allocateMarker(numberRequested) -> bool
4040

41-
Allocates a range of marker number for Scintilla.
41+
Allocates a range of marker numbers for Scintilla.
4242
Use this to stop marker number collisions with other plugins / scripts.
4343

4444
Returns the start number of the requested range
4545

46+
.. method:: notepad.allocateIndicator(numberRequested) -> bool
47+
48+
Allocates a range of indicator numbers for Scintilla.
49+
Use this to stop indicator number collisions with other plugins / scripts.
50+
51+
Returns the start number of the requested range
52+
4653

4754
.. method:: notepad.allocateSupported() -> bool
4855

0 commit comments

Comments
 (0)