NppExec Console not recognizing block pasting of input into it.
- 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
aand 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 last edited by
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_consolecommand’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 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:
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.
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.
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 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”.
- artie-finkelstein 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
NppExeccould note the pasted text as raw characters for use in any recall; BUT I don’t expect
NppExecto interpret/modify anything sent to the application.
NppExecmay 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
NppExecbecause 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
NppExecto kill the spawned process.
However, when in ‘command’ mode I expect everything to go to the
NppExec‘engine’. I’m not opposed to
NppExeclogging (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.
- 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
NppExecto 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
NppExecof today to use today than still be waiting for the ‘uber alles’ version.