Hi Andy,

I'm still not familiar with the text system, so I don't know if the
proxy was a good way to do this.

But assuming it was, try implementing forwardingTargetForSelector:
instead of forwardInvocation:. It's less flexible, but much faster,
and your case doesn't require the flexibility.

-Ken

On Tue, Aug 12, 2008 at 5:12 PM, Andy Kim <[EMAIL PROTECTED]> wrote:
> Many thanks to everyone who helped in this thread.
>
>> I wonder if this is a larger bug in the text system? I was going to
>> suggest
>> just inserting the Unicode character "zero-width no-break space" (U+FEFF)
>> after the slash, but when I tried it (in TextEdit) I got the very
>> phenomenon
>> you describe - the break occurs before "delete", not after.
>>
>> I was able to solve the problem, though, by also inserting a "zero-width
>> space" (U+200B) before the slash... So there's a solution for you, but it
>> seems unnecessarily elaborate. m.
>
> Matt,
>
> I may have to go with your solution for cell drawing although I'm hesitant
> before proceeding. The program has to make it seem like the character is not
> there and that could get a bit hairy with all the delete operations and copy
> paste, but I'm leaning towards that solution because I can't figure out how
> to get an outline view cell to draw efficiently using a custom
> NSTextStorage.
>
> In a text view though, Ken's suggestion of subclassing a NSTextStorage and
> overriding lineBreakBeforeIndex:withinRange: worked out well. It turns out
> that subclassing is a little tricky because NSTextStorage is not a concrete
> class so here's what I did for posterity sake:
>
> @interface PFTextStorage : NSProxy
> {
>        NSTextStorage *realStorage;
> }
> - (id)initWithTextStorage:(NSTextStorage *)storage;
> @end
>
>
> @implementation PFTextStorage
>
> - (id)init
> {
>        realStorage = [[NSTextStorage alloc] init];
>        return self;
> }
>
> - (id)initWithTextStorage:(NSTextStorage *)storage
> {
>        realStorage = [storage retain];
>        return self;
> }
>
> - (void)dealloc
> {
>        [realStorage release];
>        [super dealloc];
> }
>
> - (BOOL)respondsToSelector:(SEL)aSelector
> {
>        return [realStorage respondsToSelector:aSelector];
> }
>
> - (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector
> {
>        return [realStorage methodSignatureForSelector:aSelector];
> }
>
> - (void)forwardInvocation:(NSInvocation *)invocation
> {
>        SEL aSelector = [invocation selector];
>
>   if ([realStorage respondsToSelector:aSelector])
>       [invocation invokeWithTarget:realStorage];
>   else
>       [realStorage doesNotRecognizeSelector:aSelector];
> }
>
> - (NSUInteger)lineBreakBeforeIndex:(NSUInteger)index
> withinRange:(NSRange)aRange
> {
>        NSString *string = [realStorage string];
>        NSUInteger breakIndex = [realStorage lineBreakBeforeIndex:index
> withinRange:aRange];
>        if (breakIndex >= 2 &&
>                [string characterAtIndex:breakIndex-1] == '/' &&
>                [[NSCharacterSet whitespaceCharacterSet]
> characterIsMember:[string characterAtIndex:breakIndex-2]])
>                return breakIndex - 2;
>
>        return breakIndex;
> }
>
> @end
>
> _______________________________________________
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/kenferry%40gmail.com
>
> This email sent to [EMAIL PROTECTED]
>
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to