From sking@arbor.net Mon Feb 28 16:02:19 2011 From: Steve King To: textmate@lists.macromates.com Subject: [TxMt] Re: Pasting styled text into buffer's syntax Date: Mon, 28 Feb 2011 11:02:09 -0500 Message-ID: <4D6BC701.8030207@arbor.net> In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1953088307974270262==" --===============1953088307974270262== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit On 2011-02-26 17:48, Turadg Aleahmad wrote: > Is it possible for a Textmate bundle to capture the paste and > transform the styled text to the syntax of the current buffer? E.g. > styled text "This is bold and this has a link" would paste into a > Markdown doc as "This is **bold** and this has a > [link](http://example.com)" and into an HTML doc as "This is > bold and this has a link". Very interesting suggestion. I see no reason why it wouldn't be possible for a bundle, so long as you could figure out how to access the clipboard. /usr/bin/pbpaste has an option to return RTF that was previously copied, but when I tried copying formatted text from Text Edit, pbpaste would only give me the plain ASCII. If you're lucky you'll be able to find a pre-built clipboard module for your favorite scripting language, or at worst you'd have to compile some C or Objective-C code to access the system APIs. Once you got the raw clipboard bytes you'd just have to parse the RTF and output it as the appropriate markup for the current document type. Sounds cool. Let us know when it's done. :-) -- Steve King Sr. Software Engineer Arbor Networks +1 734 821 1461 www.arbornetworks.com --===============1953088307974270262==--