Windows 10 and line wrapping selection?

May 20, 2008
9,708
67
Syracuse, NY, USA
I have this in my console.
1565362389829.png
Line wrapping selection is enabled. If I select/copy the first two lines it looks like it line-wrapped right up to the last 'x'. But when I past it into TextPad I get two lines (i.e., it's not wrapped).
Code:
v:\> echo xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxx
OTOH, if I select/copy the 3rd and 4th lines, it (again) looks like it line-wrapped, and when I paste into TextPad it is wrapped.
Code:
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Does anyone know what's going on there? I wouldn't expect Windows to know the difference between selecting/copying a command line versus selecting/copying output.
 
May 20, 2008
9,708
67
Syracuse, NY, USA
One more time, this time all in one console, with no color, and smaller. I'm a bit amazed. What's in the console screen buffer is what's in the console screen buffer (yes/no?). Yet it seems to matter (1) who put it there and (2) whether it's command line or output. When it's a TCC command line it doesn't get wrapped. Below, all the text selected/copied at once with with left-drag/right-click and pasted into TextPad with Ctrl-V.

1565371897093.png
 
May 20, 2008
9,708
67
Syracuse, NY, USA
does it do the same if you use @repeat[x,screen buffer width]
I don't know, but I now seem to recall that TCC doesn't write the command line to stdout (while CMD does). That's good for us because it gives us much greater control over what happens on the command line. I also suppose that the Windows line wrapping selection mechanism only deals with what was written to stdout (and stderr?). That mechanism MUST involve more than just reading the console screen buffer because newlines don't don't make it into that buffer.

This doesn't bother me often ... only when, after spending a lot of time constructing a long command line, I want to copy that command line and paste it into my savedcommands.txt for future reference. That usually happens when I'm dealing with regular expressions, WMI queries, or Windows admin utilities with complicated syntax (that I don't use often enough to remember).
 
Aug 23, 2010
445
5
The copy behavior depends on the type of terminal used. Old native console don't have the notion of "wrapped text", the new (win8+) console have something like this, but the behavior is erratic.
I would suggest not wasting your time trying to comprehend it.