1// 2// PXHotkeyFormatter.m 3// Pixen-XCode 4// 5// Created by Andy Matuschak on Sun Apr 04 2004. 6// Copyright (c) 2004 Open Sword Group. All rights reserved. 7// 8 9#import "PXHotkeyFormatter.h" 10 11 12@implementation PXHotkeyFormatter 13 14- stringForObjectValue:(NSString *)anObject 15{ 16 if (![anObject isKindOfClass:[NSString class]]) { return nil; } 17 if ([anObject length] > 0) 18 { 19 unichar theCharacter = [anObject characterAtIndex:([anObject length] - 1)]; 20 if(![[NSCharacterSet letterCharacterSet] characterIsMember:theCharacter]) 21 { 22 return nil; 23 } 24 return [NSString stringWithFormat:@"%c", theCharacter]; 25 } 26 else 27 return @""; 28} 29 30- (BOOL)isPartialStringValid:(NSString *)partialString newEditingString:(NSString **)newString errorDescription:(NSString **)error 31{ 32 if ([partialString length] > 0) 33 { 34 unichar theCharacter = [partialString characterAtIndex:([partialString length] - 1)]; 35 if(![[NSCharacterSet letterCharacterSet] characterIsMember:theCharacter]) 36 { 37 *newString = nil; 38 return NO; 39 } 40 if ([partialString length] > 1) { 41 *newString = [NSString stringWithFormat:@"%c", theCharacter]; 42 return NO; 43 } 44 } 45 return YES; 46} 47 48- (BOOL)getObjectValue:(id *)anObject forString:string errorDescription:(NSString **)error; 49{ 50 *anObject = [[string copy] autorelease]; 51 return YES; 52} 53 54- attributedStringForObjectValue:anObject defaultAttributes:attributes 55{ 56 return [[[NSAttributedString alloc] initWithString:[self stringForObjectValue:anObject]] autorelease]; 57} 58 59@end 60