If of you knows the codes for bold and such, and whether it is represented for each character on the clipboard, of for a stream of characters until the formatting change, or, could give me a pointer to some doc on this, then I would be very happy
What I need to know, restating it, is how styled text on the clipboard relates to rtf encoded text, if I may call it that. that.
All I really need to know is how to reckognize text in a document as bold, and encode the clipboard, consisting of a tag, to whatever combination of bold, italics and plain text is there, not considering (hopefully) font, or any other font-attributes.
set theDesk to path to desktop as text
set x to the clipboard as «class RTF »
set fileRef to (open for access file (theDesk & "Test.rtf") with write permission)
set eof fileRef to 0
write x to fileRef
close access fileRef
set theRTF to read file (theDesk & "Test.rtf")
Thanks, guys. This has turned into a really interesting topic. I’ve often wondered what dictates what the inline tags actually mean. I’m assuming it’s an internal Microsoft thing as you can have the “same” tag in two different sentences, but have a different effect.
I’m in the middle of something at the moment, but I’ll give that other script a shot later today.
I now believe I have a way to go with this, given the knowledge you were so kind to provide for me.
I now have deduced that the first part of the data, is kind of a common header, for the particular document at least, when coercing the clipboard to a record, as I have had something readable to reason from.
I have also deduced that the scrapstyles contains the styles I am interested in.
What I basically will do, is to make a paste and match style function, and see if it works. The “attribute run” seems to be of constant length, and not related to the number of chars copied from the document in the first place.
What I am after is a paste and match style, so I’ll use System Events to copy one character to the left of the insertion point, get it from the clipboard as a record, and set the text attributes in that record with new values, before I
coerce the record back to «class RTF » ( three chars ) and puts it on the clipboard, and paste it back.
Then I have the correct “RTF header” and everything, I haven’t have the time to program it yet, I’ll come back with a solution, when I have it working.