Get Scintilla HWND for an ILexer/syntax highlighter plugin
William Newbery last edited by
Was looking at the possibility of doing some extra config (e.g.
SCI_STYLESETEOLFILLEDand some other style things Notepad++ hardcoded for the built in styling) and so want to send messages to the Scintilla editor control.
NppDatastruct has a
_scintillaSecondHandle. Anyone know of a way to determine which one owns a specific lexer instance (at the time it is being set, so changes apply to the initial rendering)?
You can catch certain notifications from Notepad++ and then use
NPPM_GETCURRENTSCINTILLAto see which handle to use.
That being said…
I’ve ran across this before – wanting to tweak style settings that aren’t configurable. You can easily do it with one of the scripting plugins. For example using LuaScript you could use something like:
npp.AddEventHandler("OnSwitchFile", function(filename, bufferid) if npp.BufferLangType[bufferid] == L_CPP then editor.StyleEOLFilled[SCE_C_COMMENTLINE] = true end end)
Also easily doable with PythonScript if you are familiar with it.
William Newbery last edited by
Not really familiar with LuaScript/Python script for Notepad++, but looks like
But not sure about the third line though, how does
editorknow to which of those 2 handles to send the message? Also id need to know what index above
L_EXTERNALmy lexer is. I see that being stored by
I think I can listen to
NPPN_LANGCHANGED(although sent after
ILexer::Lex, hopefully that is ok). Then maybe
SCI_GETLEXERLANGUAGEto both windows instead of the
L_*enum as I get a string.
Will give it a go, but for now I patched in a
execute(SCI_PRIVATELEXERCALL, 1, reinterpret_cast<LPARAM>(_hSelf));to the end of
ScintillaEditView::setExternalLexer. Just from reading all that code think I’ll end up wanting
but looks like OnSwitchFile is NPPN_BUFFERACTIVATED and npp.BufferLangType[bufferid] is NPPM_GETBUFFERLANGTYPE?
But not sure about the third line though
It is equivalent to
SendMessage(theScintillaHandle, SCI_STYLESETEOLFILLED, SCE_C_COMMENTLINE, true);
how does editor know to which of those 2 handles to send the message?
When the plugin catches
NPPN_BUFFERACTIVATEDit internally calls
editorto be the appropriate scintilla handle before running the chunk of Lua.
Also id need to know what index above L_EXTERNAL my lexer is.
That I’m not sure. Haven’t done much with external lexers. You might have to use something like
NPPM_GETLANGUAGENAMEto see if the name of the language matches your external lexer’s name.
Will give it a go, but for now I patched in a execute(SCI_PRIVATELEXERCALL, 1, reinterpret_cast<LPARAM>(_hSelf)); to the end of ScintillaEditView::setExternalLexer. Just from reading all that code think I’ll end up wanting ScintillaEditView::makeStyle anyway…
Are you making your own plugin or a custom Notepad++ version?
William Newbery last edited by William Newbery
Ah, yes, that seems a cleaner way to get the window.
If I can make it all in a separate plugin that would seem more ideal.
Ok. I just wanted to make sure you weren’t heading down a path you didn’t need to :). Under normal situations, an external lexer can be fully contained within a plugin.