Arbortext Command Language > Functions by Alphabetical Listing > buffer_clipboard_contents
  
buffer_clipboard_contents
buffer_clipboard_contents(buf[, format])
This function copies the contents of a specified format from the system clipboard to the scalar variable buf. If format is omitted or empty, then the standard clipboard text format is copied and the function returns the number of characters copied into buf. If format is specified and matches an application registered clipboard format (for example, rich text format), then that format is copied and the function returns the number of bytes copied into buf.
If the set selectionsvc option is off, this function always returns 0.
Following is an example of a paste callback that pastes Rich Text Format content, instead of normal text content, when RTF is available:
global PASTE_RTF_BUFFER_NAME = 'rtfpaste';
function cb_rtf_paste(doc, buff, op) {
if (op != 2) {
return 0;
}
# Check if there is RTF available on the system clipboard
if (! buffer_is_clipboard("rich text format")) {
return 0;
}
local text;
local len = buffer_clipboard_contents(text, "rich text format");
if (len == 0) {
return 0;
}
# There is, so create a named paste buffer
local second_doc = buffer_create(PASTE_RTF_BUFFER_NAME, public_id(doc));
current_doc(second_doc);
# and insert the RTF
insert(mbstoucs(text, len));
current_doc(doc);
# remember original paste buffer
local org_buffer = option('paste');
# paste from our named paste buffer
set paste = $PASTE_RTF_BUFFER_NAME;
paste;
# reset paste buffer
if ('' == org_buffer) {
set paste = default;
} else {
set paste = $org_buffer;
}
# delete the special buffer
delete_buffer $PASTE_RTF_BUFFER_NAME;
return 1;
}
Related Topics
set selectionsvc command
buffer_clipboard_formats function