3 * Copyright (c) 2007 - 2011, Blue Static <http://www.bluestatic.org>
5 * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
6 * General Public License as published by the Free Software Foundation; either version 2 of the
7 * License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
10 * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public License along with this program; if not,
14 * write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 #import "BreakpointController.h"
19 #import "AppDelegate.h"
20 #import "PreferenceNames.h"
22 @implementation BreakpointController
{
23 BreakpointManager
* _manager
;
25 BSSourceView
* _sourceView
;
26 NSArrayController
* _arrayController
;
32 - (instancetype
)initWithBreakpointManager
:(BreakpointManager
*)breakpointManager
33 sourceView
:(BSSourceView
*)sourceView
35 if ((self = [super initWithNibName
:@
"Breakpoints" bundle
:nil])) {
36 _manager
= breakpointManager
;
37 _sourceView
= sourceView
;
43 * Adds a breakpoint by calling up a file chooser and selecting a file for
46 - (IBAction
)addBreakpoint
:(id)sender
48 NSOpenPanel
* panel
= [NSOpenPanel openPanel
];
50 if ([panel runModal
] != NSOKButton
)
55 [_sourceView setFile
:[[panel URL
] path
]];
59 * Removes a breakpoint
61 - (IBAction
)removeBreakpoint
:(id)sender
63 NSArray
* selection
= [_arrayController selectedObjects
];
64 if ([selection count
] < 1)
69 for (Breakpoint
* bp
in selection
)
71 [_manager removeBreakpointAt
:[bp line
] inFile
:[bp file
]];
75 #pragma mark NSTableView Delegate
78 * NSTableView delegate method that informs the controller that the stack selection did change and that
79 * we should update the source viewer
81 - (void)tableViewSelectionDidChange
:(NSNotification
*)notif
83 NSArray
* selection
= [_arrayController selectedObjects
];
84 if ([selection count
] < 1)
89 Breakpoint
* bp
= [selection objectAtIndex
:0];
90 [_sourceView setFile
:[bp file
]];
91 [_sourceView scrollToLine
:[bp line
]];
92 [_sourceView setMarkers
:[_manager breakpointsForFile
:bp.file
]];
95 #pragma mark BSSourceView Delegate
98 * Accepts a file dragged to set the contents of the display.
100 - (BOOL)sourceView
:(BSSourceView
*)sv acceptsDropOfFile
:(NSString
*)filename