From ae30058e9ff5fa7c8fa0273d5c747156269ce736 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sun, 4 Dec 2016 00:41:49 -0500 Subject: [PATCH] Remove the dedicated Breakpoints source view. Use the same source view for the stack as the breakpoints. --- English.lproj/Breakpoints.xib | 204 +++++++++++++++------------------- Source/BreakpointController.h | 11 +- Source/BreakpointController.m | 48 +++----- Source/BreakpointManager.m | 8 +- Source/DebuggerController.m | 2 +- 5 files changed, 116 insertions(+), 157 deletions(-) diff --git a/English.lproj/Breakpoints.xib b/English.lproj/Breakpoints.xib index 774a213..832ff6a 100644 --- a/English.lproj/Breakpoints.xib +++ b/English.lproj/Breakpoints.xib @@ -9,7 +9,6 @@ - @@ -18,128 +17,105 @@ - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + file line - + diff --git a/Source/BreakpointController.h b/Source/BreakpointController.h index c5c4069..c19f83e 100644 --- a/Source/BreakpointController.h +++ b/Source/BreakpointController.h @@ -20,15 +20,10 @@ #import "BSSourceView.h" @interface BreakpointController : NSViewController -{ - BreakpointManager* manager; - - IBOutlet NSArrayController* arrayController; - IBOutlet BSSourceView* sourceView; -} -@property(readonly) BSSourceView* sourceView; -@property(readonly) NSArrayController* arrayController; +@property(nonatomic, assign) IBOutlet NSArrayController* arrayController; + +- (instancetype)initWithSourceView:(BSSourceView*)sourceView; - (IBAction)addBreakpoint:(id)sender; - (IBAction)removeBreakpoint:(id)sender; diff --git a/Source/BreakpointController.m b/Source/BreakpointController.m index 1b71ce2..318422d 100644 --- a/Source/BreakpointController.m +++ b/Source/BreakpointController.m @@ -19,18 +19,21 @@ #import "AppDelegate.h" #import "PreferenceNames.h" -@implementation BreakpointController +@implementation BreakpointController { + BreakpointManager* _manager; -@synthesize sourceView, arrayController; + BSSourceView* _sourceView; + NSArrayController* _arrayController; +} /** * Constructor */ -- (id)init +- (id)initWithSourceView:(BSSourceView*)sourceView { - if (self = [super initWithNibName:@"Breakpoints" bundle:nil]) - { - manager = [BreakpointManager sharedManager]; + if ((self = [super initWithNibName:@"Breakpoints" bundle:nil])) { + _manager = [BreakpointManager sharedManager]; + _sourceView = sourceView; } return self; } @@ -48,7 +51,7 @@ return; } - [sourceView setFile:[[panel URL] path]]; + [_sourceView setFile:[[panel URL] path]]; } /** @@ -56,7 +59,7 @@ */ - (IBAction)removeBreakpoint:(id)sender { - NSArray* selection = [arrayController selectedObjects]; + NSArray* selection = [_arrayController selectedObjects]; if ([selection count] < 1) { return; @@ -64,7 +67,7 @@ for (Breakpoint* bp in selection) { - [manager removeBreakpointAt:[bp line] inFile:[bp file]]; + [_manager removeBreakpointAt:[bp line] inFile:[bp file]]; } } @@ -76,39 +79,20 @@ */ - (void)tableViewSelectionDidChange:(NSNotification*)notif { - NSArray* selection = [arrayController selectedObjects]; + NSArray* selection = [_arrayController selectedObjects]; if ([selection count] < 1) { return; } Breakpoint* bp = [selection objectAtIndex:0]; - [sourceView setFile:[bp file]]; - [sourceView scrollToLine:[bp line]]; - [sourceView setMarkers:[manager breakpointsForFile:bp.file]]; + [_sourceView setFile:[bp file]]; + [_sourceView scrollToLine:[bp line]]; + [_sourceView setMarkers:[_manager breakpointsForFile:bp.file]]; } #pragma mark BSSourceView Delegate -/** - * The gutter was clicked, which indicates that a breakpoint needs to be changed - */ -- (void)gutterClickedAtLine:(NSUInteger)line forFile:(NSString*)file -{ - if ([manager hasBreakpointAt:line inFile:file]) - { - [manager removeBreakpointAt:line inFile:file]; - } - else - { - Breakpoint* bp = [[Breakpoint alloc] initWithLine:line inFile:file]; - [manager addBreakpoint:bp]; - [bp release]; - } - - [sourceView setMarkers:[manager breakpointsForFile:file]]; -} - /** * Accepts a file dragged to set the contents of the display. */ diff --git a/Source/BreakpointManager.m b/Source/BreakpointManager.m index 2a3e2c0..64ff5f6 100644 --- a/Source/BreakpointManager.m +++ b/Source/BreakpointManager.m @@ -75,7 +75,10 @@ { if (![breakpoints containsObject:bp]) { + [self willChangeValueForKey:@"breakpoints"]; [breakpoints addObject:bp]; + [self didChangeValueForKey:@"breakpoints"]; + [connection addBreakpoint:bp]; [savedBreakpoints addObject:[bp dictionary]]; @@ -98,7 +101,10 @@ // array. [[b retain] autorelease]; + [self willChangeValueForKey:@"breakpoints"]; [breakpoints removeObject:b]; + [self didChangeValueForKey:@"breakpoints"]; + [connection removeBreakpoint:b]; [savedBreakpoints removeObject:[b dictionary]]; @@ -144,8 +150,6 @@ { AppDelegate* appDel = [NSApp delegate]; [[[appDel breakpoint] arrayController] rearrangeObjects]; - [[[appDel breakpoint] sourceView] setNeedsDisplay:YES]; - [[[appDel breakpoint] sourceView] setMarkers:[self breakpointsForFile:file]]; [[[appDel debugger] sourceViewer] setNeedsDisplay:YES]; [[[appDel debugger] sourceViewer] setMarkers:[self breakpointsForFile:file]]; } diff --git a/Source/DebuggerController.m b/Source/DebuggerController.m index 352eecb..b6a3e43 100644 --- a/Source/DebuggerController.m +++ b/Source/DebuggerController.m @@ -101,7 +101,7 @@ self.connection.autoAttach = [attachedCheckbox_ state] == NSOnState; // Load view controllers into the tab views. - _breakpointsController = [[BreakpointController alloc] init]; + _breakpointsController = [[BreakpointController alloc] initWithSourceView:sourceViewer]; [[self.tabView tabViewItemAtIndex:1] setView:_breakpointsController.view]; _evalController = [[EvalController alloc] initWithBackEnd:connection]; -- 2.43.5