Detect event and perform action in notepad++ plugin

2013-01-07
2013-01-08
  • Damien LEVEQUE

    Damien LEVEQUE - 2013-01-07

    I'm trying to develop a plugin and I need to detect when the user opens a file or change tab on notepad + +. Is there the possibility to create an event and detect this action and how ?
    I develop in C + +

    Thanks

     
  • François-R Boyer

    Your plugin should have a extern "C" __declspec(dllexport) void beNotified(SCNotification *notifyCode) function. Notepad++ notification codes have NPPN_* defines, and Scintilla notifications have SCN_* defines. For file open there is NPPN_FILEOPENED, NPPN_FILEBEFOREOPEN, NPPN_FILEBEFORELOAD, and for tab change there is NPPN_BUFFERACTIVATED.

     
  • Damien LEVEQUE

    Damien LEVEQUE - 2013-01-07

    Thanks for this answer but how I should use NPPN_BUFFERACTIVATED ? Via SendMessage ? What parameters should I put ? Where I need to put this in my source code? Can I have an exemple of source code with NPPN_BUFFERACTIVATED who call a function?

     
  • François-R Boyer

    You should not call NPPN_BUFFERACTIVATED, it is Notepad++ which will call your beNotified function with notifyCode->nmhdr.code having a value of NPPN_BUFFERACTIVATED (thus you should have a switch case in your function), notifyCode->nmhdr.hwndFrom will have the HWND of Notepad++ window and notifyCode->nmhdr.idFrom will have the ID of the buffer which is activated. You can look at Notepad_plus_msgs.h to have a list of all NPPN_ messages and what they contain.

     
  • Damien LEVEQUE

    Damien LEVEQUE - 2013-01-08

    Thanks for your answer. I didn't see the extern "C" __declspec(dllexport) void beNotified(SCNotification *notifyCode) method in NppPluginDemo

    So, now all is alright!!
    Thank you again

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks