diff --git a/Framework/PCEditorManager.m b/Framework/PCEditorManager.m index 2c61808..e691d54 100644 --- a/Framework/PCEditorManager.m +++ b/Framework/PCEditorManager.m @@ -30,10 +30,12 @@ #import #import #import - +#import #import #import +#import + #import "Modules/Preferences/Misc/PCMiscPrefs.h" NSString *PCEditorDidChangeFileNameNotification = @@ -556,13 +558,10 @@ NSString *PCEditorDidResignActiveNotification = - (void)gotoFile: (NSString *)fileName atLine: (NSUInteger)line { - id editor = [self openEditorForFile: fileName - editable: YES - windowed: NO]; - PCProject *project = [_projectManager rootActiveProject]; - [[project projectBrowser] setPath: fileName]; - [_projectManager openFileAtPath: fileName]; + PCProjectEditor *pe = [project projectEditor]; + + id editor = [pe openEditorForFilePath: fileName windowed: NO]; // [self orderFrontEditorForFile:fileName]; [editor scrollToLineNumber: line]; diff --git a/Framework/PCProjectEditor.m b/Framework/PCProjectEditor.m index 989ed18..d743995 100644 --- a/Framework/PCProjectEditor.m +++ b/Framework/PCProjectEditor.m @@ -177,6 +177,48 @@ return NO; } +- (id) openEditorForFilePath: (NSString *)filePath + windowed: (BOOL)windowed +{ + PCProject *activeProject = [[_project projectManager] activeProject]; + NSString *fileName = [filePath lastPathComponent]; + BOOL editable = YES; + id editor = nil; + + NSLog(@"PCPE: fileName: %@, filePath: %@, project: %@", + fileName, filePath, [activeProject projectName]); + + // Determine if file should be opened for read only + if (![_project isEditableFile:fileName]) + { + editable = NO; + } + + // Set the 'editor' var either by requesting already opened + // editor or by creating the new one. + editor = [self openEditorForFile:filePath + editable:editable + windowed:windowed]; + if (!editor) + { + NSLog(@"We don't have editor for file: %@", fileName); + [self setActiveEditor: nil]; + return nil; + } + + // Category path was changed by user's clicking inside browser. + // That's why new category path must be transfered to editor. + NSString *categoryPath = [NSString stringWithFormat: @"/Classes/%@/", fileName]; + [editor setCategoryPath:categoryPath]; + [self orderFrontEditorForFile:filePath]; + + // Reload last column because editor has just been loaded + [[_project projectBrowser] reloadLastColumnAndNotify:NO]; + [editor fileStructureItemSelected:fileName]; + + return editor; +} + // Called by PCProjectBrowser // categoryPath: // 1. "/Classes/Class.m/- init" diff --git a/Headers/ProjectCenter/PCProjectEditor.h b/Headers/ProjectCenter/PCProjectEditor.h index d7d834b..4af6fe7 100644 --- a/Headers/ProjectCenter/PCProjectEditor.h +++ b/Headers/ProjectCenter/PCProjectEditor.h @@ -67,6 +67,9 @@ - (BOOL)editorProvidesBrowserItemsForItem:(NSString *)item; +- (id)openEditorForFilePath:(NSString *)categoryPath + windowed:(BOOL)windowed; + - (id)openEditorForCategoryPath:(NSString *)categoryPath windowed:(BOOL)windowed; diff --git a/Modules/Debuggers/ProjectCenter/PCDebugger.m b/Modules/Debuggers/ProjectCenter/PCDebugger.m index 5d5774e..8596280 100644 --- a/Modules/Debuggers/ProjectCenter/PCDebugger.m +++ b/Modules/Debuggers/ProjectCenter/PCDebugger.m @@ -312,13 +312,11 @@ NSString *PCDBDebuggerStartedNotification = @"PCDBDebuggerStartedNotification"; - (void) updateEditor { - NSLog(@"****************** UPDATE EDITOR HIT ***********************"); PCAppController *controller = (PCAppController *)[NSApp delegate]; PCProjectManager *pm = [controller projectManager]; PCEditorManager *em = [pm editorManager]; [em gotoFile: lastFileNameParsed atLine: lastLineNumberParsed]; - NSLog(@"****************** UPDATE EDITOR HIT ***********************"); } // kill process diff --git a/Modules/Editors/ProjectCenter/PCEditorView.m b/Modules/Editors/ProjectCenter/PCEditorView.m index 7ba2482..2c41b3e 100644 --- a/Modules/Editors/ProjectCenter/PCEditorView.m +++ b/Modules/Editors/ProjectCenter/PCEditorView.m @@ -183,7 +183,7 @@ static int ComputeIndentingOffset(NSString * string, unsigned int start) } } - NSLog(@"index: %i start: %i", index, line_start); + NSLog(@"index: %li start: %li", index, line_start); return line_start > index ? index : line_start; } @@ -311,7 +311,7 @@ static int ComputeIndentingOffset(NSString * string, unsigned int start) if (![wsCharSet characterIsMember:c]) { offset = offset - line_start; - NSLog(@"offset: %i", offset); + NSLog(@"offset: %li", offset); break; } } @@ -328,7 +328,7 @@ static int ComputeIndentingOffset(NSString * string, unsigned int start) // Get offset from BOL of previous line // offset = ComputeIndentingOffset([self string], line_start-1); - NSLog(@"Indent offset: %i", offset); + NSLog(@"Indent offset: %li", offset); // Replace current line whitespaces with new ones indentString = [[NSMutableString alloc] initWithString:@""];