Styled text in Panther
Styled text in Panther
- Subject: Styled text in Panther
- From: Brennan <email@hidden>
- Date: Mon, 26 Jan 2004 14:38:20 +0100
Looking at the dictionary for Image events and TextEdit, it would appear
that we are on our way to some kind of standard Applescript treatment of
styled/rich text. Unfortunately, I can't fathom it, so I wonder whether
this is unfinshed or never properly started.
My goal is to have a piece of styled text open in a standard text editing
Application (preferably TextEdit, Appleworks or something which has a
chance of having been bundled with a Mac) and then pull out the style
information.
You don't need to know what I want to do with this style data afterwards,
suffice to say it will be akin to generating HTML code for formatted text.
It would also be acceptable to read the styled text directly from a file.
TextEdit has this nice 'attribute run' class, but this includes font,
fontsize and color, it omits actual style information (bold, underline
etc.). Most cocoa applications seems to offer this, but I can't see
any/many which actually support it explicitly.
For example, Image events seems to offer this class, but I can't see how
to get some styled text into that app in the first place. The 'open'
command only returns image objects.
Beyond that, there's TexEdit Plus and Style, both of which I trust to do
what they say on the tin, although their terminology is different. It used
to be possible to get style information from a chunk of Appleworks text,
but it appears that the terminology has changed in some recent version.
I have some ugly old code for generating styled text, involving a
clipboard hack which still works under OSX (astonishing!)
set styleRecord to {styled text:"AppleComputer", style:<<data
styl000200000000000C000C2F8B0100000CFFFF0000000000000005001800182F8B020000
18FFFF0000FFFF>>}
-- hack: use the clipboard to coerce the record to rendered styled text
set oldClipboard to the clipboard
set the clipboard to styleRecord
set myStyledClip to the clipboard
set the clipboard to oldClipboard
return myStyledClip
(watch those chevrons). However I actually want to go the *other* way.
Any ideas?
Brennan
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.