From 3740643f6bf479c90b164d8825a77c2061d6cad6 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Wed, 2 Apr 2008 16:29:22 -0400 Subject: [PATCH] Add support for removing a breakpoint * Source/BSLineNumberView.m: ([BSLineNumberView drawRect:]): Remove an NSLog() * Source/BreakpointManager.m: ([BreakpointManager removeBreakpointAt:inFile:]): New method * Source/DebuggerWindowController.m: ([DebuggerWindowController gutterClickedAtLine:forFile:]): Add support for removing breakpoints --- Source/BSLineNumberView.m | 1 - Source/BreakpointManager.h | 1 + Source/BreakpointManager.m | 16 ++++++++++++++++ Source/DebuggerWindowController.m | 14 ++++++++++++-- 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/Source/BSLineNumberView.m b/Source/BSLineNumberView.m index 67cffc9..59cbd29 100644 --- a/Source/BSLineNumberView.m +++ b/Source/BSLineNumberView.m @@ -88,7 +88,6 @@ if ([markers containsObject:[[Breakpoint alloc] initWithLine:line inFile:[sourceView file]]]) { [self drawMarkerInRect:fragRect]; - NSLog(@"marking %i", line); } } diff --git a/Source/BreakpointManager.h b/Source/BreakpointManager.h index e5bca81..81af299 100644 --- a/Source/BreakpointManager.h +++ b/Source/BreakpointManager.h @@ -24,6 +24,7 @@ + (BreakpointManager *)sharedManager; - (void)addBreakpoint:(Breakpoint *)bp; +- (void)removeBreakpointAt:(int)line inFile:(NSString *)file; - (NSSet *)breakpointsForFile:(NSString *)file; - (BOOL)hasBreakpointAt:(int)line inFile:(NSString *)file; diff --git a/Source/BreakpointManager.m b/Source/BreakpointManager.m index c840fa0..8226917 100644 --- a/Source/BreakpointManager.m +++ b/Source/BreakpointManager.m @@ -62,6 +62,22 @@ NSLog(@"breakpoints = %@", breakpoints); } +/** + * Removes a breakpoint at a given line/file combination + */ +- (void)removeBreakpointAt:(int)line inFile:(NSString *)file +{ + NSMutableSet *lines = [breakpoints valueForKey:file]; + for (Breakpoint *b in lines) + { + if ([b line] == line) + { + [lines removeObject:b]; + return; + } + } +} + /** * Returns all the breakpoints for a given file */ diff --git a/Source/DebuggerWindowController.m b/Source/DebuggerWindowController.m index 6814c9e..11d160a 100644 --- a/Source/DebuggerWindowController.m +++ b/Source/DebuggerWindowController.m @@ -273,8 +273,18 @@ */ - (void)gutterClickedAtLine:(int)line forFile:(NSString *)file { - [[BreakpointManager sharedManager] addBreakpoint:[[Breakpoint alloc] initWithLine:line inFile:file]]; - [[sourceViewer numberView] setMarkers:[[BreakpointManager sharedManager] breakpointsForFile:file]]; + BreakpointManager *mngr = [BreakpointManager sharedManager]; + + if ([mngr hasBreakpointAt:line inFile:file]) + { + [mngr removeBreakpointAt:line inFile:file]; + } + else + { + [mngr addBreakpoint:[[Breakpoint alloc] initWithLine:line inFile:file]]; + } + + [[sourceViewer numberView] setMarkers:[mngr breakpointsForFile:file]]; [[sourceViewer numberView] setNeedsDisplay:YES]; } -- 2.43.5