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

Copy/paste from SC IDE to Mail loses formatting & tabs (OS X) #657

Closed
totalgee opened this issue Nov 19, 2012 · 12 comments
Closed

Copy/paste from SC IDE to Mail loses formatting & tabs (OS X) #657

totalgee opened this issue Nov 19, 2012 · 12 comments

Comments

@totalgee
Copy link
Contributor

One disadvantage of the new IDE is that when you copy/paste text from the editor to an email (on OS X, at least), all formatting is lost. The colouring of code isn't so important (though it would be nice -- 3.5.x used to keep it), but the indenting is very important. Right now, when you paste from the IDE to a Mail message, all the code is flush with the leftmost column.

Note: if you paste from SC to TextEdit, there is no formatting, but at least the tabs are kept. So it would be nice if this also worked when pasting into Mail (a workaround is to paste into TextEdit, then copy that new text and paste it into Mail, though that's a bit of a pain).

@jamshark70
Copy link
Contributor

  1. This would be better as a mailing list thread.
  2. You can configure the IDE to use spaces, instead of tabs.
  3. IIRC, you can set apple mail to send plain text email, instead of html. That's probably a good idea in general for technical subjects.

@totalgee
Copy link
Contributor Author

This would be better as a mailing list thread.

Why? Sorry, I thought this was a valid issue to log and have commented in the database, even if it may be pushed. For future reference, should all issues be first brought up in sc-users before logging?

You can configure the IDE to use spaces, instead of tabs.

I tried this -- it makes no difference. If I convert everything to spaces, the regular paste still (strangely!) leaves everything left-aligned. It's odd, because the normal RichText pasting into (for example) TextEdit works properly.

IIRC, you can set apple mail to send plain text email, instead of html. That's probably a good idea in general for technical subjects.

This one does make a difference. if I use plain text messages, the tabs (or spaces) are indeed preserved. That means another workaround is to keep RichText messages, but use "Paste And Match Style" when pasting into Mail, to get the plaintext code to pasted correctly. Still, it would be nice if (someday) there was a way to get it pasting with all the formatting, colours, etc. But at least I'm happy to know this workaround to the indenting issue.

Thanks,
Glen.

On Nov 19, 2012, at 10:44 AM, jamshark70 notifications@github.com wrote:

This would be better as a mailing list thread.

You can configure the IDE to use spaces, instead of tabs.

IIRC, you can set apple mail to send plain text email, instead of html. That's probably a good idea in general for technical subjects.

@timblechmann
Copy link
Contributor

frankly, this sounds more like a bug in apple mail

@totalgee
Copy link
Contributor Author

Okay, but "frankly", this worked just fine with 3.5.x, keeping formatting, syntax colouring, etc. So, yes, perhaps it's a "bug" in Mail, but there must be some difference in the way the clipboard data is being captured between 3.5 and 3.6. When using the same Mail version, I get nice formatting with 3.5 pastes, and no formatting whatsoever (not even tabs/spaces) with 3.6 pastes. Just speaking from a user's POV.

Glen.

On Nov 19, 2012, at 11:21 AM, Tim Blechmann notifications@github.com wrote:

frankly, this sounds more like a bug in apple mail


Reply to this email directly or view it on GitHub.

@timblechmann
Copy link
Contributor

neither jakob nor me is using osx, so what worked for you in 3.5, never worked for us. that said, you are more than welcome to have a look at the sources and provide a patch.
iac, please report a bug to apple ...

@jamshark70
Copy link
Contributor

There is a difference: SC.app uses a rich text editor while the IDE uses plain text. The issue basically looks like Apple mail doesn't handle plain text pasting very well. I guess it doesn't have to, since the vast majority of Apple mail users are sending baby pictures to grandma rather than code snippets.

Simple test: Write some plain text in TextEdit (make sure to choose the plain text option from whichever menu). Include some tabs. Then copy and paste into an email message. If the tabs disappear, then the issue is not specific to the SC IDE and therefore is unlikely to be fixable within the IDE. If they don't disappear, then the other variable is that the IDE code editor is a qt widget, whereas TextEdit is native cocoa. That might be fixable in the SC codebase, or it could be a qt bug.

I'd suggested this would be better as a list thread because it's not clear that this is, in fact, an IDE bug. If there's doubt, better to start on the mailing list.

@timblechmann
Copy link
Contributor

btw, apple mail is known to cause some troubles when pasting: iirc pasting something like SinOsc.ar, as it will convert it to an html link

@jamshark70
Copy link
Contributor

Btw, this:

I tried this -- it makes no difference. If I convert everything to spaces, the regular paste still (strangely!) leaves everything left-aligned.

... really sounds like an Apple mail bug. Any reasonable HTML conversion would turn multiple consecutive spaces into non-breaking spaces, or nbsp spc nbsp spc... If Apple mail isn't doing that, then it isn't sc's fault.

@totalgee
Copy link
Contributor Author

Looks like a Qt widget thing, then (or the interaction between Qt widgets and Mail). James -- I tried the TextEdit.app thing you suggested, copying from a Plain Text file. Both tabs and spaces pasted correctly into Mail. I then tried with a Qt widget (I created a TextView in a Window using SC), put some text containing tabs and also with indenting spaces into it, then copied from it and pasted into Mail. Same result as from the SC IDE (flush with left margin). If you can suggest some other Qt apps I could try this with, I would do it… Anyhow, how do I go about logging a Qt bug (or an Apple Mail one, for that matter)?

Thanks again,
Glen.

On Nov 19, 2012, at 11:46 AM, jamshark70 notifications@github.com wrote:

There is a difference: SC.app uses a rich text editor while the IDE uses plain text. The issue basically looks like Apple mail doesn't handle plain text pasting very well. I guess it doesn't have to, since the vast majority of Apple mail users are sending baby pictures to grandma rather than code snippets.

Simple test: Write some plain text in TextEdit (make sure to choose the plain text option from whichever menu). Include some tabs. Then copy and paste into an email message. If the tabs disappear, then the issue is not specific to the SC IDE and therefore is unlikely to be fixable within the IDE. If they don't disappear, then the other variable is that the IDE code editor is a qt widget, whereas TextEdit is native cocoa. That might be fixable in the SC codebase, or it could be a qt bug.

I'd suggested this would be better as a list thread because it's not clear that this is, in fact, an IDE bug. If there's doubt, better to start on the mailing list.


Reply to this email directly or view it on GitHub.

@totalgee
Copy link
Contributor Author

(for those who are interested)

Okay, so I've never looked at any Qt code before. I got SC compiling on my Mac for the first time, then tried figuring out where the darn copy/paste code is (turns out there isn't any; it uses the Qt default behaviour from QPlainTextEdit and QTextEdit). The HTML that is copied by SC (for a very simple example) is:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
p, li { white-space: pre-wrap; }
</style></head><body>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><!--StartFragment-->(</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">5.do {</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">   3.postln;</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">}</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">)<!--EndFragment--></p></body></html>

