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 | |
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')
-rw-r--r-- | Source/SPTextViewAdditions.h | 1 | ||||
-rw-r--r-- | Source/SPTextViewAdditions.m | 22 |
2 files changed, 23 insertions, 0 deletions
diff --git a/Source/SPTextViewAdditions.h b/Source/SPTextViewAdditions.h index e5e38d3d..95075165 100644 --- a/Source/SPTextViewAdditions.h +++ b/Source/SPTextViewAdditions.h @@ -34,5 +34,6 @@ - (IBAction)doPrecomposedStringWithCanonicalMapping:(id)sender; - (IBAction)doPrecomposedStringWithCompatibilityMapping:(id)sender; - (IBAction)doTranspose:(id)sender; +- (IBAction)doRemoveDiacritics:(id)sender; @end
\ No newline at end of file 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. */ |