From 491745fd360291edb0d58424ef377bb0c0815766 Mon Sep 17 00:00:00 2001 From: Riccardo Mottola Date: Tue, 22 Jun 2010 16:03:05 +0000 Subject: [PATCH] Fix highlighting for standalone editors. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/projectcenter/trunk@30819 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 8 +++++++ Modules/Editors/ProjectCenter/PCEditor.h | 4 ++-- Modules/Editors/ProjectCenter/PCEditor.m | 28 +++++++++++++++--------- 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 03cddb0..91e419f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,14 @@ * Modules/Editors/ProjectCenter/PCEditor+Document.m Clean up parenthesis highlighting. + * Modules/Editors/ProjectCenter/PCEditor.h + * Modules/Editors/ProjectCenter/PCEditor.m + Fix highlighting for standalone editors. + + * Modules/Editors/ProjectCenter/PCEditor+Document.m + Deleted + + 2010-06-15 Wolfgang Lux * Framework/PCProject.m (-fileTypesForCategoryKey:): Add .dylib to diff --git a/Modules/Editors/ProjectCenter/PCEditor.h b/Modules/Editors/ProjectCenter/PCEditor.h index 593a43a..9aa292f 100644 --- a/Modules/Editors/ProjectCenter/PCEditor.h +++ b/Modules/Editors/ProjectCenter/PCEditor.h @@ -149,8 +149,8 @@ @interface PCEditor (Parenthesis) -- (void)unhighlightCharacter; -- (void)highlightCharacterAt:(unsigned int)location; +- (void)unhighlightCharacter: (NSTextView *)editorView; +- (void)highlightCharacterAt:(unsigned int)location inEditor: (NSTextView *)editorView; - (void)computeNewParenthesisNesting: (NSTextView *)editorView; @end diff --git a/Modules/Editors/ProjectCenter/PCEditor.m b/Modules/Editors/ProjectCenter/PCEditor.m index 3097fc6..e5caa4e 100644 --- a/Modules/Editors/ProjectCenter/PCEditor.m +++ b/Modules/Editors/ProjectCenter/PCEditor.m @@ -212,6 +212,10 @@ NSLog(@"PCEditor: %@ dealloc", [_path lastPathComponent]); #endif + [_extEditorView setEditor: nil]; + [_window setDelegate: nil]; + + [[NSNotificationCenter defaultCenter] removeObserver:self]; [_window close]; @@ -850,7 +854,10 @@ editorTextViewIsPressingKey = YES; // NSLog(@"Will pressing key"); - [self unhighlightCharacter]; + if (sender == _intEditorView || sender == _extEditorView) + [self unhighlightCharacter: sender]; + else + NSLog(@"PCEditor: unexpected sender"); } - (void)editorTextViewDidPressKey:sender @@ -858,6 +865,8 @@ // NSLog(@"Did pressing key"); if (sender == _intEditorView || sender == _extEditorView) [self computeNewParenthesisNesting: sender]; + else + NSLog(@"PCEditor: unexpected sender"); editorTextViewIsPressingKey = NO; } @@ -1212,10 +1221,10 @@ unsigned int FindDelimiterInString(NSString * string, @implementation PCEditor (Parenthesis) -- (void)unhighlightCharacter +- (void)unhighlightCharacter: (NSTextView *)editorView { int i; - NSTextStorage *textStorage = [_intEditorView textStorage]; + NSTextStorage *textStorage = [editorView textStorage]; [textStorage beginEditing]; @@ -1225,7 +1234,6 @@ unsigned int FindDelimiterInString(NSString * string, NSRange r = NSMakeRange(highlited_chars[i], 1); // NSRange r = NSMakeRange(highlitCharacterLocation, i); -// NSLog(@"unhighlight"); isCharacterHighlit = NO; @@ -1271,7 +1279,7 @@ unsigned int FindDelimiterInString(NSString * string, [textStorage endEditing]; } -- (void)highlightCharacterAt:(unsigned int)location +- (void)highlightCharacterAt:(unsigned int)location inEditor: (NSTextView *)editorView { int i; @@ -1280,7 +1288,7 @@ unsigned int FindDelimiterInString(NSString * string, // if (isCharacterHighlit == NO) if (i < 2) { - NSTextStorage *textStorage = [_intEditorView textStorage]; + NSTextStorage *textStorage = [editorView textStorage]; NSRange r = NSMakeRange(location, 1); NSRange tmp; @@ -1290,7 +1298,7 @@ unsigned int FindDelimiterInString(NSString * string, highlited_chars[i] = location; isCharacterHighlit = YES; - + NSAssert(textStorage, @"textstorage can't be nil"); [textStorage beginEditing]; // store the previous character's attributes @@ -1337,7 +1345,7 @@ unsigned int FindDelimiterInString(NSString * string, selectedRange = [editorView selectedRange]; // make sure we un-highlight a previously highlit delimiter - [self unhighlightCharacter]; + [self unhighlightCharacter :editorView]; // if we have a character at the selected location, check // to see if it is a delimiter character @@ -1367,8 +1375,8 @@ unsigned int FindDelimiterInString(NSString * string, // and in case a delimiter is found, highlight it if (result != NSNotFound) { - [self highlightCharacterAt:selectedRange.location]; - [self highlightCharacterAt:result]; + [self highlightCharacterAt:selectedRange.location inEditor:editorView]; + [self highlightCharacterAt:result inEditor:editorView]; } } }