It's kind of funny. I wrote the function to get text from the clipboard years ago, but I hardly ever use it. Most of the time, if I want to do something with the clipboard I find it much more effective to just put it in a buffer.
I start with a _command I use dozens of times a day that just inserts the current clipboard into a new window.
/**
* Insert the text in the clipboard into a newly created window. Useful as a quick pseudo-clipboard viewer,
* and for quick edits to text that's in the clipboard.
*/
_command void InsertClipboardIntoNewWindow() name_info(',') {
_str clipFile = _temp_path() '\Clipbrd.txt';
if(file_exists(clipFile))
delete_file(clipFile);
e(clipFile);
top();
paste();
p_line = 1;
// If the text is from a line clipboard, an extra blank line was added at the top of the file, so delete
// it. Only happens when we have line selections in VSlick.
if (clipboard_itype(0) == 'LINE' && GetWorkline() == '')
delete_line();
top();
convert_tabs2spaces();
save();
}
I have that one in my customized menu and bound to a key because I use it so much.
The function to get the string isn't all that handy because I find most of my string manipulations work better in a buffer than in a string,s o I usually just load it and work with it. When I do need the string, I use this function. This is a chopped down version of my function (because I have a lot of dependancies on internal libraries) that I think works, but haven't tested it.
/**
* Get the text from a specific line of the clipboard, or the entire clipboard. Note that as a side-effect,
* the original file is also stored in C:\Temp\Clip.tmp, where it can be processed in other ways.
*
* @return Specified clipboard text as a string. The same text is also stored in the global <code>Workline</code>
*/
_str ClipGet() {
InsertClipboardIntoNewWindow();
_str result = get_text(200000);
close_window('W', false);
refresh('AW');
return result;
}