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

Middle mouse button paste in gecko #31

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Middle mouse button paste in gecko #31

wants to merge 3 commits into from

Conversation

pstjvn
Copy link

@pstjvn pstjvn commented Jun 5, 2012

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.

…ny source.


Not as aesthetically pleasing (the pasted content appears for a moment there), but works correctly for pasting from any source.

Needs some testing on older hardware for the timeout in the timing of receiving DOMCharacterDataModified but works good on recent netbooks and recent PCs.
@pstjvn
Copy link
Author

pstjvn commented Jun 6, 2012

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.

@chjj
Copy link
Owner

chjj commented Jun 10, 2012

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.

@risacher
Copy link

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
Copy link

risacher commented Dec 7, 2013

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants