Notepad ++ Plugin -Entwicklung in C ++: Nicht direkt nach dem Öffnen der Datei in die angegebene Zeile springen

Post a reply

Smilies
:) :( :oops: :chelo: :roll: :wink: :muza: :sorry: :angel: :read: *x) :clever:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Notepad ++ Plugin -Entwicklung in C ++: Nicht direkt nach dem Öffnen der Datei in die angegebene Zeile springen

by Anonymous » 20 Aug 2025, 01:25

Ich bin neu bei Notepad ++ Plugin-Entwicklung und habe einen kleinen Befehl zum navigieren, um zwischen Dateien zu navigieren. Öffnet anschließend eine andere Datei und setzt den Cursor dort an eine Position, die dem gefundenen Wort entspricht. Das funktioniert gut. Was funktioniert nicht, scrollt diese Zeile mit Sci_Setfirstvissibleline sichtbar und oben. Wie mache ich das? Während ich das Ereignis bekomme (NPPN_BufferActivated), scheint es immer noch zu früh zu sein. Wenn ich sci_setfirstvissibleline an eine bereits geöffnete Datei sende, dann springt Notepad ++ richtig. Leeren Sie den Körper von ihnen und fügen Sie hinzu: < /p>

Code: Select all

std::wstring filepath = L"PATH TO A LONG TEXT FILE";
::SendMessage(nppData._nppHandle, NPPM_DOOPEN, 0, (LPARAM)filepath.c_str()); // works

int which = -1;
::SendMessage(nppData._nppHandle, NPPM_GETCURRENTSCINTILLA, 0, (LPARAM)&which);
HWND curScintilla = (which == 0) ? nppData._scintillaMainHandle : ppData._scintillaSecondHandle;
int line = 300; // go to line 300
::SendMessage(curScintilla, SCI_GOTOLINE, line - 1, 0); // works
::SendMessage(curScintilla, SCI_SETFIRSTVISIBLELINE, line - 1, 0); // does NOT work
//::SendMessage(curScintilla, SCI_SCROLLCARET, 0, 0); // works sometimes

Top