Took a quick shot a 1, would look something like:
//PluginInterface.h
static const int NPPLEX_SET = 1;
// Configure a Scintilla lexer when it is being set as the active lexer
// This is passed to the ILexer via PrivateCall(NPP_LEX_SET, ISetLexerConfig)
class ISetLexerConfig
{
public:
// The Scintilla window this lexer is for
virtual HWND getScintilla() = 0;
// Adds the styles defined by a language (overwrites any existing style with the same ID)
// By default Notepad++ will have added the styles for the lexers own language already
virtual void addStyles(const TCHAR *languageName) = 0;
};
//ScintillaEditView.cpp end of void ScintillaEditView::setExternalLexer(LangType typeDoc)
class SetLexerConfig : public ISetLexerConfig
{
public:
explicit SetLexerConfig(ScintillaEditView *self) : _self(self) {}
virtual HWND getScintilla()override
{
return _self->getHSelf();
}
virtual void addStyles(const TCHAR *languageName)override
{
LexerStyler *pStyler = (_self->_pParameter->getLStylerArray()).getLexerStylerByName(languageName);
if (pStyler)
{
for (int i = 0; i < pStyler->getNbStyler(); ++i)
{
_self->setStyle(pStyler->getStyler(i));
}
}
}
private:
ScintillaEditView *_self;
};
SetLexerConfig setLexerConfig(this);
execute(SCI_PRIVATELEXERCALL, NPPLEX_SET, reinterpret_cast<LPARAM>(&setLexerConfig));
Then the lexer can just do something like:
config->addStyles(L"Scss");
config->addStyles(L"Javascipt");
config->addStyles(L"Markdown");
config->addStyles(L"Ruby");
As well as having a convenient handle to the Scintilla control for more advanced things outside the Notepad++ style GUI.
Not really looked at the “word lists” yet, but should be same idea (maybe included in addStyles).
It also occurred to me that maybe some of this could be put in the XML file, which I guess would be approach 4.