@John-HUANG-0 said in Looking for Scintilla examples for a Notepad++ plugin:
I want to write a Notepad++ plugin that can change the font color and background color of certain specific text.
Depending on your needs, the first thing you should consider is whether you really need a plugin, or whether a User Defined Language could do what you want.
However, using a method like this:
SendMessage(hSci, SCI_STYLESETFORE, SCE_USER1, RGB(255, 0, 0));
is not very efficient, especially when dealing with very large files.
When making many calls to Scintilla, it is best to use Direct Access. Even better, if you are writing in C++, is to use the ScintillaCall interface. Annoyingly, that interface does not seem to be documented anywhere. You can read the relevant section in the help for my Visual Studio template and, if it makes sense, either use that template or look at the code (start here) to see how it’s done.
I asked ChatGPT about this, and it suggested that using Lexilla could be much more efficient. I found the Lexilla source code here:
https://github.com/notepad-plus-plus/notepad-plus-plus/tree/master/scintilla
I have never attempted to write a lexer, so I can’t give advice there, except to say that unless you are trying to implement full syntax highlighting for a computer language that doesn’t already have a lexer, it’s probably not the way to go. The efficiency problem can be solved by using the direct access interface or ScintillaCall.