tty.js icon indicating copy to clipboard operation
tty.js copied to clipboard

Middle mouse button paste in gecko

Open pstjvn opened this issue 12 years ago • 4 comments

This is a naive/lazy implementation for gecko middle mouse paste.

Gecko prohibits access to clipboard data in paste events. There are two solutions for this: either Flash or making diff to the content before the paste event and after it.

Because of how the terminal works (i.e. it expects text only, not html) a more simple solution would be to detect selection in the page and save the text of the selection and then use it in the case of paste event. It will not cover the case where the user wants to paste text from the clipboard, but is still useful because it can store selections from other windows/tabs in the same page.

pstjvn avatar Jun 05 '12 11:06 pstjvn

I see an issue with the second attempt: If I paste text with space in it the bash interpreter does not seem to like it. For example I paste 'telnet 192.168.0.9' (which in code is Terminal.prototype.send('whatever I pasted as text string'); ). However when I press enter the bash interpreter thinks the whole string is one command (i.e. 'telnet\ 192.168.0.9') and thus cannot interpret it. Any idea why this is happening? I see that exactly the same code path is executed with the webkit approach of handling clipboad data.

pstjvn avatar Jun 06 '12 10:06 pstjvn

There are two solutions for this: .

either Flash

No.

making diff to the content before the paste event and after it

What you have looks interesting. I kind to want to fool around with it a bit first.

I see an issue with the second attempt

Hmm, I'll see if I can figure it out once I try it.

chjj avatar Jun 10 '12 18:06 chjj

Bump, +1, etc.
It really helps me to be able to paste into tty.js. I would love to see something like this in the main project so I don't have to re-apply the patch every time I upgrade tty.js.

It is a little flaky, though. Sometimes it pastes twice, for no adequately explained reason.

risacher avatar Oct 22 '13 17:10 risacher

I spent some time today trying to get this working again with current tty.js and current Firefox. The reason I was getting things pasted twice (2 months ago) was that the regular paste handler was running as well as the code from @pstjvn. It seems that Firefox 25.0.1 and Nightly now support right-click paste events for divs if they have contentEditable == true.

See this gist for a user.js file that patches up bindPaste() and adds a new mousedown listener: https://gist.github.com/risacher/7837761

This seems to work in Firefox, Chrome, and Safari - but I'm not sure I'm testing all the cases that are supposed to work.

risacher avatar Dec 07 '13 06:12 risacher