diff --git a/ChangeLog b/ChangeLog index 5ef2526..03cddb0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2010-06-22 Riccardo Mottola + + * Modules/Editors/ProjectCenter/PCEditor.h + * Modules/Editors/ProjectCenter/PCEditor.m + * Modules/Editors/ProjectCenter/PCEditor+Document.m + Clean up parenthesis highlighting. + 2010-06-15 Wolfgang Lux * Framework/PCProject.m (-fileTypesForCategoryKey:): Add .dylib to diff --git a/Modules/Editors/ProjectCenter/PCEditor+Document.m b/Modules/Editors/ProjectCenter/PCEditor+Document.m index 880019a..1f83382 100644 --- a/Modules/Editors/ProjectCenter/PCEditor+Document.m +++ b/Modules/Editors/ProjectCenter/PCEditor+Document.m @@ -245,58 +245,6 @@ unsigned int FindDelimiterInString(NSString * string, } } -- (void)computeNewParenthesisNesting -{ - NSRange selectedRange; - NSString * myString; - - if ([[NSUserDefaults standardUserDefaults] boolForKey: @"DontTrackNesting"]) - { - return; - } - - selectedRange = [textView selectedRange]; - - // make sure we un-highlight a previously highlit delimiter - [self unhighlightCharacter]; - - // if we have a character at the selected location, check - // to see if it is a delimiter character - myString = [textView string]; - if (selectedRange.length <= 1 && [myString length] > selectedRange.location) - { - unichar c; - // we must initialize these explicitly in order to make - // gcc shut up about flow control - unichar oppositeDelimiter = 0; - BOOL searchBackwards = NO; - - c = [myString characterAtIndex: selectedRange.location]; - - // if it is, search for the opposite delimiter in a range - // of at most 1000 characters around it in either forward - // or backward direction (depends on the kind of delimiter - // we're searching for). - if (CheckDelimiter(c, &oppositeDelimiter, &searchBackwards)) - { - unsigned int result; - - result = FindDelimiterInString(myString, - oppositeDelimiter, - c, - selectedRange.location, - searchBackwards); - - // and in case a delimiter is found, highlight it - if (result != NSNotFound) - { - [self highlightCharacterAt: result]; - } - } - } -} - - // --- State - (void)updateMiniwindowIconToEdited:(BOOL)flag diff --git a/Modules/Editors/ProjectCenter/PCEditor.h b/Modules/Editors/ProjectCenter/PCEditor.h index 767a261..593a43a 100644 --- a/Modules/Editors/ProjectCenter/PCEditor.h +++ b/Modules/Editors/ProjectCenter/PCEditor.h @@ -24,9 +24,6 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ -#ifndef _PCEditor_h_ -#define _PCEditor_h_ - #import #import @@ -154,9 +151,6 @@ - (void)unhighlightCharacter; - (void)highlightCharacterAt:(unsigned int)location; -- (void)computeNewParenthesisNesting; +- (void)computeNewParenthesisNesting: (NSTextView *)editorView; @end - -#endif // _PCEDITOR_H_ - diff --git a/Modules/Editors/ProjectCenter/PCEditor.m b/Modules/Editors/ProjectCenter/PCEditor.m index b527978..3097fc6 100644 --- a/Modules/Editors/ProjectCenter/PCEditor.m +++ b/Modules/Editors/ProjectCenter/PCEditor.m @@ -837,7 +837,11 @@ { if (editorTextViewIsPressingKey == NO) { - [self computeNewParenthesisNesting]; + id object; + + object = [notification object]; + if (object == _intEditorView || object == _extEditorView) + [self computeNewParenthesisNesting: object]; } } @@ -852,7 +856,8 @@ - (void)editorTextViewDidPressKey:sender { // NSLog(@"Did pressing key"); - [self computeNewParenthesisNesting]; + if (sender == _intEditorView || sender == _extEditorView) + [self computeNewParenthesisNesting: sender]; editorTextViewIsPressingKey = NO; } @@ -1318,7 +1323,7 @@ unsigned int FindDelimiterInString(NSString * string, } } -- (void)computeNewParenthesisNesting +- (void)computeNewParenthesisNesting: (NSTextView *)editorView { NSRange selectedRange; NSString *myString; @@ -1328,19 +1333,18 @@ unsigned int FindDelimiterInString(NSString * string, return; } - selectedRange = [_intEditorView selectedRange]; + NSAssert(editorView, @"computeNewParenthesis: editorView is nil"); + selectedRange = [editorView selectedRange]; // make sure we un-highlight a previously highlit delimiter [self unhighlightCharacter]; // if we have a character at the selected location, check // to see if it is a delimiter character - myString = [_intEditorView string]; + myString = [editorView string]; if (selectedRange.length <= 1 && [myString length] > selectedRange.location) { unichar c; - // we must initialize these explicitly in order to make - // gcc shut up about flow control unichar oppositeDelimiter = 0; BOOL searchBackwards = NO;