Skip to content

Instantly share code, notes, and snippets.

@michaelschade
Created November 1, 2010 21:09
Show Gist options
  • Save michaelschade/658873 to your computer and use it in GitHub Desktop.
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/
#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