• Login
Community
  • Login

NppExec v0.8.6 has been released!

Scheduled Pinned Locked Moved Notepad++ & Plugin Development
26 Posts 6 Posters 3.0k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V
    Vitalii Dovgan
    last edited by Aug 8, 2023, 4:25 PM

    NppExec is:
    https://github.com/d0vgan/nppexec/

    NppExec v0.8.6:

    • Glory to Ukraine! Glory to the heroes!
    • fixed: “nppexec:npp_console off” did not close the Console after a child process has been finished by the @exit_cmd
    • fixed: the Console was not automatically shown when the first command of a script was “npp_console local -” or “npp_console local +”
    • added: $(NPP_PID)
    • added: “set +v …” for delayed substitution of variables
    • added: “set <var> ~ fileexists <path>”, “set <var> ~ direxists <path>”
    • built-in help slightly updated
    • NppExec Manual updated

    Get it here:
    https://github.com/d0vgan/nppexec/releases/tag/v086
    https://sourceforge.net/projects/npp-plugins/files/NppExec/NppExec Plugin v0.8.6/

    Notes:
    The NppExec Manual includes 3 new sections:

    • 4.6.14. Notepad++ as a Clipboard Monitor
    • 4.6.15. Triggering certain actions while saving a file
    • 4.8.3. Console child process workflow

    In terms of the core functionality, there were a few improvements and new features added while updating the NppExec Manual.
    There was no further progress in the direction of PseudoConsole since the previous release.

    V J 2 Replies Last reply Aug 9, 2023, 10:51 AM Reply Quote 7
    • V
      Vitalii Dovgan @Vitalii Dovgan
      last edited by Aug 9, 2023, 10:51 AM

      As a proof of concept, I’ve added index.html to NppExec Manual’s files to mimic the .chm user experience while accessing the Manual via web browser:
      https://htmlpreview.github.io/?https://github.com/d0vgan/nppexec/blob/develop/NppExec/doc/NppExec/NppExec_Manual/index.html

      It would be interesting to add the ability to search the HTML content, similarly to how it is possible within a .chm file. I assume it will require additional styles (.css) and scripts (.js) applied to the index.html and this is something beyond of my knowledge.
      If somebody knows how to do that, please let me know.

      L 1 Reply Last reply Aug 9, 2023, 7:24 PM Reply Quote 3
      • L
        Lycan Thrope @Vitalii Dovgan
        last edited by Lycan Thrope Aug 9, 2023, 7:47 PM Aug 9, 2023, 7:24 PM

        @Vitalii-Dovgan ,
        The easiest way for you to emulate a chm, is with the use of a frame layout, where your index.html is the host, and it’s screen is broken into frames. For instance, one frame on the left with the “contents” and one on the right for the display of the actual content.

        I’m not sure what current html standards use, but at least with version 4.0 (which most browsers should be backward compatible with) you can still write html code that allows for this by just changing the header to reflect that version of html.

        Here’s some sample code showing a page, with 3 framed areas and if you copy this into a new file in NPP and name it index.html you can view it in a browser. Firefox is my choice:

        <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
        <html>
          <head>
            <meta http-equiv="content-type" content="text/html; charset=utf-8">
            <meta name="description" content="">
            <meta name="keywords" content="">
          <title>NPP Frame Reconstruction</title>
          </head> 
        <frameset rows="20%,*">
            <frame classname="ridge" name="indexheader" src="https://htmlpreview.github.io/?https://raw.githubusercontent.com/d0vgan/nppexec/develop/NppExec/doc/NppExec/NppExec_Manual/0.%20Title%20Page.html" marginwidth="0" marginheight="0" scrolling="no" frameborder="5" noresize="noresize" bordercolor="#48800C" >
                <frameset cols="15%,*">
                <frame name="indexmenu" src="" marginwidth="0" marginheight="0" scrolling="auto" frameborder="5" noresize="noresize" bordercolor="#48800C" >
                <frame name="indexviewport" src="" marginwidth="0" marginheight="0" scrolling="auto" frameborder="5" noresize="noresize" bordercolor="#48800C" >
            </frameset>
        </frameset>
        </html>
        
        V 1 Reply Last reply Aug 9, 2023, 8:55 PM Reply Quote 3
        • V
          Vitalii Dovgan @Lycan Thrope
          last edited by Aug 9, 2023, 8:55 PM

          Thank you for the hints!

          This thing works locally:
          https://github.com/d0vgan/nppexec/blob/develop/NppExec/doc/NppExec/NppExec_Manual/index-2.html

          But not remotely:
          https://htmlpreview.github.io/?https://github.com/d0vgan/nppexec/blob/develop/NppExec/doc/NppExec/NppExec_Manual/index-2.html

          I’m so far from this HTML stuff that even this simple “index-2.html” took me noticeable time to make it work locally.
          Now I see it does not work remotely :( Moreover, <frame> is stated as “deprecated”, whereas <iframe> does not seem to support automatic resizing when you have two of them and want to move the divider between them. Or I just don’t understand it (that is most likely) :)

          R 1 Reply Last reply Aug 10, 2023, 2:59 AM Reply Quote 0
          • R
            rdipardo @Vitalii Dovgan
            last edited by rdipardo Aug 10, 2023, 3:01 AM Aug 10, 2023, 2:59 AM

            This thing works locally:
            https://github.com/d0vgan/nppexec/blob/develop/NppExec/doc/NppExec/NppExec_Manual/index-2.html

            But not remotely:
            https://htmlpreview.github.io/?https://github.com/d0vgan/nppexec/blob/develop/NppExec/doc/NppExec/NppExec_Manual/index-2.html

            The <frameset> is strongly discouraged by contemporary web standards, so it’s no wonder the hosting server won’t load it (although the frame borders are still clearly visible).

            As you’ve noticed, the file:/// protocol works fine, as it’s not handled as securely as a remote host — even though a page at a file:/// address will still execute whatever scripts may be embedded in it.

            1 Reply Last reply Reply Quote 1
            • J
              Joseph Samuel @Vitalii Dovgan
              last edited by Aug 11, 2023, 9:29 PM

              @Vitalii-Dovgan
              I think you have an option to use github pages with frames as suggested by @Lycan-Thrope
              Like this https://bjsam.github.io/nppexec/
              https://github.com/BJSam/nppexec/tree/gh-pages
              instead of having a new branch(like I did) move all the docs to a docs folder at root and configure github pages to point docs folder.

              L V 2 Replies Last reply Aug 11, 2023, 11:36 PM Reply Quote 3
              • L
                Lycan Thrope @Joseph Samuel
                last edited by Aug 11, 2023, 11:36 PM

                @Joseph-Samuel ,
                Thanks. I don’t have a lot of experience with the main purpose of github, myself, let alone all the little tricks it involves.

                My suggestion of using the html standard of the frameset of 4.0 or 4.01 was to at least allow for someone to setup a local usage, like downloading the documentation to the hard drive and being able to view it in a browser.

                Thanks for giving him a better usable solution with his current intent.

                1 Reply Last reply Reply Quote 3
                • V
                  Vitalii Dovgan @Joseph Samuel
                  last edited by Aug 13, 2023, 7:07 PM

                  Wow, kudos to Joseph, now NppExec’s Manual is available online!!!
                  https://d0vgan.github.io/nppexec/

                  V 1 Reply Last reply Aug 13, 2023, 9:14 PM Reply Quote 1
                  • V
                    Vitalii Dovgan @Vitalii Dovgan
                    last edited by Aug 13, 2023, 9:14 PM

                    Just wondering: is it possible to alter the “index.html” (in the root) to make it work both from the web and locally? As far as I understand, locally <base href="/nppexec/"> confuses a browser, so maybe there could be some conditional instruction?

                    L 1 Reply Last reply Aug 14, 2023, 5:06 AM Reply Quote 0
                    • L
                      Lycan Thrope @Vitalii Dovgan
                      last edited by Lycan Thrope Aug 14, 2023, 5:24 AM Aug 14, 2023, 5:06 AM

                      @Vitalii-Dovgan ,
                      Not sure what you mean? Just saving the file via browser, saves it to the person’s chosen directory with all the html links so it can be navigated. What are you trying to do differently?

                      V 1 Reply Last reply Aug 14, 2023, 8:13 AM Reply Quote 0
                      • V
                        Vitalii Dovgan @Lycan Thrope
                        last edited by Aug 14, 2023, 8:13 AM

                        @Lycan-Thrope
                        I mean if I get these files from github to my local machine:
                        https://github.com/d0vgan/nppexec/tree/develop/docs
                        and open the “index.html” in the root of the “docs” folder on my local machine, the content is not shown because of the <base href="/nppexec/">. Hence the question whether it is possible to make the <base> tag conditional, depending on whether the path to “index.html” is local or not.

                        R 1 Reply Last reply Aug 14, 2023, 11:27 AM Reply Quote 0
                        • R
                          rdipardo @Vitalii Dovgan
                          last edited by Aug 14, 2023, 11:27 AM

                          @Vitalii-Dovgan said in NppExec v0.8.6 has been released!:

                          Hence the question whether it is possible to make the <base> tag conditional, depending on whether the path to “index.html” is local or not.

                          Dynamic HTML is pretty hard without the benefits of a server-side language like PHP. You could more easily just fake the <base> path on local machines.

                          First, make a nppexec/ subtree in the docs/ root, and create empty files for the pages you need, e.g.

                          docs/
                          ├── fparser.html
                          ├── index.html
                          ├── nppexec
                          │   └── NppExec_Manual
                          │       ├── 0. Title Page.html
                          │       └── toc.html
                          ├── ...
                          ├── NppExec_Manual
                          |   └── . . .
                          ├── ...
                          ├── ...
                          ├── ...
                          └── style.css
                          

                          Now the dummy pages can simply redirect to the real pages using location.replace :

                          <!-- docs/nppexec/NppExec_Manual/toc.html -->
                          <!DOCTYPE html>
                          <body>
                            <!-- fallback for when JS is disabled by the user agent -->
                            <noscript>
                              <h1>301 - Moved permanently</h1>
                              <p>
                                This page has moved to <a href="../../../NppExec_Manual/toc.html">../../../NppExec_Manual/toc.html</a>.
                              </p>
                            </noscript>
                            <script>
                              window.onload = function() {
                                location.replace("../../../NppExec_Manual/toc.html");
                              }
                            </script>
                          </body>
                          </html>
                          
                          <!-- docs/nppexec/NppExec_Manual/0. Title Page.html -->
                          <!DOCTYPE html>
                          <body>
                            <!-- blah... -->
                            <script>
                              window.onload = function() {
                                location.replace("../../../NppExec_Manual/0. Title Page.html");
                              }
                            </script>
                          </body>
                          </html>
                          
                          1 Reply Last reply Reply Quote 5
                          • R
                            rdipardo
                            last edited by Aug 15, 2023, 7:44 AM

                            I should’ve mentioned that the above will only work on a local server. When that’s the case, the forward slash in the /nppexec base path resolves to the server’s root (presumably docs/). It does not matter where on the file system the docs/ directory happens to be saved.

                            But if you’re just browsing the docs over the file:// protocol, the forward slash resolves to the file system’s root, and since docs/ will never be saved directly under C:\ or similar, the /nppexec path won’t be found either.

                            Fortunately there’s a client-side solution for this, too; and it’s even simpler.

                            Just create a second index page, for example index-1.html, identical to index.html except leaving out the <base> path. This will be for locally browsing the file tree.

                            Now your main index just needs a few lines of JavaScript to know when to serve index-1.html instead, e.g.

                              window.onload = function() {
                                if (location.protocol == 'file:') {
                                  location.replace(location.href.replace(/\/index\.(php|x?html?)$/, '/index-1.html'));
                                }
                              }
                            
                            1 Reply Last reply Reply Quote 2
                            • R
                              rdipardo
                              last edited by rdipardo Aug 15, 2023, 10:05 AM Aug 15, 2023, 10:02 AM

                              Just a few more things.

                              If we don’t want to prejudice local servers, we should check the hostname, too, and take into account that index file paths are usually omitted when requesting a server address.

                              Binding a callback to window.onload is also not ideal when it gives the server time to log 404 codes, and the user may see flickering error messages in the window.

                              A full patch would look like this, excluding a new index-1.html page. The <script> element is now a child of <head>, to respect HTML document standards.

                              diff --git a/docs/index.html b/docs/index.html
                              index 97dbc11..28ebe28 100644
                              --- a/docs/index.html
                              +++ b/docs/index.html
                              @@ -7,24 +7,21 @@
                               <title>NppExec Manual: Index</title>
                               <meta http-equiv="Permissions-Policy" content="interest-cohort=()"> <!--Remove warning in browser: feature not enabled: 'interest-cohort'-->
                               <base href="/nppexec/">
                              -</HEAD>
                              -<script>
                              -  // var protocol = location.protocol;
                              -  // var hostname = location.hostname;
                              -  // var pathname = location.pathname;
                              -  // var protocol = location.protocol
                              -  // var port     = window.location.port
                              -  // var baseHref = new URL('http://github.com'); 
                              -  // baseHref.host = hostname
                              -  // baseHref.port = port.length>0 ? port : null
                              -  // baseHref.pathname = pathname
                              -  // baseHref.protocol = protocol
                              -  // console.log(baseHref.href);
                              -  // var head = document.getElementsByTagName('head')[0];
                              -  // var base = document.createElement('base');
                              -  // base.href = baseHref.href;
                              -  // head.appendChild(base);
                              +<script type="text/javascript">
                              +    var protocol = location.protocol;
                              +    var hostname = location.hostname;
                              +    var pathname = location.pathname;
                              +    var href     = location.href;
                              +    var newPath  = 'index-1.html';
                              +    var redir    = href.replace(/\/index\.(php|x?html?)$/, '/'+newPath);
                              +    if (protocol == 'file:') {
                              +        location.replace(redir);
                              +    } else if (Array('localhost', '127.0.0.1').indexOf(hostname) > -1) {
                              +        redir = (pathname == '/') ? href + newPath : redir;
                              +        location.replace(redir);
                              +    }
                               </script>
                              +</HEAD>
                               <FRAMESET cols="30%, 70%">
                                 <FRAME name="toc" src="./NppExec_Manual/toc.html">
                                 <FRAME name="content" src="./NppExec_Manual/0. Title Page.html">
                              
                              
                              V 1 Reply Last reply Aug 15, 2023, 12:10 PM Reply Quote 3
                              • V
                                Vitalii Dovgan @rdipardo
                                last edited by Aug 15, 2023, 12:10 PM

                                @rdipardo
                                Thank you! I’ve integrated this - seems to work like a charm!
                                Now I probably understand the feelings of people who are looking at Python’s or NppExec’s scripts with understanding of the general idea behind them but anyway perceiving the entire script like a form of a magic spell :)

                                PeterJonesP 1 Reply Last reply Aug 15, 2023, 1:00 PM Reply Quote 2
                                • PeterJonesP
                                  PeterJones @Vitalii Dovgan
                                  last edited by Aug 15, 2023, 1:00 PM

                                  @Vitalii-Dovgan and all,

                                  It seems like this is mostly wrapped up, but if there’s anything more on the HTML/presentation of the NppExec manual, it would be a better fit in the NppExec repo’s issue section than here.

                                  Of course, discussion on the plugin itself is quite encouraged here. :-)

                                  1 Reply Last reply Reply Quote 3
                                  • V
                                    Vitalii Dovgan
                                    last edited by Aug 18, 2023, 7:53 PM

                                    Recently I had made some optimizations around variables handling in NppExec (in the develop branch). So I decided to create a scenario that would help to compare the performance between 0.8.6 and pre-0.8.7. Hence the following simple NppExec’s script was born:

                                    npe_console local -- m-
                                    set local N = 20
                                    set local i = 0
                                    
                                    :1
                                    set local i ~ $(i) + 1
                                    if $(i) >= 8400 goto 3
                                    if~ $(i) % 100 != 0 goto 1
                                    set local k ~ ord a
                                    set local kk = 0
                                    :2
                                    set local c ~ chr $(k)
                                    set local v ~ strupper $(c)
                                    set local $($(c)_) = $($(c)_)$(v)
                                    set local k ~ $(k) + 1
                                    set local kk ~ $(kk) + 1
                                    if $(kk) < $(N) goto 2
                                    goto 1
                                    
                                    :3
                                    set local k ~ ord a
                                    set local kk = 0
                                    :4
                                    set local c ~ chr $(k)
                                    echo $($(c)_)
                                    set local k ~ $(k) + 1
                                    set local kk ~ $(kk) + 1
                                    if $(kk) < $(N) goto 4
                                    

                                    This script intentionally does not use nested IF-THEN-ELSE because, as I discovered during these tests, all the versions of NppExec prior to pre-0.8.7 (in development) had problems with nested IF-THEN-ELSE. I wonder how it happened that no one had reported that before.
                                    Anyway, here is the script that works in both NppExec 0.8.6 and pre-0.8.7 and here are the average execution times of this script on my i5-6600 CPU @ 3.30GHz :

                                    0.8.6 - 2.00 seconds
                                    0.8.7 - 0.65 seconds

                                    Not bad, I should say.
                                    Now, if you want the very same script to take extra long time of around 2 minutes and 30 seconds (just compare it to 0.65 seconds!), just replace npe_console local -- m- in the beginning of the script with npe_console local -- m+. This clearly shows that the implementation of CNppExecConsole::PrintMessage which is basically:

                                    SendMessage(hRichEdit, EM_EXGETSEL, 0, (LPARAM) &cr);
                                    SendMessage(hRichEdit, WM_SETREDRAW, FALSE, 0);
                                    SendMessage(hRichEdit, EM_EXSETSEL, 0, (LPARAM) &CHARRANGE{-1, -1});
                                    SendMessage(hRichEdit, EM_SETCHARFORMAT, (WPARAM) dwOptions, (LPARAM) &cf);
                                    SendMessage(hRichEdit, EM_REPLACESEL, FALSE, (LPARAM) cszText);
                                    SendMessage(hRichEdit, EM_EXSETSEL, 0, (LPARAM) &cr);
                                    SendMessage(hRichEdit, EM_SCROLLCARET, 0, 0);
                                    SendMessage(hRichEdit, WM_SETREDRAW, TRUE, 0);
                                    if (InvalidateRect(hRichEdit, NULL, TRUE))
                                        UpdateWindow(hRichEdit);
                                    

                                    is slow as hell.
                                    As you can see, all of these are actually messages to a RichEdit window.
                                    I tried to remove SendMessage(hRichEdit, WM_SETREDRAW, FALSE, 0);, together with SendMessage(hRichEdit, WM_SETREDRAW, TRUE, 0);, InvalidateRect(hRichEdit, NULL, TRUE) and UpdateWindow(hRichEdit) - and got 3 minutes and 40 seconds - i.e. 1 minute was added to the previous extra long result!
                                    Oh my, is there a way to append text to RichEdit more effectively, without waiting forever?

                                    PeterJonesP 1 Reply Last reply Aug 18, 2023, 9:10 PM Reply Quote 1
                                    • PeterJonesP
                                      PeterJones @Vitalii Dovgan
                                      last edited by Aug 18, 2023, 9:10 PM

                                      @Vitalii-Dovgan said in NppExec v0.8.6 has been released!:

                                      As you can see, all of these are actually messages to a RichEdit window.

                                      It sounds like you’ve got a generic win32 API programming question, then, rather than something specific to Notepad++, and there are other forums on the internet that will have a higher concentration of RichEdit experts than here, where we focus on the specifics to the Plugin/Notepad++ interface.

                                      1 Reply Last reply Reply Quote 0
                                      • Alan KilbornA
                                        Alan Kilborn
                                        last edited by Aug 18, 2023, 9:39 PM

                                        Hmm, told TWICE now to avoid off-topic conversations…

                                        1 Reply Last reply Reply Quote 0
                                        • V
                                          Vitalii Dovgan
                                          last edited by Aug 18, 2023, 9:55 PM

                                          Guys, I respect your will to avoid off-topic.
                                          Let’s, however, analyze the content of my last message:

                                          • First I’m presenting an interesting NppExec’s script. Not off-topic.
                                          • Second, I’m describing some technical details of NppExec’s implementation. Not off-topic.
                                          • then I mention the details of implementation of CNppExecConsole::PrintMessage to illustrate that exactly the implementation of this method adds extra execution time.
                                            Until this point, there’s nothing about “a generic win32 API programming question”, as you mentioned.
                                            Finally, summing up with the slow implementation of CNppExecConsole::PrintMessage, I’m asking “is there a way to append text to RichEdit more effectively”. This question was not the goal of the entire text above.
                                          PeterJonesP 1 Reply Last reply Aug 18, 2023, 10:01 PM Reply Quote 1
                                          5 out of 26
                                          • First post
                                            5/26
                                            Last post
                                          The Community of users of the Notepad++ text editor.
                                          Powered by NodeBB | Contributors