Let's say I simply want to insert some text at my current cursor position...
How do I do this? It looks like I need to send the SCI_INSERTTEXT message but I'm really not sure how to do this. I've tried looking at the Delphi template and the DbgpPlugin source code but it doesn't look like either of them send any Scintilla messages.
Can anybody help me out?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Take a look at the source for the SimpleScript plugin. It's based off of a template that Zobo (the author of DBGP) sent me. You'll need everything in the \lib subfolder, which I recommend you copy directly into your own project without changes. That's what I did. It looks like it's all the same as in the DBGP plugin. It's licensed under the GPL, so if you intend to distribute your plugin you'll also need to license it under the GPL.
You can ignore MergeTextLib, scriptprogress, ScriptWriter, and textscriptfunctions units; they're specific to the SimpleScript plugin.
The actual interface between Notepad++ and the plugin is all handled in the simplescriptplugin.pas file. Hopefully it's not too complex to figure out.
Specifically, look at the TSimpleScriptPlugin.FuncRepeatScript procedure. This is the only place in the plugin where messages are sent to Notepad++. To help you decipher it, basically, this function reads in the selected text from the active document (or the full document if no text is selected), sends it to another function to convert it, and replaces either the selection or the full document.
The actual code to send the message is something like the following:
(The above replaces the entire text of the document with the string variable Selected. You'll need to look up the message that inserts text instead)
Any text you send must be converted into a PChar first because the Windows messaging system can't handle Delphi strings. You also need to wrap it in LPARAM. I don't know why; that's just the way it was in the template, so I wasn't going to second-guess it.
Let me know if you need any more help.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Use the win32 SendMessage function with the scintilla handles found in NppData, which gets set at startup of the plugin. Cross reference the delphi plugin with the original N++ NppInsertPlugin template, it inserts text aswell (date/time).
I dk about Delphi, but it should work similar to the c++ examples, just written differently ;)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Let's say I simply want to insert some text at my current cursor position...
How do I do this? It looks like I need to send the SCI_INSERTTEXT message but I'm really not sure how to do this. I've tried looking at the Delphi template and the DbgpPlugin source code but it doesn't look like either of them send any Scintilla messages.
Can anybody help me out?
Take a look at the source for the SimpleScript plugin. It's based off of a template that Zobo (the author of DBGP) sent me. You'll need everything in the \lib subfolder, which I recommend you copy directly into your own project without changes. That's what I did. It looks like it's all the same as in the DBGP plugin. It's licensed under the GPL, so if you intend to distribute your plugin you'll also need to license it under the GPL.
You can ignore MergeTextLib, scriptprogress, ScriptWriter, and textscriptfunctions units; they're specific to the SimpleScript plugin.
The actual interface between Notepad++ and the plugin is all handled in the simplescriptplugin.pas file. Hopefully it's not too complex to figure out.
Specifically, look at the TSimpleScriptPlugin.FuncRepeatScript procedure. This is the only place in the plugin where messages are sent to Notepad++. To help you decipher it, basically, this function reads in the selected text from the active document (or the full document if no text is selected), sends it to another function to convert it, and replaces either the selection or the full document.
The actual code to send the message is something like the following:
SendMessage(self.NppData.ScintillaMainHandle, SCI_SETTEXT, 0, LPARAM(PChar(Selected)));
(The above replaces the entire text of the document with the string variable Selected. You'll need to look up the message that inserts text instead)
Any text you send must be converted into a PChar first because the Windows messaging system can't handle Delphi strings. You also need to wrap it in LPARAM. I don't know why; that's just the way it was in the template, so I wasn't going to second-guess it.
Let me know if you need any more help.
Use the win32 SendMessage function with the scintilla handles found in NppData, which gets set at startup of the plugin. Cross reference the delphi plugin with the original N++ NppInsertPlugin template, it inserts text aswell (date/time).
I dk about Delphi, but it should work similar to the c++ examples, just written differently ;)