From cf83a507b6732f20f3b49b453333b7e20e80037b Mon Sep 17 00:00:00 2001 From: Bibiko Date: Sun, 5 Apr 2009 16:12:30 +0000 Subject: =?UTF-8?q?=E2=80=A2=20ADDED=20to=20SPTextViewAdditions:=20-=20(NS?= =?UTF-8?q?Range)getRangeForCurrentWord=20-=20(IBAction)selectCurrentWord:?= =?UTF-8?q?(id)sender;=20-=20(IBAction)selectCurrentLine:(id)sender;=20-?= =?UTF-8?q?=20(IBAction)doSelectionUpperCase:(id)sender;=20-=20(IBAction)d?= =?UTF-8?q?oSelectionLowerCase:(id)sender;=20-=20(IBAction)doSelectionTitl?= =?UTF-8?q?eCase:(id)sender;=20-=20(IBAction)doDecomposedStringWithCanonic?= =?UTF-8?q?alMapping:(id)sender;=20-=20(IBAction)doDecomposedStringWithCom?= =?UTF-8?q?patibilityMapping:(id)sender;=20-=20(IBAction)doPrecomposedStri?= =?UTF-8?q?ngWithCanonicalMapping:(id)sender;=20-=20(IBAction)doPrecompose?= =?UTF-8?q?dStringWithCompatibilityMapping:(id)sender;=20=E2=80=A2=20BOUND?= =?UTF-8?q?ED=20these=20IBAction=20to=20mainmenu.xib?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/CMTextView.m | 147 ---------------------------------------------------- 1 file changed, 147 deletions(-) (limited to 'Source/CMTextView.m') diff --git a/Source/CMTextView.m b/Source/CMTextView.m index 49aee2cf..0493f0c8 100644 --- a/Source/CMTextView.m +++ b/Source/CMTextView.m @@ -116,46 +116,6 @@ YY_BUFFER_STATE yy_scan_string (const char *); return YES; } -/* - * Select current line and returns found NSRange. - */ -- (NSRange)selectCurrentLine -{ - [self doCommandBySelector:@selector(moveToBeginningOfLine:)]; - [self doCommandBySelector:@selector(moveToEndOfLineAndModifySelection:)]; - - return([self selectedRange]); -} - -/* - * Select current word and returns found NSRange. - * finds: [| := caret] |word wo|rd word| - * If | is in between whitespaces nothing will be selected. - */ -- (NSRange)selectCurrentWord -{ - NSRange curRange = [self selectedRange]; - unsigned long curLocation = curRange.location; - [self doCommandBySelector:@selector(moveWordLeft:)]; - [self doCommandBySelector:@selector(moveWordRightAndModifySelection:)]; - - unsigned long newStartRange = [self selectedRange].location; - unsigned long newEndRange = newStartRange + [self selectedRange].length; - - // if current location does not intersect with found range - // then caret is at the begin of a word -> change strategy - if(curLocation < newStartRange || curLocation > newEndRange) - { - [self setSelectedRange:curRange]; - [self doCommandBySelector:@selector(moveWordRightAndModifySelection:)]; - } - - if([[[self string] substringWithRange:[self selectedRange]] rangeOfCharacterFromSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]].location != NSNotFound) - [self setSelectedRange:curRange]; - - return([self selectedRange]); -} - /* * Copy selected text chunk as RTF to preserve syntax highlighting */ @@ -175,76 +135,6 @@ YY_BUFFER_STATE yy_scan_string (const char *); } -/* - * Change selection or current word to upper case and preserves the selection. - */ -- (void)doSelectionUpperCase -{ - NSRange curRange = [self selectedRange]; - [self insertText:[[[self string] substringWithRange:(curRange.length)?curRange:[self selectCurrentWord]] uppercaseString]]; - [self setSelectedRange:curRange]; -} - -/* - * Change selection or current word to lower case and preserves the selection. - */ -- (void)doSelectionLowerCase -{ - NSRange curRange = [self selectedRange]; - [self insertText:[[[self string] substringWithRange:(curRange.length)?curRange:[self selectCurrentWord]] lowercaseString]]; - [self setSelectedRange:curRange]; -} - -/* - * Change selection or current word to title case and preserves the selection. - */ -- (void)doSelectionTitleCase -{ - NSRange curRange = [self selectedRange]; - [self insertText:[[[self string] substringWithRange:(curRange.length)?curRange:[self selectCurrentWord]] capitalizedString]]; - [self setSelectedRange:curRange]; -} - -/* - * Change selection or current word according to Unicode's NFD and preserves the selection. - */ -- (void)doDecomposedStringWithCanonicalMapping -{ - NSRange curRange = [self selectedRange]; - [self insertText:[[[self string] substringWithRange:(curRange.length)?curRange:[self selectCurrentWord]] decomposedStringWithCanonicalMapping]]; - [self setSelectedRange:curRange]; -} - -/* - * Change selection or current word according to Unicode's NFKD and preserves the selection. - */ -- (void)doDecomposedStringWithCompatibilityMapping -{ - NSRange curRange = [self selectedRange]; - [self insertText:[[[self string] substringWithRange:(curRange.length)?curRange:[self selectCurrentWord]] decomposedStringWithCompatibilityMapping]]; - [self setSelectedRange:curRange]; -} - -/* - * Change selection or current word according to Unicode's NFC and preserves the selection. - */ -- (void)doPrecomposedStringWithCanonicalMapping -{ - NSRange curRange = [self selectedRange]; - [self insertText:[[[self string] substringWithRange:(curRange.length)?curRange:[self selectCurrentWord]] precomposedStringWithCanonicalMapping]]; - [self setSelectedRange:curRange]; -} - -/* - * Change selection or current word according to Unicode's NFKC to title case and preserves the selection. - */ -- (void)doPrecomposedStringWithCompatibilityMapping -{ - NSRange curRange = [self selectedRange]; - [self insertText:[[[self string] substringWithRange:(curRange.length)?curRange:[self selectCurrentWord]] precomposedStringWithCompatibilityMapping]]; - [self setSelectedRange:curRange]; -} - /* * Handle some keyDown events in order to provide autopairing functionality (if enabled). @@ -271,20 +161,6 @@ YY_BUFFER_STATE yy_scan_string (const char *); // Note: switch(insertedCharacter) {} does not work instead use charactersIgnoringModifiers - if([charactersIgnMod isEqualToString:@"w"]) // ^W select current word - if(curFlags==(NSControlKeyMask)) - { - [self selectCurrentWord]; - return; - } - - if([charactersIgnMod isEqualToString:@"l"]) // ^L select current line - if(curFlags==(NSControlKeyMask)) - { - [self selectCurrentLine]; - return; - } - if([charactersIgnMod isEqualToString:@"c"]) // ^C copy as RTF if(curFlags==(NSControlKeyMask)) { @@ -292,29 +168,6 @@ YY_BUFFER_STATE yy_scan_string (const char *); return; } - if([charactersIgnMod isEqualToString:@"u"]) - // ^U upper case - if(curFlags==(NSControlKeyMask)) - { - [self doSelectionUpperCase]; - return; - } - // ^⌥U title case - if(curFlags==(NSControlKeyMask|NSAlternateKeyMask)) - { - [self doSelectionTitleCase]; - return; - } - - if([charactersIgnMod isEqualToString:@"U"]) // ^⇧U lower case - if(([theEvent modifierFlags] - & (NSControlKeyMask|NSAlternateKeyMask|NSCommandKeyMask))==(NSControlKeyMask)) - { - [self doSelectionLowerCase]; - return; - } - - // Only process for character autopairing if autopairing is enabled and a single character is being added. if (autopairEnabled && characters && [characters length] == 1) { -- cgit v1.2.3