This markup relies on the CSS2 property white-space: pre-wrap, which tells the HTML client not to ignore white space at the start of lines. The HTML above renders properley in Safari and Firefox, of course. So, it looks indeed like this is a bug in Mail (as well as in MS Word, into which I also tried pasting code from SC, just for fun). They maybe aren't CSS2 compliant, or else just do it wrong. I will log an issue with Apple.

Interestingly, if I make an overload for GenericCodeEditor::createMimeDataFromSelection() and have it only put "text/plain" MIME data into the clipboard, of course it pastes properly into Mail -- since the only thing for it to grab then is plain text. Also, as I mentioned earlier, if you paste explicitly as plain text (Cmd-Alt-Shift-V), it also works.

Thanks all for your feedback.
Glen.

P.S. Note that there is no text colour or font information in the HTML copied data from SC. If it were needed or wanted at some point, I suppose we could generate our own HTML code here to copy to the clipboard, with full colour, font, etc.

@jleben
Copy link
Member

jleben commented Nov 19, 2012

P.S. Note that there is no text colour or font information in the HTML copied data from SC. If it were needed or wanted at some point, I suppose we could generate our own HTML code here to copy to the clipboard, with full colour, font, etc.

That's because the syntax highlighting is applied on-the-fly, just before rendering to screen, and does not make part of the document's content. Hence, this is not a bug/feature of HTML generation on copying.

@jleben
Copy link
Member

jleben commented Nov 19, 2012

In any case, I think it would make sense to make the code editor only copy plain text, as that's what code really is.

timblechmann added a commit that referenced this issue Nov 20, 2012
Fix for #657; copy/paste to OS X Mail loses tabs
timblechmann pushed a commit that referenced this issue Nov 28, 2012
sofakid pushed a commit to sofakid/supercollider that referenced this issue Apr 6, 2015
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

No branches or pull requests

4 participants