Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fix for #657; copy/paste to OS X Mail loses tabs #659

Merged
merged 1 commit into from

4 participants

@totalgee

In the mail thread for issue #657, Jakob mentioned: "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."

If you do want to do that, you can take this pull request. It makes copying from the code editor or the post window have MIME type "text/plain". Please do check it, though -- this is my first foray in to the wonderful world of SC and Qt code. I tested on OS X 10.8, and also checked that it works with characters from another character set (Spanish - ISO), not just basic ASCII.

I did not change the behaviour everywhere. For example, I didn't touch the Help window or TextView widgets, because those potentially should be formatted (or have the possibility?). Note that these also don't paste very nicely -- you don't get any formatting at all when copying from the Help window, for example, even to OS X's TextEdit app (which handles the pasting of code properly, and did so even before this fix).

If there is anywhere else you think this may be needed, please let me know!

Thanks,
Glen.

@danstowell
Owner

Looks good to me (just from reading through, since I don't have a mac). The commit messages could be a little more meaningful - things like "(part 2)" will not make much sense in future when someone wants to know what changed, so something like "(fix post window too)" would be preferable.

If a mac developer wants to try this out before merging that'd be handy.

@timblechmann

glen, thanks for the patch ... it is great to see not only bug reports and feature requests, but also patches/pull requests!

regarding the code, could you adapt the code with dan/jakob's suggestions? and regarding the commit message, we tend to have something like this to increase the readability:

compontent: subcomponent - short description

fixes #whatever

in this case component/subcomponent would be scide: code editor

thanks, tim

@totalgee

Please let me know what is the proper process to follow in following up on these code reviews? Do I just submit a new version on top of this pull request, without the comments and fixing the 'p' prefix? Thanks.

One minor note (my changes don't break this -- it was already broken, so this really is just a side note): in Word (OS X, Office 2008 version), when I paste in plaintext code from SC, it all appears on one line... This is stupid, I suspect it's because they are wanting DOS-style '\r\n' line endings. Dumb. Anyhow, my change doesn't fix or break that. And again, at worst people can paste it somewhere else, then copy from there and into Word. Sigh. This will only make all those Linux-lovers on here even more convinced of the superiority of their positions, I'm sure. (-;

@timblechmann

thanks. if you are comfortable with git, maybe you could squash all three commits to a single one? afaict, the github pull requests should then automatically be updated ... otherwise, i'm ok with merging this as it is

@jleben
Owner

if you are comfortable with git, maybe you could squash all three commits to a single one?

I also agree that would be desirable.
I'm not sure though that github would allow you to push the branch with changed history (non-fast-forward update).
In that case, you would need to create a new pull request, I believe...

@timblechmann

actually i think that the pull request track's glen's branch, so i don't think a new pull request will be required. not 100% sure, though

@jleben
Owner

actually i think that the pull request track's glen's branch, so i don't think a new pull request will be required. not 100% sure, though

Well, the only way he could do (simulate) a non-fast-forward update, is to delete the public branch, than push it anew. The question is whether the pull request would persist across these actions, or would be automatically destroyed the moment the branch is deleted.

@jleben
Owner

See for example the description of this arbitrary project's pull request:
plack/psgi-specs#26

@totalgee

I wasn't sure it would work (as you also were wondering), but I interactively rebased my local branch, then force-pushed it (using git push --force), and it seems to have worked. Let me know if there's anything else you need.

@jleben
Owner

Great :)
Looks fine for merging, imo...

@timblechmann timblechmann merged commit feb9ffc into supercollider:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 20, 2012
  1. @totalgee
This page is out of date. Refresh to see the latest.
View
9 editors/sc-ide/widgets/code_editor/editor.cpp
@@ -903,4 +903,13 @@ void GenericCodeEditor::hideMouseCursor()
QApplication::setOverrideCursor( Qt::BlankCursor );
}
+QMimeData *GenericCodeEditor::createMimeDataFromSelection() const
+{
+ // Here, we bundle up just the plaintext (not HTML, as is the default) of
+ // the editor's selected contents.
+ QMimeData *data = new QMimeData;
+ data->setText(textCursor().selection().toPlainText());
+ return data;
+}
+
} // namespace ScIDE
View
2  editors/sc-ide/widgets/code_editor/editor.hpp
@@ -59,7 +59,7 @@ class GenericCodeEditor : public QPlainTextEdit
virtual void wheelEvent( QWheelEvent * );
virtual void dragEnterEvent( QDragEnterEvent * );
void hideMouseCursor(QKeyEvent *);
-
+ virtual QMimeData *createMimeDataFromSelection() const;
public slots:
void applySettings( Settings::Manager * );
View
10 editors/sc-ide/widgets/post_window.cpp
@@ -33,6 +33,7 @@
#include <QScrollBar>
#include <QShortcut>
#include <QKeyEvent>
+#include <QTextDocumentFragment>
namespace ScIDE {
@@ -268,6 +269,15 @@ void PostWindow::mouseDoubleClickEvent(QMouseEvent *e)
cursor.endEditBlock();
}
+QMimeData *PostWindow::createMimeDataFromSelection() const
+{
+ // Here, we bundle up just the plaintext (not HTML, as is the default) of
+ // the post window's selected contents.
+ QMimeData *data = new QMimeData;
+ data->setText(textCursor().selection().toPlainText());
+ return data;
+}
+
bool PostWindow::openDocumentation()
{
return Main::openDocumentation(symbolUnderCursor());
View
1  editors/sc-ide/widgets/post_window.hpp
@@ -77,6 +77,7 @@ public slots:
virtual void wheelEvent( QWheelEvent * );
virtual void focusOutEvent (QFocusEvent *e);
virtual void mouseDoubleClickEvent(QMouseEvent *e);
+ virtual QMimeData *createMimeDataFromSelection() const;
private slots:
void onAutoScrollTriggered(bool);
Something went wrong with that request. Please try again.