Menu

NppExec Suggestion

2007-06-13
2012-11-14
  • Hashim Kubba

    Hashim Kubba - 2007-06-13

    Hi,

    I have been using N++ for over a year now and it a great product.

    I have a suggestion for NppExec next release, is it possible to add ${left_view_file} and ${right_view_file} to the list of variables?

    That would be very useful in comparing files using an external tool like WinMerge (http://winmerge.org/) so I can simply say:
    C:\program files …\WinMerge ${left_view_file} ${right_view_file}

    That will add the ability to compare files to N++

    Regards, and thanks for the good job

     
    • DV

      DV - 2007-08-20

      Thanks for httrack, maybe it's a tool I was for a long time looking for.
      By the way, if somebody is interested in dictionaries, here is a perfect one: http://stardict.sourceforge.net/ (recently ver. 3.0.0 has been released). It has really a lot of additional dictionaries almost for all languages, works very fast, and it's free! No more Lingvo, StarDict rulez! :-)
      Returning to NppExec, NPP_SAVEALL is planned to be in the next version together with a menu item "Auto save all before executing a script" (well, the name of this menu item will be different :-)
      Also I thought about TCL and I don't think it's a good idea to support it internally. It's completely new language which is not easy to be used by beginners (such as I am). If I should integrate some interpretter into the plugin, I prefer Gentee which is very close to C++ and its basic functionality is provided by dll-file with a size of just 150 kB (for version 2.5).
      But I have an interesting idea when you talk about API functions. I could add a new function in the plugin:
      NPP_SENDMSG <message>, <wparam>, <lparam>
      which can be used as a wrapper for SendMessage(hNppWnd, uMessage, wParam, lParam) and, thus, give a possibility to execute Notepad++'s functions directly. For example, implementation of 'NPP_SENDMSG WM_COMMAND, <wparam>, <lparam>' would give us almost full control on Notepad++. But, as you can see, implementation of such mechanism needs really a lot of time, because this command must be safe and support both names of the messages (such as WM_COMMAND, WM_USER etc.) and their codes (0x0111, 0x0400 etc.). So, if somebody wants to help me with implementation of a parser for such command, I'll be very thankful ;-)
      Internal parameters for NPP_SENDMSG command can be described as a structure:

      typedef struct _NPP_SENDMSG_STRUCT {
      unsigned int uMessageCode, // 0x0111, ...
      const TCHAR* szMessageName, // _T("WM_COMMAND"), ...
      unsigned int type_of_wParam, // enum EParamType
      unsigned int type_of_lParam, // enum EParamType
      } NPP_SENDMSG_STRUCT;

      enum EParamType {
      TYPE_UNKNOWN = 0, // type of parameter is unknown
      TYPE_INT, // parameter is an integer, e.g. NPP_SENDMSG NPPM_ACTIVATEDOC, 1, 0
      TYPE_STR, // parameter is a string, e.g. NPP_SENDMSG NPPM_SWITCHTOFILE, 0, "file.txt"
      ...
      };

       
    • DV

      DV - 2007-06-14

      OK, it make sense. Will be added in 0.2 beta4.

       
      • Hashim Kubba

        Hashim Kubba - 2007-06-14

        Thanks for your fast response;

        To make this even better, you should think of a way to save files to the OS temporary folder (in windows it is c:\windows\temp or so) if they are not saved yet, then use file names (any name like 243598723.txt) as the parameter.

        That will make it easy to paste text into new file, paste other text into a second new file, chose the second file and click 'go to another view', the click F6 and chose 'compare' without worrying about saving the files.

        Either that or show us how to write this in a sample code :D

        Regards

         
        • Nobody/Anonymous

          Hi,

          I have another NppExec suggestion. Well, two actually. This plugin is really handy and I think it could be much improved by the addition of.

          1) Access to the system environment variables. $(PATH), $(ANT_HOME) etc... these would be very useful.
          2) Key Assignment. If I could assign keys to individual commands like in the Run menu that would be great. Or maybe if we could extend the run menu option to allow you to execute NppExec scripts. That would be less work.

          That's it. It's a great little tool. Keep up the good work.

          -Mark

           
    • DV

      DV - 2007-08-10

      Number of system environment variables varies which each version of Windows, so there is one possible solution I see: to add a global variable such as $(SYS) which will be an array of system variables e.g. $(SYS[PATH]), $(SYS[TEMP]), $(SYS[SYSTEMROOT]) etc. Such environment variables can be extracted with GetEnvironmentVariable() API function. But I am not sure it will handle user-defined variables such as ANT_HOME. I'll think about it.
      Talking about key assignment, I have no obvious solution for it - the best idea so far, IMHO, is to implement shortcut keys inside the plugin's Execute Dialog.

       
      • Mark Lynch

        Mark Lynch - 2007-08-10

        Rather than storing all these somewhere (and thereby creating the need to support specific variables) could you wait until you are parsing the line you are about to execute, and then if it isn't one the ones you recognise (the NPPExec specific ones) you then call the GetEnvironmentVariable() API. That way any user defined variable will be accessible.

         
    • steakhacher

      steakhacher - 2007-08-10

      Should be possible to insert tcl support in nppexec plugin or is it totally impossible. With tcl it could be possible to access API function without need of compiling C++.

      Thanks for your answer

       
    • DV

      DV - 2007-08-13

      Does this TCL have some portable form? I mean, can it be distributed as an executable file (interpretter) with some needed libraries (dll-files) or as stand-alone library (dll-file)? Or, in other words, does it have an command-line interface or can its functions be called directly from its dynamic-link library?
      If it has command-line interface, its functions can be called from command-line in such way:

      tcl.exe "<functions>"

      If it has dll-interface, its functions can be called within another application in such way (approximately):

      HANDLE hTCL = LoadLibrary( ... );
      FARPROC funcTCLExecute = GetProcAddress(hTCL, ...);
      ...
      char* szTCLfunction = "<some TCL function>";
      funcTCLExecute(szTCLfunction);
      ...
      FreeLibrary(hTCL);

      If something described above is possible, give me direct links to portable version of TCL. I don't want to deal with interpretters/languages which are: 1) gigantic; 2) register a lot of its stuff in the OS; 3) works through OLE or something similar.

       
    • Rod Zilla

      Rod Zilla - 2007-08-15

      Tcl exists as both a library (tcl84.dll) and an executable interpreter (tclsh.exe).
      It does not mess with the OS, is not gigantic (though if you want a *really* light scripting language, Lua is probably the way to go), and is extremely good at manipulating strings (much better than Lua).
      Tcl is also the scripting language used in most Electronic Design Automation software.

      A good Tcl documentation (the Tcl language + the C API): http://tmml.sourceforge.net/doc/tcl
      Sources for Tcl: http://www.tcl.tk/software/tcltk/downloadnow84.html

      Integrating it into Notepad++ would consist in (1) creating and handling a Tcl interpreter and (2) binding useful Notepad++ functions into Tcl.

      (1) should be pretty simple:

      // To create an interpreter:
      Tcl_Interp* theInterpreter = Tcl_CreateInterp();

      // To execute a script:
      if (Tcl_Eval(theInterpreter, theScript) == TCL_ERROR) {
        // Handle the error using 'const char *Tcl_GetStringResult(theInterpreter)'
      }

      (2) should be a bit more complicated because functions you will wrap must be chosen carefully.
      To actually wrap functions, you might want to use SWIG (http://www.swig.org/), a wrapper generator that has support for quite a few scripting languages (just in case you have similar requests :D).

      Hope this helps,
      Rod

       
    • DV

      DV - 2007-08-17

      Can I download somewhere an offline version of documentation at 'tmml.sourceforge.net/doc/tcl' ?
      In a form of .chm file, for example ?
      This documentation seems to be more detailed than TCL's internal help (the compiled .hlp file), but it's not handy for me to read it on-line only.

       
      • steakhacher

        steakhacher - 2007-08-19

        Hi

        I don't know but you can use software like http://www.httrack.com that allows you to download a World Wide Web site from the Internet to a local directory.

         
    • Nobody/Anonymous

      Hello,

        Thank you for NPP :) This tool makes my life a lot easier!

        I am using NPP for embedded app developing in C++. I have a suggestion for NppExec next release: is it possible to add $NPP_SAVE_ALL to the list of commands?
        
        My script starts a makefile and a debugger. It would be nice to to avoid unneccessary debug cycles :( just because I forgot pressing Ctrl+Shift+S before execuing the compile script.

      Thank you and best regards

        Attila