Author Topic: Clipboard format swap  (Read 6158 times)

MindprisM

  • Senior Community Member
  • Posts: 127
  • Hero Points: 8
Clipboard format swap
« on: September 07, 2009, 09:37:30 AM »
I want to create a special COPY command that will copy the text in an editor window, but then I want to get a hold of the HTML/RTF version on the clip and modify it and place it on the clip again as plain text.

for example, the following two keywords are colored in blue in the editor:
Code: [Select]
echo %1
pause

I copy that code and go somewhere that accepts a rich clipboard, and I paste it, I get:
Code: [Select]
<SPAN style="FONT-FAMILY: 'AUltraFontII'; FONT-SIZE: 5pt"><PRE><SPAN style="BACKGROUND: #000000; COLOR: #3e3eff">echo</SPAN><SPAN style="BACKGROUND: #000000; COLOR: #c4c4c4"> %1</SPAN>
<SPAN style="BACKGROUND: #000000; COLOR: #3e3eff">pause</SPAN></PRE></SPAN>

I want to do some modifications to the above markup and place it back on the clipboard as plain (but marked-up) text.

So is there a way to get a hold of that, or is it being generated in the accepting application?


Lee

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1299
  • Hero Points: 130
Re: Clipboard format swap
« Reply #1 on: September 08, 2009, 01:37:05 PM »
SlickEdit generates the HTML/RTF fragment on the Windows platform and adds it to the system clipboard in the appropriate format type.  There is no direct way to get at the generated fragment in SlickEdit, and SlickEdit currently doesn't accept HTML or Rich Text Format clipboard formats.  It would be a handy to feature to be able to paste the HTML clipboard as plain text, I can add a Feature Request to add that functionality.  There is also a command that generates an HTML file (File > Export to HTML...) from a given source file for capturing color-coding, that could be extended to work on selection basis too.  So make that two feature requests.

If you have a clipboard viewer application of some sort, you should be able to get at the formats generated by SlickEdit.  SlickEdit Gadgets (http://www.slickedit.com/index.php?option=com_content&view=article&id=78&Itemid=90) is a free download for Visual Studio 2008/2005 users and it has a tool that inspects the clipboard.  I have used the Data Object Analyzer while working with clipboard and drag and drop issues, it comes in very handy.

MindprisM

  • Senior Community Member
  • Posts: 127
  • Hero Points: 8
Re: Clipboard format swap
« Reply #2 on: September 09, 2009, 05:14:00 AM »
I can add a Feature Request to add that functionality...make that two feature requests.


I would suggest the following in OPTIONS:

==RICH COPYING==
Checkbox: Use editor font
Checkbox: Use editor font size
Checkbox: Use editor background color

(if any of the above are unchecked, allow user to select a font, size or background, or, for each, select <none>, meaning do not include any markup for that element type)




MindprisM

  • Senior Community Member
  • Posts: 127
  • Hero Points: 8
Re: Clipboard format swap
« Reply #3 on: September 12, 2009, 08:28:11 AM »
Stumbles across it....
Code: [Select]
/**
 * Copies color formatted text selection to the operating system
 * clipboard.
 *
 * @appliesTo Edit_Window, Editor_Control
 * @categories Clipboard_Functions, Edit_Window_Methods, Editor_Control_Methods
 *
 * @param format - currently available clipboard formats
 *    'R' - 'RTF Format' (Windows format)
 *    'H' - 'HTML Format' (Windows format)
 *
 * @param markid Handle to a selection returned by one of the built-ins _alloc_selection or
 *               _duplicate_selection.  A mark_id of '' or no mark_id parameter identifies
 *               the active selection.
 *
 * @return Returns 0 if successful.
 * @see copy_to_clipboard
 */
int _copy_color_coding_to_clipboard(_str format, _str markid="");