From 56d789e2321bb2e1437dc29b4136cf2a476a103b Mon Sep 17 00:00:00 2001 From: Gregory John Casamento Date: Sun, 1 Aug 2021 17:01:58 -0400 Subject: [PATCH 01/15] Add capability to debugger to focus on file and line which has been stopped on --- Framework/PCEditorManager.m | 14 ++++++++++++ Framework/PCProjectManager.m | 9 +++++++- Headers/ProjectCenter/PCEditorManager.h | 1 + Headers/ProjectCenter/PCProjectManager.h | 1 + Modules/Debuggers/ProjectCenter/GDBWrapper.m | 24 ++++++++++++++++++++ Modules/Debuggers/ProjectCenter/PCDebugger.h | 1 + Modules/Debuggers/ProjectCenter/PCDebugger.m | 15 ++++++++++++ 7 files changed, 64 insertions(+), 1 deletion(-) diff --git a/Framework/PCEditorManager.m b/Framework/PCEditorManager.m index 5108b8e..2c61808 100644 --- a/Framework/PCEditorManager.m +++ b/Framework/PCEditorManager.m @@ -554,5 +554,19 @@ NSString *PCEditorDidResignActiveNotification = [editor scrollToLineNumber: [line integerValue]]; } +- (void)gotoFile: (NSString *)fileName atLine: (NSUInteger)line +{ + id editor = [self openEditorForFile: fileName + editable: YES + windowed: NO]; + + PCProject *project = [_projectManager rootActiveProject]; + [[project projectBrowser] setPath: fileName]; + [_projectManager openFileAtPath: fileName]; + + // [self orderFrontEditorForFile:fileName]; + [editor scrollToLineNumber: line]; +} + @end diff --git a/Framework/PCProjectManager.m b/Framework/PCProjectManager.m index 0b0a3d8..0bc4358 100644 --- a/Framework/PCProjectManager.m +++ b/Framework/PCProjectManager.m @@ -1124,6 +1124,7 @@ NSString *PCActiveProjectDidChangeNotification = @"PCActiveProjectDidChange"; // ============================================================================ - (void)openFileAtPath:(NSString *)filePath + windowed:(BOOL)windowed { editorManager = [self editorManager]; @@ -1131,11 +1132,17 @@ NSString *PCActiveProjectDidChangeNotification = @"PCActiveProjectDidChange"; { [editorManager openEditorForFile:filePath editable:YES - windowed:YES]; + windowed:windowed]; [editorManager orderFrontEditorForFile:filePath]; } } +- (void)openFileAtPath:(NSString *)filePath +{ + [self openFileAtPath: filePath windowed: YES]; +} + + - (void)openFile { NSArray *files = nil; diff --git a/Headers/ProjectCenter/PCEditorManager.h b/Headers/ProjectCenter/PCEditorManager.h index 142aebb..e2b6edc 100644 --- a/Headers/ProjectCenter/PCEditorManager.h +++ b/Headers/ProjectCenter/PCEditorManager.h @@ -69,6 +69,7 @@ - (NSArray *)allEditors; - (void)closeActiveEditor:(id)sender; - (void)closeEditorForFile:(NSString *)file; +- (void)gotoFile: (NSString *)fileName atLine: (NSUInteger)line; - (NSArray *)modifiedFiles; - (BOOL)hasModifiedFiles; diff --git a/Headers/ProjectCenter/PCProjectManager.h b/Headers/ProjectCenter/PCProjectManager.h index 4109b5f..34fdd5a 100644 --- a/Headers/ProjectCenter/PCProjectManager.h +++ b/Headers/ProjectCenter/PCProjectManager.h @@ -164,6 +164,7 @@ extern NSString *PCActiveProjectDidChangeNotification; // Also called by PCAppController - (void)openFileAtPath:(NSString *)filePath; +- (void)openFileAtPath:(NSString *)filePath windowed: (BOOL)windowed; - (void)openFile; - (void)newFile; - (BOOL)saveFile; diff --git a/Modules/Debuggers/ProjectCenter/GDBWrapper.m b/Modules/Debuggers/ProjectCenter/GDBWrapper.m index 33a89ee..86a1245 100644 --- a/Modules/Debuggers/ProjectCenter/GDBWrapper.m +++ b/Modules/Debuggers/ProjectCenter/GDBWrapper.m @@ -379,6 +379,29 @@ [debugger setLastLineNumberParsed: NSNotFound]; } } + + if ([dictionaryName isEqualToString: @"thread-selected"]) + { + NSDictionary *d = [dict objectForKey: @"frame"]; + NSString *fileName; + NSString *lineNum; + + fileName = [d objectForKey:@"fullname"]; + lineNum = [d objectForKey:@"line"]; + + NSLog(@"parsed from GDB thread-selected: %@:%@", fileName, lineNum); + if (fileName != nil && lineNum != nil) + { + [debugger setLastFileNameParsed: fileName]; + [debugger setLastLineNumberParsed: [lineNum intValue]]; + [debugger updateEditor]; + } + else + { + [debugger setLastFileNameParsed: nil]; + [debugger setLastLineNumberParsed: NSNotFound]; + } + } } else { @@ -423,6 +446,7 @@ { [debugger setLastFileNameParsed: fileName]; [debugger setLastLineNumberParsed: [lineNum intValue]]; + [debugger updateEditor]; } else { diff --git a/Modules/Debuggers/ProjectCenter/PCDebugger.h b/Modules/Debuggers/ProjectCenter/PCDebugger.h index f37e309..4e75d9a 100644 --- a/Modules/Debuggers/ProjectCenter/PCDebugger.h +++ b/Modules/Debuggers/ProjectCenter/PCDebugger.h @@ -66,5 +66,6 @@ extern NSString *PCDBDebuggerStartedNotification; - (void) setLastFileNameParsed: (NSString *)fname; - (NSUInteger)lastLineNumberParsed; - (void)setLastLineNumberParsed: (NSUInteger)num; +- (void)updateEditor; @end diff --git a/Modules/Debuggers/ProjectCenter/PCDebugger.m b/Modules/Debuggers/ProjectCenter/PCDebugger.m index 341bd07..5d5774e 100644 --- a/Modules/Debuggers/ProjectCenter/PCDebugger.m +++ b/Modules/Debuggers/ProjectCenter/PCDebugger.m @@ -33,6 +33,10 @@ #import "PCDebugger.h" #import "PCDebuggerView.h" +#import +#import +#import "PCAppController.h" + #import "Modules/Preferences/EditorFSC/PCEditorFSCPrefs.h" #import "PCDebuggerWrapperProtocol.h" #import "GDBWrapper.h" @@ -306,6 +310,17 @@ NSString *PCDBDebuggerStartedNotification = @"PCDBDebuggerStartedNotification"; lastLineNumberParsed = num; } +- (void) updateEditor +{ + NSLog(@"****************** UPDATE EDITOR HIT ***********************"); + PCAppController *controller = (PCAppController *)[NSApp delegate]; + PCProjectManager *pm = [controller projectManager]; + PCEditorManager *em = [pm editorManager]; + [em gotoFile: lastFileNameParsed + atLine: lastLineNumberParsed]; + NSLog(@"****************** UPDATE EDITOR HIT ***********************"); +} + // kill process - (void) interrupt { From 87988f435cc923fc3b337f4c30575d48d887a01b Mon Sep 17 00:00:00 2001 From: Gregory John Casamento Date: Tue, 3 Aug 2021 17:16:26 -0400 Subject: [PATCH 02/15] Make update of file appear in the in-window editor instead of external editors --- Framework/PCEditorManager.m | 13 +++--- Framework/PCProjectEditor.m | 42 ++++++++++++++++++++ Headers/ProjectCenter/PCProjectEditor.h | 3 ++ Modules/Debuggers/ProjectCenter/PCDebugger.m | 2 - Modules/Editors/ProjectCenter/PCEditorView.m | 6 +-- 5 files changed, 54 insertions(+), 12 deletions(-) diff --git a/Framework/PCEditorManager.m b/Framework/PCEditorManager.m index 2c61808..e691d54 100644 --- a/Framework/PCEditorManager.m +++ b/Framework/PCEditorManager.m @@ -30,10 +30,12 @@ #import #import #import - +#import #import #import +#import + #import "Modules/Preferences/Misc/PCMiscPrefs.h" NSString *PCEditorDidChangeFileNameNotification = @@ -556,13 +558,10 @@ NSString *PCEditorDidResignActiveNotification = - (void)gotoFile: (NSString *)fileName atLine: (NSUInteger)line { - id editor = [self openEditorForFile: fileName - editable: YES - windowed: NO]; - PCProject *project = [_projectManager rootActiveProject]; - [[project projectBrowser] setPath: fileName]; - [_projectManager openFileAtPath: fileName]; + PCProjectEditor *pe = [project projectEditor]; + + id editor = [pe openEditorForFilePath: fileName windowed: NO]; // [self orderFrontEditorForFile:fileName]; [editor scrollToLineNumber: line]; diff --git a/Framework/PCProjectEditor.m b/Framework/PCProjectEditor.m index 989ed18..d743995 100644 --- a/Framework/PCProjectEditor.m +++ b/Framework/PCProjectEditor.m @@ -177,6 +177,48 @@ return NO; } +- (id) openEditorForFilePath: (NSString *)filePath + windowed: (BOOL)windowed +{ + PCProject *activeProject = [[_project projectManager] activeProject]; + NSString *fileName = [filePath lastPathComponent]; + BOOL editable = YES; + id editor = nil; + + NSLog(@"PCPE: fileName: %@, filePath: %@, project: %@", + fileName, filePath, [activeProject projectName]); + + // Determine if file should be opened for read only + if (![_project isEditableFile:fileName]) + { + editable = NO; + } + + // Set the 'editor' var either by requesting already opened + // editor or by creating the new one. + editor = [self openEditorForFile:filePath + editable:editable + windowed:windowed]; + if (!editor) + { + NSLog(@"We don't have editor for file: %@", fileName); + [self setActiveEditor: nil]; + return nil; + } + + // Category path was changed by user's clicking inside browser. + // That's why new category path must be transfered to editor. + NSString *categoryPath = [NSString stringWithFormat: @"/Classes/%@/", fileName]; + [editor setCategoryPath:categoryPath]; + [self orderFrontEditorForFile:filePath]; + + // Reload last column because editor has just been loaded + [[_project projectBrowser] reloadLastColumnAndNotify:NO]; + [editor fileStructureItemSelected:fileName]; + + return editor; +} + // Called by PCProjectBrowser // categoryPath: // 1. "/Classes/Class.m/- init" diff --git a/Headers/ProjectCenter/PCProjectEditor.h b/Headers/ProjectCenter/PCProjectEditor.h index d7d834b..4af6fe7 100644 --- a/Headers/ProjectCenter/PCProjectEditor.h +++ b/Headers/ProjectCenter/PCProjectEditor.h @@ -67,6 +67,9 @@ - (BOOL)editorProvidesBrowserItemsForItem:(NSString *)item; +- (id)openEditorForFilePath:(NSString *)categoryPath + windowed:(BOOL)windowed; + - (id)openEditorForCategoryPath:(NSString *)categoryPath windowed:(BOOL)windowed; diff --git a/Modules/Debuggers/ProjectCenter/PCDebugger.m b/Modules/Debuggers/ProjectCenter/PCDebugger.m index 5d5774e..8596280 100644 --- a/Modules/Debuggers/ProjectCenter/PCDebugger.m +++ b/Modules/Debuggers/ProjectCenter/PCDebugger.m @@ -312,13 +312,11 @@ NSString *PCDBDebuggerStartedNotification = @"PCDBDebuggerStartedNotification"; - (void) updateEditor { - NSLog(@"****************** UPDATE EDITOR HIT ***********************"); PCAppController *controller = (PCAppController *)[NSApp delegate]; PCProjectManager *pm = [controller projectManager]; PCEditorManager *em = [pm editorManager]; [em gotoFile: lastFileNameParsed atLine: lastLineNumberParsed]; - NSLog(@"****************** UPDATE EDITOR HIT ***********************"); } // kill process diff --git a/Modules/Editors/ProjectCenter/PCEditorView.m b/Modules/Editors/ProjectCenter/PCEditorView.m index 7ba2482..2c41b3e 100644 --- a/Modules/Editors/ProjectCenter/PCEditorView.m +++ b/Modules/Editors/ProjectCenter/PCEditorView.m @@ -183,7 +183,7 @@ static int ComputeIndentingOffset(NSString * string, unsigned int start) } } - NSLog(@"index: %i start: %i", index, line_start); + NSLog(@"index: %li start: %li", index, line_start); return line_start > index ? index : line_start; } @@ -311,7 +311,7 @@ static int ComputeIndentingOffset(NSString * string, unsigned int start) if (![wsCharSet characterIsMember:c]) { offset = offset - line_start; - NSLog(@"offset: %i", offset); + NSLog(@"offset: %li", offset); break; } } @@ -328,7 +328,7 @@ static int ComputeIndentingOffset(NSString * string, unsigned int start) // Get offset from BOL of previous line // offset = ComputeIndentingOffset([self string], line_start-1); - NSLog(@"Indent offset: %i", offset); + NSLog(@"Indent offset: %li", offset); // Replace current line whitespaces with new ones indentString = [[NSMutableString alloc] initWithString:@""]; From 736093b0c1977ffe1767cf0c127d115c87f1d831 Mon Sep 17 00:00:00 2001 From: Gregory John Casamento Date: Tue, 3 Aug 2021 18:48:00 -0400 Subject: [PATCH 03/15] Fix centering issue --- Framework/PCEditorManager.m | 21 --------------------- Framework/PCProjectEditor.m | 6 ++++++ Modules/Editors/ProjectCenter/PCEditor.m | 2 ++ 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/Framework/PCEditorManager.m b/Framework/PCEditorManager.m index e691d54..9e890bf 100644 --- a/Framework/PCEditorManager.m +++ b/Framework/PCEditorManager.m @@ -99,15 +99,6 @@ NSString *PCEditorDidResignActiveNotification = selector:@selector(editorDidChangeFileName:) name:PCEditorDidChangeFileNameNotification object:nil]; - - // Debugger - [[NSNotificationCenter defaultCenter] - addObserver:self - selector:@selector(debuggerDidHitBreakpoint:) - name:PCProjectBreakpointNotification - object:nil]; - - // Preferences } return self; @@ -544,18 +535,6 @@ NSString *PCEditorDidResignActiveNotification = [_editorsDict setObject:_editor forKey:_newFileName]; } -- (void)debuggerDidHitBreakpoint:(NSNotification *)aNotif -{ - id object = [aNotif object]; - NSString *filePath = [object objectForKey: @"file"]; - NSString *line = [object objectForKey: @"line"]; - id editor = [self openEditorForFile: filePath - editable: YES - windowed: NO]; - [self orderFrontEditorForFile:filePath]; - [editor scrollToLineNumber: [line integerValue]]; -} - - (void)gotoFile: (NSString *)fileName atLine: (NSUInteger)line { PCProject *project = [_projectManager rootActiveProject]; diff --git a/Framework/PCProjectEditor.m b/Framework/PCProjectEditor.m index d743995..db10092 100644 --- a/Framework/PCProjectEditor.m +++ b/Framework/PCProjectEditor.m @@ -184,10 +184,16 @@ NSString *fileName = [filePath lastPathComponent]; BOOL editable = YES; id editor = nil; + NSFileManager *mgr = [NSFileManager defaultManager]; NSLog(@"PCPE: fileName: %@, filePath: %@, project: %@", fileName, filePath, [activeProject projectName]); + if (![mgr fileExistsAtPath: filePath]) + { + return nil; + } + // Determine if file should be opened for read only if (![_project isEditableFile:fileName]) { diff --git a/Modules/Editors/ProjectCenter/PCEditor.m b/Modules/Editors/ProjectCenter/PCEditor.m index 3a0afb5..0b90ff7 100644 --- a/Modules/Editors/ProjectCenter/PCEditor.m +++ b/Modules/Editors/ProjectCenter/PCEditor.m @@ -1069,6 +1069,8 @@ { [_intEditorView goToLineNumber:lineNumber]; [_extEditorView goToLineNumber:lineNumber]; + [_intEditorView centerSelectionInVisibleArea: self]; + [_extEditorView centerSelectionInVisibleArea: self]; } @end From 0f6ce6ba95ad414a7a0ab4d33bf5c93b729fa1d9 Mon Sep 17 00:00:00 2001 From: armm77 Date: Sun, 8 Aug 2021 17:53:48 -0400 Subject: [PATCH 04/15] Centered information panel. --- PCInfoController.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PCInfoController.m b/PCInfoController.m index fee1c2f..0294bcb 100644 --- a/PCInfoController.m +++ b/PCInfoController.m @@ -61,7 +61,7 @@ // PCLogError(self, @"error loading Menu NIB file!"); return; } - + [infoWindow center]; [infoWindow makeKeyAndOrderFront:self]; [versionField setStringValue:[NSString stringWithFormat:@"Version %@", [infoDict objectForKey:@"ApplicationRelease"]]]; From c0742c88a3a2f0c00c904a4f89ca5fe5948be5f3 Mon Sep 17 00:00:00 2001 From: Gregory John Casamento Date: Tue, 10 Aug 2021 10:06:00 -0400 Subject: [PATCH 05/15] Changelog update --- ChangeLog | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/ChangeLog b/ChangeLog index 5c91b6d..08746cb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,23 @@ +2021-08-10 Gregory John Casamento + + * Framework/PCEditorManager.m: Add method -gotoFile:atLine: + * Framework/PCProjectEditor.m: Add method openEditorForFilePath:windowed: + * Framework/PCProjectManager.m: Add method openFileAtPath:windowed: + * Headers/ProjectCenter/PCEditorManager.h + * Headers/ProjectCenter/PCProjectEditor.h + * Headers/ProjectCenter/PCProjectManager.h: Declarations for above methods. + * Modules/Debuggers/ProjectCenter/GDBWrapper.h + * Modules/Debuggers/ProjectCenter/GDBWrapper.m: Add code to pull + "thread-selected" dictionary when the debugger stops by using break/pause + or by using up or down. Code to syncronize editor with where the debugger + has stopped. + * Modules/Debuggers/ProjectCenter/PCDebugger.h + * Modules/Debuggers/ProjectCenter/PCDebugger.m: updateEditor method. This + method makes use of the gotoFile:atLine: method to get the file and show it + in the code editor and go to the line where it has stopped. + * Modules/Editors/ProjectCenter/PCEditor.m: Update internal editor + * Modules/Editors/ProjectCenter/PCEditorView.m: minor bugfixes. + 2021-07-16 Riccardo Mottola * Modules/Debuggers/ProjectCenter/GDBWrapper.h From ffcf6cfff60332a5e375ddd7341b8ff1f40cc28c Mon Sep 17 00:00:00 2001 From: Gregory John Casamento Date: Wed, 11 Aug 2021 00:14:59 -0400 Subject: [PATCH 06/15] Add code to set environment explicitly to prevent build failure. --- ChangeLog | 23 +++++++++++++++++------ Framework/PCProjectBuilder.m | 12 ++++++++++++ 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 08746cb..dddf01a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,19 +1,30 @@ +2021-08-11 Gregory John Casamento + + * Framework/PCProjectBuilder.m: Fix issue where environment var + was causing build to fail. Explicitly set environment for NSTask + for build to prevent this problem. + 2021-08-10 Gregory John Casamento * Framework/PCEditorManager.m: Add method -gotoFile:atLine: - * Framework/PCProjectEditor.m: Add method openEditorForFilePath:windowed: + * Framework/PCProjectEditor.m: Add method openEditorForFilePath: + windowed: * Framework/PCProjectManager.m: Add method openFileAtPath:windowed: * Headers/ProjectCenter/PCEditorManager.h * Headers/ProjectCenter/PCProjectEditor.h - * Headers/ProjectCenter/PCProjectManager.h: Declarations for above methods. + * Headers/ProjectCenter/PCProjectManager.h: Declarations for above + methods. * Modules/Debuggers/ProjectCenter/GDBWrapper.h * Modules/Debuggers/ProjectCenter/GDBWrapper.m: Add code to pull - "thread-selected" dictionary when the debugger stops by using break/pause - or by using up or down. Code to syncronize editor with where the debugger + "thread-selected" dictionary when the debugger stops by using + break/pause + or by using up or down. Code to syncronize editor with where the + debugger has stopped. * Modules/Debuggers/ProjectCenter/PCDebugger.h - * Modules/Debuggers/ProjectCenter/PCDebugger.m: updateEditor method. This - method makes use of the gotoFile:atLine: method to get the file and show it + * Modules/Debuggers/ProjectCenter/PCDebugger.m: updateEditor method. + This method makes use of the gotoFile:atLine: method to get the + file and show it in the code editor and go to the line where it has stopped. * Modules/Editors/ProjectCenter/PCEditor.m: Update internal editor * Modules/Editors/ProjectCenter/PCEditorView.m: minor bugfixes. diff --git a/Framework/PCProjectBuilder.m b/Framework/PCProjectBuilder.m index e6db521..0cfd57a 100644 --- a/Framework/PCProjectBuilder.m +++ b/Framework/PCProjectBuilder.m @@ -596,13 +596,25 @@ name:NSTaskDidTerminateNotification object:nil]; + NSMutableDictionary *env = [[NSMutableDictionary alloc] init]; + + // optionally copy in existing environment first: + // (we could also copy values for a limited set of specific keys, if we wanted.) + [env addEntriesFromDictionary:[[NSProcessInfo processInfo] environment]]; + // then add/remove anything else we might want: + [env removeObjectForKey:@"GNUSTEP_USER_ROOT"]; + makeTask = [[NSTask alloc] init]; + // now set the task up to use this newly-built environment: + [makeTask setEnvironment:env]; [makeTask setArguments:buildArgs]; [makeTask setCurrentDirectoryPath:[project projectPath]]; [makeTask setLaunchPath:buildTool]; [makeTask setStandardOutput:stdOutPipe]; [makeTask setStandardError:stdErrorPipe]; + NSLog(@"buildArgs = %@, buildTool = %@, projectPath = %@", buildArgs, buildTool, [project projectPath]); + [self logBuildString: [NSString stringWithFormat:@"=== %@ started ===", buildStatusTarget] newLine:YES]; From 0bce14634746c3102ed4d9c639887271726f802e Mon Sep 17 00:00:00 2001 From: Gregory John Casamento Date: Wed, 11 Aug 2021 00:17:59 -0400 Subject: [PATCH 07/15] Add codeowners file --- CODEOWNERS | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 CODEOWNERS diff --git a/CODEOWNERS b/CODEOWNERS new file mode 100644 index 0000000..66ab87c --- /dev/null +++ b/CODEOWNERS @@ -0,0 +1,5 @@ +# These owners will be the default owners for everything in +# the repo. Unless a later match takes precedence, +# @global-owner1 and @global-owner2 will be requested for +# review when someone opens a pull request. +* @rmottola From 538016b3722554d689ec3c1485960f93dfbec145 Mon Sep 17 00:00:00 2001 From: Riccardo Mottola Date: Mon, 16 Aug 2021 15:45:53 +0200 Subject: [PATCH 08/15] Revert "Merge branch 'dock_fix'" This commit is a hack, for an unclean environment. It is especially bad to copy an environment and then remove just a single environment variable. This reverts commit 82d4d12f82c16bdeb13000aeac0a787bcf3fed8d, reversing changes made to 0bce14634746c3102ed4d9c639887271726f802e. --- ChangeLog | 23 ++++++----------------- Framework/PCProjectBuilder.m | 12 ------------ 2 files changed, 6 insertions(+), 29 deletions(-) diff --git a/ChangeLog b/ChangeLog index dddf01a..08746cb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,30 +1,19 @@ -2021-08-11 Gregory John Casamento - - * Framework/PCProjectBuilder.m: Fix issue where environment var - was causing build to fail. Explicitly set environment for NSTask - for build to prevent this problem. - 2021-08-10 Gregory John Casamento * Framework/PCEditorManager.m: Add method -gotoFile:atLine: - * Framework/PCProjectEditor.m: Add method openEditorForFilePath: - windowed: + * Framework/PCProjectEditor.m: Add method openEditorForFilePath:windowed: * Framework/PCProjectManager.m: Add method openFileAtPath:windowed: * Headers/ProjectCenter/PCEditorManager.h * Headers/ProjectCenter/PCProjectEditor.h - * Headers/ProjectCenter/PCProjectManager.h: Declarations for above - methods. + * Headers/ProjectCenter/PCProjectManager.h: Declarations for above methods. * Modules/Debuggers/ProjectCenter/GDBWrapper.h * Modules/Debuggers/ProjectCenter/GDBWrapper.m: Add code to pull - "thread-selected" dictionary when the debugger stops by using - break/pause - or by using up or down. Code to syncronize editor with where the - debugger + "thread-selected" dictionary when the debugger stops by using break/pause + or by using up or down. Code to syncronize editor with where the debugger has stopped. * Modules/Debuggers/ProjectCenter/PCDebugger.h - * Modules/Debuggers/ProjectCenter/PCDebugger.m: updateEditor method. - This method makes use of the gotoFile:atLine: method to get the - file and show it + * Modules/Debuggers/ProjectCenter/PCDebugger.m: updateEditor method. This + method makes use of the gotoFile:atLine: method to get the file and show it in the code editor and go to the line where it has stopped. * Modules/Editors/ProjectCenter/PCEditor.m: Update internal editor * Modules/Editors/ProjectCenter/PCEditorView.m: minor bugfixes. diff --git a/Framework/PCProjectBuilder.m b/Framework/PCProjectBuilder.m index 0cfd57a..e6db521 100644 --- a/Framework/PCProjectBuilder.m +++ b/Framework/PCProjectBuilder.m @@ -596,25 +596,13 @@ name:NSTaskDidTerminateNotification object:nil]; - NSMutableDictionary *env = [[NSMutableDictionary alloc] init]; - - // optionally copy in existing environment first: - // (we could also copy values for a limited set of specific keys, if we wanted.) - [env addEntriesFromDictionary:[[NSProcessInfo processInfo] environment]]; - // then add/remove anything else we might want: - [env removeObjectForKey:@"GNUSTEP_USER_ROOT"]; - makeTask = [[NSTask alloc] init]; - // now set the task up to use this newly-built environment: - [makeTask setEnvironment:env]; [makeTask setArguments:buildArgs]; [makeTask setCurrentDirectoryPath:[project projectPath]]; [makeTask setLaunchPath:buildTool]; [makeTask setStandardOutput:stdOutPipe]; [makeTask setStandardError:stdErrorPipe]; - NSLog(@"buildArgs = %@, buildTool = %@, projectPath = %@", buildArgs, buildTool, [project projectPath]); - [self logBuildString: [NSString stringWithFormat:@"=== %@ started ===", buildStatusTarget] newLine:YES]; From 994aff232c2ac2d16cc3c8a5fca1dfa3383af064 Mon Sep 17 00:00:00 2001 From: Riccardo Date: Wed, 18 Aug 2021 19:16:05 +0200 Subject: [PATCH 09/15] Revert "Centered information panel." --- PCInfoController.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PCInfoController.m b/PCInfoController.m index 0294bcb..fee1c2f 100644 --- a/PCInfoController.m +++ b/PCInfoController.m @@ -61,7 +61,7 @@ // PCLogError(self, @"error loading Menu NIB file!"); return; } - [infoWindow center]; + [infoWindow makeKeyAndOrderFront:self]; [versionField setStringValue:[NSString stringWithFormat:@"Version %@", [infoDict objectForKey:@"ApplicationRelease"]]]; From d49d4d6e5f1407289e69ff9ad2141f92152fa4d6 Mon Sep 17 00:00:00 2001 From: Riccardo Mottola Date: Wed, 18 Aug 2021 23:11:45 +0200 Subject: [PATCH 10/15] cleanup inforpanel init and proper centering --- ChangeLog | 5 +++++ PCInfoController.m | 29 +++++++---------------------- 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/ChangeLog b/ChangeLog index 08746cb..4677521 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2021-08-18 Riccardo Mottola + + * PCInfoContronoller.m + Center info panel correctly the first time on load. + 2021-08-10 Gregory John Casamento * Framework/PCEditorManager.m: Add method -gotoFile:atLine: diff --git a/PCInfoController.m b/PCInfoController.m index fee1c2f..15c15e3 100644 --- a/PCInfoController.m +++ b/PCInfoController.m @@ -37,6 +37,13 @@ infoDict = [NSDictionary dictionaryWithContentsOfFile:file]; RETAIN(infoDict); + + if ([NSBundle loadNibNamed:@"Info" owner:self] == NO) + { + return nil; + } + [versionField setStringValue:[NSString stringWithFormat:@"Version %@", [infoDict objectForKey:@"ApplicationRelease"]]]; + [infoWindow center]; } return self; @@ -56,29 +63,7 @@ - (void)showInfoWindow:(id)sender { - if ([NSBundle loadNibNamed:@"Info" owner:self] == NO) - { -// PCLogError(self, @"error loading Menu NIB file!"); - return; - } - [infoWindow makeKeyAndOrderFront:self]; - [versionField setStringValue:[NSString stringWithFormat:@"Version %@", [infoDict objectForKey:@"ApplicationRelease"]]]; - -/*#if defined(GNUSTEP) - if (!infoWindow) - { - infoWindow = [[GSInfoPanel alloc] initWithDictionary:infoDict]; - } - - [infoWindow setTitle:@"Info"]; - [infoWindow center]; - [infoWindow makeKeyAndOrderFront:self]; -#else - NSRunAlertPanel(@"Info", - @"OPENSTEP has no support for GSInfoPanel", - @"OK",nil,nil,nil); -#endif*/ } @end From b3fa5f19495ee7e87fa6f280771089d7970a7083 Mon Sep 17 00:00:00 2001 From: Riccardo Mottola Date: Thu, 19 Aug 2021 14:50:58 +0200 Subject: [PATCH 11/15] turn off ligatures in the code editor --- ChangeLog | 6 ++++++ Modules/Editors/ProjectCenter/PCEditor.m | 3 +++ 2 files changed, 9 insertions(+) diff --git a/ChangeLog b/ChangeLog index 4677521..5f24604 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2021-08-18 Riccardo Mottola + + * Modules/Editors/ProjectCenter/PCEditor.m + Turn off ligatures, both when setting up the editor as well as when + loading a file. + 2021-08-18 Riccardo Mottola * PCInfoContronoller.m diff --git a/Modules/Editors/ProjectCenter/PCEditor.m b/Modules/Editors/ProjectCenter/PCEditor.m index add31b3..750612d 100644 --- a/Modules/Editors/ProjectCenter/PCEditor.m +++ b/Modules/Editors/ProjectCenter/PCEditor.m @@ -170,6 +170,7 @@ tSelCol, NSForegroundColorAttributeName, nil]; [ev setSelectedTextAttributes:selAttributes]; + [ev turnOffLigatures:self]; // Activate undo [ev setAllowsUndo: YES]; @@ -321,6 +322,8 @@ [attributes setObject:font forKey:NSFontAttributeName]; [attributes setObject:textBackground forKey:NSBackgroundColorAttributeName]; [attributes setObject:[prefs colorForKey:EditorForegroundColor defaultValue:textColor] forKey:NSForegroundColorAttributeName]; + [attributes setObject:[NSNumber numberWithInt: 0] // disable ligatures + forKey:NSLigatureAttributeName]; text = [NSString stringWithContentsOfFile:_path]; attributedString = [attributedString initWithString:text attributes:attributes]; From b701d1a40b1fecb3cdc2078683439f738f90d9ea Mon Sep 17 00:00:00 2001 From: Riccardo Mottola Date: Thu, 19 Aug 2021 14:57:24 +0200 Subject: [PATCH 12/15] also keep ligatures off when reverting --- Modules/Editors/ProjectCenter/PCEditor.m | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Modules/Editors/ProjectCenter/PCEditor.m b/Modules/Editors/ProjectCenter/PCEditor.m index 750612d..3732c78 100644 --- a/Modules/Editors/ProjectCenter/PCEditor.m +++ b/Modules/Editors/ProjectCenter/PCEditor.m @@ -766,7 +766,11 @@ // This is temporary ft = [NSFont userFixedPitchFontOfSize:0.0]; - at = [NSDictionary dictionaryWithObject:ft forKey:NSFontAttributeName]; + at = [NSDictionary dictionaryWithObjectsAndKeys: + ft, NSFontAttributeName, + [NSNumber numberWithInt: 0], NSLigatureAttributeName, + nil]; + as = [[NSAttributedString alloc] initWithString:text attributes:at]; [self setIsEdited:NO]; From aa76e6406cdf59193697dfb7905558b64c54aeb5 Mon Sep 17 00:00:00 2001 From: Gregory John Casamento Date: Sun, 29 Aug 2021 06:44:08 -0400 Subject: [PATCH 13/15] Release infoController and projectManager --- PCAppController.m | 2 ++ 1 file changed, 2 insertions(+) diff --git a/PCAppController.m b/PCAppController.m index f4120b8..0e903b6 100644 --- a/PCAppController.m +++ b/PCAppController.m @@ -64,6 +64,8 @@ - (void)dealloc { + RELEASE(infoController); + RELEASE(projectManager); [super dealloc]; } From bae62a963b76882d7de9c264ec79f57e176d0d4a Mon Sep 17 00:00:00 2001 From: Riccardo Mottola Date: Thu, 16 Sep 2021 00:52:15 +0200 Subject: [PATCH 14/15] actually store the preference color in textColor ivar --- Modules/Editors/ProjectCenter/PCEditor.m | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Modules/Editors/ProjectCenter/PCEditor.m b/Modules/Editors/ProjectCenter/PCEditor.m index 3732c78..35759e9 100644 --- a/Modules/Editors/ProjectCenter/PCEditor.m +++ b/Modules/Editors/ProjectCenter/PCEditor.m @@ -319,9 +319,11 @@ textBackground = readOnlyColor; } + textColor = [prefs colorForKey:EditorForegroundColor defaultValue:textColor]; + [attributes setObject:font forKey:NSFontAttributeName]; [attributes setObject:textBackground forKey:NSBackgroundColorAttributeName]; - [attributes setObject:[prefs colorForKey:EditorForegroundColor defaultValue:textColor] forKey:NSForegroundColorAttributeName]; + [attributes setObject:textColor forKey:NSForegroundColorAttributeName]; [attributes setObject:[NSNumber numberWithInt: 0] // disable ligatures forKey:NSLigatureAttributeName]; From aff171ceff13334a9231497f1ec91d83d6e89b03 Mon Sep 17 00:00:00 2001 From: Riccardo Mottola Date: Fri, 17 Sep 2021 00:53:40 +0200 Subject: [PATCH 15/15] instead of using getLineStart which returns a character after scanning lines, we directly scan lines and count the newlines, so the string is needs to be scanned once only to know hoe many newlines. Some IMP caching to improve this ineffcient o(n) at every cursor movement --- Modules/Editors/ProjectCenter/PCEditor.m | 37 +++++++++++++++++++----- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/Modules/Editors/ProjectCenter/PCEditor.m b/Modules/Editors/ProjectCenter/PCEditor.m index 35759e9..2c93504 100644 --- a/Modules/Editors/ProjectCenter/PCEditor.m +++ b/Modules/Editors/ProjectCenter/PCEditor.m @@ -967,15 +967,36 @@ if ([object isKindOfClass:[NSTextView class]]) { NSTextView *tv = (NSTextView *)object; - NSArray *selArray; - NSRange lastSelection; - NSRange selRange; - NSUInteger selLine; + NSString *str = [tv string]; + NSRange selection; + NSUInteger selLine = NSNotFound; - selArray = [tv selectedRanges]; - lastSelection = [[selArray lastObject] rangeValue]; - NSLog(@"last selection is %@", [selArray lastObject]); - [[tv string] getLineStart:NULL end:&selLine contentsEnd:NULL forRange:lastSelection]; + // for speed reasons we cache [NSString characterAtIndex:index] + SEL charAtIndexSel = @selector(characterAtIndex:); + unichar (*charAtIndexFunc)(NSString *, SEL, NSUInteger); + charAtIndexFunc = (unichar (*)())[str methodForSelector:charAtIndexSel]; + + selection = [tv selectedRange]; + // now we calculate given the selection the line count, splitting on \n + // calling lineRangeForRange / paragraphForRange does the same thing + // we want to avoid to scan the string twice + { + NSUInteger i; + unichar ch; + NSUInteger nlCount; + + nlCount = 0; + for (i = 0; i < selection.location; i++) + { + // ch = [str characterAtIndex:i]; + ch = (*charAtIndexFunc)(str, charAtIndexSel, i); + if (ch == (unichar)0x000A) // new line + nlCount++; + } + + selLine = nlCount + 1; + } + NSLog(@"%u corresponds to %u", selection.location, selLine); } }