From bfadad26e2d3a9a9def30c4597497d4d976106ed Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Thu, 12 Jun 2008 11:31:53 -0400 Subject: [PATCH] The breakpoint manager now works -- breakpoints can be set from the main debugger or the manager * English.lproj/Breakpoints.xib: Set the NSTableView's delegate to be File's Owner and disconnect the content IBO to the NS-AC * Source/BreakpointManager.m: (updateDisplaysForfile:): New private method (addBreakpoint:): Call [updateDisplaysForfile:] (removeBreakpointAt:inFile:): ditto * BreakpointWindowController.m+h: Add props and synth them for sourceView and arrayController ivars (removeBreakpoint:): Fill out method stub (tableViewSelectionDidChange:): Implement delegate method * DebuggerWindowController.m+h: Add prop/synth for sourceViewer ivar --- English.lproj/Breakpoints.xib | 20 ++++++++++---------- Source/BreakpointManager.m | 24 ++++++++++++++++++++++++ Source/BreakpointWindowController.h | 3 +++ Source/BreakpointWindowController.m | 25 ++++++++++++++++++++++++- Source/DebuggerWindowController.h | 1 + Source/DebuggerWindowController.m | 2 +- 6 files changed, 63 insertions(+), 12 deletions(-) diff --git a/English.lproj/Breakpoints.xib b/English.lproj/Breakpoints.xib index 9f6e861..c0fa433 100644 --- a/English.lproj/Breakpoints.xib +++ b/English.lproj/Breakpoints.xib @@ -8,7 +8,7 @@ 352.00 YES - + YES @@ -375,14 +375,6 @@ 30 - - - content - - - - 34 - arrayController @@ -439,6 +431,14 @@ 41 + + + delegate + + + + 42 + @@ -701,7 +701,7 @@ - 41 + 42 diff --git a/Source/BreakpointManager.m b/Source/BreakpointManager.m index 0b2e431..a592959 100644 --- a/Source/BreakpointManager.m +++ b/Source/BreakpointManager.m @@ -15,6 +15,11 @@ */ #import "BreakpointManager.h" +#import "AppDelegate.h" + +@interface BreakpointManager (Private) +- (void)updateDisplaysForFile:(NSString *)file; +@end @implementation BreakpointManager @@ -57,6 +62,8 @@ { [breakpoints addObject:bp]; [connection addBreakpoint:bp]; + + [self updateDisplaysForFile:[bp file]]; } } @@ -71,6 +78,7 @@ { [breakpoints removeObject:b]; [connection removeBreakpoint:b]; + [self updateDisplaysForFile:file]; return b; } } @@ -102,4 +110,20 @@ return [breakpoints containsObject:[[Breakpoint alloc] initWithLine:line inFile:file]]; } +#pragma mark Private + +/** + * This marks BSSourceView needsDisplay, rearranges the objects in the breakpoints controller, + * and sets the markers for the BSLineNumberView + */ +- (void)updateDisplaysForFile:(NSString *)file +{ + AppDelegate *appDel = [NSApp delegate]; + [[[appDel breakpoint] arrayController] rearrangeObjects]; + [[[appDel breakpoint] sourceView] setNeedsDisplay:YES]; + [[[[appDel breakpoint] sourceView] numberView] setMarkers:[NSSet setWithArray:[self breakpointsForFile:file]]]; + [[[appDel debugger] sourceViewer] setNeedsDisplay:YES]; + [[[[appDel debugger] sourceViewer] numberView] setMarkers:[NSSet setWithArray:[self breakpointsForFile:file]]]; +} + @end diff --git a/Source/BreakpointWindowController.h b/Source/BreakpointWindowController.h index 9441cf5..f7c66a5 100644 --- a/Source/BreakpointWindowController.h +++ b/Source/BreakpointWindowController.h @@ -26,6 +26,9 @@ IBOutlet BSSourceView *sourceView; } +@property(readonly) BSSourceView *sourceView; +@property(readonly) NSArrayController *arrayController; + - (IBAction)addBreakpoint:(id)sender; - (IBAction)removeBreakpoint:(id)sender; diff --git a/Source/BreakpointWindowController.m b/Source/BreakpointWindowController.m index 531bed4..ed088f2 100644 --- a/Source/BreakpointWindowController.m +++ b/Source/BreakpointWindowController.m @@ -15,10 +15,13 @@ */ #import "BreakpointWindowController.h" +#import "AppDelegate.h" @implementation BreakpointWindowController +@synthesize sourceView, arrayController; + /** * Constructor */ @@ -31,7 +34,6 @@ return self; } - /** * Adds a breakpoint by calling up a file chooser and selecting a file for * breaking in @@ -53,7 +55,28 @@ */ - (IBAction)removeBreakpoint:(id)sender { + Breakpoint *bp = [[arrayController selectedObjects] objectAtIndex:0]; + [manager removeBreakpointAt:[bp line] inFile:[bp file]]; +} + +#pragma mark NSTableView Delegate + +/** + * NSTableView delegate method that informs the controller that the stack selection did change and that + * we should update the source viewer + */ +- (void)tableViewSelectionDidChange:(NSNotification *)notif +{ + NSArray *selection = [arrayController selectedObjects]; + if ([selection count] < 1) + { + return; + } + Breakpoint *bp = [selection objectAtIndex:0]; + [sourceView setFile:[bp file]]; + [sourceView scrollToLine:[bp line]]; + [[sourceView numberView] setMarkers:[NSSet setWithArray:[manager breakpointsForFile:[bp file]]]]; } #pragma mark BSSourceView Delegate diff --git a/Source/DebuggerWindowController.h b/Source/DebuggerWindowController.h index 29f1f84..ddfe46a 100644 --- a/Source/DebuggerWindowController.h +++ b/Source/DebuggerWindowController.h @@ -43,6 +43,7 @@ } @property(readonly) DebuggerConnection *connection; +@property(readonly) BSSourceView *sourceViewer; - (id)initWithPort:(int)aPort session:(NSString *)aSession; diff --git a/Source/DebuggerWindowController.m b/Source/DebuggerWindowController.m index c2e1533..069f77b 100644 --- a/Source/DebuggerWindowController.m +++ b/Source/DebuggerWindowController.m @@ -26,7 +26,7 @@ @implementation DebuggerWindowController -@synthesize connection; +@synthesize connection, sourceViewer; /** * Initializes the window controller and sets the connection -- 2.22.5