Interacting with npp

Paulius
2005-07-26
2012-11-14
  • Paulius

    Paulius - 2005-07-26

    Ok, so i started my plugin already and wanted to ask a few questions:
    1) Is there a way for a plugin to get the full list of supported languages, including user defined languages?
    2) Is there a way for a plugin to tell npp to open a file without showing any dialogs? I'm thinking about something like this:
    ::PostMessage (nppWnd, OPEN_FILE_MESSAGE, (WPARAM) "C:\\filename.ext", 0);
    And then npp recieves this message and opens the file in WPARAM as if it was opened using file->open dialog.

    Thank you for this great program, now that it has plugin support - it's even better!!! :)

     
    • Don HO

      Don HO - 2005-07-27

      > but i suppose WM_DOOPEN will replace currently open file.
      Negative.
      When you send WM_DOOPEN message the current file won't be closed. So notepad++ will open the file you want (and keep the current file open), then activate your file as current file. You don't need to (and mustn't) call IDM_FILE_NEW command.

       
      • Paulius

        Paulius - 2005-07-28

        Oh... In that case i will use WM_DOOPEN.
        Thank you.

         
    • Don HO

      Don HO - 2005-07-26

      To answer your question :

      1) For the moment, no. But I'll think about it (what kind of data structure should we use to present such list : an int array or a an object of vector<string>).

      2) Not yet, but I can make this message available :
      paste these 2 lines in your pluginInterface.h :

      #define SCINTILLA_USER     (WM_USER + 2000)
      #define WM_DOOPEN  (SCINTILLA_USER + 8)

      Usage :
      std::string filePath = "c:\\myfile.txt";
      ::SendMessage(nppHandle, WM_DOOPEN, 0, (LPARAM)filePath.c_str());

      it will open the filePath in current Scintilla View.

      Don

       
    • Paulius

      Paulius - 2005-07-26

      1) If you provide an array of ints - would there be a way to get language display name from such integer? If so, then i would stick to this solution, because providing a vector (list or any other object) of string objects is a no no - that would not work with other programming languages than C++ (with STL enabled).
      - OR (another option) -
      At this moment, i will investigate if it's possible to obtain this list by simply investigating Language menu items. It might be a problem when user uses localized version of npp (not English).

      2) Thanks, i will try this solution.

       
      • Don HO

        Don HO - 2005-07-27

        > At this moment, i will investigate if it's possible
        > to obtain this list by simply investigating Language menu items.
        > It might be a problem when user uses localized version of npp (not English).

        Then I suggest you adapt this solution :
        The Language menu items will be never translatable.

        Don

         
        • Don HO

          Don HO - 2005-07-27

          In addition, you can get all the string items for all language via menu items - even the User Defined Languages which I wonder if I can provide via a message.

          Don

           
    • Paulius

      Paulius - 2005-07-26

      Hm... Going back to question #2.
      I looked at original sources of npp v3.1, the file winmain.cpp lines 171-194 is dealing with the situation where there is already instance of npp running. Lines that interests me the most is 183-191. On those lines npp prepairs and sends a command line arguments to already running instance of npp.
      So i'm thinking - maybe i should use the same approach?
      It isn't a problem for my plugin to create some *fake* command line string and send it with WM_COPYDATA message. I think i'm gonna try both solutions and i will look wich one works faster... :)

       
      • Don HO

        Don HO - 2005-07-27

        The execution speed for WM_DOOPEN message will be faster than WM_COPYDATA message since there's less information to treat in WM_DOOPEN message (only a file path).

        But WM_COPYDATA message give more options : the language type (sytanx highlighting and folding), the line to scroll to and multi-files option - you have to fill in the COPYDATASTRUCT structure.

        So it's up to your purpos - if you only want to open one file in the current view, WM_DOOPEN will be a better choice.

        Don

         
        • Paulius

          Paulius - 2005-07-27

          > if you only want to open one file in the current
          > view, WM_DOOPEN will be a better choice.
          I see. Well, i haven't tested it yet, but i suppose WM_DOOPEN will replace currently open file. In wich case, before sending WM_DOOPEN i must trigger IDM_FILE_NEW command (WM_COMMAND message). So... To summarize options i have:
          1) Send a single message WM_COPYDATA (handling the COPYDATASTRUCT structure adds to execution time);
          2) Send messages WM_COMMAND (IDM_FILE_NEW) and WM_DOOPEN (data handling is faster, but it is TWO messages to be handled by npp).

          I think i need more testing wich one of those solutions is faster.

           

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

Sign up for the SourceForge newsletter:





No, thanks