Notepad ++ notepad - reading the entire text of a document

I am writing a notepad ++ plugin using the C # template http://sourceforge.net/projects/sourcecookifier/files/other%20plugins/NppPlugin.NET.v0.5.zip/download .

Does anyone know how I can read all the current text of a document, since I need to read all the text in a string?

Does anyone know a function that reads the current text of a document?

+5
source share
2 answers

The link to the Scintilla API documentation should point in the right direction:

http://www.scintilla.org/ScintillaDoc.html#SCI_GETTEXT

The demo project you linked has an example of sending messages.

+5
source

, Demo #, - Notepad ++:

int length = (int) Win32.SendMessage(GetCurrentScintilla(), SciMsg.SCI_GETLENGTH, 0, 0);
IntPtr ptrToText = Marshal.AllocHGlobal(length+1);
Win32.SendMessage(GetCurrentScintilla(), SciMsg.SCI_GETTEXT, length, ptrToText);
string textAnsi = Marshal.PtrToStringAnsi(ptrToText);
Console.WriteLine(textAnsi);
Marshal.FreeHGlobal(ptrToText);
  • .
  • .
  • , .
  • Console.WriteLine , .
  • .

: http://www.scintilla.org/ScintillaDoc.html#SCI_GETTEXT

^^

+2

All Articles