From ad0926d2c5749c8a6eb2a291d606da98415dcd2f Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Tue, 11 Jan 2011 18:11:37 -0500 Subject: [PATCH] Initial work to get a source view using NSRulerView. Redefine the BSSourceView interface to have a markers property, so that clients don't dig in for the numberView to set them. Remove the BSSourceViewTextView as that custom view is no longer needed. --- MacGDBp.xcodeproj/project.pbxproj | 30 +++--- ...ViewTextView.h => BSLineNumberRulerView.h} | 10 +- Source/BSLineNumberRulerView.m | 35 +++++++ ...BSLineNumberView.m => BSLineNumberView.mm} | 0 Source/BSSourceView.h | 29 +++--- Source/{BSSourceView.m => BSSourceView.mm} | 94 ++++++++++--------- Source/BSSourceViewTextView.m | 52 ---------- Source/BreakpointController.h | 4 +- Source/BreakpointController.m | 9 +- Source/BreakpointManager.m | 4 +- Source/DebuggerController.h | 3 +- Source/DebuggerController.m | 10 +- 12 files changed, 139 insertions(+), 141 deletions(-) rename Source/{BSSourceViewTextView.h => BSLineNumberRulerView.h} (81%) create mode 100644 Source/BSLineNumberRulerView.m rename Source/{BSLineNumberView.m => BSLineNumberView.mm} (100%) rename Source/{BSSourceView.m => BSSourceView.mm} (72%) delete mode 100644 Source/BSSourceViewTextView.m diff --git a/MacGDBp.xcodeproj/project.pbxproj b/MacGDBp.xcodeproj/project.pbxproj index cc5bd05..f25179a 100644 --- a/MacGDBp.xcodeproj/project.pbxproj +++ b/MacGDBp.xcodeproj/project.pbxproj @@ -22,9 +22,8 @@ 1E67E6FD0F3C052000E68F1B /* PreferencesPathsArrayController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1E67E6FC0F3C052000E68F1B /* PreferencesPathsArrayController.m */; }; 1E6B5947116106FE001189D2 /* LoggingController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1E6B5946116106FE001189D2 /* LoggingController.m */; }; 1E6B594C11610993001189D2 /* Log.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1E6B594A11610993001189D2 /* Log.xib */; }; - 1E7188680D839F6300969277 /* BSLineNumberView.m in Sources */ = {isa = PBXBuildFile; fileRef = 1E7188630D839F6300969277 /* BSLineNumberView.m */; }; - 1E7188690D839F6300969277 /* BSSourceView.m in Sources */ = {isa = PBXBuildFile; fileRef = 1E7188650D839F6300969277 /* BSSourceView.m */; }; - 1E71886A0D839F6300969277 /* BSSourceViewTextView.m in Sources */ = {isa = PBXBuildFile; fileRef = 1E7188670D839F6300969277 /* BSSourceViewTextView.m */; }; + 1E7188680D839F6300969277 /* BSLineNumberView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1E7188630D839F6300969277 /* BSLineNumberView.mm */; }; + 1E7188690D839F6300969277 /* BSSourceView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1E7188650D839F6300969277 /* BSSourceView.mm */; }; 1E822CDD0DA28AC30027A23F /* Breakpoint.m in Sources */ = {isa = PBXBuildFile; fileRef = 1E822CDC0DA28AC30027A23F /* Breakpoint.m */; }; 1E9582620E252474001A3D89 /* Preferences.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1E9582600E252474001A3D89 /* Preferences.xib */; }; 1E9582670E2524AD001A3D89 /* PreferencesController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1E9582660E2524AD001A3D89 /* PreferencesController.m */; }; @@ -37,6 +36,7 @@ 1EC6965812BBC6A700A8D984 /* modp_b64.cc in Sources */ = {isa = PBXBuildFile; fileRef = 1EC6965212BBC6A700A8D984 /* modp_b64.cc */; }; 1EC6965912BBC6A700A8D984 /* README.bluestatic in Resources */ = {isa = PBXBuildFile; fileRef = 1EC6965512BBC6A700A8D984 /* README.bluestatic */; }; 1EC6965A12BBC6A700A8D984 /* README.chromium in Resources */ = {isa = PBXBuildFile; fileRef = 1EC6965612BBC6A700A8D984 /* README.chromium */; }; + 1EDA9CF812DD13B300596211 /* BSLineNumberRulerView.m in Sources */ = {isa = PBXBuildFile; fileRef = 1EDA9CF712DD13B300596211 /* BSLineNumberRulerView.m */; }; 1EEBFBE50D34C793008F835B /* Debugger.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1EEBFBE30D34C793008F835B /* Debugger.xib */; }; 1EEBFC2B0D358EBD008F835B /* StepIn.png in Resources */ = {isa = PBXBuildFile; fileRef = 1EEBFC2A0D358EBD008F835B /* StepIn.png */; }; 1EEBFC370D358F1B008F835B /* StepOut.png in Resources */ = {isa = PBXBuildFile; fileRef = 1EEBFC360D358F1B008F835B /* StepOut.png */; }; @@ -92,11 +92,9 @@ 1E6B5946116106FE001189D2 /* LoggingController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = LoggingController.m; path = Source/LoggingController.m; sourceTree = ""; }; 1E6B594B11610993001189D2 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = English.lproj/Log.xib; sourceTree = ""; }; 1E7188620D839F6300969277 /* BSLineNumberView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BSLineNumberView.h; path = Source/BSLineNumberView.h; sourceTree = ""; }; - 1E7188630D839F6300969277 /* BSLineNumberView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = BSLineNumberView.m; path = Source/BSLineNumberView.m; sourceTree = ""; }; - 1E7188640D839F6300969277 /* BSSourceView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BSSourceView.h; path = Source/BSSourceView.h; sourceTree = ""; }; - 1E7188650D839F6300969277 /* BSSourceView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = BSSourceView.m; path = Source/BSSourceView.m; sourceTree = ""; }; - 1E7188660D839F6300969277 /* BSSourceViewTextView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BSSourceViewTextView.h; path = Source/BSSourceViewTextView.h; sourceTree = ""; }; - 1E7188670D839F6300969277 /* BSSourceViewTextView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = BSSourceViewTextView.m; path = Source/BSSourceViewTextView.m; sourceTree = ""; }; + 1E7188630D839F6300969277 /* BSLineNumberView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = BSLineNumberView.mm; path = Source/BSLineNumberView.mm; sourceTree = ""; }; + 1E7188640D839F6300969277 /* BSSourceView.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; fileEncoding = 4; name = BSSourceView.h; path = Source/BSSourceView.h; sourceTree = ""; }; + 1E7188650D839F6300969277 /* BSSourceView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = BSSourceView.mm; path = Source/BSSourceView.mm; sourceTree = ""; }; 1E822CDB0DA28AC30027A23F /* Breakpoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Breakpoint.h; path = Source/Breakpoint.h; sourceTree = ""; }; 1E822CDC0DA28AC30027A23F /* Breakpoint.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Breakpoint.m; path = Source/Breakpoint.m; sourceTree = ""; }; 1E9582610E252474001A3D89 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = English.lproj/Preferences.xib; sourceTree = ""; }; @@ -115,6 +113,8 @@ 1EC6965412BBC6A700A8D984 /* modp_b64_data.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = modp_b64_data.h; sourceTree = ""; }; 1EC6965512BBC6A700A8D984 /* README.bluestatic */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README.bluestatic; sourceTree = ""; }; 1EC6965612BBC6A700A8D984 /* README.chromium */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README.chromium; sourceTree = ""; }; + 1EDA9CF612DD13B300596211 /* BSLineNumberRulerView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BSLineNumberRulerView.h; path = Source/BSLineNumberRulerView.h; sourceTree = ""; }; + 1EDA9CF712DD13B300596211 /* BSLineNumberRulerView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = BSLineNumberRulerView.m; path = Source/BSLineNumberRulerView.m; sourceTree = ""; }; 1EEBFBE40D34C793008F835B /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = English.lproj/Debugger.xib; sourceTree = ""; }; 1EEBFC2A0D358EBD008F835B /* StepIn.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = StepIn.png; path = Icons/StepIn.png; sourceTree = ""; }; 1EEBFC360D358F1B008F835B /* StepOut.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = StepOut.png; path = Icons/StepOut.png; sourceTree = ""; }; @@ -252,11 +252,11 @@ 1EEBFD080D3599E8008F835B /* BSSplitView.h */, 1EEBFD070D3599E8008F835B /* BSSplitView.m */, 1E7188620D839F6300969277 /* BSLineNumberView.h */, - 1E7188630D839F6300969277 /* BSLineNumberView.m */, + 1E7188630D839F6300969277 /* BSLineNumberView.mm */, 1E7188640D839F6300969277 /* BSSourceView.h */, - 1E7188650D839F6300969277 /* BSSourceView.m */, - 1E7188660D839F6300969277 /* BSSourceViewTextView.h */, - 1E7188670D839F6300969277 /* BSSourceViewTextView.m */, + 1E7188650D839F6300969277 /* BSSourceView.mm */, + 1EDA9CF612DD13B300596211 /* BSLineNumberRulerView.h */, + 1EDA9CF712DD13B300596211 /* BSLineNumberRulerView.m */, ); name = "Source View"; sourceTree = ""; @@ -447,9 +447,8 @@ 1E02C5F60C610724006F1752 /* DebuggerController.m in Sources */, 1E35FC760C6579CA0030F527 /* NSXMLElementAdditions.m in Sources */, 1EEBFD090D3599E8008F835B /* BSSplitView.m in Sources */, - 1E7188680D839F6300969277 /* BSLineNumberView.m in Sources */, - 1E7188690D839F6300969277 /* BSSourceView.m in Sources */, - 1E71886A0D839F6300969277 /* BSSourceViewTextView.m in Sources */, + 1E7188680D839F6300969277 /* BSLineNumberView.mm in Sources */, + 1E7188690D839F6300969277 /* BSSourceView.mm in Sources */, 1E822CDD0DA28AC30027A23F /* Breakpoint.m in Sources */, 1E4C7AF90DA401C7000A9DC7 /* BreakpointManager.m in Sources */, 1EFF70C30DFDC018006B9D33 /* BreakpointController.m in Sources */, @@ -462,6 +461,7 @@ 1EC6965812BBC6A700A8D984 /* modp_b64.cc in Sources */, 1EFBE63012C515C200F96D6E /* NetworkConnection.mm in Sources */, 1EFBE66B12C51E3900F96D6E /* NetworkCallbackController.mm in Sources */, + 1EDA9CF812DD13B300596211 /* BSLineNumberRulerView.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Source/BSSourceViewTextView.h b/Source/BSLineNumberRulerView.h similarity index 81% rename from Source/BSSourceViewTextView.h rename to Source/BSLineNumberRulerView.h index 4fd2ac9..f2493f4 100644 --- a/Source/BSSourceViewTextView.h +++ b/Source/BSLineNumberRulerView.h @@ -16,13 +16,13 @@ #import -@class BSSourceView; - -@interface BSSourceViewTextView : NSTextView +// The NSRulerView that draws line numbers on the BSSourceView. +@interface BSLineNumberRulerView : NSRulerView { - BSSourceView* sourceView; + } -@property(readwrite, assign) BSSourceView* sourceView; +// Designated initializer. +- (id)initWithScrollView:(NSScrollView*)scrollView; @end diff --git a/Source/BSLineNumberRulerView.m b/Source/BSLineNumberRulerView.m new file mode 100644 index 0000000..601c5ac --- /dev/null +++ b/Source/BSLineNumberRulerView.m @@ -0,0 +1,35 @@ +/* + * MacGDBp + * Copyright (c) 2007 - 2011, Blue Static + * + * This program is free software; you can redistribute it and/or modify it under the terms of the GNU + * General Public License as published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program; if not, + * write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#import "BSLineNumberRulerView.h" + + +@implementation BSLineNumberRulerView + +- (id)initWithScrollView:(NSScrollView*)scrollView +{ + if (self = [super initWithScrollView:scrollView orientation:NSVerticalRuler]) { + [self setClientView:[scrollView documentView]]; + } + return self; +} + +- (void)awakeFromNib +{ + [self setClientView:[[self scrollView] documentView]]; +} + +@end diff --git a/Source/BSLineNumberView.m b/Source/BSLineNumberView.mm similarity index 100% rename from Source/BSLineNumberView.m rename to Source/BSLineNumberView.mm diff --git a/Source/BSSourceView.h b/Source/BSSourceView.h index 811f834..cb53f19 100644 --- a/Source/BSSourceView.h +++ b/Source/BSSourceView.h @@ -15,29 +15,34 @@ */ #import +#include + #import "BSLineNumberView.h" -#import "BSSourceViewTextView.h" @protocol BSSourceViewDelegate; @interface BSSourceView : NSView { - BSLineNumberView* numberView; - BSSourceViewTextView* textView; - NSScrollView* scrollView; - + @private + NSTextView* textView_; + NSScrollView* scrollView_; + + std::vector lineIndex_; + + NSSet* markers_; + NSString* file; int markedLine; - + id delegate; } -@property(readwrite, assign) BSLineNumberView* numberView; -@property(readwrite, assign) BSSourceViewTextView* textView; -@property(readwrite, assign) NSScrollView* scrollView; -@property(readwrite, nonatomic, assign) NSString* file; -@property(readwrite, assign) int markedLine; -@property(readwrite, assign) id delegate; +@property (assign) NSTextView* textView; +@property (assign) NSScrollView* scrollView; +@property (retain) NSSet* markers; +@property (nonatomic, assign) NSString* file; +@property (assign) int markedLine; +@property (assign) id delegate; - (void)setFile:(NSString*)f; - (void)setString:(NSString*)source asFile:(NSString*)path; diff --git a/Source/BSSourceView.m b/Source/BSSourceView.mm similarity index 72% rename from Source/BSSourceView.m rename to Source/BSSourceView.mm index 55481eb..9a6fbe8 100644 --- a/Source/BSSourceView.m +++ b/Source/BSSourceView.mm @@ -16,6 +16,8 @@ #import "BSSourceView.h" +#include "BSLineNumberRulerView.h" + @interface BSSourceView (Private) - (void)setupViews; - (void)errorHighlightingFile:(NSNotification*)notif; @@ -24,7 +26,12 @@ @implementation BSSourceView -@synthesize numberView, textView, scrollView, markedLine, delegate, file; +@synthesize textView = textView_; +@synthesize scrollView = scrollView_; +@synthesize markers = markers_; +@synthesize markedLine; +@synthesize delegate; +@synthesize file; /** * Initializes the source view with the path of a file @@ -51,9 +58,8 @@ { [file release]; - [numberView removeFromSuperview]; - [scrollView removeFromSuperview]; - [textView removeFromSuperview]; + [scrollView_ removeFromSuperview]; + [textView_ removeFromSuperview]; [super dealloc]; } @@ -71,7 +77,7 @@ if (![[NSFileManager defaultManager] fileExistsAtPath:f]) { - [textView setString:@""]; + [textView_ setString:@""]; return; } @@ -92,7 +98,7 @@ NSData* data = [[outPipe fileHandleForReading] readDataToEndOfFile]; NSAttributedString* source = [[NSAttributedString alloc] initWithHTML:data documentAttributes:NULL]; - [[textView textStorage] setAttributedString:source]; + [[textView_ textStorage] setAttributedString:source]; [source release]; } @catch (NSException* exception) @@ -113,7 +119,7 @@ [source writeToFile:tmpPath atomically:NO encoding:NSUTF8StringEncoding error:&error]; if (error) { - [textView setString:source]; + [textView_ setString:source]; return; } @@ -154,20 +160,20 @@ */ - (void)scrollToLine:(int)line { - if ([[textView textStorage] length] == 0) + if ([[textView_ textStorage] length] == 0) return; // go through the document until we find the NSRange for the line we want int rangeIndex = 0; for (int i = 0; i < line; i++) { - rangeIndex = NSMaxRange([[textView string] lineRangeForRange:NSMakeRange(rangeIndex, 0)]); + rangeIndex = NSMaxRange([[textView_ string] lineRangeForRange:NSMakeRange(rangeIndex, 0)]); } // now get the true start/end markers for it unsigned lineStart, lineEnd; - [[textView string] getLineStart:&lineStart end:NULL contentsEnd:&lineEnd forRange:NSMakeRange(rangeIndex - 1, 0)]; - [textView scrollRangeToVisible:[[textView string] lineRangeForRange:NSMakeRange(lineStart, lineEnd - lineStart)]]; + [[textView_ string] getLineStart:&lineStart end:NULL contentsEnd:&lineEnd forRange:NSMakeRange(rangeIndex - 1, 0)]; + [textView_ scrollRangeToVisible:[[textView_ string] lineRangeForRange:NSMakeRange(lineStart, lineEnd - lineStart)]]; } /** @@ -177,45 +183,43 @@ { int gutterWidth = 30; - // setup the line number view - NSRect numberFrame = [self bounds]; - numberFrame.origin = NSMakePoint(0.0, 0.0); - numberFrame.size.width = gutterWidth; - numberView = [[BSLineNumberView alloc] initWithFrame:numberFrame]; - [numberView setAutoresizingMask:NSViewHeightSizable]; - [numberView setSourceView:self]; - [self addSubview:numberView]; - - // create the scroll view + // Create the scroll view. NSRect scrollFrame = [self bounds]; scrollFrame.origin.x = gutterWidth; scrollFrame.size.width = scrollFrame.size.width - gutterWidth; - scrollView = [[NSScrollView alloc] initWithFrame:scrollFrame]; - [scrollView setHasHorizontalScroller:YES]; - [scrollView setHasVerticalScroller:YES]; - [scrollView setAutohidesScrollers:YES]; - [scrollView setBorderType:NSBezelBorder]; - [scrollView setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)]; - [[scrollView contentView] setAutoresizesSubviews:YES]; - [self addSubview:scrollView]; - + scrollView_ = [[[NSScrollView alloc] initWithFrame:scrollFrame] autorelease]; + [scrollView_ setHasHorizontalScroller:YES]; + [scrollView_ setHasVerticalScroller:YES]; + [scrollView_ setAutohidesScrollers:YES]; + [scrollView_ setBorderType:NSBezelBorder]; + [scrollView_ setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)]; + [[scrollView_ contentView] setAutoresizesSubviews:YES]; + [self addSubview:scrollView_]; + + // Set up the ruler. + BSLineNumberRulerView* lineNumberView = + [[[BSLineNumberRulerView alloc] initWithScrollView:scrollView_] autorelease]; + [scrollView_ setVerticalRulerView:lineNumberView]; + [scrollView_ setHasHorizontalRuler:NO]; + [scrollView_ setHasVerticalRuler:YES]; + [scrollView_ setRulersVisible:YES]; + // add the text view to the scroll view NSRect textFrame; textFrame.origin = NSMakePoint(0.0, 0.0); - textFrame.size = [scrollView contentSize]; - textView = [[BSSourceViewTextView alloc] initWithFrame:textFrame]; - [textView setSourceView:self]; - [textView setEditable:NO]; - [textView setFont:[NSFont fontWithName:@"Monaco" size:10.0]]; - [textView setHorizontallyResizable:YES]; - [textView setVerticallyResizable:YES]; - [textView setMinSize:textFrame.size]; - [textView setMaxSize:NSMakeSize(FLT_MAX, FLT_MAX)]; - [[textView textContainer] setContainerSize:NSMakeSize(FLT_MAX, FLT_MAX)]; - [[textView textContainer] setWidthTracksTextView:NO]; - [[textView textContainer] setHeightTracksTextView:NO]; - [textView setAutoresizingMask:NSViewNotSizable]; - [scrollView setDocumentView:textView]; + textFrame.size = [scrollView_ contentSize]; + textView_ = [[[NSTextView alloc] initWithFrame:textFrame] autorelease]; + [textView_ setEditable:NO]; + [textView_ setFont:[NSFont fontWithName:@"Monaco" size:10.0]]; + [textView_ setHorizontallyResizable:YES]; + [textView_ setVerticallyResizable:YES]; + [textView_ setMinSize:textFrame.size]; + [textView_ setMaxSize:NSMakeSize(FLT_MAX, FLT_MAX)]; + [[textView_ textContainer] setContainerSize:NSMakeSize(FLT_MAX, FLT_MAX)]; + [[textView_ textContainer] setWidthTracksTextView:NO]; + [[textView_ textContainer] setHeightTracksTextView:NO]; + [textView_ setAutoresizingMask:NSViewNotSizable]; + [scrollView_ setDocumentView:textView_]; NSArray* types = [NSArray arrayWithObject:NSFilenamesPboardType]; [self registerForDraggedTypes:types]; @@ -235,7 +239,7 @@ NSLog(@"Error reading file at %@: %@", filePath, error); return; } - [textView setString:contents]; + [textView_ setString:contents]; } /** diff --git a/Source/BSSourceViewTextView.m b/Source/BSSourceViewTextView.m deleted file mode 100644 index 99cead5..0000000 --- a/Source/BSSourceViewTextView.m +++ /dev/null @@ -1,52 +0,0 @@ -/* - * MacGDBp - * Copyright (c) 2007 - 2011, Blue Static - * - * This program is free software; you can redistribute it and/or modify it under the terms of the GNU - * General Public License as published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without - * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with this program; if not, - * write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#import "BSSourceViewTextView.h" -#import "BSSourceView.h" - -@implementation BSSourceViewTextView - -@synthesize sourceView; - -/** - * Override -[drawRect:] so we can tell the line numbers to draw - */ -- (void)drawRect:(NSRect)rect -{ - [super drawRect:rect]; - - unsigned i = 0, line = 1; - while (i < [[self layoutManager] numberOfGlyphs]) - { - NSRange fragRange; - NSRect fragRect = [self convertRect:[[self layoutManager] lineFragmentRectForGlyphAtIndex:i effectiveRange:&fragRange] fromView:self]; - fragRect.origin.x = rect.origin.x; // horizontal scrolling matters not - - if ([sourceView markedLine] == line) - { - [[[NSColor redColor] colorWithAlphaComponent:0.25] set]; - [NSBezierPath fillRect:fragRect]; - break; - } - - i += fragRange.length; - line++; - } - - [[sourceView numberView] setNeedsDisplay:YES]; -} - -@end diff --git a/Source/BreakpointController.h b/Source/BreakpointController.h index 95b635a..f188a22 100644 --- a/Source/BreakpointController.h +++ b/Source/BreakpointController.h @@ -16,7 +16,9 @@ #import #import "BreakpointManager.h" -#import "BSSourceView.h" + +@class BSSourceView; +@protocol BSSourceViewDelegate; @interface BreakpointController : NSWindowController { diff --git a/Source/BreakpointController.m b/Source/BreakpointController.m index f50a63c..9f162db 100644 --- a/Source/BreakpointController.m +++ b/Source/BreakpointController.m @@ -15,8 +15,9 @@ */ #import "BreakpointController.h" -#import "AppDelegate.h" +#import "AppDelegate.h" +#import "BSSourceView.h" @implementation BreakpointController @@ -86,7 +87,7 @@ Breakpoint* bp = [selection objectAtIndex:0]; [sourceView setFile:[bp file]]; [sourceView scrollToLine:[bp line]]; - [[sourceView numberView] setMarkers:[NSSet setWithArray:[manager breakpointsForFile:[bp file]]]]; + [sourceView setMarkers:[NSSet setWithArray:[manager breakpointsForFile:[bp file]]]]; } #pragma mark BSSourceView Delegate @@ -107,8 +108,8 @@ [bp release]; } - [[sourceView numberView] setMarkers:[NSSet setWithArray:[manager breakpointsForFile:file]]]; - [[sourceView numberView] setNeedsDisplay:YES]; + [sourceView setMarkers:[NSSet setWithArray:[manager breakpointsForFile:file]]]; + [sourceView setNeedsDisplay:YES]; } /** diff --git a/Source/BreakpointManager.m b/Source/BreakpointManager.m index 0407a47..b4654a4 100644 --- a/Source/BreakpointManager.m +++ b/Source/BreakpointManager.m @@ -137,9 +137,9 @@ AppDelegate* appDel = [NSApp delegate]; [[[appDel breakpoint] arrayController] rearrangeObjects]; [[[appDel breakpoint] sourceView] setNeedsDisplay:YES]; - [[[[appDel breakpoint] sourceView] numberView] setMarkers:[NSSet setWithArray:[self breakpointsForFile:file]]]; + [[[appDel breakpoint] sourceView] setMarkers:[NSSet setWithArray:[self breakpointsForFile:file]]]; [[[appDel debugger] sourceViewer] setNeedsDisplay:YES]; - [[[[appDel debugger] sourceViewer] numberView] setMarkers:[NSSet setWithArray:[self breakpointsForFile:file]]]; + [[[appDel debugger] sourceViewer] setMarkers:[NSSet setWithArray:[self breakpointsForFile:file]]]; } @end diff --git a/Source/DebuggerController.h b/Source/DebuggerController.h index caba4bb..9471729 100644 --- a/Source/DebuggerController.h +++ b/Source/DebuggerController.h @@ -15,11 +15,12 @@ */ #import -#import "BSSourceView.h" #import "DebuggerBackEnd.h" #import "StackController.h" #include "VariableNode.h" +@class BSSourceView; + @interface DebuggerController : NSWindowController { DebuggerBackEnd* connection; diff --git a/Source/DebuggerController.m b/Source/DebuggerController.m index efd037e..e481daa 100644 --- a/Source/DebuggerController.m +++ b/Source/DebuggerController.m @@ -15,9 +15,11 @@ */ #import "DebuggerController.h" -#import "NSXMLElementAdditions.h" + #import "AppDelegate.h" +#import "BSSourceView.h" #import "BreakpointManager.h" +#import "NSXMLElementAdditions.h" @interface DebuggerController (Private) - (void)updateSourceViewer; @@ -290,7 +292,7 @@ [sourceViewer setString:frame.source asFile:filename]; NSSet* breakpoints = [NSSet setWithArray:[[BreakpointManager sharedManager] breakpointsForFile:filename]]; - [[sourceViewer numberView] setMarkers:breakpoints]; + [sourceViewer setMarkers:breakpoints]; } [sourceViewer setMarkedLine:frame.lineNumber]; @@ -349,8 +351,8 @@ [bp release]; } - [[sourceViewer numberView] setMarkers:[NSSet setWithArray:[mngr breakpointsForFile:file]]]; - [[sourceViewer numberView] setNeedsDisplay:YES]; + [sourceViewer setMarkers:[NSSet setWithArray:[mngr breakpointsForFile:file]]]; + [sourceViewer setNeedsDisplay:YES]; } #pragma mark GDBpConnectionDelegate -- 2.22.5