From ae30058e9ff5fa7c8fa0273d5c747156269ce736 Mon Sep 17 00:00:00 2001 From: Robert Sesek <rsesek@bluestatic.org> 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 @@ <customObject id="-2" userLabel="File's Owner" customClass="BreakpointController"> <connections> <outlet property="arrayController" destination="28" id="35"/> - <outlet property="sourceView" destination="hds-fn-ZMp" id="xJW-ll-wla"/> <outlet property="view" destination="uUK-Ll-YSm" id="ujh-9q-BWz"/> </connections> </customObject> @@ -18,128 +17,105 @@ <rect key="frame" x="0.0" y="0.0" width="574" height="484"/> <autoresizingMask key="autoresizingMask"/> <subviews> - <splitView dividerStyle="thin" id="dSm-S9-gg1"> - <rect key="frame" x="0.0" y="0.0" width="574" height="484"/> + <button verticalHuggingPriority="750" misplaced="YES" id="NEA-NE-e2L"> + <rect key="frame" x="23" y="-1" width="24" height="23"/> + <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> + <buttonCell key="cell" type="smallSquare" bezelStyle="smallSquare" image="NSRemoveTemplate" imagePosition="overlaps" alignment="center" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="RTj-JH-bdO"> + <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/> + <font key="font" metaFont="system"/> + <string key="keyEquivalent"></string> + </buttonCell> + <connections> + <action selector="removeBreakpoint:" target="-2" id="65m-Li-WgP"/> + </connections> + </button> + <button verticalHuggingPriority="750" misplaced="YES" id="lru-8s-P8q"> + <rect key="frame" x="0.0" y="-1" width="24" height="23"/> + <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> + <buttonCell key="cell" type="smallSquare" bezelStyle="smallSquare" image="NSAddTemplate" imagePosition="overlaps" alignment="center" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="7HD-4r-sdn"> + <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/> + <font key="font" metaFont="system"/> + </buttonCell> + <connections> + <action selector="addBreakpoint:" target="-2" id="qiy-D7-vZp"/> + </connections> + </button> + <scrollView focusRingType="none" misplaced="YES" autohidesScrollers="YES" horizontalLineScroll="19" horizontalPageScroll="10" verticalLineScroll="19" verticalPageScroll="10" usesPredominantAxisScrolling="NO" id="QUj-nl-H1n"> + <rect key="frame" x="0.0" y="20" width="574" height="464"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> - <subviews> - <customView id="hds-fn-ZMp" customClass="BSSourceView"> - <rect key="frame" x="0.0" y="0.0" width="574" height="221"/> - <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> - <connections> - <outlet property="delegate" destination="-2" id="yPG-gl-ySf"/> - </connections> - </customView> - <customView id="siI-sb-Ohb"> - <rect key="frame" x="0.0" y="222" width="574" height="262"/> - <autoresizingMask key="autoresizingMask"/> - <subviews> - <button verticalHuggingPriority="750" misplaced="YES" id="NEA-NE-e2L"> - <rect key="frame" x="23" y="-1" width="26" height="23"/> - <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> - <buttonCell key="cell" type="smallSquare" bezelStyle="smallSquare" image="NSRemoveTemplate" imagePosition="overlaps" alignment="center" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="RTj-JH-bdO"> - <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/> - <font key="font" metaFont="system"/> - <string key="keyEquivalent"></string> - </buttonCell> - <connections> - <action selector="removeBreakpoint:" target="-2" id="65m-Li-WgP"/> - </connections> - </button> - <button verticalHuggingPriority="750" misplaced="YES" id="lru-8s-P8q"> - <rect key="frame" x="0.0" y="-1" width="24" height="23"/> - <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> - <buttonCell key="cell" type="smallSquare" bezelStyle="smallSquare" image="NSAddTemplate" imagePosition="overlaps" alignment="center" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="7HD-4r-sdn"> - <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/> - <font key="font" metaFont="system"/> - </buttonCell> - <connections> - <action selector="addBreakpoint:" target="-2" id="qiy-D7-vZp"/> - </connections> - </button> - <scrollView misplaced="YES" autohidesScrollers="YES" horizontalLineScroll="19" horizontalPageScroll="10" verticalLineScroll="19" verticalPageScroll="10" usesPredominantAxisScrolling="NO" id="QUj-nl-H1n"> - <rect key="frame" x="0.0" y="20" width="574" height="242"/> - <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> - <clipView key="contentView" id="vnD-I2-3RC"> - <rect key="frame" x="1" y="0.0" width="572" height="241"/> - <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> - <subviews> - <tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnSelection="YES" autosaveColumns="NO" headerView="XI3-4j-eHA" id="d8X-q7-NYd"> - <rect key="frame" x="0.0" y="0.0" width="572" height="218"/> - <autoresizingMask key="autoresizingMask"/> - <size key="intercellSpacing" width="3" height="2"/> - <color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/> - <color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/> - <tableColumns> - <tableColumn width="425" minWidth="40" maxWidth="1000" id="RCP-bP-B4d"> - <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="File"> - <font key="font" metaFont="smallSystem"/> - <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/> - <color key="backgroundColor" white="0.33333299" alpha="1" colorSpace="calibratedWhite"/> - </tableHeaderCell> - <textFieldCell key="dataCell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" alignment="left" title="Text Cell" id="IV1-Sj-2od"> - <font key="font" metaFont="smallSystem"/> - <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/> - <color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/> - </textFieldCell> - <tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/> - <connections> - <binding destination="28" name="value" keyPath="arrangedObjects.file" id="8aj-3i-nGj"/> - </connections> - </tableColumn> - <tableColumn width="141" minWidth="40" maxWidth="1000" id="MvD-nE-8qa"> - <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Line"> - <font key="font" metaFont="smallSystem"/> - <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/> - <color key="backgroundColor" white="0.33333299" alpha="1" colorSpace="calibratedWhite"/> - </tableHeaderCell> - <textFieldCell key="dataCell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" alignment="left" title="Text Cell" id="kPe-Mi-bAY"> - <font key="font" metaFont="smallSystem"/> - <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/> - <color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/> - </textFieldCell> - <tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/> - <connections> - <binding destination="28" name="value" keyPath="arrangedObjects.line" id="keh-Aa-ayp"/> - </connections> - </tableColumn> - </tableColumns> - <connections> - <outlet property="delegate" destination="-2" id="Tc8-nD-s4R"/> - </connections> - </tableView> - </subviews> - </clipView> - <scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="Abm-OM-c9d"> - <rect key="frame" x="1" y="223" width="557" height="15"/> - <autoresizingMask key="autoresizingMask"/> - </scroller> - <scroller key="verticalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="NO" id="NaV-vD-Og8"> - <rect key="frame" x="558" y="17" width="15" height="206"/> - <autoresizingMask key="autoresizingMask"/> - </scroller> - <tableHeaderView key="headerView" id="XI3-4j-eHA"> - <rect key="frame" x="0.0" y="0.0" width="572" height="23"/> - <autoresizingMask key="autoresizingMask"/> - </tableHeaderView> - </scrollView> - </subviews> - </customView> - </subviews> - <holdingPriorities> - <real value="250"/> - <real value="250"/> - </holdingPriorities> - </splitView> + <clipView key="contentView" id="vnD-I2-3RC"> + <rect key="frame" x="1" y="0.0" width="572" height="463"/> + <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> + <subviews> + <tableView focusRingType="none" verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnSelection="YES" autosaveColumns="NO" headerView="XI3-4j-eHA" id="d8X-q7-NYd"> + <rect key="frame" x="0.0" y="0.0" width="572" height="440"/> + <autoresizingMask key="autoresizingMask"/> + <size key="intercellSpacing" width="3" height="2"/> + <color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/> + <color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/> + <tableColumns> + <tableColumn width="425" minWidth="40" maxWidth="1000" id="RCP-bP-B4d"> + <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="File"> + <font key="font" metaFont="smallSystem"/> + <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/> + <color key="backgroundColor" white="0.33333299" alpha="1" colorSpace="calibratedWhite"/> + </tableHeaderCell> + <textFieldCell key="dataCell" lineBreakMode="truncatingMiddle" selectable="YES" editable="YES" alignment="left" title="Text Cell" id="IV1-Sj-2od"> + <font key="font" metaFont="smallSystem"/> + <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/> + <color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/> + </textFieldCell> + <tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/> + <connections> + <binding destination="28" name="value" keyPath="arrangedObjects.file" id="8aj-3i-nGj"/> + </connections> + </tableColumn> + <tableColumn width="141" minWidth="40" maxWidth="1000" id="MvD-nE-8qa"> + <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Line"> + <font key="font" metaFont="smallSystem"/> + <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/> + <color key="backgroundColor" white="0.33333299" alpha="1" colorSpace="calibratedWhite"/> + </tableHeaderCell> + <textFieldCell key="dataCell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" alignment="left" title="Text Cell" id="kPe-Mi-bAY"> + <font key="font" metaFont="smallSystem"/> + <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/> + <color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/> + </textFieldCell> + <tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/> + <connections> + <binding destination="28" name="value" keyPath="arrangedObjects.line" id="keh-Aa-ayp"/> + </connections> + </tableColumn> + </tableColumns> + <connections> + <outlet property="delegate" destination="-2" id="Tc8-nD-s4R"/> + </connections> + </tableView> + </subviews> + </clipView> + <scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="Abm-OM-c9d"> + <rect key="frame" x="1" y="223" width="557" height="15"/> + <autoresizingMask key="autoresizingMask"/> + </scroller> + <scroller key="verticalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="NO" id="NaV-vD-Og8"> + <rect key="frame" x="558" y="17" width="15" height="206"/> + <autoresizingMask key="autoresizingMask"/> + </scroller> + <tableHeaderView key="headerView" id="XI3-4j-eHA"> + <rect key="frame" x="0.0" y="0.0" width="572" height="23"/> + <autoresizingMask key="autoresizingMask"/> + </tableHeaderView> + </scrollView> </subviews> </view> <customObject id="-3" userLabel="Application" customClass="NSObject"/> - <arrayController objectClassName="Breakpoint" automaticallyPreparesContent="YES" automaticallyRearrangesObjects="YES" id="28"> + <arrayController objectClassName="Breakpoint" automaticallyPreparesContent="YES" preservesSelection="NO" selectsInsertedObjects="NO" avoidsEmptySelection="NO" automaticallyRearrangesObjects="YES" id="28"> <declaredKeys> <string>file</string> <string>line</string> </declaredKeys> <connections> - <binding destination="-2" name="contentArray" keyPath="manager.breakpoints" id="30"/> + <binding destination="-2" name="contentArray" keyPath="_manager.breakpoints" id="3RA-Ia-VZL"/> </connections> </arrayController> <userDefaultsController representsSharedInstance="YES" id="43"/> 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<BSSourceViewDelegate> -{ - 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