-
Notifications
You must be signed in to change notification settings - Fork 286
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
"Paste as Plain Text" Action #230
Comments
You can enter The fact that I know that should tell you that other people have a need for something like this. There should be an easier way. |
So I’m thinking there are two scenarios we care about here:
For the first scenario, to literally paste something as plain text, we’d have to put it in the clipboard as the most recent item which would replace whatever was there. I’m hesitant to do that (but then again the current Paste action does this). It would be nice to paste the plain text version of something without creating a new entry in the clipboard. I don’t know if that could be done, but there is something very similar: the Type Text action. However, that only works well for small amounts of text. Is it worth it to modify the clipboard to pull this off? The second scenario is another animal, but one I’m sure we would like to see. This would have to be provided by something in the first pane. A proxy object representing the plain text version of the current item maybe? And I have to wonder if there’s already a way to do this. |
Here's how it works for me in Launch bar, which I'm very happy with:
That's it. I almost never, ever, want to paste as styled text. Ever since OS X came out this has driven me crazy, because I almost always want to match the existing style, not preserve the old style. However, if I do want to paste styled text I can hold the control key when I hit return. (The default settings can be flipped in the preferences.) |
The clipboard history operates outside the normal interface, so that would have to be a preference item or something. Although it is possible to access the items within Quicksilver using Show Contents or Search Contents, at which point you could run other actions on them. |
@lovequicksilver pointed me here. I actually created an action for this last night using AppleScript and posted the solution here: http://www.webrealm.org/2011/04/paste-unformatted-text-with-quicksilver.html It's no substitute for the real solution Skurfer is working on, but it's something to tide us over! |
I was thinking a solution for the second scenario could be an addition to the Extra Scripts plug-in. AppleScript isn’t my thing. Would you know how to take “the thing currently in the clipboard” and paste it as text (instead of the thing from Quicksilver’s first pane)? If so, could we use this in the plug-in? (If you’re really ambitious, you could fork the Plugins repository and submit a pull request, but that’s a lot to wrap your head around if you’re not familiar.) |
I'm not that great an AppleScript coder myself, but I got this code to work. Maybe later tonight, I can try to figure out how to get this into the repository; I've never actually used Git but one has to learn some time! tell application "Finder" to set frontApp to (name of 1st process whose frontmost = true) delay 1 |
Thinking about it, there is a downside to both of these AppleScripts: they add to the clipboard history - twice. The action replaces the current clipboard with the contents of the clipboard history, then again with the plain-text version. The script above replaces the contents of the clipboard with the plain-text version, then again with the original version when it's finished pasting. That seems like a nuisance bug, but a nuisance none the less. I don't really know how to get around that. |
Things already show up there over and over. I was going to suggest a list of modifications for the clipboard stuff and this is one of them: see if something matches what’s already there before adding it again. Also, if it came from QS’s own history, delete it from the old position and move it to the top. For pasting as plain text, adding something new is probably unavoidable, but since it’s technically a different thing, I don’t mind it as much. (Although it would be nice, if the text was already plain, not to replace the original.) |
I like the idea of not replacing text if it's already plain, but it doesn't seem doable using the conversion method above. I tried some string comparison to see if copied plain text is the same as the result of a pbpaste. Even copying Terminal, which we know is plain text, appears to be different based on my tests. I suspect this is because copying in OS X probably always contains some style data, even if that data is "no style." That's distinctly different from pbcopy and pbpaste, which appear to have no style data at all. Even using pbpaste -Prefer rtf yields no positive result in the string comparison. I'm using the pbpaste |pbcopy because it's my understanding that the other method I know - set the clipboard to «class ktxt» of ((the clipboard as text) as record) - has a limit to how many characters it can handle. I'm not sure what that limit is or how likely it is a user will ever hit that limit, but I do know that pbcopy and pbpaste interact directly with the clipboard. That's why I ultimately went with that method where I had previously tried the other. |
You can do this with the existing code by using "Type Text" instead of pasting. |
@skurfer are you doing anything with this? I'd got this far until I realised you were assigned to the issue (editing QSActionProvider_EmbeddedProvider.m)
|
The type text action works well for a few words or a line, but it’s inadequate for general use. It’s too slow and if you “type” into an application that does auto-indenting, all kinds of weird stuff can happen. I’ve got a branch for it, but not much has been done. I guess I’d like to fix the issue with duplicates in the history before copying/extending the behavior of the existing paste action. Do you think this needs to be done for ß60? It was originally under that milestone but I took it out a while back when I realized it was more complicated than I first thought. |
Paste with plain text should be a pretty simple fix no? I just need to expand on the code written above: make a new text object from The business with adding duplicate items to the pasteboard - I should be P.S. On 15 May 2011 19:06, skurfer <
|
That reminds me, I was going to figure out how to check that in. I'll do that now! |
What was that? P.S. that reminds me of another paste bug: I'll put it here as it's late and If you try and paste a URL (I'm assuming any HTML data) into a textarea (?) Steps to reproduce:
Strange On 15 May 2011 23:53, machad <
|
Good news / less good news; I sorted out how to fork the Plugins repository, but I don't actually see the Extra Scripts plugin to add the script to. Has that been changed? |
@pjrobertson: Skurfer suggested I learn git (which I really ought to do anyway) and check the AppleScript I'd mentioned above into the Extra Scripts plugin, then submit a pull request. |
We don't have the source for the extra scripts plugin (yet). I'll be adding it to the repo very shortly. :) On 16 May 2011 00:16, machad <
|
Here's the source:
|
I think a plain-text representation already exists for all copied text. There’s stuff in NSPasteBoard like
I can’t reproduce this. Pasting a hand-typed URL works and so does pasting formatted HTML from a web page. (I tested here on GitHub. Maybe it’s something with Gmail?)
None, but this could be confusing for users and/or cause them problems. Which of the two would the new combined version update? Or would it be a third plug-in? And either way, how would we warn every single person to remove the obsolete versions manually before using this one? |
Quick reply:
Close. I think the name's changed in Snow Leopard (the whole pasteboard
Pretty sure it's just GMail text areas (probably somewhere else as well),
Using our code that we've yet to write to check for 'known bad plugins' on On 16 May 2011 05:10, skurfer <
|
I got that name by running
Good call. Yet another reason to create such a thing. |
Just FYI, I’ve found this plug-in in the repo. It’s in the |
The pasteboard plugin? I've already altered the code quite a bit and fixed quite a few things - On 27 May 2011 02:51, skurfer <
|
No, Extra Scripts. |
Just a few things on this:
|
That’s fine with me. I unassigned myself from it a while ago when it seemed like you were looking at it. :) |
Implemented in #439. There’s a “Paste as Plain Text” action. You can use it directly, or as an alternate to the regular “Paste” action by holding ⌘. This doesn’t affect what happens using the clipboard window, but that might come later. |
I would like to have the default action for text be "Paste as Plain Text" but currently there is no such action. THere is a "Paste with clipboard" action, but that pastes as styled text, not plain text.
The text was updated successfully, but these errors were encountered: