home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / sys / next / programm / 5351 < prev    next >
Encoding:
Internet Message Format  |  1992-07-29  |  4.0 KB

  1. Path: sparky!uunet!usc!sol.ctr.columbia.edu!The-Star.honeywell.com!umn.edu!noc.msc.net!gacvx2.gac.edu!gacvax2!scott
  2. Newsgroups: comp.sys.next.programmer
  3. Subject: Handling custom RTF directives in Text.
  4. Message-ID: <SCOTT.92Jul30040409@nic.gac.edu>
  5. From: scott@nic.gac.edu (Scott Hess)
  6. Date: 30 Jul 92 04:04:09
  7. Distribution: world
  8. Organization: Gustavus Adolphus College
  9. Nntp-Posting-Host: nic.gac.edu
  10. Lines: 85
  11.  
  12. I've been attempting to get some stuff done using custom RTF
  13. directives in Text, specifically an \attachment directive (like
  14. what Mail uses for attachments).  I've got a special Cell type that
  15. can hold a filename, and will image the file's icon and everything
  16. - just as we expect.  I've registered the Cell subclass' class
  17. using Text's +registerDirective:forClass:.
  18.  
  19. I've been having problems with Copy/Paste, though.  I enter "This
  20. is a test.  ", then drag in a Stuart icon from my ~/Apps directory.
  21. I use Text's -replaceSelWithCell: to replace the text, and it works
  22. peachily.
  23.  
  24. When I then select the entire area, and Copy it, here's what I get
  25. in the rich text area on the Pasteboard (indented for readability):
  26.  
  27.     {\rtf0\ansi{\fonttbl\f0\fswiss Helvetica;}
  28.     \smartcopy0
  29.     \f0\b0\i0\ul0\ql\fs24\fi0\li0\gray0\up0\dn0 This is a test.  
  30.     {{\attachment17 /Users/scott/Apps/Stuart.app
  31.     }
  32.     ,}}
  33.  
  34. Where I have ',', there's actually a character that looks like a
  35. small '<' character.  (Specifically, I believe that it is ASCII
  36. code xAC, or ',' with the high bit set.  Available as Alternate-9
  37. on the US keyboard.  It's called "guilsinglleft" in Keyboard.)
  38. I've seen this character often enough in Mail.app.  This is the
  39. first question - anyone know where this character comes from?
  40.  
  41. Another problem is that I can't Paste from the Pasteboard into the
  42. program.  My Cell subclass is never called on to do anything - an
  43. instance is not even created, much less read into.  I've checked
  44. +alloc, +allocWithZone:, and -init, and none are being called on
  45. Paste.  All I get is one of those guilsinglleft characters again
  46. where the graphic belongs.  It works fine pasting RTF - it can
  47. accept font changes and everything.  Just not this custom attachment.
  48.  
  49.  
  50.  
  51. For some more information, I checked out the MMText example from
  52. Joe Freeman.  On Copy, it has nearly the same text on the Pasteboard
  53. - the only difference is that there are a bunch of tab-setting
  54. sequences added.  Here it is, again indented for readability:
  55.  
  56.     {\rtf0\ansi{\fonttbl\f0\fswiss Helvetica;}
  57.     \smartcopy0
  58.     {\colortbl\red0\green0\blue0;}
  59.     \pard\tx533\tx1067\tx1601\tx2135\tx2668\tx3202\tx3736\tx4270\tx4803\tx5337\f0\b0\i0\ul0\fs24\fc0 This is a test.  
  60.     {\pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600{\attach17 /Users/scott/Apps/Stuart.app
  61.     }
  62.     ,}}
  63.  
  64. It doesn't look substantially different.  He uses \attach instead
  65. of \attachment.  But, for instance, the guilsinglleft character is
  66. still right in there.  Another difference is that MMText allows
  67. this to be pasted back to itself.  MMText does _not_ accept the
  68. data copied from my program, though.
  69.  
  70.  
  71.  
  72. For the same text, Mail.app gives a Pasteboard like:
  73.  
  74.     {\rtf0\ansi{\fonttbl\f1\fmodern Ohlfs;}
  75.     \smartcopy0
  76.     \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\f1\b0\i0\ul0\fs20 This is a test.  
  77.     {{\attachment17 /Users/scott/Apps/Stuart.app
  78.     }
  79.     }
  80.  
  81. We've got a different font, but otherwise this again looks
  82. substantially similar to my original output, with two major
  83. exceptions.  First, the guilsinglleft character is not there.
  84. Also, note that in my original output and in the output from MMText,
  85. the curly braces match up - while in the Mail output, they don't.
  86. It appears to have one too few.
  87.  
  88. Mail _does_ accept Copied text from my program, no problem,
  89. attachments intact.  My program does _not_ paste attachments if I
  90. copy the data from Mail.
  91.  
  92. Thanks for any helpful hints,
  93. --
  94. scott hess <shess@ssesco.com>  <Who's now in a programming Berserker-frenzy>
  95. 12901 Upton Avenue South, #326  Burnsville, MN 55337 (612) 895-1208 Anytime!
  96. <I want to become so famous that people buy tapes of me reading source code>
  97.