NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
Terminal "Paste" pastes text interspersed with exi


Joined: 23 Aug 2005
Posts: 44
Reply with quote
I have noticed that when I used the menu Edit -> Paste into a terminal window (which I do fairly regularly), that the text does not appear to be pasted correctly if it contains a newline character.

Say I have a file open in an editor (I use vi and nano) with the following contents:

Code:
This is line 1
This is line 2
This is line 3
This is line 4
This is line 5


If I try to paste the following between line 1 and 2:

Code:
Pasted text line 1
Pasted text line 2
Pasted text line 3


I get the following result:

Code:
This is line 1
Pasted text line 1
This is line 2
Pasted text line 2
This is line 3
Pasted text line 3
This is line 4
This is line 5


Really, it should be:

Code:
This is line 1
Pasted text line 1
Pasted text line 2
Pasted text line 3
This is line 2
This is line 3
This is line 4
This is line 5


Originally I thought it may have something to do with Windows line-breaks, but it does this no matter what File Format I use (Windows or Unix).
View user's profileFind all posts by willbondSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8344
Reply with quote
It is related to \r handling in the application you run in the terminal. PhpEd has very little to do with this.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 23 Aug 2005
Posts: 44
Reply with quote
I am going to have to respectfully disagree with you here that this is a PHPEd issue, or at least something that can be fixed with PHPEd. Using these same two programs (nano and vi) with putty (the golden standard for Windows SSH clients), I do not have these problems.

Supposing that PHPEd just posts the raw contents of the clipboard into the terminal, perhaps there could be some issues, however I tested using Autocopy with the terminal window and pasting right back in and have trouble with that also. Here are the results:

Code:
This is line 1 Pasted text line 1 This is line 2 This is line 3 This is line 4 This is line 5 Pasted text line 2
Pasted text line 3


I also pasted the same Auto-Copied three lines into Notepad++ on Windows, and it was properly saved with Unix line breaks.

Thus, it is quite clear PHPEd is not properly pasting into terminals.
View user's profileFind all posts by willbondSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8344
Reply with quote
I tried that golden standard and it inserted couple of \r without any problems. Should I assume that that standard is somehow broken?

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 23 Aug 2005
Posts: 44
Reply with quote
I don't believe I stated that Putty does anything about \r. I do believe I stated that it "just works" when pasting text into nano and vi.

Back to your product, I gave a nice and clear example of how it fails to work as expected. If you need anything more from me, I would be more than happy to provide it.

I am looking forward to being able to paste text into the PHPEd terminal. It will save me the hastle of having to switch programs to paste text into remote files.

Thanks!
View user's profileFind all posts by willbondSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8344
Reply with quote
Probably it makes sense where or how you get text into the clipboard. If this text contains \r symbols, they will be inserted by Putty and will break your text in vi or nano. That's all I meant.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 23 Aug 2005
Posts: 44
Reply with quote
So, for now, lets ignore \r characters.

Even with just \n characters, PHPEd is not pasting properly, as I showed in my reply at 3:33 pm.
View user's profileFind all posts by willbondSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8344
Reply with quote
How can you make sure that there are only \n and no \r were added when you copied to the clipboard?

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 23 Aug 2005
Posts: 44
Reply with quote
Well, first off, I copied the text form the terminal using PHPEds Auto Copy function. Thus, the only way anything other than a \n would be on the clipboard is if PHPEd added it, since the source file was on my FreeBSD server and only contained \n for linebreaks.

Secondly I pasted the auto-copied text into a unix and windows capable text editor, and it saved in unix format. However, if I copy and paste something from a Windows source, that same text editor will save the file as a windows file.
View user's profileFind all posts by willbondSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8344
Reply with quote
Quote:
Well, first off, I copied the text form the terminal using PHPEds Auto Copy function. Thus, the only way anything other than a \n would be on the clipboard is if PHPEd added it, since the source file was on my FreeBSD server and only contained \n for linebreaks

probably you did not get it right. Terminals (running on the client) do not see the source file. They see stream of escape sequencies the far end send to the client. This stream has nothing in common with source files you see in the terminal Smile. When you copy content into the clipboard you do it on the local terminal screen buffer produced from parsing those escapes. Terminal adds line breaks on its own. Maybe it is the source of the problem you encountered in nano and vi. I just tried mc's editor (cooledit) and it works just fine and adds ^M in place of \r symbols, as expected. I also tried to paste into the shell command prompt and it did work well too. So I guess that neither nano nor vi can handle \r symbols properly.
I'll check what's up with nano in a day or two. If the problem is with PhpED, it will be fixed.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 23 Aug 2005
Posts: 44
Reply with quote
So wait, are you saying that the PHPEd terminal is taking the remote "\n" characters and turning them into windows line breaks "\r\n"? If so, then I would imagine that this is the problem. However, my anecdotal experience (with pasting into Notepad++) seems to indicate that PHPEd's auto-copy actually puts the "\n" character into the windows clipboard. Could you comment on what PHPEd is actually doing with auto-copy and pasting related to line-breaks?

----
Side Note:

Probably what would solve all of these issues would be to have an option in the ssh account setup to translate windows line-breaks (\r\n) to unix line-breaks (\n). Then people who wanted literal character to character transmission would get it, and the rest of us would get a terminal that easily supports pasting.

Nothing is more frustrating than trying to paste commands found in help documents, etc into the terminal and have them fail because of line-break issues. This is the biggest reason I still have Putty installed on my system. Obviously there is a work-around where I can paste text into a unix-formatted document, copy again and then paste into the terminal, but this takes about 300% longer than just pasting straight into the terminal.

Of course at the same time it would be great to allow us users to set up some sort of short-cut for pasting (I know this has been talked about in the feature request section).
View user's profileFind all posts by willbondSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8344
Reply with quote
oh, sorry if I did not make it clear.
There are neither remote \n nor \r that termals can ever get.
It's just like Graphics Adapter reneders characters and represents them as dots and those dots are what display sees.
Similarly, terminal gets ANSI ESCAPES, not \r not \n.

What may fix the problem is an option like you said - append string ending as \n instead of \r\n and it will be useful when such broken programs like nano are used.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website
Terminal "Paste" pastes text interspersed with exi
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic