From 0360e20f009b0e252be31a6844d3bf3c9a23212a Mon Sep 17 00:00:00 2001 From: Sergii Stoian Date: Tue, 5 Sep 2006 16:42:23 +0000 Subject: [PATCH] Synchronize local repository with SVN after long delay git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/projectcenter/branches/UNSTABLE_0_5@23393 72102866-910b-0410-8b05-ffd578937521 --- Documentation/ANNOUNCE | 5 +- Documentation/TODO | 13 +- GNUmakefile | 7 +- Headers/ProjectCenter/PCFileNameField.h | 2 + Headers/ProjectCenter/PCFileNameIcon.h | 15 +- Headers/ProjectCenter/PCProjectBrowser.h | 4 +- Headers/ProjectCenter/PCProjectEditor.h | 48 +- Headers/ProjectCenter/PCProjectInspector.h | 4 +- Headers/ProjectCenter/PCProjectWindow.h | 9 +- Headers/Protocols/CodeEditor.h | 25 +- Headers/Protocols/ProjectEditor.h | 67 -- Library/GNUmakefile.preamble | 2 +- Library/PCFileNameField.m | 7 +- Library/PCFileNameIcon.m | 141 +--- Library/PCLogController.m | 4 +- Library/PCPrefController.m | 22 +- Library/PCProject.m | 108 ++- Library/PCProjectBrowser.m | 187 ++++- Library/PCProjectEditor.m | 102 ++- Library/PCProjectInspector.m | 48 +- Library/PCProjectLoadedFiles.m | 26 +- Library/PCProjectManager.m | 7 +- Library/PCProjectWindow.m | 123 ++- .../FileAttributes.gorm/data.classes | 6 +- .../Resources/FileAttributes.gorm/data.info | Bin 210 -> 184 bytes .../FileAttributes.gorm/objects.gorm | Bin 4185 -> 3844 bytes .../Resources/ProjectWindow.gorm/data.info | Bin 210 -> 210 bytes .../Resources/ProjectWindow.gorm/objects.gorm | Bin 39315 -> 39315 bytes Modules/Editors/ProjectCenter/GNUmakefile | 8 +- .../Editors/ProjectCenter/PCEditor+Document.m | 165 +--- Modules/Editors/ProjectCenter/PCEditor.h | 53 ++ Modules/Editors/ProjectCenter/PCEditor.m | 732 +++++++++++++++--- Modules/Editors/ProjectCenter/PCEditorView.h | 4 +- Modules/Editors/ProjectCenter/PCEditorView.m | 68 +- .../ProjectCenter/Resources/FileC.tiff | Bin 0 -> 9554 bytes .../ProjectCenter/Resources/FileCH.tiff | Bin 0 -> 9554 bytes .../ProjectCenter/Resources/FileH.tiff | Bin 0 -> 9554 bytes .../ProjectCenter/Resources/FileHH.tiff | Bin 0 -> 9554 bytes .../ProjectCenter/Resources/FileM.tiff | Bin 0 -> 9554 bytes .../ProjectCenter/Resources/FileMH.tiff | Bin 0 -> 9554 bytes .../ProjectCenter/Resources/ObjC.syntax | 4 +- .../Editors/ProjectCenter/SyntaxHighlighter.m | 16 +- Modules/GNUmakefile.bundles | 4 +- Modules/Parsers/ProjectCenter/GNUmakefile | 2 + .../Parsers/ProjectCenter/ObjCClassHandler.h | 43 +- .../Parsers/ProjectCenter/ObjCClassHandler.m | 194 +++-- .../Parsers/ProjectCenter/ObjCMethodHandler.h | 5 +- .../Parsers/ProjectCenter/ObjCMethodHandler.m | 69 +- Modules/Parsers/ProjectCenter/PCParser.m | 29 +- PCMenuController.m | 10 +- 50 files changed, 1488 insertions(+), 900 deletions(-) delete mode 100644 Headers/Protocols/ProjectEditor.h create mode 100644 Modules/Editors/ProjectCenter/Resources/FileC.tiff create mode 100644 Modules/Editors/ProjectCenter/Resources/FileCH.tiff create mode 100644 Modules/Editors/ProjectCenter/Resources/FileH.tiff create mode 100644 Modules/Editors/ProjectCenter/Resources/FileHH.tiff create mode 100644 Modules/Editors/ProjectCenter/Resources/FileM.tiff create mode 100644 Modules/Editors/ProjectCenter/Resources/FileMH.tiff diff --git a/Documentation/ANNOUNCE b/Documentation/ANNOUNCE index 92ba2f2..16accd5 100644 --- a/Documentation/ANNOUNCE +++ b/Documentation/ANNOUNCE @@ -1,7 +1,8 @@ + ANNOUNCE ************ -This is version 0.4.1 of ProjectCenter. This is a bugfix version. +This is version 0.5.0 of ProjectCenter. What is ProjectCenter? ====================== @@ -15,7 +16,7 @@ What is ProjectCenter? distribution fees, for others to use the program. You should read the Documentation/COPYING file for more information. -Noteworthy changes in version `0.4.1'. +Noteworthy changes in version `0.5.0'. ====================================== * diff --git a/Documentation/TODO b/Documentation/TODO index 36cef8e..27328be 100644 --- a/Documentation/TODO +++ b/Documentation/TODO @@ -29,15 +29,16 @@ ProjectCenter 0.5 - Finish save/restore size of split views in Project Window [done!] - Save last used path separately for different file panels stoyan --- Project Editor: - - Implement on demand loading (editor for file type) stoyan - - Open some files read only (Supporting Files) stoyan - - Implement code parser (get it from CodeEditor?) stoyan - - Project Browser should show file structure. stoyan - - Click on Browser item should move cursor to line in file stoyan + - Implement on demand loading (editor for file type) [done!] + - Open some files read only (Supporting Files) [done!] + - Implement code parser (get it from CodeEditor?) [done!] + - Project Browser should show file structure. [done!] + - Click on Browser item should move cursor to line in file [done!] - Implement Editor indentation stoyan --- Project Builder: - Implement root build directory handling stoyan - - Parse gcc output + - Finish options handling stoyan + - Parse gcc output stoyan - Display warnings,errors,options etc. as clickable list stoyan - Imlement pending adding/removal of files (history?) stoyan - Finish FileNameIcon (draggable, files can be dragged to it) stoyan diff --git a/GNUmakefile b/GNUmakefile index af5d35d..bc876b5 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -4,6 +4,7 @@ include $(GNUSTEP_MAKEFILES)/common.make GNUSTEP_INSTALLATION_DIR = $(GNUSTEP_SYSTEM_ROOT) +#GNUSTEP_BUILD_DIR = $(HOME)/Projects/GNUstep/==BUILD==/ProjectCenter # # Main application @@ -27,12 +28,6 @@ ProjectCenter_RESOURCE_FILES = \ Resources/ProjectCenter.gorm \ Resources/Info-gnustep.plist \ Images/ProjectCenter.tiff \ -Images/FileC.tiff \ -Images/FileCH.tiff \ -Images/FileH.tiff \ -Images/FileHH.tiff \ -Images/FileM.tiff \ -Images/FileMH.tiff \ Images/FileRTF.tiff \ Images/FileProject.tiff \ Images/Build.tiff \ diff --git a/Headers/ProjectCenter/PCFileNameField.h b/Headers/ProjectCenter/PCFileNameField.h index 297b5ed..2cba6b3 100644 --- a/Headers/ProjectCenter/PCFileNameField.h +++ b/Headers/ProjectCenter/PCFileNameField.h @@ -27,6 +27,8 @@ @class NSTextField; +extern NSString *PCFileNameFieldNoFiles; + @interface PCFileNameField : NSTextField { } diff --git a/Headers/ProjectCenter/PCFileNameIcon.h b/Headers/ProjectCenter/PCFileNameIcon.h index 800a07d..c7b59b0 100644 --- a/Headers/ProjectCenter/PCFileNameIcon.h +++ b/Headers/ProjectCenter/PCFileNameIcon.h @@ -32,11 +32,22 @@ NSString *filePath; NSTextField *fileNameField; NSString *msfText; + + id delegate; } - (void)setFileNameField:(NSTextField *)field; -- (void)setMultipleFilesSelectionText:(NSString *)text; -- (void)setFileIcon:(NSNotification *)notification; + +- (void)setDelegate:(id)object; + +- (void)updateIcon; + +@end + +@interface PCFileNameIcon (FileNameIconDelegate) + +- (NSImage *)fileNameIconImage; +- (NSString *)fileNameIconTitle; @end diff --git a/Headers/ProjectCenter/PCProjectBrowser.h b/Headers/ProjectCenter/PCProjectBrowser.h index 044b12c..a09c536 100644 --- a/Headers/ProjectCenter/PCProjectBrowser.h +++ b/Headers/ProjectCenter/PCProjectBrowser.h @@ -53,12 +53,12 @@ extern NSString *PCBrowserDidSetPathNotification; // Returns nil if multiple files selected - (NSString *)nameOfSelectedFile; - (NSString *)pathToSelectedFile; + // Returns nil if multiple categories selected - (NSString *)nameOfSelectedCategory; -// Returns nil of multiple categories selected - (NSString *)pathToSelectedCategory; -// Returns nil of multiple categories selected - (NSString *)pathFromSelectedCategory; + - (NSString *)nameOfSelectedRootCategory; // Returns nil if multiple category selected diff --git a/Headers/ProjectCenter/PCProjectEditor.h b/Headers/ProjectCenter/PCProjectEditor.h index a2bae10..d0c2ad9 100644 --- a/Headers/ProjectCenter/PCProjectEditor.h +++ b/Headers/ProjectCenter/PCProjectEditor.h @@ -29,9 +29,7 @@ #include #include -#include - -#include "PCProject.h" +#include @class PCProject; @class PCEditor; @@ -41,9 +39,7 @@ @class NSView; @class NSScrollView; -@protocol CodeParser; - -@interface PCProjectEditor : NSObject +@interface PCProjectEditor : NSObject { PCProject *project; NSBox *componentView; @@ -79,17 +75,16 @@ - (BOOL)editorProvidesBrowserItemsForItem:(NSString *)item; -- (id)editorForCategoryPath:(NSString *)categoryPath - windowed:(BOOL)windowed; +// Returns nil if editor is not opened +- (id)editorForFile:(NSString *)fileName key:(NSString *)key; -/*- (id)editorForFile:(NSString *)path - categoryPath:(NSString *)categoryPath - windowed:(BOOL)yn;*/ - -- (id)editorForFile:(NSString *)path - categoryPath:(NSString *)categoryPath - editable:(BOOL)editable - windowed:(BOOL)windowed; +- (id)openEditorForCategoryPath:(NSString *)categoryPath + windowed:(BOOL)windowed; + +- (id)openEditorForFile:(NSString *)path + categoryPath:(NSString *)categoryPath + editable:(BOOL)editable + windowed:(BOOL)windowed; - (void)orderFrontEditorForFile:(NSString *)path; - (id)activeEditor; @@ -120,5 +115,26 @@ @end +extern NSString *PCEditorDidChangeFileNameNotification; + +extern NSString *PCEditorWillOpenNotification; +extern NSString *PCEditorDidOpenNotification; +extern NSString *PCEditorWillCloseNotification; +extern NSString *PCEditorDidCloseNotification; + +extern NSString *PCEditorWillChangeNotification; +extern NSString *PCEditorDidChangeNotification; +extern NSString *PCEditorWillSaveNotification; +extern NSString *PCEditorDidSaveNotification; +extern NSString *PCEditorWillRevertNotification; +extern NSString *PCEditorDidRevertNotification; + +extern NSString *PCEditorDidBecomeActiveNotification; +extern NSString *PCEditorDidResignActiveNotification; + +/* +extern NSString *PCEditorSaveDidFailNotification; +*/ + #endif diff --git a/Headers/ProjectCenter/PCProjectInspector.h b/Headers/ProjectCenter/PCProjectInspector.h index b2512af..8d1026c 100644 --- a/Headers/ProjectCenter/PCProjectInspector.h +++ b/Headers/ProjectCenter/PCProjectInspector.h @@ -90,8 +90,8 @@ // File Attributes IBOutlet NSBox *fileAttributesView; - IBOutlet PCFileNameIcon *fileIcon; - IBOutlet PCFileNameField *fileIconField; + IBOutlet PCFileNameIcon *fileIconView; + IBOutlet PCFileNameField *fileNameField; NSString *fileName; IBOutlet NSButton *localizableButton; IBOutlet NSButton *publicHeaderButton; diff --git a/Headers/ProjectCenter/PCProjectWindow.h b/Headers/ProjectCenter/PCProjectWindow.h index 161f322..5a07c32 100644 --- a/Headers/ProjectCenter/PCProjectWindow.h +++ b/Headers/ProjectCenter/PCProjectWindow.h @@ -26,9 +26,9 @@ #ifndef _PCProjectWindow_h_ #define _PCProjectWindow_h_ -#include -#include -#include +#import +#import +#import @class PCProject; @class PCProjectBrowser; @@ -71,9 +71,6 @@ // ==== Intialization & deallocation // ============================================================================ -// Will go into gorm file -- (void)_initUI; - - (id)initWithProject:(PCProject *)owner; - (void)setTitle; diff --git a/Headers/Protocols/CodeEditor.h b/Headers/Protocols/CodeEditor.h index 75cb1c3..0674d18 100644 --- a/Headers/Protocols/CodeEditor.h +++ b/Headers/Protocols/CodeEditor.h @@ -28,10 +28,6 @@ #include #include -//#include - -@protocol ProjectEditor; - @protocol CodeEditor // =========================================================================== @@ -41,12 +37,12 @@ - (id)openFileAtPath:(NSString *)file categoryPath:(NSString *)categoryPath - projectEditor:(id)aProjectEditor + projectEditor:(id)aProjectEditor editable:(BOOL)editable; - (id)openExternalEditor:(NSString *)editor withPath:(NSString *)file - projectEditor:(id)aProjectEditor; + projectEditor:(id)aProjectEditor; - (void)show; - (void)setWindowed:(BOOL)yn; @@ -55,17 +51,26 @@ // =========================================================================== // ==== Accessor methods // =========================================================================== -- (id)projectEditor; +- (id)projectEditor; + - (NSWindow *)editorWindow; - (NSView *)editorView; - (NSView *)componentView; + - (NSString *)path; - (void)setPath:(NSString *)path; + - (NSString *)categoryPath; - (void)setCategoryPath:(NSString *)path; + - (BOOL)isEdited; - (void)setIsEdited:(BOOL)yn; +- (NSImage *)fileIcon; + +// Returns class or method names +- (NSArray *)browserItemsForItem:(NSString *)item; + // =========================================================================== // ==== Object managment // =========================================================================== @@ -79,12 +84,10 @@ // ==== Parser and scrolling // =========================================================================== -// Returns class or method names -- (NSArray *)browserItemsForItem:(NSString *)item; - +- (void)fileStructureItemSelected:(NSString *)item; - (void)scrollToClassName:(NSString *)className; - (void)scrollToMethodName:(NSString *)methodName; -- (void)scrollToLineNumber:(int)line; +- (void)scrollToLineNumber:(unsigned int)lineNumber; @end diff --git a/Headers/Protocols/ProjectEditor.h b/Headers/Protocols/ProjectEditor.h deleted file mode 100644 index 49df971..0000000 --- a/Headers/Protocols/ProjectEditor.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - GNUstep ProjectCenter - http://www.gnustep.org/experience/ProjectCenter.html - - Copyright (C) 2002-2004 Free Software Foundation - - Authors: Philippe C.D. Robert - Serg Stoyan - - This file is part of GNUstep. - - This application is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This application is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU General Public - License along with this library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. -*/ - -#ifndef _PCProjectEditorProtocol_h_ -#define _PCProjectEditorProtocol_h_ - -#include - -@protocol CodeParser; - -@protocol ProjectEditor - -// =========================================================================== -// ==== File handling -// =========================================================================== - -- (BOOL)saveEditedFiles:(NSArray *)files; -- (BOOL)saveAllFiles; -- (BOOL)saveFile; -- (BOOL)saveFileAs:(NSString *)file; -- (BOOL)saveFileTo:(NSString *)file; -- (BOOL)revertFileToSaved; - -@end - -extern NSString *PCEditorDidChangeFileNameNotification; - -extern NSString *PCEditorWillOpenNotification; -extern NSString *PCEditorDidOpenNotification; -extern NSString *PCEditorDidCloseNotification; - -extern NSString *PCEditorDidBecomeActiveNotification; -extern NSString *PCEditorDidResignActiveNotification; - -/*extern NSString *PCEditorDidChangeNotification; -extern NSString *PCEditorWillSaveNotification; -extern NSString *PCEditorDidSaveNotification; -extern NSString *PCEditorSaveDidFailNotification; -extern NSString *PCEditorWillRevertNotification; -extern NSString *PCEditorDidRevertNotification; -extern NSString *PCEditorDeletedNotification; -extern NSString *PCEditorRenamedNotification;*/ - -#endif - diff --git a/Library/GNUmakefile.preamble b/Library/GNUmakefile.preamble index f8d6252..e024c2c 100644 --- a/Library/GNUmakefile.preamble +++ b/Library/GNUmakefile.preamble @@ -45,7 +45,7 @@ GDB = `which gdb` ADDITIONAL_CPPFLAGS += # Additional flags to pass to the Objective-C compiler -ADDITIONAL_OBJCFLAGS += -Wall -DPCDefaultBuildTool=@"\"$(GMAKE)\"" \ +ADDITIONAL_OBJCFLAGS += -W -DPCDefaultBuildTool=@"\"$(GMAKE)\"" \ -DPCDefaultDebugger=@"\"$(GDB)\"" # Additional flags to pass to the C compiler diff --git a/Library/PCFileNameField.m b/Library/PCFileNameField.m index 453ce92..dd0cec4 100644 --- a/Library/PCFileNameField.m +++ b/Library/PCFileNameField.m @@ -26,6 +26,8 @@ #include +NSString *PCFileNameFieldNoFiles = @"No files selected"; + @implementation PCFileNameField - (void)setFont:(NSFont *)fontObject @@ -106,10 +108,9 @@ - (BOOL)textShouldSetEditable:(NSString *)text { - id delegate = [self delegate]; + id delegate = [self delegate]; - if ([text isEqualToString:@"No files selected"] - || [text isEqualToString:@"Multiple files selected"]) + if ([text isEqualToString:PCFileNameFieldNoFiles]) { return NO; } diff --git a/Library/PCFileNameIcon.m b/Library/PCFileNameIcon.m index 64c3625..e0540d5 100644 --- a/Library/PCFileNameIcon.m +++ b/Library/PCFileNameIcon.m @@ -22,11 +22,11 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ -#include +#import -#include -#include -#include +#import +#import +#import @implementation PCFileNameIcon @@ -59,6 +59,7 @@ [[NSNotificationCenter defaultCenter] removeObserver:self]; RELEASE(fileNameField); + RELEASE(delegate); [super dealloc]; } @@ -68,128 +69,36 @@ fileNameField = RETAIN(field); } -- (void)setMultipleFilesSelectionText:(NSString *)text +- (void)setDelegate:(id)object { - msfText = [text copy]; + delegate = object; } -- (void)setFileIcon:(id)object +- (void)updateIcon { - NSString *categoryName = nil; - NSString *fileName = nil; - NSString *fileExtension = nil; - NSString *iconName = nil; - NSImage *icon = nil; - - fileName = [object nameOfSelectedFile]; - if (fileName) + if (delegate) { - fileExtension = [fileName pathExtension]; - } - else - { - categoryName = [object nameOfSelectedCategory]; - } - -/* PCLogError(self,@"{setFileIcon} file %@ category %@", - fileName, categoryName);*/ - - // Should be provided by PC*Proj bundles - if ([[object selectedFiles] count] > 1) - { - iconName = [[NSString alloc] initWithString:@"MultiFiles"]; - } - else if (!categoryName && !fileName) // Nothing selected - { - iconName = [[NSString alloc] initWithString:@"projectSuitcase"]; - } - else if ([categoryName isEqualToString: @"Classes"]) - { - iconName = [[NSString alloc] initWithString:@"classSuitcase"]; - } - else if ([categoryName isEqualToString: @"Headers"]) - { - iconName = [[NSString alloc] initWithString:@"headerSuitcase"]; - } - else if ([categoryName isEqualToString: @"Other Sources"]) - { - iconName = [[NSString alloc] initWithString:@"genericSuitcase"]; - } - else if ([categoryName isEqualToString: @"Interfaces"]) - { - iconName = [[NSString alloc] initWithString:@"nibSuitcase"]; - } - else if ([categoryName isEqualToString: @"Images"]) - { - iconName = [[NSString alloc] initWithString:@"iconSuitcase"]; - } - else if ([categoryName isEqualToString: @"Other Resources"]) - { - iconName = [[NSString alloc] initWithString:@"otherSuitcase"]; - } - else if ([categoryName isEqualToString: @"Subprojects"]) - { - iconName = [[NSString alloc] initWithString:@"subprojectSuitcase"]; - } - else if ([categoryName isEqualToString: @"Documentation"]) - { - iconName = [[NSString alloc] initWithString:@"helpSuitcase"]; - } - else if ([categoryName isEqualToString: @"Supporting Files"]) - { - iconName = [[NSString alloc] initWithString:@"genericSuitcase"]; - } - else if ([categoryName isEqualToString: @"Libraries"]) - { - iconName = [[NSString alloc] initWithString:@"librarySuitcase"]; - } - else if ([categoryName isEqualToString: @"Non Project Files"]) - { - iconName = [[NSString alloc] initWithString:@"projectSuitcase"]; - } - - if (iconName != nil) - { - icon = IMAGE(iconName); - RELEASE(iconName); - } - else //if (fileExtension != nil && ![fileExtension isEqualToString:@""]) - { - icon = [[NSWorkspace sharedWorkspace] iconForFile:fileName]; - } - - // Set icon - if (icon != nil) - { - [self setImage:icon]; - } - - // Set title - if ([[object selectedFiles] count] > 1) - { - if (msfText != nil) + if ([delegate respondsToSelector:@selector(fileNameIconImage)]) { - [fileNameField setStringValue:msfText]; + [self setImage:[delegate fileNameIconImage]]; } - else + if ([delegate respondsToSelector:@selector(fileNameIconTitle)]) { - [fileNameField setStringValue: - [NSString stringWithFormat: - @"%i files", [[object selectedFiles] count]]]; + [fileNameField setStringValue:[delegate fileNameIconTitle]]; } } - else if (categoryName) - { - [fileNameField setStringValue:categoryName]; - } - else if (fileName) - { - [fileNameField setStringValue:fileName]; - } - else - { - [fileNameField setStringValue:@"No files selected"]; - } +} + +@end + +@implementation PCFileNameIcon (FileNameIconDelegate) + +- (NSImage *)fileNameIconImage +{ +} + +- (NSString *)fileNameIconTitle +{ } @end diff --git a/Library/PCLogController.m b/Library/PCLogController.m index fdd10a8..0017082 100644 --- a/Library/PCLogController.m +++ b/Library/PCLogController.m @@ -20,7 +20,7 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ -#include +#import void PCLog(id sender, int tag, NSString* format, va_list args) @@ -128,6 +128,8 @@ static PCLogController *_logCtrllr = nil; NSLog(@"PCLogController: dealloc"); #endif RELEASE(textAttributes); + + [super dealloc]; } - (void)showPanel diff --git a/Library/PCPrefController.m b/Library/PCPrefController.m index 9e4a6cc..3924d23 100644 --- a/Library/PCPrefController.m +++ b/Library/PCPrefController.m @@ -20,10 +20,10 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ -#include -#include +#import +#import -#include +#import // TODO: rewrite it as PCPrefernces, use +sharedPreferences instead of // [NSUserDefaults standardUserDefaults] in every part of ProjectCenter @@ -139,8 +139,8 @@ static PCPrefController *_prefCtrllr = nil; - (void)loadPreferences { - NSDictionary *prefs = nil; - NSString *val = nil; + NSDictionary *prefs; + NSString *val; prefs = [[NSUserDefaults standardUserDefaults] dictionaryRepresentation]; [preferencesDict addEntriesFromDictionary: prefs]; @@ -148,14 +148,14 @@ static PCPrefController *_prefCtrllr = nil; // Fill in the defaults // Building - [successField setStringValue: - (val = [preferencesDict objectForKey: SuccessSound]) ? val : @""]; + val = [preferencesDict objectForKey:SuccessSound]; + [successField setStringValue: (val == nil) ? @"" : val]; [failureField setStringValue: - (val = [preferencesDict objectForKey: FailureSound]) ? val : @""]; + (val = [preferencesDict objectForKey:FailureSound]) ? val : @""]; [promptOnClean setState: - ([[preferencesDict objectForKey: PromptOnClean] + ([[preferencesDict objectForKey:PromptOnClean] isEqualToString: @"YES"]) ? NSOnState : NSOffState]; [rootBuildDirField setStringValue: @@ -250,8 +250,8 @@ static PCPrefController *_prefCtrllr = nil; - (void)awakeFromNib { - NSArray *tabMatrixCells = nil; - int i; + NSArray *tabMatrixCells; + unsigned i; [promptOnClean setRefusesFirstResponder:YES]; diff --git a/Library/PCProject.m b/Library/PCProject.m index 1c5fea1..dd62c4f 100644 --- a/Library/PCProject.m +++ b/Library/PCProject.m @@ -787,7 +787,7 @@ NSString { return; } - + resPath = [projectPath stringByAppendingPathComponent:@"Resources"]; resFilePath = [resPath stringByAppendingPathComponent:file]; localizedResources = [[self localizedResources] mutableCopy]; @@ -854,8 +854,7 @@ NSString NSString *fileName = [filePath lastPathComponent]; NSString *extension = [filePath pathExtension]; - if ([key isEqualToString:PCSupportingFiles] - || [key isEqualToString:PCDocuFiles]) + if ([key isEqualToString:PCSupportingFiles]) { if ([fileName isEqualToString:@"GNUmakefile"] || [extension isEqualToString:@"plist"]) @@ -1006,7 +1005,7 @@ NSString // File is located in project's directory tree if (pathRange.length && ![type isEqualToString:PCLibraries]) { - int i; + unsigned i; for (i = 0; i < [subprojects count]; i++) { @@ -1279,12 +1278,14 @@ NSString if ([[self localizedResources] containsObject:fromFile]) {// Rename file in language dirs - NSArray *userLanguages = nil; - NSEnumerator *enumerator = nil; - NSString *lang = nil; - NSString *langPath = nil; - NSMutableArray *localizedResources = [self localizedResources]; + NSArray *userLanguages; + NSEnumerator *enumerator; + NSString *lang; + NSString *langPath; + NSMutableArray *localizedResources; + localizedResources = + [NSMutableArray arrayWithArray:[self localizedResources]]; userLanguages = [projectDict objectForKey:PCUserLanguages]; enumerator = [userLanguages objectEnumerator]; while ((lang = [enumerator nextObject])) @@ -1517,8 +1518,6 @@ NSString @implementation PCProject (ProjectBrowser) -// TODO: Think about moving all browser related methods into PCProjectBrowser - - (NSArray *)rootKeys { // e.g. CLASS_FILES @@ -1556,6 +1555,43 @@ NSString return [rootEntries objectForKey:key]; } +- (NSString *)rootCategoryForCategoryPath:(NSString *)categoryPath +{ + NSArray *pathComponents = nil; + + if ([categoryPath isEqualToString:@"/"] || [categoryPath isEqualToString:@""]) + { + return nil; + } + + pathComponents = [categoryPath componentsSeparatedByString:@"/"]; + + return [pathComponents objectAtIndex:1]; +} + +- (NSString *)keyForRootCategoryInCategoryPath:(NSString *)categoryPath +{ + NSString *category = nil; + NSString *key = nil; + + if (categoryPath == nil + || [categoryPath isEqualToString:@""] + || [categoryPath isEqualToString:@"/"]) + { + return nil; + } + + category = [self rootCategoryForCategoryPath:categoryPath]; + key = [self keyForCategory:category]; + +/* PCLogInfo(self, @"{%@}(keyForRootCategoryInCategoryPath): %@ key:%@", + projectName, categoryPath, key);*/ + + return key; +} + +// --- Requested by Project Browser + - (NSArray *)contentAtCategoryPath:(NSString *)categoryPath { NSString *key = [self keyForRootCategoryInCategoryPath:categoryPath]; @@ -1608,15 +1644,6 @@ NSString { // The file is selected, ask editor for browser items return [[projectEditor activeEditor] browserItemsForItem:listEntry]; } -/* else if ([[listEntry pathExtension] isEqualToString:@"m"] - || [[listEntry pathExtension] isEqualToString:@"h"]) - {// Class and header files (TODO: test subprojects) - return [[projectEditor activeEditor] classNames]; - } - else if ([[listEntry substringToIndex:1] isEqualToString:@"@"]) - {// Class name (TODO: test subprojects) - return [[projectEditor activeEditor] methodNamesForClass:listEntry]; - }*/ } - (BOOL)hasChildrenAtCategoryPath:(NSString *)categoryPath @@ -1646,10 +1673,10 @@ NSString return YES; } - // Files - if ([[projectDict objectForKey:categoryKey] containsObject:listEntry]) + // Files. listEntry is file in category or contents of file + if ([[projectDict objectForKey:categoryKey] containsObject:listEntry] || + [projectBrowser nameOfSelectedFile]) { -// NSLog(@"PCP [hasChildrenAtCategoryPath]: item is file selected"); // TODO: Libraries if ([category isEqualToString:@"Libraries"]) { @@ -1665,40 +1692,5 @@ NSString return NO; } -- (NSString *)rootCategoryForCategoryPath:(NSString *)categoryPath -{ - NSArray *pathComponents = nil; - - if ([categoryPath isEqualToString:@"/"] || [categoryPath isEqualToString:@""]) - { - return nil; - } - - pathComponents = [categoryPath componentsSeparatedByString:@"/"]; - - return [pathComponents objectAtIndex:1]; -} - -- (NSString *)keyForRootCategoryInCategoryPath:(NSString *)categoryPath -{ - NSString *category = nil; - NSString *key = nil; - - if (categoryPath == nil - || [categoryPath isEqualToString:@""] - || [categoryPath isEqualToString:@"/"]) - { - return nil; - } - - category = [self rootCategoryForCategoryPath:categoryPath]; - key = [self keyForCategory:category]; - -/* PCLogInfo(self, @"{%@}(keyForRootCategoryInCategoryPath): %@ key:%@", - projectName, categoryPath, key);*/ - - return key; -} - @end diff --git a/Library/PCProjectBrowser.m b/Library/PCProjectBrowser.m index 1e73ef6..3690d04 100644 --- a/Library/PCProjectBrowser.m +++ b/Library/PCProjectBrowser.m @@ -23,14 +23,15 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ -#include -#include -#include -#include -#include -#include +#import +#import +#import +#import +#import +#import +#import -#include +#import NSString *PCBrowserDidSetPathNotification = @"PCBrowserDidSetPathNotification"; @@ -66,12 +67,6 @@ NSString *PCBrowserDidSetPathNotification = @"PCBrowserDidSetPathNotification"; selector:@selector(projectDictDidChange:) name:PCProjectDictDidChangeNotification object:nil]; - - [[NSNotificationCenter defaultCenter] - addObserver:self - selector:@selector(editorDidOpen:) - name:PCEditorDidOpenNotification - object:nil]; } return self; @@ -366,6 +361,7 @@ NSString *PCBrowserDidSetPathNotification = @"PCBrowserDidSetPathNotification"; NSString *category; PCProject *activeProject; NSString *browserPath; + NSString *filePath; if (sender != browser) { @@ -376,17 +372,20 @@ NSString *PCBrowserDidSetPathNotification = @"PCBrowserDidSetPathNotification"; category = [self nameOfSelectedCategory]; activeProject = [[project projectManager] activeProject]; browserPath = [self path]; + filePath = [self pathToSelectedFile]; - NSLog(@"browserPath: %@ forProject: %@", - browserPath, [activeProject projectName]); +/* NSLog(@"browserPath: %@ forProject: %@", + browserPath, [activeProject projectName]);*/ - if ([[self selectedFiles] count] == 1 - && ![[ud objectForKey:SeparateEditor] isEqualToString:@"YES"]) +// if ([[self selectedFiles] count] == 1 + if (filePath && + [filePath isEqualToString:browserPath] && + ![[ud objectForKey:SeparateEditor] isEqualToString:@"YES"]) { /* PCLogInfo(self, @"[click] category: %@ filePath: %@", category, filePath);*/ - [[activeProject projectEditor] editorForCategoryPath:browserPath - windowed:NO]; + [[activeProject projectEditor] openEditorForCategoryPath:browserPath + windowed:NO]; } [[NSNotificationCenter defaultCenter] @@ -423,8 +422,8 @@ NSString *PCBrowserDidSetPathNotification = @"PCBrowserDidSetPathNotification"; { if ([[NSWorkspace sharedWorkspace] openFile:filePath] == NO) { - [[project projectEditor] editorForCategoryPath:[browser path] - windowed:YES]; + [[project projectEditor] openEditorForCategoryPath:[browser path] + windowed:YES]; } } } @@ -474,15 +473,6 @@ NSString *PCBrowserDidSetPathNotification = @"PCBrowserDidSetPathNotification"; } } -- (void)editorDidOpen:(NSNotification *)aNotif -{ -/* PCEditor *object = [aNotif object]; - - NSLog(@"PCBrowser: %@ classes: %@", - [object categoryPath], [object classNames]);*/ - [self reloadLastColumnAndNotify:NO]; -} - @end @implementation PCProjectBrowser (ProjectBrowserDelegate) @@ -527,7 +517,144 @@ NSString *PCBrowserDidSetPathNotification = @"PCBrowserDidSetPathNotification"; [categoryPath appendString:[files objectAtIndex:i]]; [cell setLeaf:![project hasChildrenAtCategoryPath:categoryPath]]; + [cell setRefusesFirstResponder:YES]; } } @end + +@implementation PCProjectBrowser (FileNameIconDelegate) + +// If file was opened in editor: +// 1. Determine editor +// 2. Ask editor for icon +- (NSImage *)_editorIconImageForFile:(NSString *)fileName +{ + PCProjectEditor *projectEditor = [project projectEditor]; + id editor = nil; + NSString *categoryName = [self nameOfSelectedCategory]; + NSString *categoryKey = [project keyForCategory:categoryName]; + + editor = [projectEditor editorForFile:fileName key:categoryKey]; + if (editor != nil) + { + return [editor fileIcon]; + } + + return nil; +} + +- (NSImage *)fileNameIconImage +{ + NSString *categoryName = nil; + NSString *fileName = nil; + NSString *fileExtension = nil; + NSString *iconName = nil; + NSImage *icon = nil; + + fileName = [self nameOfSelectedFile]; + if (fileName) + { + if ((icon = [self _editorIconImageForFile:fileName])) + { + return icon; + } + fileExtension = [fileName pathExtension]; + } + else + { + categoryName = [self nameOfSelectedCategory]; + } + +/* PCLogError(self,@"{setFileIcon} file %@ category %@", + fileName, categoryName);*/ + + if ([[self selectedFiles] count] > 1) + { + iconName = [[NSString alloc] initWithString:@"MultiFiles"]; + } + else if (!categoryName && !fileName) // Nothing selected + { + iconName = [[NSString alloc] initWithString:@"FileProject"]; + } + else if ([categoryName isEqualToString: @"Classes"]) + { + iconName = [[NSString alloc] initWithString:@"classSuitcase"]; + } + else if ([categoryName isEqualToString: @"Headers"]) + { + iconName = [[NSString alloc] initWithString:@"headerSuitcase"]; + } + else if ([categoryName isEqualToString: @"Other Sources"]) + { + iconName = [[NSString alloc] initWithString:@"genericSuitcase"]; + } + else if ([categoryName isEqualToString: @"Interfaces"]) + { + iconName = [[NSString alloc] initWithString:@"nibSuitcase"]; + } + else if ([categoryName isEqualToString: @"Images"]) + { + iconName = [[NSString alloc] initWithString:@"iconSuitcase"]; + } + else if ([categoryName isEqualToString: @"Other Resources"]) + { + iconName = [[NSString alloc] initWithString:@"otherSuitcase"]; + } + else if ([categoryName isEqualToString: @"Subprojects"]) + { + iconName = [[NSString alloc] initWithString:@"subprojectSuitcase"]; + } + else if ([categoryName isEqualToString: @"Documentation"]) + { + iconName = [[NSString alloc] initWithString:@"helpSuitcase"]; + } + else if ([categoryName isEqualToString: @"Supporting Files"]) + { + iconName = [[NSString alloc] initWithString:@"genericSuitcase"]; + } + else if ([categoryName isEqualToString: @"Libraries"]) + { + iconName = [[NSString alloc] initWithString:@"librarySuitcase"]; + } + else if ([categoryName isEqualToString: @"Non Project Files"]) + { + iconName = [[NSString alloc] initWithString:@"projectSuitcase"]; + } + + if (iconName != nil) + { + icon = IMAGE(iconName); + RELEASE(iconName); + } + else + { + icon = [[NSWorkspace sharedWorkspace] iconForFile:fileName]; + } + + return icon; +} + +- (NSString *)fileNameIconTitle +{ + NSString *categoryName = [self nameOfSelectedCategory]; + NSString *fileName = [self nameOfSelectedFile]; + int filesCount = [[self selectedFiles] count]; + + if (filesCount > 1) + { + return [NSString stringWithFormat:@"%i files", filesCount]; + } + else if (fileName) + { + return fileName; + } + else if (categoryName) + { + return categoryName; + } + + return PCFileNameFieldNoFiles; +} + +@end diff --git a/Library/PCProjectEditor.m b/Library/PCProjectEditor.m index cd1e23b..3c7b7e9 100644 --- a/Library/PCProjectEditor.m +++ b/Library/PCProjectEditor.m @@ -23,27 +23,31 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ -#include -#include -#include -#include -#include -#include -#include +#import +#import +#import +#import +#import +#import +#import +#import -#include - -#include +#import NSString *PCEditorDidChangeFileNameNotification = @"PCEditorDidChangeFileNameNotification"; - -NSString *PCEditorWillOpenNotification = - @"PCEditorWillOpenNotification"; -NSString *PCEditorDidOpenNotification = - @"PCEditorDidOpenNotification"; -NSString *PCEditorDidCloseNotification = - @"PCEditorDidCloseNotification"; + +NSString *PCEditorWillOpenNotification = @"PCEditorWillOpenNotification"; +NSString *PCEditorDidOpenNotification = @"PCEditorDidOpenNotification"; +NSString *PCEditorWillCloseNotification = @"PCEditorWillCloseNotification"; +NSString *PCEditorDidCloseNotification = @"PCEditorDidCloseNotification"; + +NSString *PCEditorWillChangeNotification = @"PCEditorWillChangeNotification"; +NSString *PCEditorDidChangeNotification = @"PCEditorDidChangeNotification"; +NSString *PCEditorWillSaveNotification = @"PCEditorWillSaveNotification"; +NSString *PCEditorDidSaveNotification = @"PCEditorDidSaveNotification"; +NSString *PCEditorWillRevertNotification = @"PCEditorWillRevertNotification"; +NSString *PCEditorDidRevertNotification = @"PCEditorDidRevertNotification"; NSString *PCEditorDidBecomeActiveNotification = @"PCEditorDidBecomeActiveNotification"; @@ -258,8 +262,21 @@ NSString *PCEditorDidResignActiveNotification = // TODO: Should it be editor or parser? - (BOOL)editorProvidesBrowserItemsForItem:(NSString *)item { - NSDictionary *infoTable = [self infoTableForBundleType:@"editor" - andFileType:[item pathExtension]]; + NSString *file = [[project projectBrowser] nameOfSelectedFile]; + NSDictionary *infoTable = nil; + + // File selected and editor should already be loaded + if (file != nil) + { + if ([[item substringToIndex:1] isEqualToString:@"@"]) + { + return YES; + } + } + + // Category selected + infoTable = [self infoTableForBundleType:@"editor" + andFileType:[item pathExtension]]; if ([[infoTable objectForKey:@"ProvidesBrowserItems"] isEqualToString:@"YES"]) { @@ -269,11 +286,20 @@ NSString *PCEditorDidResignActiveNotification = return NO; } +- (id)editorForFile:(NSString *)fileName key:(NSString *)key +{ + NSString *filePath = nil; + + filePath = [project pathForFile:fileName forKey:key]; + + return [editorsDict objectForKey:filePath]; +} + // categoryPath: // 1. "/Classes/Class.m/- init" // 2. "/Subprojects/Project/Classes/Class.m/- init" // 3. "/Library/gnustep-gui" -- (id)editorForCategoryPath:(NSString *)categoryPath +- (id)openEditorForCategoryPath:(NSString *)categoryPath windowed:(BOOL)windowed { NSArray *pathArray = [categoryPath pathComponents]; @@ -316,10 +342,10 @@ NSString *PCEditorDidResignActiveNotification = // NSLog(@"fileName: %@ > %@", fileName, listEntry); - editor = [self editorForFile:filePath - categoryPath:categoryPath - editable:editable - windowed:windowed]; + editor = [self openEditorForFile:filePath + categoryPath:categoryPath + editable:editable + windowed:windowed]; if (!editor) { NSLog(@"We don't have editor for file: %@", fileName); @@ -332,7 +358,7 @@ NSString *PCEditorDidResignActiveNotification = [pathLastObject substringWithRange:NSMakeRange(0,1)]);*/ pathLastObject = [pathArray lastObject]; - firstSymbol = [pathLastObject substringWithRange:NSMakeRange(0,1)]; + firstSymbol = [pathLastObject substringToIndex:1]; if ([pathLastObject isEqualToString:@"/"]) // file selected { [[project projectBrowser] reloadLastColumnAndNotify:NO]; @@ -349,10 +375,10 @@ NSString *PCEditorDidResignActiveNotification = return editor; } -- (id)editorForFile:(NSString *)path - categoryPath:(NSString *)categoryPath - editable:(BOOL)editable - windowed:(BOOL)windowed +- (id)openEditorForFile:(NSString *)path + categoryPath:(NSString *)categoryPath + editable:(BOOL)editable + windowed:(BOOL)windowed { // NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; // NSString *ed = [ud objectForKey:Editor]; @@ -385,7 +411,7 @@ NSString *PCEditorDidResignActiveNotification = } // Parser - parserClassName = [self classNameForBundleType:@"parser" +/* parserClassName = [self classNameForBundleType:@"parser" andFile:[path lastPathComponent]]; if (parserClassName != nil) { @@ -393,9 +419,9 @@ NSString *PCEditorDidResignActiveNotification = parser = [bundleManager objectForClassName:parserClassName withProtocol:@protocol(CodeParser) inBundleType:@"parser"]; - AUTORELEASE(parser); [editor setParser:parser]; - } + RELEASE(parser); + }*/ [editor openFileAtPath:path categoryPath:categoryPath @@ -593,10 +619,10 @@ NSString *PCEditorDidResignActiveNotification = res = [editor saveFileTo:file]; [editor closeFile:self save:NO]; - [self editorForFile:file - categoryPath:categoryPath - editable:YES - windowed:iw]; + [self openEditorForFile:file + categoryPath:categoryPath + editable:YES + windowed:iw]; return res; } @@ -654,7 +680,7 @@ NSString *PCEditorDidResignActiveNotification = { return; } - + [editorsDict removeObjectForKey:[editor path]]; if ([editorsDict count]) @@ -683,7 +709,7 @@ NSString *PCEditorDidResignActiveNotification = id editor = [aNotif object]; NSString *categoryPath = nil; - if ([editor projectEditor] != self) // || activeEditor == editor) + if ([editor projectEditor] != self) { return; } diff --git a/Library/PCProjectInspector.m b/Library/PCProjectInspector.m index 02de726..f19ac86 100644 --- a/Library/PCProjectInspector.m +++ b/Library/PCProjectInspector.m @@ -23,14 +23,14 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ -#include -#include -#include -#include -#include -#include +#import +#import +#import +#import +#import +#import -#include +#import @implementation PCProjectInspector @@ -342,13 +342,14 @@ [authorsList reloadData]; // File Attributes - [fileIcon setFileIcon:(id)[project projectBrowser]]; + [fileIconView setDelegate:[project projectBrowser]]; + [fileIconView updateIcon]; [self updateFileAttributes]; } - (void)browserDidSetPath:(NSNotification *)aNotif { - [fileIcon setFileIcon:[aNotif object]]; + [fileIconView updateIcon]; [self updateFileAttributes]; } @@ -637,9 +638,9 @@ - (void)downAuthor:(id)sender { - int selectedRow = [authorsList selectedRow]; - id nextRow; - id currentRow; + unsigned selectedRow = [authorsList selectedRow]; + id nextRow; + id currentRow; if (selectedRow < [authorsItems count]-1) { @@ -669,7 +670,7 @@ if ([NSBundle loadNibNamed:@"FileAttributes" owner:self] == NO) { - PCLogError(self, @"error loading ProjectDescription NIB file!"); + PCLogError(self, @"error loading FileAttributes NIB file!"); return; } @@ -677,8 +678,7 @@ [localizableButton setRefusesFirstResponder:YES]; [publicHeaderButton setRefusesFirstResponder:YES]; - [fileIcon setFileNameField:fileIconField]; - [fileIcon setMultipleFilesSelectionText:@"Multiple files selected"]; + [fileIconView setFileNameField:fileNameField]; [[NSNotificationCenter defaultCenter] addObserver:self @@ -790,8 +790,8 @@ - (void)beginFileRename { - [fileIconField setEditableField:YES]; - [inspectorPanel makeFirstResponder:fileIconField]; + [fileNameField setEditableField:YES]; + [inspectorPanel makeFirstResponder:fileNameField]; } // Delegate method of PCFileNameField class @@ -817,17 +817,17 @@ - (void)fileNameDidChange:(id)sender { - if ([fileName isEqualToString:[fileIconField stringValue]]) + if ([fileName isEqualToString:[fileNameField stringValue]]) { return; } /* PCLogInfo(self, @"{%@} file name changed from: %@ to: %@", - [project projectName], fileName, [fileIconField stringValue]);*/ + [project projectName], fileName, [fileNameField stringValue]);*/ - if ([project renameFile:fileName toFile:[fileIconField stringValue]] == NO) + if ([project renameFile:fileName toFile:[fileNameField stringValue]] == NO) { - [fileIconField setStringValue:fileName]; + [fileNameField setStringValue:fileName]; } } @@ -873,10 +873,10 @@ - (void)panelDidResignKey:(NSNotification *)aNotif { - if ([fileIconField isEditable] == YES) + if ([fileNameField isEditable] == YES) { - [inspectorPanel makeFirstResponder:fileIcon]; - [fileIconField setStringValue:fileName]; + [inspectorPanel makeFirstResponder:fileIconView]; + [fileNameField setStringValue:fileName]; } } diff --git a/Library/PCProjectLoadedFiles.m b/Library/PCProjectLoadedFiles.m index 1edc98e..7f74d09 100644 --- a/Library/PCProjectLoadedFiles.m +++ b/Library/PCProjectLoadedFiles.m @@ -23,15 +23,15 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ -#include -#include -#include +#import +#import +#import -#include -#include +#import +#import -#include -#include +#import +#import @implementation PCProjectLoadedFiles @@ -75,7 +75,7 @@ [filesScroll setHasHorizontalScroller:NO]; [filesScroll setHasVerticalScroller:YES]; if ([[[[NSUserDefaults standardUserDefaults] dictionaryRepresentation] - objectForKey: SeparateLoadedFiles] isEqualToString: @"NO"]) + objectForKey:SeparateLoadedFiles] isEqualToString:@"NO"]) { [filesScroll setBorderType:NSBezelBorder]; } @@ -86,8 +86,8 @@ [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(fileWillOpen:) - name:PCEditorWillOpenNotification + selector:@selector(fileDidOpen:) + name:PCEditorDidOpenNotification object:nil]; [[NSNotificationCenter defaultCenter] @@ -228,7 +228,7 @@ // ==== Notifications // =========================================================================== -- (void)fileWillOpen:(NSNotification *)aNotif +- (void)fileDidOpen:(NSNotification *)aNotif { id editor = [aNotif object]; NSString *filePath = nil; @@ -255,7 +255,7 @@ row = [[self editedFilesRep] indexOfObject:filePath]; [filesList selectRow:row byExtendingSelection:NO]; - PCLogInfo(self, @"fileWillOpen.END"); +// PCLogInfo(self, @"fileDidOpen.END"); } - (void)fileDidClose:(NSNotification *)aNotif @@ -301,7 +301,7 @@ { filePath = [editor path]; index = [[self editedFilesRep] indexOfObject:filePath]; - if (index >=0 && index < filesCount) + if (index < filesCount) { [filesList selectRow:index byExtendingSelection:NO]; } diff --git a/Library/PCProjectManager.m b/Library/PCProjectManager.m index 3eb0177..ba20d3f 100644 --- a/Library/PCProjectManager.m +++ b/Library/PCProjectManager.m @@ -42,7 +42,6 @@ #include "Protocols/ProjectType.h" #include "Protocols/CodeEditor.h" -#include "Protocols/ProjectEditor.h" NSString *PCActiveProjectDidChangeNotification = @"PCActiveProjectDidChange"; @@ -445,7 +444,7 @@ NSString *PCActiveProjectDidChangeNotification = @"PCActiveProjectDidChange"; NSString *_file = nil; NSString *_2file = nil; NSString *_resFile = nil; - int i = 0; + unsigned i = 0; PCProject *project = nil; NSMutableArray *otherResArray = nil; NSString *plistFile = nil; @@ -825,7 +824,7 @@ NSString *PCActiveProjectDidChangeNotification = @"PCActiveProjectDidChange"; NSString *directory = [activeProject dirForCategoryKey:categoryKey]; NSString *removeString = nil; NSMutableArray *subprojs = [NSMutableArray array]; - int i; + unsigned i; // Determining target project if ([categoryKey isEqualToString:PCSubprojects]) @@ -1293,7 +1292,7 @@ NSString *PCActiveProjectDidChangeNotification = @"PCActiveProjectDidChange"; NSString *spDir = nil; NSDictionary *spDict = nil; NSString *spName = nil; - int i; + unsigned i; files = [fileManager filesForAddOfTypes:[NSArray arrayWithObjects:@"subproj",nil]]; diff --git a/Library/PCProjectWindow.m b/Library/PCProjectWindow.m index 3d4ac26..f7f409f 100644 --- a/Library/PCProjectWindow.m +++ b/Library/PCProjectWindow.m @@ -23,23 +23,23 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ -#include -#include -#include +#import +#import +#import -#include -#include +#import +#import -#include -#include -#include -#include -#include -#include -#include +#import +#import +#import +#import +#import +#import +#import -#include -#include +#import +#import @implementation PCProjectWindow @@ -63,21 +63,9 @@ [h_split adjustSubviews]; } -- (void)_initUI +- (void)awakeFromNib { NSRect rect; -// NSView *browserView = nil; - - if (projectWindow != nil) - { - return; - } - - if ([NSBundle loadNibNamed:@"ProjectWindow" owner:self] == NO) - { - PCLogError(self, @"error loading ProjectWindow NIB file!"); - return; - } [buildButton setToolTip:@"Build"]; // [buildButton setImage:IMAGE(@"Build")]; @@ -103,6 +91,8 @@ // [inspectorButton setImage:IMAGE(@"Inspector")]; [fileIcon setFileNameField:fileIconTitle]; + [fileIcon setDelegate:[project projectBrowser]]; + [fileIcon updateIcon]; [statusLine setStringValue:@""]; @@ -167,11 +157,18 @@ _isToolbarVisible = YES; _splitViewsRestored = NO; - [self _initUI]; + if (projectWindow == nil) + { + if ([NSBundle loadNibNamed:@"ProjectWindow" owner:self] == NO) + { + PCLogError(self, @"error loading ProjectWindow NIB file!"); + return nil; + } + } [self setTitle]; // Window - [projectWindow setFrameAutosaveName: @"ProjectWindow"]; + [projectWindow setFrameAutosaveName:@"ProjectWindow"]; pcWindows = [[project projectDict] objectForKey:@"PC_WINDOWS"]; windowFrame = [pcWindows objectForKey:@"ProjectWindow"]; @@ -225,6 +222,23 @@ selector:@selector (browserDidSetPath:) name:PCBrowserDidSetPathNotification object:[project projectBrowser]]; + + // Editor changes + [[NSNotificationCenter defaultCenter] + addObserver:self + selector:@selector (editorDidChange:) + name:PCEditorDidChangeNotification + object:nil]; + [[NSNotificationCenter defaultCenter] + addObserver:self + selector:@selector (editorDidSave:) + name:PCEditorDidSaveNotification + object:nil]; + [[NSNotificationCenter defaultCenter] + addObserver:self + selector:@selector (editorDidRevert:) + name:PCEditorDidRevertNotification + object:nil]; } return self; @@ -372,8 +386,10 @@ - (void)showProjectLoadedFiles:(id)sender { - NSPanel *panel = [[project projectManager] loadedFilesPanel]; - NSScrollView *componentView = [[project projectLoadedFiles] componentView]; + NSPanel *panel = [[project projectManager] loadedFilesPanel]; + NSScrollView *componentView; + + componentView = (NSScrollView *)[[project projectLoadedFiles] componentView]; // PCLogInfo(self, @"showProjectLoadedFiles"); @@ -618,7 +634,50 @@ - (void)browserDidSetPath:(NSNotification *)aNotif { - [fileIcon setFileIcon:[aNotif object]]; + PCProjectBrowser *browser = [aNotif object]; + + if (browser != [project projectBrowser]) + { + return; + } + + [fileIcon updateIcon]; +} + +- (void)editorDidChange:(NSNotification *)aNotif +{ + id editor = [aNotif object]; + + if ([editor projectEditor] != [project projectEditor]) + { + return; + } + + [fileIcon updateIcon]; +} + +- (void)editorDidSave:(NSNotification *)aNotif +{ + id editor = [aNotif object]; + + if ([editor projectEditor] != [project projectEditor]) + { + return; + } + + [fileIcon updateIcon]; +} + +- (void)editorDidRevert:(NSNotification *)aNotif +{ + id editor = [aNotif object]; + + if ([editor projectEditor] != [project projectEditor]) + { + return; + } + + [fileIcon updateIcon]; } // ============================================================================ diff --git a/Library/Resources/FileAttributes.gorm/data.classes b/Library/Resources/FileAttributes.gorm/data.classes index 8eda59d..977d846 100644 --- a/Library/Resources/FileAttributes.gorm/data.classes +++ b/Library/Resources/FileAttributes.gorm/data.classes @@ -2,7 +2,8 @@ "## Comment" = "Do NOT change this file, Gorm maintains it"; FirstResponder = { Actions = ( - "fileNameDidChange:" + "fileNameDidChange:", + "setLocalizableResource:" ); Super = NSObject; }; @@ -23,7 +24,8 @@ PCProjectInspector = { Actions = ( "fileNameDidChange:", - "setPublicHeader:" + "setPublicHeader:", + "setLocalizableResource:" ); Outlets = ( fileIconView, diff --git a/Library/Resources/FileAttributes.gorm/data.info b/Library/Resources/FileAttributes.gorm/data.info index 00306638ad4ccc9a393036917c5cf7fc3da47b57..9915451f28c8a8936bacda895c06687d44d966fe 100644 GIT binary patch delta 98 zcmcb_xPx(m2y;@h!9;Q25Jm`R!1Llp)AQe1t6+BEKl?ACO3P2-L6LSI4>l5w( delta 124 zcmdnNc!_a>2y^d-YghwleX#S^Zk5(ect!{tBKxdwyDAbWY@yN z;A3&&&FuRZVpb4@5l}DHZG3=Kw`MtQ`ocC8`{E46GSl?ISQ$`llsb-!&61%w&W6&4 z(SF$H02t$BDIiOrW-2XoUq@XS=U^%TQ#4;iH_)b1Hc?H*7L?A%Z=)l(q9a3tLmW&8 z@#!GmL_X!@XXryH$%>4DV#jr{Mc#(rU0{Ebpx$X3x|&}{iiXI&$c_A<9Tl45n+)dVt|OiPilC@oP6_G5ac4YUQVuzuL$%(ekBf!FizLX zoKBvma~B6nZDw@lbDM+xbdE13103Y?gTV0ud_gwaK?PSGZy>numWt(=Y>SIvC(mT>opLW%Uu5hdwdm8 delta 1438 zcmaJ>&rcIk5FY63k1eI8genJun23rd=E1=r#)N`^je-a$Dn_iO6|}$7Zl!vGM6W33 z8860zCVJk6vjua%-Qk3$WM0M`E%-t?;n+ikYY}H|oJ%VLiysvzGTQU8=|+qcId{s{)H8 zMtyJkl%ZY5sL@?ySOc3rx`1qHTEQv4`-YEs5=o*3d_k9%A=f(GZ2(s3GUX^IX01i> ziuE5+{vh^0fANJKjwnZ;q*bDwU+iMbarIA}L7ftK zl42RA!3E#Ynq zfim;}V=LFChM+4(h6+z=bikkyeG!CRG#}G;zp}^V_W9);x!k_CZB2MBXqq}_(6O9D zd{SeXiOuv7)M?N;$)_3-xoRqAOuUXfH_Pn}#6I$w#kn{2JSt8OYG+RyG`=0!dah*Wb`2_jz%BmBC`F~M)>9C4Ea z120E!?<_Sb$8Rchj4x?)r$P_7Z@qHU{{G$GO4GuNWc0vQ)e*ex7-Pyr@!bF!Dg+e( delta 11 Scmcb_c!_a>7-RB8@!bF!CIl1! diff --git a/Library/Resources/ProjectWindow.gorm/objects.gorm b/Library/Resources/ProjectWindow.gorm/objects.gorm index 3e03f09a5888bf5f8d37ec6c862d7a5899cb6f87..1005e7185912e408d4829ba08d0e0260707438bb 100644 GIT binary patch delta 105 zcmbQdnQ8K7rU_zZATZ-f+X&@&?A$l@@)$Gla zl*%9i95xUEJG&Suwgv`nm!t!m7eq)hF*0u66%`>jN&4^P{W4mU&)ODlURCu{4gdxZ BC*c49 delta 381 zcmbQdnQ8K7rU_z<$s5JFStcK4SulAi^8zRxy*ZZczvSdOiqVq~D4GK?A53C$EZgkO zla$INCwtgNPj0YP24W=?Njtk3DK-WMZkJ?+%?lzVnHZTi?~00$t7lYO#=tOeL_Go9 Z1sH&Ub_DliV++m6XKf2Nuc~?}2LR*tOT+*G diff --git a/Modules/Editors/ProjectCenter/GNUmakefile b/Modules/Editors/ProjectCenter/GNUmakefile index a08f38f..52dfdc5 100644 --- a/Modules/Editors/ProjectCenter/GNUmakefile +++ b/Modules/Editors/ProjectCenter/GNUmakefile @@ -23,7 +23,13 @@ ProjectCenter_RESOURCE_FILES= \ Resources/Info.table \ Resources/C.syntax \ Resources/ObjC.syntax \ - Resources/Plist.syntax + Resources/Plist.syntax \ + Resources/FileC.tiff \ + Resources/FileCH.tiff \ + Resources/FileH.tiff \ + Resources/FileHH.tiff \ + Resources/FileM.tiff \ + Resources/FileMH.tiff # # Header files diff --git a/Modules/Editors/ProjectCenter/PCEditor+Document.m b/Modules/Editors/ProjectCenter/PCEditor+Document.m index 1e992f0..880019a 100644 --- a/Modules/Editors/ProjectCenter/PCEditor+Document.m +++ b/Modules/Editors/ProjectCenter/PCEditor+Document.m @@ -2,9 +2,6 @@ // TODO: Needs checking @implementation PCEditor (Document) -#import "CommandQueryPanel.h" -#import "LineQueryPanel.h" -#import "TextFinder.h" #import "EditorRulerView.h" #import "EditorTextView.h" #import "SyntaxHighlighter.h" @@ -154,76 +151,9 @@ unsigned int FindDelimiterInString(NSString * string, } } -- (void)pipeOutputOfCommand:(NSString *)command -{ - NSTask * task; - NSPipe * inPipe, * outPipe; - NSString * inString, * outString; - NSFileHandle * inputHandle; +// --- Parentesis highlighting - inString = [[textView string] substringWithRange: - [textView selectedRange]]; - inPipe = [NSPipe pipe]; - outPipe = [NSPipe pipe]; - - task = [[NSTask new] autorelease]; - - [task setLaunchPath: @"/bin/sh"]; - [task setArguments: [NSArray arrayWithObjects: @"-c", command, nil]]; - [task setStandardInput: inPipe]; - [task setStandardOutput: outPipe]; - [task setStandardError: outPipe]; - - inputHandle = [inPipe fileHandleForWriting]; - - [task launch]; - [inputHandle writeData: [inString - dataUsingEncoding: NSUTF8StringEncoding]]; - [inputHandle closeFile]; - [task waitUntilExit]; - outString = [[[NSString alloc] - initWithData: [[outPipe fileHandleForReading] availableData] - encoding: NSUTF8StringEncoding] - autorelease]; - if ([task terminationStatus] != 0) - { - if (NSRunAlertPanel(_(@"Error running command"), - _(@"The command returned with a non-zero exit status" - @" -- aborting pipe.\n" - @"Do you want to see the command's output?\n"), - _(@"No"), _(@"Yes"), nil) == NSAlertAlternateReturn) - { - NSRunAlertPanel(_(@"The command's output"), - outString, nil, nil, nil); - } - } - else - { - [textView replaceCharactersInRange:[textView selectedRange] - withString:outString]; - [self textDidChange: nil]; - } -} - -- (void) updateMiniwindowIconToEdited: (BOOL) flag -{ - NSImage * icon; - - if (flag) - { - icon = [NSImage imageNamed: - [NSString stringWithFormat: @"File_%@_mod", [self fileType]]]; - } - else - { - icon = [NSImage imageNamed: - [NSString stringWithFormat: @"File_%@", [self fileType]]]; - } - - [myWindow setMiniwindowImage: icon]; -} - -- (void) unhighlightCharacter +- (void)unhighlightCharacter { if (isCharacterHighlit) { @@ -274,7 +204,7 @@ unsigned int FindDelimiterInString(NSString * string, } } -- (void) highlightCharacterAt: (unsigned int) location +- (void)highlightCharacterAt:(unsigned int)location { if (isCharacterHighlit == NO) { @@ -315,7 +245,7 @@ unsigned int FindDelimiterInString(NSString * string, } } -- (void) computeNewParenthesisNesting +- (void)computeNewParenthesisNesting { NSRange selectedRange; NSString * myString; @@ -367,93 +297,24 @@ unsigned int FindDelimiterInString(NSString * string, } +// --- State -- (void)goToLine:sender +- (void)updateMiniwindowIconToEdited:(BOOL)flag { -/* LineQueryPanel * lqp = [LineQueryPanel shared]; + NSImage * icon; - if ([lqp runModal] == NSOKButton) + if (flag) { - [self goToLineNumber: (unsigned int) [lqp unsignedIntValue]]; - }*/ -} - -- (void)goToLineNumber:(unsigned int)lineNumber -{ -/* unsigned int offset; - unsigned int i; - NSString * line; - NSEnumerator * e; - NSArray * lines = [[textView string] componentsSeparatedByString: @"\n"]; - e = [lines objectEnumerator]; - NSRange r; - - for (offset = 0, i=1; - (line = [e nextObject]) != nil && i < lineNumber; - i++, offset += [line length] + 1); - - if (line != nil) - { - r = NSMakeRange(offset, [line length]); + icon = [NSImage imageNamed: + [NSString stringWithFormat: @"File_%@_mod", [self fileType]]]; } else { - r = NSMakeRange([[textView string] length], 0); - } - [textView setSelectedRange: r]; - [textView scrollRangeToVisible: r];*/ -} - -- (void)textViewDidChangeSelection:(NSNotification *)notification -{ - if (editorTextViewIsPressingKey == NO) - { - [self computeNewParenthesisNesting]; - } - [(EditorRulerView *) [[textView enclosingScrollView] horizontalRulerView] - refreshHighlightedArea]; - [(EditorRulerView *) [[textView enclosingScrollView] verticalRulerView] - refreshHighlightedArea]; -} - -- (void) textDidChange: (NSNotification *) notif -{ - - if (![self isDocumentEdited]) - { - [self updateMiniwindowIconToEdited: YES]; + icon = [NSImage imageNamed: + [NSString stringWithFormat: @"File_%@", [self fileType]]]; } - [self updateChangeCount: NSChangeDone]; -} - -- (void) editorTextViewWillPressKey: sender -{ - editorTextViewIsPressingKey = YES; - - [self unhighlightCharacter]; -} - -- (void) editorTextViewDidPressKey: sender -{ - [self computeNewParenthesisNesting]; - - editorTextViewIsPressingKey = NO; -} - -- (void) findNext: sender -{ - [[TextFinder sharedInstance] findNext: self]; -} - -- (void) findPrevious: sender -{ - [[TextFinder sharedInstance] findPrevious: self]; -} - -- (void) jumpToSelection: sender -{ - [textView scrollRangeToVisible: [textView selectedRange]]; + [myWindow setMiniwindowImage: icon]; } @end diff --git a/Modules/Editors/ProjectCenter/PCEditor.h b/Modules/Editors/ProjectCenter/PCEditor.h index 7ff4474..48250d7 100644 --- a/Modules/Editors/ProjectCenter/PCEditor.h +++ b/Modules/Editors/ProjectCenter/PCEditor.h @@ -57,6 +57,36 @@ NSArray *parserMethods; // NSMutableArray *classNames; // NSMutableArray *methodNames; + + IBOutlet NSMenu *menu; + + NSFont *defaultFont; + NSFont *highlightFont; + + NSColor *textColor; + NSColor *highlightColor; + NSColor *backgroundColor; + NSColor *readOnlyColor; + NSColor *textBackground; + + // location of the highlit delimiter character + unsigned int highlitCharacterLocation; + + // is YES if we are currently highlighting a delimiter character + // otherwise NO + BOOL isCharacterHighlit; + + // the stored color and font attributes of the highlit character, so + // that they can be restored later on when the character is un-highlit + NSColor *previousFGColor; + NSColor *previousBGColor; + NSColor *previousFont; + + // This is used to protect that -textViewDidChangeSelection: invocations + // don't do anything when the text view changing, because this causes + // further changes to the text view and infinite recursive invocations + // of this method. + BOOL editorTextViewIsPressingKey; } - (BOOL)editorShouldClose; @@ -72,6 +102,10 @@ // ==== TextView (_intEditorView, _extEditorView) delegate // =========================================================================== - (void)textDidChange:(NSNotification *)aNotification; +- (void)textViewDidChangeSelection:(NSNotification *)notification; +- (void)editorTextViewWillPressKey:sender; +- (void)editorTextViewDidPressKey:sender; + - (BOOL)becomeFirstResponder; - (BOOL)resignFirstResponder; @@ -85,5 +119,24 @@ @end +@interface PCEditor (Menu) + +- (void)pipeOutputOfCommand:(NSString *)command; +// Find +- (void)findNext:sender; +- (void)findPrevious:sender; +- (void)jumpToSelection:sender; +- (void)goToLine:sender; + +@end + +@interface PCEditor (Parentesis) + +- (void)unhighlightCharacter; +- (void)highlightCharacterAt:(unsigned int)location; +- (void)computeNewParenthesisNesting; + +@end + #endif // _PCEDITOR_H_ diff --git a/Modules/Editors/ProjectCenter/PCEditor.m b/Modules/Editors/ProjectCenter/PCEditor.m index d73eec8..a24d80a 100644 --- a/Modules/Editors/ProjectCenter/PCEditor.m +++ b/Modules/Editors/ProjectCenter/PCEditor.m @@ -23,12 +23,15 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ -#include -#include -#include +#import +#import +#import -#include "PCEditor.h" -#include "PCEditorView.h" +#import "PCEditor.h" +#import "PCEditorView.h" +//#import "CommandQueryPanel.h" +//#import "LineQueryPanel.h" +//#import "TextFinder.h" @implementation PCEditor (UInterface) @@ -124,6 +127,8 @@ RELEASE(lm); ev = [[PCEditorView alloc] initWithFrame:fr textContainer:tc]; + [ev setBackgroundColor:textBackground]; + [ev setTextColor:textColor]; [ev createSyntaxHighlighterForFileType:[_path pathExtension]]; [ev setEditor:self]; @@ -165,18 +170,57 @@ _isEdited = NO; _isWindowed = NO; _isExternal = YES; + + ASSIGN(defaultFont, [PCEditorView defaultEditorFont]); + ASSIGN(highlightFont, [PCEditorView defaultEditorBoldFont]); + ASSIGN(textColor, [NSColor blackColor]); + ASSIGN(backgroundColor, [NSColor whiteColor]); + ASSIGN(readOnlyColor, [NSColor lightGrayColor]); + + previousFGColor = nil; + previousBGColor = nil; + previousFont = nil; + + isCharacterHighlit = NO; } return self; } +- (void)dealloc +{ +#ifdef DEVELOPMENT +#endif + NSLog(@"PCEditor: %@ dealloc", [_path lastPathComponent]); + + [[NSNotificationCenter defaultCenter] removeObserver:self]; + + // _window is setReleasedWhenClosed:YES + RELEASE(_path); + RELEASE(_categoryPath); + RELEASE(_intScrollView); + RELEASE(_storage); + +// RELEASE(parserClasses); + RELEASE(parserMethods); + RELEASE(aParser); + + RELEASE(defaultFont); + RELEASE(highlightFont); + RELEASE(textColor); + RELEASE(backgroundColor); + RELEASE(readOnlyColor); + + [super dealloc]; +} + - (void)setParser:(id)parser { -// NSLog(@"RC aParser:%i parser:%i", -// [aParser retainCount], [parser retainCount]); +/* NSLog(@"RC aParser:%i parser:%i", + [aParser retainCount], [parser retainCount]);*/ ASSIGN(aParser, parser); -// NSLog(@"RC aParser:%i parser:%i", -// [aParser retainCount], [parser retainCount]); +/* NSLog(@"RC aParser:%i parser:%i", + [aParser retainCount], [parser retainCount]);*/ } - (id)openFileAtPath:(NSString *)file @@ -184,37 +228,38 @@ projectEditor:(id)aProjectEditor editable:(BOOL)editable { - NSString *text; - NSAttributedString *attributedString; - NSDictionary *attributes; - NSFont *font; - NSColor *textBackground; + NSString *text; + NSAttributedString *attributedString = [NSAttributedString alloc]; + NSMutableDictionary *attributes = [NSMutableDictionary new]; + NSFont *font; +// NSColor *textBackground; + NSLog(@"PCEditor: openFileAtPath"); + + // Inform about future file opening + [[NSNotificationCenter defaultCenter] + postNotificationName:PCEditorWillOpenNotification + object:self]; projectEditor = aProjectEditor; _path = [file copy]; _categoryPath = [categoryPath copy]; - _storage = [[NSTextStorage alloc] init]; // Prepare font = [NSFont userFixedPitchFontOfSize:0.0]; if (editable) { - textBackground = [NSColor whiteColor]; + textBackground = backgroundColor; } else { - textBackground = [NSColor colorWithCalibratedRed:0.97 - green:0.90 - blue:0.90 - alpha:1.0]; + textBackground = readOnlyColor; } - attributes = [NSDictionary dictionaryWithObjectsAndKeys: - font, NSFontAttributeName, - textBackground, NSBackgroundColorAttributeName]; + [attributes setObject:font forKey:NSFontAttributeName]; + [attributes setObject:textBackground forKey:NSBackgroundColorAttributeName]; + text = [NSString stringWithContentsOfFile:file]; - attributedString = [[NSAttributedString alloc] initWithString:text - attributes:attributes]; + [attributedString initWithString:text attributes:attributes]; // _storage = [[NSTextStorage alloc] init]; @@ -229,7 +274,6 @@ { [self _createInternalView]; [_intEditorView setEditable:editable]; - [_intEditorView setBackgroundColor:textBackground]; [[NSNotificationCenter defaultCenter] addObserver:self @@ -244,11 +288,12 @@ selector:@selector(textDidChange:) name:NSTextDidChangeNotification object:_extEditorView]; - - // Inform about future file opening + + // File open was finished [[NSNotificationCenter defaultCenter] - postNotificationName:PCEditorWillOpenNotification + postNotificationName:PCEditorDidOpenNotification object:self]; + return self; } @@ -315,31 +360,12 @@ object:self]; } -- (void)dealloc -{ -#ifdef DEVELOPMENT -#endif - NSLog(@"PCEditor: %@ dealloc", [_path lastPathComponent]); - - [[NSNotificationCenter defaultCenter] removeObserver:self]; - - // _window is setReleasedWhenClosed:YES - RELEASE(_path); - RELEASE(_categoryPath); - RELEASE(_intScrollView); - RELEASE(_storage); - -// RELEASE(parserClasses); - RELEASE(parserMethods); - RELEASE(aParser); - - [super dealloc]; -} - // =========================================================================== // ==== Accessory methods // =========================================================================== +//--- CodeEditor protocol + - (id)projectEditor { return projectEditor; @@ -411,6 +437,84 @@ _isEdited = yn; } +- (NSImage *)fileIcon +{ + NSString *fileExtension = [[_path lastPathComponent] uppercaseString]; + NSString *imageName = nil; + NSString *imagePath = nil; + NSBundle *bundle = nil; + NSImage *image = nil; + + fileExtension = [[[_path lastPathComponent] pathExtension] uppercaseString]; + if (_isEdited) + { + imageName = [NSString stringWithFormat:@"File%@H", fileExtension]; + } + else + { + imageName = [NSString stringWithFormat:@"File%@", fileExtension]; + } + + bundle = [NSBundle bundleForClass:NSClassFromString(@"PCEditor")]; + imagePath = [bundle pathForResource:imageName ofType:@"tiff"]; + + image = [[NSImage alloc] initWithContentsOfFile:imagePath]; + + return AUTORELEASE(image); +} + +- (NSArray *)browserItemsForItem:(NSString *)item +{ + NSEnumerator *enumerator; + NSDictionary *method; + NSDictionary *class; + NSMutableArray *items; + + NSLog(@"PCEditor: asked for browser items for: %@", item); + + [aParser setString:[_storage string]]; + + // If item is .m or .h file show class list + if ([[item pathExtension] isEqualToString:@"m"] + || [[item pathExtension] isEqualToString:@"h"]) + { + ASSIGN(parserClasses, [aParser classNames]); + + NSLog(@"Class names %@@", parserClasses); + + items = [NSMutableArray array]; + enumerator = [parserClasses objectEnumerator]; + while ((class = [enumerator nextObject])) + { + NSLog(@"Class> %@", class); + [items addObject:[class objectForKey:@"ClassName"]]; + } + } + + // If item starts with "@" show method list + if ([[item substringToIndex:1] isEqualToString:@"@"]) + { + ASSIGN(parserMethods, [aParser methodNames]); + + items = [NSMutableArray array]; + enumerator = [parserMethods objectEnumerator]; + while ((method = [enumerator nextObject])) + { + // NSLog(@"Method> %@", method); + [items addObject:[method objectForKey:@"MethodName"]]; + } + } + + return items; +} + +- (NSMenu *)menu +{ + return nil; +} + +//--- protocol end + - (BOOL)isWindowed { return _isWindowed; @@ -461,9 +565,28 @@ - (BOOL)saveFile { - [self setIsEdited:NO]; + BOOL saved = NO; - return [[_storage string] writeToFile:_path atomically:YES]; + if (_isEdited == NO) + { + return YES; + } + + [[NSNotificationCenter defaultCenter] + postNotificationName:PCEditorWillSaveNotification + object:self]; + + saved = [[_storage string] writeToFile:_path atomically:YES]; + + if (saved == YES) + { + [self setIsEdited:NO]; + [[NSNotificationCenter defaultCenter] + postNotificationName:PCEditorDidSaveNotification + object:self]; + } + + return saved; } - (BOOL)saveFileTo:(NSString *)path @@ -478,6 +601,15 @@ NSDictionary *at = nil; NSFont *ft = nil; + if (_isEdited == NO) + { + return YES; + } + + [[NSNotificationCenter defaultCenter] + postNotificationName:PCEditorWillRevertNotification + object:self]; + // This is temporary ft = [NSFont userFixedPitchFontOfSize:0.0]; at = [NSDictionary dictionaryWithObject:ft forKey:NSFontAttributeName]; @@ -492,6 +624,10 @@ [_intEditorView setNeedsDisplay:YES]; [_extEditorView setNeedsDisplay:YES]; + [[NSNotificationCenter defaultCenter] + postNotificationName:PCEditorDidRevertNotification + object:self]; + return YES; } @@ -611,10 +747,45 @@ if ([object isKindOfClass:[PCEditorView class]] && (object == _intEditorView || object == _extEditorView)) { - [self setIsEdited:YES]; + if (_isEdited == NO) + { + [[NSNotificationCenter defaultCenter] + postNotificationName:PCEditorWillChangeNotification + object:self]; + + [self setIsEdited:YES]; + + [[NSNotificationCenter defaultCenter] + postNotificationName:PCEditorDidChangeNotification + object:self]; + } } } +- (void)textViewDidChangeSelection:(NSNotification *)notification +{ + if (editorTextViewIsPressingKey == NO) + { + [self computeNewParenthesisNesting]; + } +} + +- (void)editorTextViewWillPressKey:sender +{ + editorTextViewIsPressingKey = YES; +// NSLog(@"Will pressing key"); + + [self unhighlightCharacter]; +} + +- (void)editorTextViewDidPressKey:sender +{ +// NSLog(@"Did pressing key"); + [self computeNewParenthesisNesting]; + + editorTextViewIsPressingKey = NO; +} + - (BOOL)becomeFirstResponder { [[NSNotificationCenter defaultCenter] @@ -637,57 +808,12 @@ // ==== Parser and scrolling // =========================================================================== -// ==== Parsing - -- (BOOL)providesChildrenForBrowserItem:(NSString *)item -{ -} - -// protocol -- (NSArray *)browserItemsForItem:(NSString *)item -{ - NSEnumerator *enumerator = nil; - NSDictionary *method = nil; - NSMutableArray *methodNames = nil; - - NSLog(@"PCEditor: asked for browser items"); - - // If item is .m or .h file show class list -/* if ([[item pathExtension] isEqualToString:@"m"] - || [[item pathExtension] isEqualToString:@"h"]) - { - return [aParser classNames]; - } - - // If item starts with "@" show method list - if ([[item substringToIndex:1] isEqualToString:@"@"]) - { - }*/ - -/* if (aParser) - { - [aParser setString:[_storage string]]; - NSLog(@"===\nMethods list:\n%@\n\n", [aParser methods]); - }*/ - - [aParser setString:[_storage string]]; - - // Methods - ASSIGN(parserMethods, [aParser methodNames]); - - methodNames = [NSMutableArray array]; - enumerator = [parserMethods objectEnumerator]; - while ((method = [enumerator nextObject])) - { -// NSLog(@"Method> %@", method); - [methodNames addObject:[method objectForKey:@"MethodName"]]; - } - - return methodNames; -} - // === Scrolling +- (void)fileStructureItemSelected:(NSString *)item +{ +} + - (void)scrollToClassName:(NSString *)className { } @@ -719,8 +845,408 @@ } } -- (void)scrollToLineNumber:(int)line +- (void)scrollToLineNumber:(unsigned int)lineNumber { + unsigned int offset; + unsigned int i; + NSString *line; + NSEnumerator *e; + NSArray *lines; + NSRange range; + + lines = [[_intEditorView string] componentsSeparatedByString: @"\n"]; + e = [lines objectEnumerator]; + + for (offset = 0, i = 1; + (line = [e nextObject]) != nil && i < lineNumber; + i++, offset += [line length] + 1); + + if (line != nil) + { + range = NSMakeRange(offset, [line length]); + } + else + { + range = NSMakeRange([[_intEditorView string] length], 0); + } + [_intEditorView setSelectedRange:range]; + [_intEditorView scrollRangeToVisible:range]; +} + +@end + +@implementation PCEditor (Menu) + +- (void)pipeOutputOfCommand:(NSString *)command +{ + NSTask * task; + NSPipe * inPipe, * outPipe; + NSString * inString, * outString; + NSFileHandle * inputHandle; + + inString = [[_intEditorView string] substringWithRange: + [_intEditorView selectedRange]]; + inPipe = [NSPipe pipe]; + outPipe = [NSPipe pipe]; + + task = [[NSTask new] autorelease]; + + [task setLaunchPath: @"/bin/sh"]; + [task setArguments: [NSArray arrayWithObjects: @"-c", command, nil]]; + [task setStandardInput: inPipe]; + [task setStandardOutput: outPipe]; + [task setStandardError: outPipe]; + + inputHandle = [inPipe fileHandleForWriting]; + + [task launch]; + [inputHandle writeData: [inString + dataUsingEncoding: NSUTF8StringEncoding]]; + [inputHandle closeFile]; + [task waitUntilExit]; + outString = [[[NSString alloc] + initWithData: [[outPipe fileHandleForReading] availableData] + encoding: NSUTF8StringEncoding] + autorelease]; + if ([task terminationStatus] != 0) + { + if (NSRunAlertPanel(_(@"Error running command"), + _(@"The command returned with a non-zero exit status" + @" -- aborting pipe.\n" + @"Do you want to see the command's output?\n"), + _(@"No"), _(@"Yes"), nil) == NSAlertAlternateReturn) + { + NSRunAlertPanel(_(@"The command's output"), + outString, nil, nil, nil); + } + } + else + { + [_intEditorView replaceCharactersInRange:[_intEditorView selectedRange] + withString:outString]; + [self textDidChange: nil]; + } +} + +- (void)findNext:sender +{ +// [[TextFinder sharedInstance] findNext: self]; +} + +- (void)findPrevious:sender +{ +// [[TextFinder sharedInstance] findPrevious: self]; +} + +- (void)jumpToSelection:sender +{ + [_intEditorView scrollRangeToVisible:[_intEditorView selectedRange]]; +} + +- (void)goToLine:sender +{ +/* LineQueryPanel * lqp = [LineQueryPanel shared]; + + if ([lqp runModal] == NSOKButton) + { + [self goToLineNumber: (unsigned int) [lqp unsignedIntValue]]; + }*/ +} + +@end + +/** + * Checks whether a character is a delimiter. + * + * This function checks whether `character' is a delimiter character, + * (i.e. one of "(", ")", "[", "]", "{", "}") and returns YES if it + * is and NO if it isn't. Additionaly, if `character' is a delimiter, + * `oppositeDelimiter' is set to a string denoting it's opposite + * delimiter and `searchBackwards' is set to YES if the opposite + * delimiter is located before the checked delimiter character, or + * to NO if it is located after the delimiter character. + */ +static inline BOOL CheckDelimiter(unichar character, + unichar * oppositeDelimiter, + BOOL * searchBackwards) +{ + if (character == '(') + { + *oppositeDelimiter = ')'; + *searchBackwards = NO; + + return YES; + } + else if (character == ')') + { + *oppositeDelimiter = '('; + *searchBackwards = YES; + + return YES; + } + else if (character == '[') + { + *oppositeDelimiter = ']'; + *searchBackwards = NO; + + return YES; + } + else if (character == ']') + { + *oppositeDelimiter = '['; + *searchBackwards = YES; + + return YES; + } + else if (character == '{') + { + *oppositeDelimiter = '}'; + *searchBackwards = NO; + + return YES; + } + else if (character == '}') + { + *oppositeDelimiter = '{'; + *searchBackwards = YES; + + return YES; + } + else + { + return NO; + } +} + +/** + * Attempts to find a delimiter in a certain string around a certain location. + * + * Attempts to locate `delimiter' in `string', starting at + * location `startLocation' a searching forwards (backwards if + * searchBackwards = YES) at most 1000 characters. The argument + * `oppositeDelimiter' denotes what is considered to be the opposite + * delimiter of the one being search for, so that nested delimiters + * are ignored correctly. + * + * @return The location of the delimiter if it is found, or NSNotFound + * if it isn't. + */ +unsigned int FindDelimiterInString(NSString * string, + unichar delimiter, + unichar oppositeDelimiter, + unsigned int startLocation, + BOOL searchBackwards) +{ + unsigned int i; + unsigned int length; + unichar (*charAtIndex)(id, SEL, unsigned int); + SEL sel = @selector(characterAtIndex:); + int nesting = 1; + + charAtIndex = (unichar (*)(id, SEL, unsigned int)) [string + methodForSelector: sel]; + + if (searchBackwards) + { + if (startLocation < 1000) + length = startLocation; + else + length = 1000; + + for (i=1; i <= length; i++) + { + unichar c; + + c = charAtIndex(string, sel, startLocation - i); + if (c == delimiter) + nesting--; + else if (c == oppositeDelimiter) + nesting++; + + if (nesting == 0) + break; + } + + if (i > length) + return NSNotFound; + else + return startLocation - i; + } + else + { + if ([string length] < startLocation + 1000) + length = [string length] - startLocation; + else + length = 1000; + + for (i=1; i < length; i++) + { + unichar c; + + c = charAtIndex(string, sel, startLocation + i); + if (c == delimiter) + nesting--; + else if (c == oppositeDelimiter) + nesting++; + + if (nesting == 0) + break; + } + + if (i == length) + return NSNotFound; + else + return startLocation + i; + } +} + +@implementation PCEditor (Parentesis) + +- (void)unhighlightCharacter +{ + if (isCharacterHighlit) + { + NSTextStorage *textStorage = [_intEditorView textStorage]; + NSRange r = NSMakeRange(highlitCharacterLocation, 1); + + NSLog(@"highlight"); + + isCharacterHighlit = NO; + + [textStorage beginEditing]; + + // restore the character's color and font attributes + if (previousFont != nil) + { + [textStorage addAttribute: NSFontAttributeName + value: previousFont + range: r]; + } + else + { + [textStorage removeAttribute: NSFontAttributeName range: r]; + } + + if (previousFGColor != nil) + { + [textStorage addAttribute: NSForegroundColorAttributeName + value: previousFGColor + range: r]; + } + else + { + [textStorage removeAttribute: NSForegroundColorAttributeName + range: r]; + } + + if (previousBGColor != nil) + { + [textStorage addAttribute: NSBackgroundColorAttributeName + value: previousBGColor + range: r]; + } + else + { + [textStorage removeAttribute: NSBackgroundColorAttributeName + range: r]; + } + + [textStorage endEditing]; + } +} + +- (void)highlightCharacterAt:(unsigned int)location +{ + if (isCharacterHighlit == NO) + { + NSTextStorage * textStorage = [_intEditorView textStorage]; + NSRange r = NSMakeRange(location, 1); + NSRange tmp; + + NSLog(@"highlight"); + + highlitCharacterLocation = location; + + isCharacterHighlit = YES; + + [textStorage beginEditing]; + + // store the previous character's attributes + ASSIGN(previousFGColor, + [textStorage attribute: NSForegroundColorAttributeName + atIndex: location + effectiveRange: &tmp]); + ASSIGN(previousBGColor, + [textStorage attribute: NSBackgroundColorAttributeName + atIndex: location + effectiveRange: &tmp]); + ASSIGN(previousFont, [textStorage attribute: NSFontAttributeName + atIndex: location + effectiveRange: &tmp]); + + [textStorage addAttribute: NSFontAttributeName + value: highlightFont + range: r]; + [textStorage addAttribute: NSForegroundColorAttributeName + value: highlightColor + range: r]; + + [textStorage removeAttribute: NSBackgroundColorAttributeName + range: r]; + + [textStorage endEditing]; + } +} + +- (void)computeNewParenthesisNesting +{ + NSRange selectedRange; + NSString * myString; + + if ([[NSUserDefaults standardUserDefaults] boolForKey: @"DontTrackNesting"]) + { + return; + } + + selectedRange = [_intEditorView 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]; + 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]; + } + } + } } @end diff --git a/Modules/Editors/ProjectCenter/PCEditorView.h b/Modules/Editors/ProjectCenter/PCEditorView.h index beebd51..07e4a83 100644 --- a/Modules/Editors/ProjectCenter/PCEditorView.h +++ b/Modules/Editors/ProjectCenter/PCEditorView.h @@ -21,9 +21,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include -/*#import -#import */ +#import @class NSColor; @class PCEditor; diff --git a/Modules/Editors/ProjectCenter/PCEditorView.m b/Modules/Editors/ProjectCenter/PCEditorView.m index d72f8d7..e1d3bfa 100644 --- a/Modules/Editors/ProjectCenter/PCEditorView.m +++ b/Modules/Editors/ProjectCenter/PCEditorView.m @@ -4,7 +4,7 @@ Implementation of the PCEditorView class for the ProjectManager application. - Copyright (C) 2005 Saso Kiselkov + Copyright (C) 2006 Saso Kiselkov, Sergii Stoian This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -40,8 +40,7 @@ #import "PCEditor.h" #import "SyntaxHighlighter.h" -static inline float -my_abs(float aValue) +static inline float my_abs(float aValue) { if (aValue >= 0) { @@ -125,7 +124,7 @@ static int ComputeIndentingOffset(NSString * string, unsigned int start) @interface PCEditorView (Private) -- (void) insertSpaceFillAlignedAtTabsOfSize: (unsigned int) tabSize; +- (void)insertSpaceFillAlignedAtTabsOfSize:(unsigned int)tabSize; @end @@ -137,7 +136,7 @@ static int ComputeIndentingOffset(NSString * string, unsigned int start) * * @argument tabSize Specifies how many spaces represent one tab. */ -- (void) insertSpaceFillAlignedAtTabsOfSize: (unsigned int) tabSize +- (void)insertSpaceFillAlignedAtTabsOfSize:(unsigned int)tabSize { char buf[tabSize]; NSString * string = [self string]; @@ -174,51 +173,51 @@ static int ComputeIndentingOffset(NSString * string, unsigned int start) @implementation PCEditorView -+ (NSFont *) defaultEditorFont ++ (NSFont *)defaultEditorFont { - NSUserDefaults * df = [NSUserDefaults standardUserDefaults]; - NSString * fontName; - float fontSize; - NSFont * font = nil; + NSUserDefaults *df = [NSUserDefaults standardUserDefaults]; + NSString *fontName; + float fontSize; + NSFont *font; fontName = [df objectForKey:@"EditorFont"]; fontSize = [df floatForKey:@"EditorFontSize"]; if (fontName != nil) { - font = [NSFont fontWithName: fontName size: fontSize]; + font = [NSFont fontWithName:fontName size:fontSize]; } if (font == nil) { - font = [NSFont userFixedPitchFontOfSize: fontSize]; + font = [NSFont userFixedPitchFontOfSize:fontSize]; } return font; } -+ (NSFont *) defaultEditorBoldFont ++ (NSFont *)defaultEditorBoldFont { - NSFont * font = [self defaultEditorFont]; + NSFont *font = [self defaultEditorFont]; - return [[NSFontManager sharedFontManager] convertFont: font - toHaveTrait: NSBoldFontMask]; + return [[NSFontManager sharedFontManager] convertFont:font + toHaveTrait:NSBoldFontMask]; } -+ (NSFont *) defaultEditorItalicFont ++ (NSFont *)defaultEditorItalicFont { - NSFont * font = [self defaultEditorFont]; + NSFont *font = [self defaultEditorFont]; - return [[NSFontManager sharedFontManager] convertFont: font - toHaveTrait: NSItalicFontMask]; + return [[NSFontManager sharedFontManager] convertFont:font + toHaveTrait:NSItalicFontMask]; } -+ (NSFont *) defaultEditorBoldItalicFont ++ (NSFont *)defaultEditorBoldItalicFont { - NSFont * font = [self defaultEditorFont]; + NSFont *font = [self defaultEditorFont]; - return [[NSFontManager sharedFontManager] convertFont: font - toHaveTrait: NSBoldFontMask | - NSItalicFontMask]; + return [[NSFontManager sharedFontManager] convertFont:font + toHaveTrait:NSBoldFontMask | + NSItalicFontMask]; } // --- @@ -238,7 +237,7 @@ static int ComputeIndentingOffset(NSString * string, unsigned int start) } // --- -- (void) dealloc +- (void)dealloc { TEST_RELEASE(highlighter); @@ -247,10 +246,10 @@ static int ComputeIndentingOffset(NSString * string, unsigned int start) - (void)setEditor:(PCEditor *)anEditor { - ASSIGN(editor, anEditor); + editor = anEditor; } -- (void) awakeFromNib +- (void)awakeFromNib { /* NSData * data; NSUserDefaults * df = [NSUserDefaults standardUserDefaults]; @@ -285,9 +284,8 @@ static int ComputeIndentingOffset(NSString * string, unsigned int start) - (void)createSyntaxHighlighterForFileType:(NSString *)fileType { ASSIGN(highlighter, [[[SyntaxHighlighter alloc] - initWithFileType: fileType textStorage: [self textStorage]] - autorelease]); -// [highlighter highlightRange: NSMakeRange(0, [[self string] length])]; + initWithFileType:fileType + textStorage:[self textStorage]] autorelease]); } - (void)insertText:text @@ -364,16 +362,16 @@ static int ComputeIndentingOffset(NSString * string, unsigned int start) */ - (void)keyDown:(NSEvent *)ev { -// [editorDocument editorTextViewWillPressKey: self]; + [editor editorTextViewWillPressKey: self]; [super keyDown:ev]; -// [editorDocument editorTextViewDidPressKey: self]; + [editor editorTextViewDidPressKey: self]; } - (void)paste:sender { -// [editorDocument editorTextViewWillPressKey: self]; + [editor editorTextViewWillPressKey:self]; [super paste:sender]; -// [editorDocument editorTextViewDidPressKey: self]; + [editor editorTextViewDidPressKey:self]; } - (void)mouseDown:(NSEvent *)ev diff --git a/Modules/Editors/ProjectCenter/Resources/FileC.tiff b/Modules/Editors/ProjectCenter/Resources/FileC.tiff new file mode 100644 index 0000000000000000000000000000000000000000..a5db07700a5d65d4ef821000e93d729c3ba5f257 GIT binary patch literal 9554 zcmeHN%}x_h6utv$h>2z-5fe2!iIAX+c1XI=-7IxMGVuj$ZGbdNXn+m7J_3)>N8qVk znt24zcV`YgJ>2Qc#g?|vV=m|KJLi7)D*;X1-#4F(+1@ZKTNnk>G|iUblnDmzi*Cd{ zqce29VafQX`VA}ov;XcR&H4N1-s>NQafSoqn7u7J>ScJ}I`7y1A?nYXOAlQ*moeAM zyw=kQx}NtvB>nl#Wg2VkBp&e~yvi==Xs>a+hwI48>@M^N-$8VB zg96vt-vHDo`0!_4s=T~*5DrQ2p)8HX+}9Y^T;DY|OoQ;T)cE>}9V`?8Cp#KE||(yXMb5?STXSHs-^h^>cZB zcg|@rR+e*Pjgmy-Io41g{(817hnDSdaBEG=_PXjm{G|pQOV9h;VLxjd@E_?falSF{ zb$K8Du6b7tyi>eE@OR;+QS;$nr5p3fx%cS}Z7z-dyuu!sYoD&`oM%vn`S8yts=tDN zLfqkJZ9e=hC)3WkIXrWfIIhjg`|z*J0sKcNtvhCCYJ&^lEcjz}Vp8Hmr|_DWuIpUm z%kux_9~T_qrO7(DO)~WL{3N{W`S6d!#OlfOoaa6v4hgrcuj&JobI0D%tlZ=3%S(Lt z%Q?g`-5C*Qc-#pu&DGa<&gGm>?86^FdnHHCW0TjByG-`&TLoV3bIn%OeE7R|+21F` zr;NLt!QbzF@N%{+_Te9yD2s?|9jlA0vuhH@hySEK^Xg55e`r6KC<{$UpHF0;0?)bZ zqbc(ohtE~c<++}BX*3P~uDy3v^WhIYV1_(mKDWuShv#L?cW@70?+2dEhd<9Ol3($k z@27F!^)KGX|4v&}KO~+h9hVKMxD2O^Ki-7iG8}MS**q2442)SP0)dI?OCaJk8$Y7| zCG;m)FX{vio)qyK#ZN{3nW2h#Px!yV3qy0X)0mB5Q(#^eF?EBjBF4S17{6_T*XD6P zyYoDFa~*F5Z^fS7A_j*&dvD8_op-_a5r%fq?fIWZ^SpO>c-HJ5_I@8U5dY}>gtxIV zU-JvEeX{%E8e*auNyJ2rnM6p?MLQ&2=&nm$kW735TN}Ve2@SAe*GJ$H`UpIg zOVda2d^7XW!*Rx$TPU{BlFRvj&hMTng$292?!9xHYi{|Pn++sMGG2sJwlJ`dMx(ht z!akNWD!Rjh@hA2UOa9rv_hjdM|J?cgM`1k1!Ot{xO8%VF*0LxcaUVbXTX`S%uXjsb z?^5fGmr1)%U;DoA-|pJl+aDz*gpK+ zUy-!4GN$1bCS7Oqi)@`w-RAl5+uAZ4yX=I+sdrk|x5)3quXjLQOZM-CgK@`!f3km_ z=c}`Ck@Vp&sxR_^JHZ_ke^K5|_e#dKLga%ox!|W@S}IzC2|Kjx#T=b z>$f)Zs^oR~6q0KxAius%=Y1r!*;q)_M)B1wlK7>a8||9Cu2w7Nv-Zv z6z620bzfXjxj9u5@?|YwoU0bI6@JB8hN5WdxOZ)5Q>6&SDAO30j&${L&_`~$MMB~tf z@_eH7`9RXvaok7SSstFNuFGs&U$l#x;4kWXTRtCt>;qg*By^r>Z1iEh);WVQNZViU z#)n_m&5OR|AJzIioz?TY>-*2|$G?;2RgQ!+kyG>uk?Hy7`q8JW=4TL&x?6jb%KHWtebEz zWQ}}xm^1#ldxr)8>fJYLwF<1;FwvavpBvYoyoq{-d;2T;TUwiK)d_ zXxx>24F8bkI?sb#{v~JOJqg(h)H8k0A%?%6+terj-}dhZAY!gn@wBMRyY<}1@TV5& zrB6-to-x#cD>)Gn_ZjoRrWV7$=}cV*E_&&l>o={_eKGu9jrATgweCCvoX+hX7{lJ} zMee+1%DW;@({;Z2G5k3*2Em0Z)Wc_Q?{+#8* z82-NgP;4k%xI(qy-?WyqV)$##LO$mYMfah+ufdCkJ&ZGSob`<9I@SYeG5pyRgF9AJ zV90Ps)`x1DkKwQHKgs88;Ergu1O1g|Iwrz|y8NMQ`Ch6yGnCgnt2xy?9iQaK@b3vnoI&GWBXdO5GtU_J zL|>dSUq5re82-8se$R5#c%??}%)Fa(_pAdpwHW@;t0$j#(YUX$(wRA6D1WJTtc9Fm z@2vB6ehh!#jLe<|q(MLIGmE}GYjuBJJ!^d!!#@-4amFlJ4F6f;O)fXVKb7agg=YlQ zd-_0~!yfg_Bd7Pid^te980nWal9kK4WcTg!|CZGcn98~iLPGY#*Yn&x>xjtHMDRk^ zNLDWElHE7`dFNR|5qzQl9X^nd{x*+iG|Ouw{H}ceN(?rdlU2tbcR+3)7Pv0#E)`f! zj9C@}iOJ+8QT|ftKal?t`jaf%xD+RktiL4wV-HOFq{Mu{7|JMHwEPZ1>R|k%_$^4C4| zHP+5oI^3)N*rV^D_Kw{57V#MVS|isF^6~K3y}`Z-?-av-s$CxbQ_Tt7Cx*Y)jXt>0 z*I04%@Yi+I`kWubpFL6N;UCo>(48};@@Ic7hV)Mx!#~Is zm|DE%Tszmkml*zan(KVE-{D_yme^QS-;AE=dk-=ED^6;DZOroj4V1nDt*?8_cpA*> zTJ6X1rxxg^Pfhfhv0{&KC1;}EuYKkVoKT|}{(9G>KDcNb*EeaMo)N>})mWb~b3}Km zA2?m{9oQJoZZG<;8m71_^5m%NeDh=Yb7l;J3$3n?b(()&PYi!*ftmC*>NxjSoSc8p z-9FS;wT}Lr<--{MzW%z{K)BHAYQcZfTF#2$uQjXlIe#F!59GTBuPP>I_?)5RtY=Ku zu^z~L41e~-;GWeKSl5R;vc9gC`56BC{^NYk2JVSgd(dBLrt{iI9qV;`oFBt~+?-G@ z11Hfnn?V1vuB;EubL02TA9@ydaP;@ZSqF4^hR(O;4_%9IDX_CHuX&Yo%6U3I&X3{W z6^_`!c|2=mj);2Z8RMDgi!4I>+#bUS0Wp z7iaNYVyQE8z`FcMZKZ|muy@w^kRQX}H=}KL0hxz>IJYhO&aBn_p?cQ(Fou6yw8swL zoLR+U_|J;txV?A5Kb7}F!#l!0eWnl8Ih;|?JaYQ%%e!|m(l3^aWnv@GL;L-I!|Df2 z#cqSpk^Oupp)=z|{SHL%p;#`KiH$rDO@DpwdGST?rT+3Q&+2{D>2LFRNAqmC@VoKz zD=|Fzf>?+@?tt7P7`QHA@Xs(ERB$tD}t$KF@0-!#c<^SJEYdY-(g{Eg(TnzLq+nEV7GVF p-~X9*n(byM{rsub?zGxF>Hb;&{Nl2Eet9zJUG(=)o2O?-=08xOl~Vu! literal 0 HcmV?d00001 diff --git a/Modules/Editors/ProjectCenter/Resources/FileM.tiff b/Modules/Editors/ProjectCenter/Resources/FileM.tiff new file mode 100644 index 0000000000000000000000000000000000000000..a9f86b53e1da06b1a0429487e1f26cadc3894e5a GIT binary patch literal 9554 zcmeHN!EVz)5FNLGDkKn8qDX+i60KA?B&n1G+;W6NC5s=Rp=zQCs#a|;z4a6LgnUB3 ziX-YLFyry_j@N4^t^!R+7CAFJ^Y+d2vm52W{yx1Y+TNhmni~g_B)M6HtI9CZKJSaQ z-|#gK-NSHqt0AA64X=fC%#DCT>OQ&W*6!fEVnl%CxqZ&C-pAD7X8_-CW_ z(&iQu%6&hZ?w8&FCSHsGP4S^;1|H>Fp6{R3yzImJV(b4ppY{7sbj{zD*QMJ)9kB#3 z1z-?OtCTj;U+1~b8mHR%=TtgJqF?v-5aicGdthyBqTilFt{O$B)e8OcEHnpRqC4aI zIB#)9Y?(*<#C+-R&xB)P`M=-bzdr+eqMw;I7t!;h>UB8TS1rryV_5Li`u(&1-q+;! z?cQpt(=KN$ujSC*^!nkyAHhj<#k0iIE0j2oD{{pN9?SBgCNac|{%rj(Yr-5q)@dqZ zt9hH~hd;uPyy&&~uNO4Hf8bp`j0J8Iuj3(}Io;nc&QwL!ewyAx6$W)8#YvpB>UeMC zzw;^J_h?b>}>r%NWCXI!05vB$%~u_ zMz2#_4(1N)cmZspA7`p!-5meStgy4ypJbjUxm>)<8f{(tS9}hxNPv^*uO|A{GnrZD z5#C9CJG)Mk#VN1O6n=kAt6%5!GS4)Yxm+JT|6Hi0kI3X}X?~CYm(Z_hJ*zV~dXVL7oIf=6N5mC+!}#CPQ{r>XNwg7d8qBjS z=Weu>WxaA0kNESapL)DfDs#a|;z4a6L1b;%m ziX-YLFq84ij@MqtZbL~(Qn@ob^Y-oA=e3DY`+a&xw7Evh&&)WGB+2zWTp`0mdzz** zeX;gyzS6Qi%$feg-@{V>-#>foInK|2?>|w@dyPlWGjc>c=NQ{4Jv&C;qz-;RE~5YN z&qnK|%`K)Z_x)@-UUdJPcrE@n#h2YP@F>^fynpQ3w7%H-UFXw2|3p{(uDmLIXF?sZ zYM;O$R%7d*pDNFFEqTw2e*Je>BF3QzZK1xc18d`L{a1~m(`to&x0n2ydA#&6-{M?d z`+iUR#B)dAKNF6*kN^D*{+ID6*UwCci(#y2ayZc+#yXsjVZpWa`*Z!VdKg~I;_GUc zIhNOQXs^D0`0qz>5?yAVUXHyKtn1rc_NjQ=2RCXGfs<(K+N-bMpX-m+)4V1hgK?E6 zU=XW#o17o(4RY&=Y7+gaOxXJa z?GlLut9V;4%N^G70@p-8=7eI^I{ut#VW+D<$vk!c?}f9h(bmO##ru2n$G}M}_K11v zy?@j*S+mF^yp#HN?J7+cr@XqR@E3da^y_-P%rlKeF4srTpI26Qwc>o~5tY}qN8F$6 zzj6pq6_@KnQz%-#5C(PULGKp+i?&XtUnBS>s-AE^kImzR*Y<5biMPq~Yq_w7zo)XX z!xla8@eW(uqg@|+ZlWLDvlN&5nO}C_7s-F3CnFCex=XxoKGypn z^VC 0) { [self beginEditingIfNeeded]; - [self fixUpContextsInRange: delayedProcessedRange]; - [self fixUpKeywordsInRange: delayedProcessedRange]; + [self fixUpContextsInRange:delayedProcessedRange]; + [self fixUpKeywordsInRange:delayedProcessedRange]; - if ([self contextAtEndOfRange: delayedProcessedRange] != - [self contextAfterRange: delayedProcessedRange]) + if ([self contextAtEndOfRange:delayedProcessedRange] != + [self contextAfterRange:delayedProcessedRange]) { NSRange invalidatedRange; @@ -765,9 +765,9 @@ LocateString(NSString * str, invalidatedRange = NSMakeRange(NSMaxRange(delayedProcessedRange), [textStorage length] - NSMaxRange(delayedProcessedRange)); - [textStorage addAttribute: KeywordsNotFixedAttributeName - value: [NSNull null] - range: invalidatedRange]; + [textStorage addAttribute:KeywordsNotFixedAttributeName + value:[NSNull null] + range:invalidatedRange]; } } else diff --git a/Modules/GNUmakefile.bundles b/Modules/GNUmakefile.bundles index a1e3174..1f45b21 100644 --- a/Modules/GNUmakefile.bundles +++ b/Modules/GNUmakefile.bundles @@ -7,8 +7,8 @@ ADDITIONAL_CPPFLAGS += ADDITIONAL_INCLUDE_DIRS += -I../../../ -I../../../Headers ADDITIONAL_LIB_DIRS += -L../../../Library/ProjectCenter.framework/Versions/Current -# BUNDLE_INSTALL_DIR = $(GNUSTEP_SYSTEM_ROOT)/Applications/ProjectCenter.app/Resources -$(BUNDLE_NAME)_STANDARD_INSTALL = no +BUNDLE_INSTALL_DIR = $(GNUSTEP_SYSTEM_ROOT)/Applications/ProjectCenter.app/Resources +# $(BUNDLE_NAME)_STANDARD_INSTALL = no DO_LIB_LINK=no ifeq ($(GNUSTEP_TARGET_OS), mingw32) diff --git a/Modules/Parsers/ProjectCenter/GNUmakefile b/Modules/Parsers/ProjectCenter/GNUmakefile index 282f8a2..d17c039 100644 --- a/Modules/Parsers/ProjectCenter/GNUmakefile +++ b/Modules/Parsers/ProjectCenter/GNUmakefile @@ -29,6 +29,7 @@ ProjectCenter_HEADERS= \ PCParser.h \ CodeHandler.h \ ObjCCommentHandler.h \ + ObjCClassHandler.h \ ObjCMethodHandler.h # @@ -37,6 +38,7 @@ ProjectCenter_HEADERS= \ ProjectCenter_OBJC_FILES= \ PCParser.m \ ObjCCommentHandler.m \ + ObjCClassHandler.m \ ObjCMethodHandler.m include ../../GNUmakefile.bundles diff --git a/Modules/Parsers/ProjectCenter/ObjCClassHandler.h b/Modules/Parsers/ProjectCenter/ObjCClassHandler.h index 9e431d0..d7ae347 100644 --- a/Modules/Parsers/ProjectCenter/ObjCClassHandler.h +++ b/Modules/Parsers/ProjectCenter/ObjCClassHandler.h @@ -28,24 +28,26 @@ #include "ObjCCommentHandler.h" /** - * ClassStart ClassSymbol ClassName ClassEnd - * @interface/@implementation Name ;/{ - * + * ClassStart ClassSymbol ClassName ClassSuper ClassProto | ClassCategory + * @... CName : CSuper < Protocol > | ( Category ) * - * MethodStart is after each ';' or new line - * MethodSymbol is +/- for objective-C - * MethodReturnValue is surround by '(' and ')', and can be ignore - * MethodName contain method name and messages - * MethodNone is not method; + * ClassStart is after each ';' or new line + * ClassSymbol is '@' with 'interface'/'implementation' after that + * ClassName started after ClassSymbol and next first ' ' + * ClassCategory is surround by '(' and ')'. Started after ClassName and ' ' + * ClassNone is not method; */ -typedef enum _CheckStep { +typedef enum _CS { ClassStart, ClassSymbol, - ClassReturnValue, - ClassName, - ClassNone -} CheckStep; + ClassName, + ClassSuper, + ClassProto, + ClassCategory, + ClassBody, + ClassNone, +} CS; @class NSMutableString; @@ -56,18 +58,27 @@ typedef enum _CheckStep { unsigned int position; BOOL inSpace; + NSMutableString *keyword; NSMutableString *class; NSMutableArray *classes; unichar _preSymbol; - unsigned classBeginPosition; + unsigned nameBeginPosition; + unsigned nameEndPosition; + unsigned bodyBeginPosition; + int bodySymbolCount; - CheckStep step; + CS step; + CS prev_step; } // NSArray of NSDictionaries -// (method = NSString; position = NSNumber) +// ClassName = NSString; +// ClassNameRange = NSString <- NSStringFromRange(NSRange) +// ClassBodyRange = NSString <- NSStringFromRange(NSRange) - (NSArray *)classes; +- (void)addClassToArray; + @end #endif /* _ObjCClassHandler_H_ */ diff --git a/Modules/Parsers/ProjectCenter/ObjCClassHandler.m b/Modules/Parsers/ProjectCenter/ObjCClassHandler.m index 1d08cc3..49acb6c 100644 --- a/Modules/Parsers/ProjectCenter/ObjCClassHandler.m +++ b/Modules/Parsers/ProjectCenter/ObjCClassHandler.m @@ -20,9 +20,9 @@ ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include +#import -#include "ObjCClassHandler.h" +#import "ObjCClassHandler.h" @implementation ObjCClassHandler @@ -30,12 +30,17 @@ { self = [super init]; position = 0; - classBeginPosition = 0; + nameBeginPosition = 0; + nameEndPosition = 0; + bodyBeginPosition = 0; + bodySymbolCount = -1; inSpace = NO; + keyword = [[NSMutableString alloc] init]; class = [[NSMutableString alloc] init]; classes = [[NSMutableArray alloc] init]; + prev_step = ClassNone; step = ClassNone; _preSymbol = 0; @@ -45,6 +50,7 @@ - (void)dealloc { NSLog(@"ClassHandler: dealloc"); + RELEASE(keyword); RELEASE(class); RELEASE(classes); [super dealloc]; @@ -52,7 +58,35 @@ - (NSArray *)classes { - return methods; + return classes; +} + +- (void)addClassToArray +{ +// NSLog(@"OCCH: class: %@", class); + if ([class length]) + { + NSDictionary *dict; + NSString *dClass; + NSString *dNRange; + NSString *dBRange; + + dClass = [class copy]; + dNRange = NSStringFromRange(NSMakeRange(nameBeginPosition, + nameEndPosition-nameBeginPosition)); + dBRange = NSStringFromRange(NSMakeRange(bodyBeginPosition, + position-bodyBeginPosition)); + + dict = [NSDictionary dictionaryWithObjectsAndKeys: + dClass, @"ClassName", + dNRange, @"ClassNameRange", + dBRange, @"ClassBodyRange", + nil]; + + [classes addObject:dict]; + RELEASE(dClass); + } + [class setString:@""]; } #define NotClass {step = ClassNone; [class setString: @""];} @@ -61,16 +95,16 @@ { unsigned int len = [element length]; - [super string: element]; + [super string:element]; /* Comments */ if (_commentType != NoComment) { } - else if (_stringBegin/* != NoString*/) + else if (_stringBegin /* != NoString*/) { } - else + else if (step != ClassNone) { inSpace = NO; @@ -78,25 +112,13 @@ { NotClass; } - else if (step == MethodSymbol) + else if (step == ClassSymbol) { - if (_preSymbol == '(') - step = MethodReturnValue; - else if ((_preSymbol == '+') || (_preSymbol == '=')) - step = MethodName; - - [method appendString: element]; + [keyword appendString:element]; } - else if (step == MethodReturnValue) + else if ((step == ClassName) || (step == ClassCategory)) { - if (_preSymbol == ')') - step = MethodName; - - [method appendString: element]; - } - else if (step == MethodName) - { - [method appendString: element]; + [class appendString:element]; } } @@ -106,7 +128,7 @@ - (void)number:(NSString *)element { - [super number: element]; + [super number:element]; /* Comments */ if (_commentType != NoComment) @@ -123,13 +145,17 @@ { NotClass; } - else if (step == ClassSymbol) +/* else if (step == ClassSymbol) { NotClass; } - else if ((step == ClassName)) + else if (step == ClassCategory) { - [class appendString: element]; + NotClass; + }*/ + else if (step == ClassName) + { + [class appendString:element]; } } @@ -141,7 +167,7 @@ { BOOL newline = NO; - [super spaceAndNewLine: element]; + [super spaceAndNewLine:element]; if ((element == 0x0A) || (element == 0x0D)) { @@ -159,20 +185,52 @@ { if (step != ClassNone) { - if ((!newline) && (!inSpace)) +/* if ((!newline) && (!inSpace)) { - [method appendString:[NSString stringWithFormat:@"%c",element]]; - } - if (element == ' ') - { - inSpace = YES; + [class appendString:[NSString stringWithFormat:@"%c",element]]; } + else*/ + if ((newline || element == ' ') && (step == ClassSymbol)) + { +// NSLog(@"keyword: %@", keyword); + if ([keyword isEqualToString:@"end"]) + { +// NSLog(@"@end reached"); + [self addClassToArray]; + step = ClassNone; + } + else if ([keyword isEqualToString:@"interface"] || + [keyword isEqualToString:@"implementation"]) + { + [class appendString:@"@"]; + step = ClassName; + prev_step = ClassNone; + nameBeginPosition = position; + } + [keyword setString:@""]; + + if (prev_step == ClassBody) + { + step = ClassBody; + prev_step = ClassNone; + } + + inSpace = YES; + } + else if (newline && (step == ClassName)) + { +// NSLog(@"Class body start: \"%@\"", class); + step = ClassBody; + nameEndPosition = position - 1; + bodyBeginPosition = position; + } } - if (newline && (step == MethodNone)) + // Class name should start from beginning of line + // (some spaces may prepend "@" symbol) + if (newline && (step == ClassNone)) { step = ClassStart; - classBeginPosition = position; } } @@ -182,7 +240,7 @@ - (void)symbol:(unichar)element { - [super symbol: element]; + [super symbol:element]; /* Comments */ if (_commentType != NoComment) @@ -196,55 +254,45 @@ inSpace = NO; _preSymbol = element; - if (step == ClassStart) + if ((step == ClassStart) || (step == ClassBody)) { - if ((element == '+') || (element == '-')) - { - step = ClassSymbol; - [method appendString:[NSString stringWithFormat: @"%c", element]]; - } - else - { - NotClass; - } + if (element == '@') + { + prev_step = step; + step = ClassSymbol; + } } - else if (step == ClassSymbol) + else if (step == ClassName) { - if ((element == '(') || (element == '_')) + if (element == '(') { - [method appendString: [NSString stringWithFormat:@"%c", element]]; + step = ClassCategory; + [class appendString:[NSString stringWithFormat:@"%c",element]]; } + else if (element == '<') + { + step = ClassProto; + } + else if (element == ':') + { + [class appendString:[NSString stringWithFormat:@"%c",element]]; + } } - else if (step == ClassReturnValue) + else if (step == ClassCategory) { if (element == ')') { step = ClassName; } - [method appendString:[NSString stringWithFormat:@"%c", element]]; + [class appendString:[NSString stringWithFormat:@"%c",element]]; } - else if (step == ClassName) - { - if (element != '{') - [method appendString:[NSString stringWithFormat: @"%c", element]]; - } - - if ((element == ';') || (element == '{') || - (element == '}') || (position == 0)) - { - step = ClassStart; - classBeginPosition = position; - if ([class length]) + else if (step == ClassProto) + { + if (element == '>') { - NSDictionary *dict; - - dict = [NSDictionary dictionaryWithObjectsAndKeys: - AUTORELEASE([class copy]), @"class", - [NSNumber numberWithUnsignedInt:methodBeginPosition], @"position", nil]; - [methods addObject: dict]; + step = ClassName; } - [class setString:@""]; - } + } } position++; @@ -254,7 +302,7 @@ - (void)invisible:(unichar)element { [super invisible:element]; - position ++; + position++; _preChar = element; } diff --git a/Modules/Parsers/ProjectCenter/ObjCMethodHandler.h b/Modules/Parsers/ProjectCenter/ObjCMethodHandler.h index b7bdb05..e6176ad 100644 --- a/Modules/Parsers/ProjectCenter/ObjCMethodHandler.h +++ b/Modules/Parsers/ProjectCenter/ObjCMethodHandler.h @@ -43,7 +43,9 @@ typedef enum _CheckStep { MethodBody, MethodSymbol, MethodReturnValue, - MethodName, + MethodName, + MethodParameterStart, + MethodParameter, MethodNone } CheckStep; @@ -65,6 +67,7 @@ typedef enum _CheckStep { int bodySymbolCount; CheckStep step; + CheckStep prev_step; } // NSArray of NSDictionaries diff --git a/Modules/Parsers/ProjectCenter/ObjCMethodHandler.m b/Modules/Parsers/ProjectCenter/ObjCMethodHandler.m index 3b2e67f..620cf0b 100644 --- a/Modules/Parsers/ProjectCenter/ObjCMethodHandler.m +++ b/Modules/Parsers/ProjectCenter/ObjCMethodHandler.m @@ -39,7 +39,7 @@ method = [[NSMutableString alloc] init]; methods = [[NSMutableArray alloc] init]; - step = MethodNone; + prev_step = step = MethodNone; _preSymbol = 0; return self; @@ -108,30 +108,14 @@ { NotMethod; } - else if (step == MethodSymbol) - { - if (_preSymbol == '(') - { - step = MethodReturnValue; - } - else if ((_preSymbol == '+') || (_preSymbol == '=')) - { - step = MethodName; - } - [method appendString:element]; - } - else if (step == MethodReturnValue) - { - if (_preSymbol == ')') - { - step = MethodName; - } - [method appendString:element]; - } else if (step == MethodName) { [method appendString:element]; } + else if (step == MethodParameterStart) + { + step = MethodParameter; + } } position += len; @@ -197,12 +181,17 @@ { if (step != MethodNone) { - if ((!newline) && (!inSpace)) +/* if ((!newline) && (!inSpace)) { [method appendString:[NSString stringWithFormat:@"%c",element]]; - } - if (element == ' ') + }*/ + if (element == ' ' || newline) { + if (step == MethodParameter) + { + step = MethodName; + prev_step = MethodNone; + } inSpace = YES; } } @@ -221,7 +210,7 @@ - (void)symbol:(unichar)element { - [super symbol: element]; + [super symbol:element]; /* Comments */ if (_commentType != NoComment) @@ -244,22 +233,34 @@ nameBeginPosition = position; } } -/* else if (step == MethodSymbol) + else if ((step == MethodName) || (step == MethodParameterStart)) { if (element == '(') { + if (step == MethodParameterStart) + { + prev_step = step; + } step = MethodReturnValue; } - [method appendString:[NSString stringWithFormat: @"%c", element]]; + else if (element == ':') + { + step = MethodParameterStart; + [method appendString:@":"]; + } } - else if (step == MethodReturnValue) + else if (step == MethodReturnValue && element == ')') { - if (element == ')') - { - step = MethodName; - } - [method appendString:[NSString stringWithFormat: @"%c", element]]; - }*/ + if (prev_step == MethodParameterStart) + { + step = prev_step; + } + else + { + step = MethodName; + } +// [method appendString:[NSString stringWithFormat: @"%c", element]]; + } else if ((step == MethodName) && (element != '{') && (element != ';')) { [method appendString:[NSString stringWithFormat: @"%c", element]]; diff --git a/Modules/Parsers/ProjectCenter/PCParser.m b/Modules/Parsers/ProjectCenter/PCParser.m index 2002021..2f1fee1 100644 --- a/Modules/Parsers/ProjectCenter/PCParser.m +++ b/Modules/Parsers/ProjectCenter/PCParser.m @@ -20,10 +20,11 @@ ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include +#import -#include "PCParser.h" -#include "ObjCMethodHandler.h" +#import "PCParser.h" +#import "ObjCClassHandler.h" +#import "ObjCMethodHandler.h" typedef enum _CodeType { StringCodeType, /* 41-5A, 61-7A, 5F */ @@ -39,17 +40,19 @@ typedef enum _CodeType { // ==== Initialisation // =========================================================================== -- (id) init +- (id)init { self = [super init]; return self; } -- (void) dealloc +- (void)dealloc { - NSLog(@"CEParser: dealloc"); + NSLog(@"PCParser: dealloc"); free(_uchar); RELEASE(_string); + + [super dealloc]; } - (id)setString:(NSString *)text @@ -70,11 +73,11 @@ typedef enum _CodeType { - (NSArray *)classNames { -/* _handler = [[ObjCClassHandler alloc] init]; + _handler = [[ObjCClassHandler alloc] init]; [self parse]; AUTORELEASE(_handler); - return [(ObjCClassHandler *)_handler methods];*/ + return [(ObjCClassHandler *)_handler classes]; } - (NSArray *)methodNames @@ -142,15 +145,15 @@ static void (*impSymbol)(id, SEL, unichar); NSLog(@"CodeParser begin..."); impString = (void (*)(id, SEL, id)) - [[_handler class] instanceMethodForSelector: selString]; + [[_handler class] instanceMethodForSelector:selString]; impNumber = (void (*)(id, SEL, id)) - [[_handler class] instanceMethodForSelector: selNumber]; + [[_handler class] instanceMethodForSelector:selNumber]; impSpaceAndNewLine = (void (*)(id, SEL, unichar)) - [[_handler class] instanceMethodForSelector: selSpaceAndNewLine]; + [[_handler class] instanceMethodForSelector:selSpaceAndNewLine]; impInvisible = (void (*)(id, SEL, unichar)) - [[_handler class] instanceMethodForSelector: selInvisible]; + [[_handler class] instanceMethodForSelector:selInvisible]; impSymbol = (void (*)(id, SEL, unichar)) - [[_handler class] instanceMethodForSelector: selSymbol]; + [[_handler class] instanceMethodForSelector:selSymbol]; start = end = 0; startType = codeType(_uchar+start); diff --git a/PCMenuController.m b/PCMenuController.m index 13979b2..fb43762 100644 --- a/PCMenuController.m +++ b/PCMenuController.m @@ -23,6 +23,8 @@ #include #include +#include + #include "PCAppController.h" #include "PCMenuController.h" #include "PCInfoController.h" @@ -206,10 +208,10 @@ [project addFiles:[NSArray arrayWithObject:newFilePath] forKey:PCNonProject notify:YES]; - [[project projectEditor] editorForFile:newFilePath - categoryPath:categoryPath - editable:YES - windowed:NO]; + [[project projectEditor] openEditorForFile:newFilePath + categoryPath:categoryPath + editable:YES + windowed:NO]; } } }