home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!usc!sol.ctr.columbia.edu!The-Star.honeywell.com!umn.edu!noc.msc.net!gacvx2.gac.edu!gacvax2!scott
- Newsgroups: comp.sys.next.programmer
- Subject: Handling custom RTF directives in Text.
- Message-ID: <SCOTT.92Jul30040409@nic.gac.edu>
- From: scott@nic.gac.edu (Scott Hess)
- Date: 30 Jul 92 04:04:09
- Distribution: world
- Organization: Gustavus Adolphus College
- Nntp-Posting-Host: nic.gac.edu
- Lines: 85
-
- I've been attempting to get some stuff done using custom RTF
- directives in Text, specifically an \attachment directive (like
- what Mail uses for attachments). I've got a special Cell type that
- can hold a filename, and will image the file's icon and everything
- - just as we expect. I've registered the Cell subclass' class
- using Text's +registerDirective:forClass:.
-
- I've been having problems with Copy/Paste, though. I enter "This
- is a test. ", then drag in a Stuart icon from my ~/Apps directory.
- I use Text's -replaceSelWithCell: to replace the text, and it works
- peachily.
-
- When I then select the entire area, and Copy it, here's what I get
- in the rich text area on the Pasteboard (indented for readability):
-
- {\rtf0\ansi{\fonttbl\f0\fswiss Helvetica;}
- \smartcopy0
- \f0\b0\i0\ul0\ql\fs24\fi0\li0\gray0\up0\dn0 This is a test.
- {{\attachment17 /Users/scott/Apps/Stuart.app
- }
- ,}}
-
- Where I have ',', there's actually a character that looks like a
- small '<' character. (Specifically, I believe that it is ASCII
- code xAC, or ',' with the high bit set. Available as Alternate-9
- on the US keyboard. It's called "guilsinglleft" in Keyboard.)
- I've seen this character often enough in Mail.app. This is the
- first question - anyone know where this character comes from?
-
- Another problem is that I can't Paste from the Pasteboard into the
- program. My Cell subclass is never called on to do anything - an
- instance is not even created, much less read into. I've checked
- +alloc, +allocWithZone:, and -init, and none are being called on
- Paste. All I get is one of those guilsinglleft characters again
- where the graphic belongs. It works fine pasting RTF - it can
- accept font changes and everything. Just not this custom attachment.
-
-
-
- For some more information, I checked out the MMText example from
- Joe Freeman. On Copy, it has nearly the same text on the Pasteboard
- - the only difference is that there are a bunch of tab-setting
- sequences added. Here it is, again indented for readability:
-
- {\rtf0\ansi{\fonttbl\f0\fswiss Helvetica;}
- \smartcopy0
- {\colortbl\red0\green0\blue0;}
- \pard\tx533\tx1067\tx1601\tx2135\tx2668\tx3202\tx3736\tx4270\tx4803\tx5337\f0\b0\i0\ul0\fs24\fc0 This is a test.
- {\pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600{\attach17 /Users/scott/Apps/Stuart.app
- }
- ,}}
-
- It doesn't look substantially different. He uses \attach instead
- of \attachment. But, for instance, the guilsinglleft character is
- still right in there. Another difference is that MMText allows
- this to be pasted back to itself. MMText does _not_ accept the
- data copied from my program, though.
-
-
-
- For the same text, Mail.app gives a Pasteboard like:
-
- {\rtf0\ansi{\fonttbl\f1\fmodern Ohlfs;}
- \smartcopy0
- \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\f1\b0\i0\ul0\fs20 This is a test.
- {{\attachment17 /Users/scott/Apps/Stuart.app
- }
- }
-
- We've got a different font, but otherwise this again looks
- substantially similar to my original output, with two major
- exceptions. First, the guilsinglleft character is not there.
- Also, note that in my original output and in the output from MMText,
- the curly braces match up - while in the Mail output, they don't.
- It appears to have one too few.
-
- Mail _does_ accept Copied text from my program, no problem,
- attachments intact. My program does _not_ paste attachments if I
- copy the data from Mail.
-
- Thanks for any helpful hints,
- --
- scott hess <shess@ssesco.com> <Who's now in a programming Berserker-frenzy>
- 12901 Upton Avenue South, #326 Burnsville, MN 55337 (612) 895-1208 Anytime!
- <I want to become so famous that people buy tapes of me reading source code>
-