int _availMarkResult[NB_MAX_PLUGINMARKERS];
// Requires communication with NppPlugin_SciMarkerSymbol.dll!
// Iterate through markers looking for available ones until the number of markers needed or
// NB_MAX_PLUGINMARKERS is reached.
// Returns array with values: -1 = hasn't been checked, 0 = not avail, 1 = avail
int * getAvailableMarkers( int nb_markers_needed )
{
namespace msg = npp_plugin::messages;
_availMarkResult[NB_MAX_PLUGINMARKERS];
for (int i = 0; i< NB_MAX_PLUGINMARKERS; i++) _availMarkResult[i] = -1;
if ( nb_markers_needed > NB_MAX_PLUGINMARKERS ) return _availMarkResult;
CommunicationInfo comm;
comm.internalMsg = msg::NPPP_MSG_MARKERSYMBOL;
comm.srcModuleName = getModuleName()->c_str();
msg::info_MARKERSYMBOL _info(NULL, NULL);
int mvSymbol;
int svSymbol;
int foundMarks = 0;
for ( int currMark = 0; currMark < NB_MAX_PLUGINMARKERS; currMark++ ) {
_info.markerNumber = currMark;
_info.targetView = MAIN_VIEW;
comm.info = &_info;
bool mvMsg = ::SendMessage( hNpp(), NPPM_MSGTOPLUGIN,
(WPARAM)TEXT("NppPlugin_SciMarkerSymbol.dll"), (LPARAM)&comm );
if ( mvMsg ) mvSymbol = _info.markerSymbol;
_info.targetView = SUB_VIEW;
comm.info = &_info;
bool svMsg = ::SendMessage( hNpp(), NPPM_MSGTOPLUGIN,
(WPARAM)TEXT("NppPlugin_SciMarkerSymbol.dll"), (LPARAM)&comm );
if ( svMsg ) svSymbol = _info.markerSymbol;
if ( mvMsg && svMsg ) {
if ( ( mvSymbol == SC_MARK_AVAILABLE ) && ( svSymbol == SC_MARK_AVAILABLE ) ) {
_availMarkResult[currMark] = 1;
foundMarks++;
}
else {
_availMarkResult[currMark] = 0;
}
}
if ( foundMarks == nb_markers_needed ) break;
}
return ( _availMarkResult );
}
// Sends message to SciMarkerSymbols.dll to undefine a Scintilla marker for both Npp views and
// remove any existing markers from margins.
void setMarkerAvailable( int markerNumber )
{
namespace msg = npp_plugin::messages;
CommunicationInfo comm;
comm.internalMsg = msg::NPPP_MSG_MARKERUNDEFINE;
comm.srcModuleName = getModuleName()->c_str();
msg::info_MARKERSYMBOL _info( markerNumber , NULL );
for ( int currView = MAIN_VIEW; currView <= SUB_VIEW; currView++ ) {
_info.targetView = currView;
comm.info = &_info;
::SendMessage( hNpp(), NPPM_MSGTOPLUGIN,
(WPARAM)TEXT("NppPlugin_SciMarkerSymbol.dll"), (LPARAM)&comm );
}
}