diff options
author | Bibiko <bibiko@eva.mpg.de> | 2009-04-06 06:59:53 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2009-04-06 06:59:53 +0000 |
commit | 2c5cc993e46a39e8ee15d82e21e88eaa7d5d602d (patch) | |
tree | 40103b6e7d0ac88bd2a9b57fde686fed171c8d21 /Source/SPTextViewAdditions.m | |
parent | d56013e27c4071465d8c5e53c125362ddb7166be (diff) | |
download | sequelpro-2c5cc993e46a39e8ee15d82e21e88eaa7d5d602d.tar.gz sequelpro-2c5cc993e46a39e8ee15d82e21e88eaa7d5d602d.tar.bz2 sequelpro-2c5cc993e46a39e8ee15d82e21e88eaa7d5d602d.zip |
• ADDED - (IBAction)doRemoveDiacritics:(id)sender
- this method removes all combining diacritics
-- e.g. façäñど ⇢ facanと after Unicode's NFD
Diffstat (limited to 'Source/SPTextViewAdditions.m')
-rw-r--r-- | Source/SPTextViewAdditions.m | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/Source/SPTextViewAdditions.m b/Source/SPTextViewAdditions.m index 4c467a22..c7491215 100644 --- a/Source/SPTextViewAdditions.m +++ b/Source/SPTextViewAdditions.m @@ -181,6 +181,28 @@ } } +- (IBAction)doRemoveDiacritics:(id)sender +{ + + NSRange curRange = [self selectedRange]; + NSRange selRange = (curRange.length) ? curRange : [self getRangeForCurrentWord]; + [self setSelectedRange:selRange]; + NSString* convString = [[[self string] substringWithRange:selRange] decomposedStringWithCanonicalMapping]; + NSArray* chars; + chars = [convString componentsSeparatedByCharactersInSet:[NSCharacterSet nonBaseCharacterSet]]; + NSString* cleanString = [chars componentsJoinedByString:@""]; + [self insertText:cleanString]; + if(curRange.length) + [self setSelectedRange:NSMakeRange(selRange.location, [cleanString length])]; + else + // if no selection place the caret at the end of the current word + { + NSRange newRange = [self getRangeForCurrentWord]; + [self setSelectedRange:NSMakeRange(newRange.location + newRange.length, 0)]; + } + +} + /* * Change selection or current word according to Unicode's NFKC to title case and preserves the selection. */ |