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"
18 #import "AppDelegate.h"
21 @implementation BreakpointController
23 @synthesize tableView
= tableView_
;
24 @synthesize arrayController
= arrayController_
;
25 @synthesize sourceView
= sourceView_
;
32 if (self = [super initWithWindowNibName
:@
"Breakpoints"])
34 manager
= [BreakpointManager sharedManager
];
35 if ([[NSUserDefaults standardUserDefaults
] boolForKey
:@
"BreakpointsWindowVisible"])
36 [[self window
] orderBack
:nil];
49 * Adds a breakpoint by calling up a file chooser and selecting a file for
52 - (IBAction
)addBreakpoint
:(id)sender
54 NSOpenPanel
* panel
= [NSOpenPanel openPanel
];
56 if ([panel runModal
] != NSOKButton
)
59 [sourceView_ setFile
:[panel filename
]];
63 * Removes a breakpoint
65 - (IBAction
)removeBreakpoint
:(id)sender
67 NSArray
* selection
= [arrayController_ selectedObjects
];
68 if ([selection count
] < 1)
71 for (Breakpoint
* bp
in selection
)
72 [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)
87 Breakpoint
* bp
= [selection objectAtIndex
:0];
88 [sourceView_ setFile
:[bp file
]];
89 [sourceView_ scrollToLine
:[bp line
]];
90 [[sourceView_ numberView
] setMarkers
:[NSSet setWithArray
:[manager breakpointsForFile
:[bp file
]]]];
93 #pragma mark NSTableView Data Source
96 * Handles the beginning of a drag operation.
98 - (BOOL)tableView
:(NSTableView
*)aTableView
99 writeRowsWithIndexes
:(NSIndexSet
*)rowIndexes
100 toPasteboard
:(NSPasteboard
*)pboard
105 * Validates the drag operation.
107 - (NSDragOperation
)tableView
:(NSTableView
*)aTableView
108 validateDrop
:(id<NSDraggingInfo
>)info
109 proposedRow
:(NSInteger
)row
110 proposedDropOperation
:(NSTableViewDropOperation
)operation
115 * Incorporates the dropped data.
117 - (BOOL)tableView
:(NSTableView
*)aTableView
118 acceptDrop
:(id<NSDraggingInfo
>)info
120 dropOperation
:(NSTableViewDropOperation
)operation
124 #pragma mark BSSourceView Delegate
127 * The gutter was clicked, which indicates that a breakpoint needs to be changed
129 - (void)gutterClickedAtLine
:(int)line forFile
:(NSString
*)file
131 if ([manager hasBreakpointAt
:line inFile
:file
]) {
132 [manager removeBreakpointAt
:line inFile
:file
];
134 Breakpoint
* bp
= [[Breakpoint alloc
] initWithLine
:line inFile
:file
];
135 [manager addBreakpoint
:bp
];
139 [[sourceView_ numberView
] setMarkers
:[NSSet setWithArray
:[manager breakpointsForFile
:file
]]];
140 [[sourceView_ numberView
] setNeedsDisplay
:YES
];