-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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
Wrap/nowrap when copying multiple lines ... SetConsoleMode? #9528
Comments
Applications what write off the end of the line force a wrap. You can disable "deferred EOL" with SetConsoleMode. |
Can you be more specific? I select two lines with the mouse and copy with a right-click. They comprised output which reached the end of the first line and was continued on the next line. What determines how they will paste (anywhere) ... as a single line or as two lines with a CRLF between them? |
Wasn't my question well-posed? Let me try a different way. Don't bother trying to reproduce this; it's apparently an anomaly of the shell I'm using. Here's a command and its output, both selected (left button drag) from a console's history. When I copy (right-click) and paste into an editor, I get What can lead to this ... the command not wrapped and the output wrapped after copy/paste? |
Try as I might, I have been unable to defeat the need for sleep. Your question will be processed in the order in which it was received. |
Sorry about that! I'm noted for impatience. I can't be the only person who has grown accustomed to your attentiveness. |
So! Wrapping. Wrapping is a source of a bunch of issues for us. In general, text is considered wrapped in the following circumstances.
Moving the cursor between writes breaks wrapping. Some applications, especially when they draw the prompt themselves, explicitly hard-wrap their output. What's likely happening is that the input line is being sent as
😅 you're right |
(Sorry -- edited the above to fix an out of order bullet that somewhat changes the meaning.) |
Hmmm! I've been trying to figure out how to ...
... then copy all the output, paste it somewhere, and have one wrap and the other not wrap. No success yet; both wrap! Any ideas? |
Nope, both of those will wrap. There is no console mode that will disable wrapping. Sorry! 😄 |
Hard wrapping must be done by the application -- measure the screen, print hard-wrapped sections of line with newlines between the sections. That's also the way voted most likely to work with all other terminal emulators. |
FYI - we are also tracking an intermittent issue where sometimes the Terminal decides that a line that should have wrapped actually didn't. We're tracking that broadly in #5800 and more specifically in #6901. I haven't the damndest clue what causes that, but if you could get a specific repro for it, then I could fix it and make a test |
(#6901) I can repro this much. TYPE the file in CMD (or TCC) in WT ... copy the wrapped line and paste into notepad ... result: one line. SSH (in WT) to localhost (no WSL involved) ... TYPE the file in the SSH session ... copy the wrapped line and paste into notepad ... result: several lines. But I can't (as in #6901) get a different (single line) result after resizing WT. [TCC is my SSH shell.] |
SSH uses an old version of ConPTY 😄 which did not support line wrapping! |
I'm not sure what you mean. SSH is using the usual conhost.exe on both ends and mine seems pretty good at line wrapping. |
When you SSH to a Windows machine, it hosts the console application using the version of conhost on that machine. That version of conhost contains whatever version of ConPTY existed at the time. The old version of ConPTY¹ cannot properly communicate which lines "wrapped" when it reproduces the screen content. The old version of ConPTY¹ will therefore emit any lines, wrapped or not, with a newline at the end of them. They will appear to be "hard-wrapped" from the perspective of any recipient. ¹ I promise you are using an old version of conpty if you're SSHing to a Windows machine. |
I'm SSHing to localhost and I see this. Both conhosts are c:\windows\system32\conhost.exe. I just want to understand.
|
I can't figure out what you do not understand. On the server, ConPTY reproduces the "screen" for the hosted console application. -AND- |
I don't have a good idea what ConPTY is ... a capability of conhost.exe separate from that of supplying the usual console window? And while console windows do wrapping, ConPTY doesn't? I gather an up-to-date OpenConsole.exe is better at this? |
You have been on, like, fourteen threads where I talk about ConPTY in an answer to your question yet you haven't ventured to ask what it is? Oi! Yep! ConPTY is a way for conhost to convert Win32 console application output to VT sequences (and the same for input) such that normal terminal emulators can "host" windows console applications. |
You might also want to read: #57, https://docs.microsoft.com/en-us/windows/console/pseudoconsoles |
As well as JDeBP's answer page about hosting console apps, which documents why it was so hard, for so long. |
How is the wrap/nowrap behavior when copying multiple lines handled? Is it controlable with SetConsoleMode?
Thanks!
The text was updated successfully, but these errors were encountered: