Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Pass command text in but do not execute #10416

Closed
shaggygi opened this issue Jun 12, 2021 · 7 comments
Closed

[Question] Pass command text in but do not execute #10416

shaggygi opened this issue Jun 12, 2021 · 7 comments
Labels
Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) Issue-Question For questions or discussion Needs-Tag-Fix Doesn't match tag requirements Product-Terminal The new Windows Terminal. Resolution-Duplicate There's another issue on the tracker that's pretty much the same thing.

Comments

@shaggygi
Copy link

Description of the new feature/enhancement

This is more of a question, but could lead to feature if not available. I'm wanting to know if there is a way to pass a command/text into WT without actually executing the command? For example, I have a partial command I want to load/display in WT and have ready to type in the remaining part of the command.

Proposed technical implementation details (optional)

@shaggygi shaggygi added the Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. label Jun 12, 2021
@ghost ghost added Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels Jun 12, 2021
@orcmid
Copy link

orcmid commented Jun 12, 2021

I think there is a misunderstanding of where the echo of stdin to the terminal display happens when you are keying at the console (and it could be my misunderstanding).

I think the ordinary way this is handled is by a new-line entry that is not taken as an end-of-line or "send." Ctrl-Enter, typically. I don't know what stdin delivers, if anything. There is an impact on the input history also, and recalling a "line" in the history, and scrolling back through it should work properly. If the app is asking for a line, that should includes everything to the final Enter whether originally entered or re-entered (pasted)) from the history (without the final, emphatic Enter, so the entry can be confirmed/edited first).

Using cmd.exe in the default console arrangement (without WT) as an example, it appears that there is an entry editor between the app (some shell or other process) and the keyboard and the display of the entry. In this case, and this presumably (need) not be handled directly by the app. I don't know enough about the innards to know whether cmd.exe (for example) provides this or has a way to ask for it. I trust that the abstractions can be layered and stitched properly with the advent of WT.

There are also accessibility considerations around how all this operates and I have no idea how that is addressed, only that it must be. Impacts by windows resizing should not matter (that is, such liine-breaking/-stitcching is probably not visible to the console app at all.

Finally, if the console app is a command-line shell, and a console app is launched, the ordinary arrangements seems to be that no line editor (or history) intervenes for that wiring of stdin and such, even if tied to the same terminal. That seems appropriate. An ordinary console app should not be able to piggy-back on all that and might even establish a different "display."

This is rather far from the feature request. It does inspire consideration of the layers of abstraction and how they are wired up. That's been on my mind in attempting to comprehend the levels of abstraction and separation of concerns that seem to arise in cosideration of WT features, even for me as an interested observer.

PS: A non-breaking newline is also desirable in the creation of script (e.g., bat) files. ;)

PPS: [2021-06-13T17:17Z] Then there are redirections and pipes to consider. And it is all supposed to work [;<).

@skyline75489
Copy link
Collaborator

For shells that support bracketed paste mode (for example bash, zsh, ipython & etc), this is possible and usually work out of the box.

Unfortunely both cmd.exe & PowerShell do not support bracketed paste mode at the moment.

@lhecker lhecker added Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) Issue-Question For questions or discussion Product-Terminal The new Windows Terminal. and removed Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Jun 15, 2021
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label Jun 15, 2021
@lhecker
Copy link
Member

lhecker commented Jun 15, 2021

@shaggygi In which way specifically do you want to pass commands? As a shortcut action?
Windows Terminal already supports pasting in text. If you Ctrl+V a single line command it'll work as you wanted.
Alternatively you can also use the sendInput action for shortcuts.

As mentioned by @skyline75489 cmd.exe and PowerShell don't support bracketed paste mode, which makes it (basically) impossible to enter multiline commands programmatically without executing them immediately.

@shaggygi
Copy link
Author

shaggygi commented Jun 15, 2021

@shaggygi In which way specifically do you want to pass commands? As a shortcut action?

I basically have a utility that generates some initial text for a command based on selections from the utility. I would like to open WT (via the utility) and add that text to the prompt (using CMD as default). I can then add the remaining text before submitting command. For example...

(within WT showing path to EXE with initial arguments.)
C:\Temp> "MyExe.exe" -arg1 "data" -arg2 "more data" -arg3

Then I would add the remaining and press Enter.
C:\Temp> "MyExe.exe" -arg1 "data" -arg2 "more data" -arg3 "Remaining Data"

@lhecker
Copy link
Member

lhecker commented Jun 15, 2021

I'm assuming your utility is a separate process, right?

On one hand we could implement (PRs welcome! 😄): #9368
But if you want to send input to an existing window you'd have to know the window name.
If you don't, you can use one of the many different approaches to send text input to another process on Windows. There's the clipboard API, EM_REPLACESEL, SendMessage, etc.
But I'm not sure if they're best suited for that task. I believe you should probably use "UI Automation" (UIA) for this purpose. This would in fact likely be required if you want to send input to an unfocused WT window, as WT might not have text focus. UIA is a very powerful tool. Try running accevent.exe or inspect.exe in your Windows SDK (if you have it installed), to get an idea.
In any case the solution for your problem depends heavily on several factors, most importantly which window should receive the input (always the focused window and pane?), but also whether you want to send VT sequences for instance.

@zadjii-msft
Copy link
Member

Hey sorry for letting this one sit for so long! This does sound a lot like /dup #9368, we may as well track this request there.

@zadjii-msft zadjii-msft closed this as not planned Won't fix, can't repro, duplicate, stale Aug 22, 2022
@ghost
Copy link

ghost commented Aug 22, 2022

Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!

@ghost ghost closed this as completed Aug 22, 2022
@ghost ghost added Resolution-Duplicate There's another issue on the tracker that's pretty much the same thing. Needs-Tag-Fix Doesn't match tag requirements labels Aug 22, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) Issue-Question For questions or discussion Needs-Tag-Fix Doesn't match tag requirements Product-Terminal The new Windows Terminal. Resolution-Duplicate There's another issue on the tracker that's pretty much the same thing.
Projects
None yet
Development

No branches or pull requests

5 participants