I suspect that most apps are using some form of RTF when pasting from the global system clipboard, so I had a look first at what Livecode reads:
Code: Select all
{\rtf1\mac {\fonttbl{\f0\fnil \fcharset77 (Text);}}
{\colortbl;\red0\green0\blue0;\red0\green32639\blue0;\red0\green0\blue0;\red32639\green32639\blue0;\red32639\green0\blue32639;\red0\green32639\blue32639;}
\pard \f0 \fs24 \cf2 # Returns a list of files with the full paths
\par \pard \cf3 function listFilesWithPaths pFolder, pRecurse
\par \pard \cf4 local\cf3 tTotalFiles, tCurrentFiles, tFolders
\par \pard
\par \pard \cf4 set\cf3 \cf5 the\cf3 \cf6 defaultFolder\cf3 \cf5 to\cf3 pFolder
\par \pard \cf4 put\cf3 filteredFilesWithPaths() \cf5 into\cf3 tCurrentFiles
\par \pard
\par \pard if \cf5 not\cf3 pRecurse then
\par \pard \cf4 return\cf3 tCurrentFiles
\par \pard end if
\par \pard if tCurrentFiles \cf5 is\cf3 \cf5 not\cf3 \cf5 empty\cf3 then
\par \pard \cf4 put\cf3 tCurrentFiles & \cf4 return\cf3 \cf5 after\cf3 tTotalFiles\cf2 #
\par \pard \cf3 end if
Code: Select all
{\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf470
\cocoascreenfonts1{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
{\colortbl;\red255\green255\blue255;\red0\green255\blue0;\red255\green255\blue0;\red255\green0\blue255;
\red0\green255\blue255;}
{\info
{\keywords cursorLocation=384, fitsPagesWidth=1}}\paperw11900\paperh16840\margl1008\margr1008\margt283\vieww15520\viewh18460\viewkind1\viewscale125
\deftab720
\pard\pardeftab720
\f0\fs24 \cf2 # Returns a list of files with the full paths\
\pard\pardeftab720
\cf0 function listFilesWithPaths pFolder, pRecurse\
\cf3 local\cf0 tTotalFiles, tCurrentFiles, tFolders\
\
\cf3 set\cf0 \cf4 the\cf0 \cf5 defaultFolder\cf0 \cf4 to\cf0 pFolder\
\cf3 put\cf0 filteredFilesWithPaths() \cf4 into\cf0 tCurrentFiles\
\
if \cf4 not\cf0 pRecurse then \
\cf3 return\cf0 tCurrentFiles\
end if\
if tCurrentFiles \cf4 is\cf0 \cf4 not\cf0 \cf4 empty\cf0 then\
\cf3 put\cf0 tCurrentFiles & \cf3 return\cf0 \cf4 after\cf0 tTotalFiles\cf2 #\
\cf0 end if\
}
Original from Livecode IDE
Code: Select all
{\colortbl;\red0\green0\blue0;\red0\green32639\blue0;\red0\green0\blue0;\red32639\green32639\blue0;\red32639\green0\blue32639;\red0\green32639\blue32639;}
Code: Select all
{\colortbl;\red255\green255\blue255;\red0\green255\blue0;\red255\green255\blue0;\red255\green0\blue255;
\red0\green255\blue255;}
Is there a simple solution? The complex one is to parse the RTF text, setting the colour table to values, less than 255, that represent colours that look similar to the originals and write the new version of the text back to the clipboard before pasting elsewhere. However, despite reading the dictionary I suspect that I may have missed some thing.
Any thoughts?
Edit:
Just found this in the Terminal man pbpaste
I'm not sure if the UTF8 also restricts the colours to 8 bit.* Encoding:
pbcopy and pbpaste use locale environment variables to determine the
encoding to be used for input and output. For example, absent other
locale settings, setting the environment variable LANG=en_US.UTF-8 will
cause pbcopy and pbpaste to use UTF-8 for input and output. If an
encoding cannot be determined from the locale, the standard C encoding
will be used. Use of UTF-8 is recommended. Note that by default the
Terminal application uses the UTF-8 encoding and automatically sets the
appropriate locale environment variable.