aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPTextViewAdditions.m
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2009-04-06 06:59:53 +0000
committerBibiko <bibiko@eva.mpg.de>2009-04-06 06:59:53 +0000
commit2c5cc993e46a39e8ee15d82e21e88eaa7d5d602d (patch)
tree40103b6e7d0ac88bd2a9b57fde686fed171c8d21 /Source/SPTextViewAdditions.m
parentd56013e27c4071465d8c5e53c125362ddb7166be (diff)
downloadsequelpro-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.m22
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.
*/