AS3 - Copy image to clipboard - actionscript-3

How to copy an image in AS3 to the clipboard?
For text it works but I can't find a way to copy an image.
System.setClipboard("my text")

You cannot. From the docs:
Parameters
string:String — A plain-text string of characters to put on the system
Clipboard, replacing its current contents (if any).
However, with Air you can use: Clipboard.setData() instead.

Related

Swift - MacOS NSPasteboard - simultaneously support HTML and plain strings

I have a use-case where I want my application to store clipboard data and later allow the user to paste it out.
The thing is - I want to both support HTML-styled text (while maintaining its styling) and also support simple plain-text.
What I have so far is:
Pasteboard variable setup
let pasteboard = NSPasteboard.general
pasteboard.declareTypes([.html, .string], owner: nil)
Storing user's clipboard data
let copiedString = pasteboard.string(forType: .html) ?? pasteboard.string(forType: .string) {
If, for example, a user copies text from the browser, this method maintains the entire HTML.Alternatively, if text is being copied from applications that don't support HTML (such as XCode, Notes, etc), `copiedString` will simply hold the plain text.
Later down the line - pushing contents back to clipboard
pasteboard.setString(copiedString, forType: .html)
My problem is, when I try to paste the content pushed into my clipboard; it only works in applications that actually support HTML-formatted text, such as Chrome / Microsoft Word.
When I try to paste the content into XCode for example, it simply doesn't spit out anything.
Ideally, I want my clipboard to adjust itself according to the application I'm on - paste the text as HTML if supported by the application, otherwise - paste the plain text.
How can I implement such behavior?
Thanks!

Force autocomplete suggestions for file paths

I am currently working on a controller file for a Phalcon project. I like how PhpStorm gives you autocomplete suggestions when writing a src or href value in an HTML file. I was wondering, is possible to enable autocomplete suggestions when adding resources in a controller?
This is what happens when I force autocomplete suggestions(Ctrl + Space)
This is what I would like to happen.
EDIT: I should also note that I have marked the folder, containing all my resources(ie. CSS, javascript, and images), as the "Resource root".
RE: EDITThis does not affect availability of this feature/functionality in any way as "Resource roots" are used for path resolutions/validation and not for actual "offer this functionality or hide it" choice. -LazyOne
Unfortunately there is no real way of automatically providing such functionality in random string as it's hard to guess that file path is expected in this particular place (function parameters is different case -- here some hinting mechanics (special annotation) may work).
But .. you can forcibly enable it manually for each particular place (should last until file or project is closed):
Have some code, e.g. $someVar = ['css' => 'aaa'];
Place caret inside aaa string (it has to be 3 or more characters, based on my observations, otherwise option in #4 will not be present -- must be some sort of optimisation/limitation from IDE side)
Invoke shortcut to bring "Quick Fix" menu (Alt + Enter on Windows)
Choose Inject language or reference from appeared menu
Choose File Reference from next menu
Start using it (Ctrl + Space)
EDIT: I should also note that I have marked the folder, containing all my resources(ie. CSS, javascript, and images), as the "Resource root".
This does not affect availability of this feature/functionality in any way as "Resource roots" are used for path resolutions/validation and not for actual "offer this functionality or hide it" choice.

When copying automatically add URL

I have seen on few websites that when you copy some text from there, and paste anywhere, it will add the URL of the page from where I copied the text.
For example:
This is text I copied.
and when I paste, I get:
This is text I copied.
Read more: http://example.com/abc/def
I'm just curious to know how this is done? How to add additional text in the copied text?
Example: Check this question (or any other) on answers.com. Copy the question text and paste. Tested with Firefox latest version.
There are many online tools which provide this and other website/blog management utilities. Answer.com is also using one such service named tynt. Open the link, scroll down to the bottom and you can see answer.com in featured clients ;).
For more information.
Zeroclipboard should help you modify the clipboard content. It's a flash movie that is hidden in the browser and exposes a JavaScript API to access the clipboard.
Example.
var clip = new ZeroClipboard.Client();
clip.addEventListener('complete', function(client, text) {
clip.setText(text + "Read more at www.");
});

How to encode a hyperlink in CSV formatted file?

When I try to encode a HTML anchor link in CSV file cell it becomes corrupted and not readable by Excel.
Is there some sort of non-HTML solution or format to encode a hyperlink in CSV file cell?
For when automagicalism doesn't work, and you're definitely using Excel, use this as the field content.
=HYPERLINK("http://stackoverflow.com")
This worked for me:
Use the =HYPERLINK function, the first parameter is the web link, the second is the cell value.
Put " quotes around the entire function.
Escape the internal quotes within the function with two sets of quotes, i.e., ""
Here's a four-column comma-delimited example.csv:
5,6,"=HYPERLINK(""http://www.yahoo.com"";""See Yahoo"")",8
When a spreadsheet program (LibreOffice, etc.) opens this .csv, it creates an active link for you.
What worked for me in Excel 2003 - output to your CSV the statement:
CELLVALUE="=HYPERLINK("+QM+URLCONTENTS+QM+";"+QM+"URLDISPLAYNAME"+QM+")"
note the semicolon ; use in the hyperlink. I've found the comma not to work for me in Excel 2003.
Depending on the script or language you use quotemarks could be handled differently. The cellvalue you put into the CSV before you import it into Excel should look exactly like this: "=HYPERLINK("URLCONTENTS";"URLDISPLAYNAME")"
where:
CELLVALUE is the output written to the CSV
QM is the ASCII value of ["] -> (ASCII 34)
URLCONTENTS is the full URL to the page you want to link to.
-URLDISPLAYNAME is the text you see in the Excel cell.
You can also use relative paths and set a base location in Excel.
File/Properties > Tab Summary > Field Hyperlink Base.
Use as fieldvalue something like http://www.SITENAME.com/SUB_LOCATION/../SUB_LOCATION that sets your starting point so you can click it in Excel. Of course, you don't have to use SUB_LOCATIONs if the sitename itself already will resolve successfully for your relative path.
What I couldn't find is how to make the links automatically underlined in Excel. From other tips found in this article:
Format manually all linkcells as underlined and darkblue (for example) and then the standard functionality appears with already visited links turning into another color.
A CSV file is simply text - it's up to the loading program how it chooses to interpret the text.
If Excel is complaining when you feed it "Link", "another cell" then try just having the raw URL and you might find Excel will automagically turn it into a link.
But in general Excel doesn't process HTML, so expecting it render HTML from a CSV file is asking too much.

Forward/Reverse link possible with emacs/HTML mode?

With emacs, it's pretty useful to edit HTML file. And I use 'Safari' (I'm a Mac user), to check if the HTML file is rendered correctly.
I always miss the AucTeX's forward/reverse link with pdf/tex files. I can shift-click on emacs/LaTeX file to corresponding pdf file, and vice versa. For example, when I shift-click on string 'abc' on tex source code, auc-tex finds the 'abc' string in the pdf file, and the other way round is possible.
Is there any way to do similar things in emacs? I mean, is there any tool/mode that can connect back/forth between html file and browser?
Use
M-x browse-url-of-file
It's generally not bound, so I use...
(global-set-key (kbd "M-P") 'browse-url-of-file)
To globally bind Alt+Shift+p .. as "preview in browser"