Created
November 1, 2010 21:09
-
-
Save michaelschade/658873 to your computer and use it in GitHub Desktop.
The Services.m for accentuateus-osx-service as described on http://mschade.me/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "Services.h" | |
@implementation Services | |
- (void)accentuate:(NSPasteboard *)pboard | |
userData:(NSString *)data | |
error:(NSString **)error { | |
NSString *text; | |
NSArray *types; | |
types = [pboard types]; | |
// Problem with supplied data | |
if(![types containsObject:NSStringPboardType] | |
|| !(text = [pboard stringForType:NSStringPboardType])) { | |
*error = NSLocalizedString(@"Error: Pasteboard doesn't contain a string.", | |
@"Pasteboard couldn't give a string."); | |
return; | |
} | |
// Error working with text? | |
if(!text) { | |
*error = NSLocalizedString(@"Error: Couldn't accentuate text $@.", | |
@"Couldn't perform service operation."); | |
return; | |
} | |
// Set new text | |
types = [NSArray arrayWithObject:NSStringPboardType]; | |
[pboard clearContents]; | |
[pboard declareTypes:types owner:nil]; | |
text = [text lowercaseString]; | |
[pboard writeObjects:[NSArray arrayWithObject:text]]; | |
return; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment