This is PSText.m in view mode; [Download] [Up]
/*
* PSText.m, subclass of Text overriding paste: for adding functionality
* Author: Ali Ozer
* Created: Mar 22, 89
*
* You may freely copy, distribute and reuse the code in this example.
* NeXT disclaims any warranty of any kind, expressed or implied,
* as to its fitness for any particular use.
*/
#import "PSText.h"
#import <string.h>
#import <mach/mach.h>
#import <appkit/Pasteboard.h>
@implementation PSText
/*
* The following method overrides the Text paste: method. If there's any
* PostScript on the pasteboard, this method will paste that in before pasting
* ASCII. If there's no PostScript on the pasteboard, then this method will
* simply call the overridden paste: method.
*/
- paste:(id)sender
{
id pb = [Pasteboard new];
char *data;
char *const *s; /* We use s to go through types. */
char *const *types = [pb types];
int len;
/* Check to see if we have any PostScript on the pasteboard... */
for (s = types; *s; s++) if (!strcmp(*s, NXPostScriptPboard)) break;
/* At this point, if *s != NULL, we found PostScript on the pasteboard. */
if (*s && [pb readType:NXPostScriptPboard data:&data length:&len] && len) {
[self replaceSel:data length:len];
vm_deallocate (task_self(), (vm_address_t)data, (vm_size_t)len);
} else {
[super paste:sender]; /* No PS; pass the task on to Text. */
}
return self;
}
@end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.