Community

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    NppExec Console not recognizing block pasting of input into it.

    Plugin Development
    4
    7
    323
    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.
    • shinya kougami
      shinya kougami last edited by shinya kougami

      For example I tried running the following c++ code.

      #include<bits/stdc++.h>
      using namespace std;
      
      int main() {
          int a,b; cin>>a>>b;
          cout<< a+b;
          return 0;
      }
      

      The code works fine if I input numbers manually into the nppexec console. It also works if I copy and paste from 1 2. But if I copy from

      1
      2
      

      (the difference is they are in separate lines now) and paste it into nppexec console it still waits for input, I think it took the last value(2) for a and is still waiting for b.

      Can anyone help me with this? Manually entering the values into the console is very tedious :(. Also the only similar question I could find is Why is NppExec reading my input for c++ exe incorrectly? which unfortunately doesn’t have an answer.

      PeterJones 1 Reply Last reply Reply Quote 0
      • PeterJones
        PeterJones @shinya kougami last edited by

        @shinya-kougami ,

        I wonder if the NppExec console is intercepting the embedded newline and not passing it into your external executable process correctly… or maybe your clipboard (copy buffer) doesn’t have the same newline sequence that your external executable is expecting.

        But yes, when i try it with a similar program in a different language, if I paste two lines of input when running from a cmd.exe window, it accepts those as the two lines of input; whereas if I paste the same two lines in NppExec console as input, the second line of my paste gets interpreted as the first line of the input, and I have to type another line to act as the second line of input to the program.

        Maybe some of the npe_console command’s options will affect that, but I’m not sure which.

        The author, @Vitaliy-Dovgan , does occaionally log in here, so he might be able to give insight. And I know that @Michael-Vincent is a power user of that plugin, so maybe he’s seen what causes that, or a way around that.

        Sorry I couldn’t be more help.

        Vitalii Dovgan 1 Reply Last reply Reply Quote 1
        • Vitalii Dovgan
          Vitalii Dovgan @PeterJones last edited by

          Here is the current situation. NppExec’s Console accepts only single line inputs. When multiple lines are pasted into NppExec’s Console, it takes only the last line into account, ignoring the previous lines.

          There are TODO items to support multiple lines pasting. The following things to be considered:

          1. When there is no console process running in the Console, the multi-line text pasted will be treated as NppExec’s script - i.e. as multiple commands similar to the ones coming from the “Execute” dialog.

          2. If a console process is running, there are several interesting points:
            2.1. If the pasted multi-line text contains ‘\r’ or ‘\r\n’ line endings, should they be replaced with ‘\n’ or not before passing them to the running process? Most likely they shoudn’t, but I’m not sure.
            2.2. If the pasted multi-line text contains commands with prefixes “nppexec:” or “nppexec::”, these commands must be executed by NppExec itself. I.e. the commands without these prefixes will go to the running process, whereas the other commands (with prefixes) will go to NppExec’s script engine. As the sequence of command execution must be preserved, this may be somewhat challenging.

          3. Updating NppExec’s commands history:
            3.1. When multi-line text is executed in the Console, the command history will be either updated with several single commands, as if each single-line command was entered separately; or updated with just the last single-line command; or will not be updated at all (i.e. ignoring multi-line text).
            3.2. When there is a multi-line text pasted to the Console and Arrow Up or Arrow Down is pressed, what exactly should happen? Should the whole multi-line text disappear and be replaced with the previous/next command from the command history? Or should the Arrow Up/Down be used to move the caret within the multi-line text, thus not dealing with the command history? Probably the latter approach would be more convenient.

          Vitalii Dovgan artie-finkelstein 2 Replies Last reply Reply Quote 5
          • Vitalii Dovgan
            Vitalii Dovgan @Vitalii Dovgan last edited by

            Regarding the ability to pass several lines as an input to an executable, there is a technique described in NppExec’s Manual, section “4.6.9. Send several commands to external tool”.

            1 Reply Last reply Reply Quote 5
            • artie-finkelstein
              artie-finkelstein @Vitalii Dovgan last edited by

              @vitalii-dovgan said in NppExec Console not recognizing block pasting of input into it.:

              If a console process is running, there are several interesting points:
              2.1. If the pasted multi-line text contains ‘\r’ or ‘\r\n’ line endings,
              (text removed)
              2.2. If the pasted multi-line text contains commands with prefixes “nppexec:” or “nppexec::”, these commands must be executed by NppExec itself.

              Since it’s being pasted into the console while ‘attached’ to the running process, I’d expect the text as submitted (even if it did have “nppexec:” in it or ‘odd’ EOL encodings) to be sent to the application. Possibly NppExec could note the pasted text as raw characters for use in any recall; BUT I don’t expect NppExec to interpret/modify anything sent to the application.

              NppExec may log what I send to a running application, but only inspects input enough to handle any supported kill/abort requests, but even that is problematic (is the kill request for the application or NppExec because the application is not handling the kill request?) My only solution to that conundrum is crude: use a timer such that if X number of kill commands are given in less than a narrow Y time interval, that’s a request for NppExec to kill the spawned process.

              However, when in ‘command’ mode I expect everything to go to the NppExec ‘engine’. I’m not opposed to NppExec logging (for later recall) what I send to a running application, I simply don’t expect it to. [It does sound like a helpful idea to be able to recall a long list of input text for the spawned process, but the text could be kept in a separate tab in Notepad++ for subsequent copy & paste actions.]

              The above is my personal viewpoint, not a criticism or a feature request (although I too would like to see multi-line input accepted). Perhaps an input ‘command stack’ to hold all input text with the each newline separated string popped off the top and fed to the execution engine when it’s idle. Any execution errors (or panic kill commands) would stop the popping.

              1. Updating NppExec’s commands history:

              As any action(s) taken in 3.2 depends on the choices made in the implementation of 3.1. – record it as a ‘text block’ and allow recall of the full block. I don’t expect NppExec to offer live script editing as if it were a REPL like command shell.

              NOTE: To me, much of this is outside the stated description in section 1.3 of the manual:

              NppExec is not a console emulator.
              

              Many times I’ve wished it were a full console based system, but I’d rather have the NppExec of today to use today than still be waiting for the ‘uber alles’ version.

              1 Reply Last reply Reply Quote 0
              • Vitalii Dovgan
                Vitalii Dovgan last edited by

                The features of multi-line input and multi-line pasting have just been added to the ‘develop’ branch:
                https://github.com/d0vgan/nppexec/commits/develop
                I need to test these changes to ensure they did not break the existing (previous) functionality.
                These features will be included in the next release 0.8.1.

                Vitalii Dovgan 1 Reply Last reply Reply Quote 6
                • Vitalii Dovgan
                  Vitalii Dovgan @Vitalii Dovgan last edited by

                  Please try NppExec20220406 under https://sourceforge.net/projects/npp-plugins/files/NppExec/NppExec Plugin (dev)/

                  1 Reply Last reply Reply Quote 2
                  • First post
                    Last post
                  Copyright © 2014 NodeBB Forums | Contributors