From 3bc3db00aadf774e4dbc1a214de961b5ae43a177 Mon Sep 17 00:00:00 2001 From: Allan Odgaard Date: Tue, 12 Feb 2013 23:06:48 +0100 Subject: [PATCH] ARC: Update OakTextView framework --- Frameworks/OakTextView/src/GutterView.h | 28 +++--- Frameworks/OakTextView/src/GutterView.mm | 29 +----- Frameworks/OakTextView/src/LiveSearchView.h | 2 +- Frameworks/OakTextView/src/LiveSearchView.mm | 15 +-- Frameworks/OakTextView/src/OTVStatusBar.h | 12 +-- Frameworks/OakTextView/src/OTVStatusBar.mm | 39 +++----- Frameworks/OakTextView/src/OakChoiceMenu.h | 4 +- Frameworks/OakTextView/src/OakChoiceMenu.mm | 18 ++-- Frameworks/OakTextView/src/OakDocumentView.mm | 23 +---- .../OakTextView/src/OakPasteboardWrapper.mm | 7 +- Frameworks/OakTextView/src/OakTextView.h | 22 ++--- Frameworks/OakTextView/src/OakTextView.mm | 96 +++++++------------ Frameworks/OakTextView/target | 2 - 13 files changed, 104 insertions(+), 193 deletions(-) diff --git a/Frameworks/OakTextView/src/GutterView.h b/Frameworks/OakTextView/src/GutterView.h index c1146ddd..dd49cc1d 100644 --- a/Frameworks/OakTextView/src/GutterView.h +++ b/Frameworks/OakTextView/src/GutterView.h @@ -30,20 +30,20 @@ struct GVLineRecord @end @interface GutterView : NSView -@property (nonatomic, retain) IBOutlet NSView* partnerView; -@property (nonatomic, retain) NSFont* lineNumberFont; -@property (nonatomic, assign) id delegate; -@property (nonatomic, retain) NSColor* foregroundColor; -@property (nonatomic, retain) NSColor* backgroundColor; -@property (nonatomic, retain) NSColor* iconColor; -@property (nonatomic, retain) NSColor* iconHoverColor; -@property (nonatomic, retain) NSColor* iconPressedColor; -@property (nonatomic, retain) NSColor* selectionForegroundColor; -@property (nonatomic, retain) NSColor* selectionBackgroundColor; -@property (nonatomic, retain) NSColor* selectionIconColor; -@property (nonatomic, retain) NSColor* selectionIconHoverColor; -@property (nonatomic, retain) NSColor* selectionIconPressedColor; -@property (nonatomic, retain) NSColor* selectionBorderColor; +@property (nonatomic) IBOutlet NSView* partnerView; +@property (nonatomic) NSFont* lineNumberFont; +@property (nonatomic, weak) id delegate; +@property (nonatomic) NSColor* foregroundColor; +@property (nonatomic) NSColor* backgroundColor; +@property (nonatomic) NSColor* iconColor; +@property (nonatomic) NSColor* iconHoverColor; +@property (nonatomic) NSColor* iconPressedColor; +@property (nonatomic) NSColor* selectionForegroundColor; +@property (nonatomic) NSColor* selectionBackgroundColor; +@property (nonatomic) NSColor* selectionIconColor; +@property (nonatomic) NSColor* selectionIconHoverColor; +@property (nonatomic) NSColor* selectionIconPressedColor; +@property (nonatomic) NSColor* selectionBorderColor; - (void)setHighlightedRange:(std::string const&)str; - (void)reloadData:(id)sender; - (void)insertColumnWithIdentifier:(NSString*)columnIdentifier atPosition:(NSUInteger)index dataSource:(id )columnDataSource delegate:(id )columnDelegate; diff --git a/Frameworks/OakTextView/src/GutterView.mm b/Frameworks/OakTextView/src/GutterView.mm index 72c90f13..111d991b 100644 --- a/Frameworks/OakTextView/src/GutterView.mm +++ b/Frameworks/OakTextView/src/GutterView.mm @@ -94,27 +94,12 @@ struct data_source_t - (void)dealloc { D(DBF_GutterView, bug("\n");); - self.partnerView = nil; - self.lineNumberFont = nil; - self.foregroundColor = nil; - self.backgroundColor = nil; - self.iconColor = nil; - self.iconHoverColor = nil; - self.iconPressedColor = nil; - self.selectionForegroundColor = nil; - self.selectionBackgroundColor = nil; - self.selectionIconColor = nil; - self.selectionIconHoverColor = nil; - self.selectionIconPressedColor = nil; - self.selectionBorderColor = nil; iterate(it, columnDataSources) { if(it->datasource) [[NSNotificationCenter defaultCenter] removeObserver:self name:GVColumnDataSourceDidChange object:it->datasource]; } - [hiddenColumns release]; [[NSNotificationCenter defaultCenter] removeObserver:self]; - [super dealloc]; } - (void)setupSelectionRects @@ -161,12 +146,8 @@ struct data_source_t D(DBF_GutterView, bug("%s (%p)\n", [[[aView class] description] UTF8String], aView);); if(_partnerView) - { [[NSNotificationCenter defaultCenter] removeObserver:self]; - [_partnerView release]; - } - - if(_partnerView = [aView retain]) + if(_partnerView = aView) [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(boundsDidChange:) name:NSViewBoundsDidChangeNotification object:[[_partnerView enclosingScrollView] contentView]]; } @@ -280,13 +261,14 @@ static CTLineRef CreateCTLineFromText (std::string const& text, NSFont* font, NS if(CGColorRef cgColor = [color tmCGColor]) CFDictionaryAddValue(dict, kCTForegroundColorAttributeName, cgColor); - if(CFStringRef fontName = (CFStringRef)[font fontName]) + if(CFStringRef fontName = (CFStringRef)CFBridgingRetain([font fontName])) { if(CTFontRef ctFont = CTFontCreateWithName(fontName, [font pointSize], NULL)) { CFDictionaryAddValue(dict, kCTFontAttributeName, ctFont); CFRelease(ctFont); } + CFRelease(fontName); } if(CFAttributedStringRef str = CFAttributedStringCreate(kCFAllocatorDefault, cf::wrap(text), dict)) @@ -532,10 +514,7 @@ static void DrawText (std::string const& text, CGRect const& rect, CGFloat basel { D(DBF_GutterView, bug("\n");); [self clearTrackingRects]; - - NSTrackingArea* trackingArea = [[NSTrackingArea alloc] initWithRect:[self visibleRect] options:NSTrackingMouseEnteredAndExited|NSTrackingMouseMoved|NSTrackingActiveInKeyWindow owner:self userInfo:nil]; - [self addTrackingArea:trackingArea]; - [trackingArea release]; + [self addTrackingArea:[[NSTrackingArea alloc] initWithRect:[self visibleRect] options:NSTrackingMouseEnteredAndExited|NSTrackingMouseMoved|NSTrackingActiveInKeyWindow owner:self userInfo:nil]]; } - (void)scrollWheel:(NSEvent*)event diff --git a/Frameworks/OakTextView/src/LiveSearchView.h b/Frameworks/OakTextView/src/LiveSearchView.h index 98938d14..a2a54591 100644 --- a/Frameworks/OakTextView/src/LiveSearchView.h +++ b/Frameworks/OakTextView/src/LiveSearchView.h @@ -1,5 +1,5 @@ #import @interface LiveSearchView : NSView -@property (nonatomic, retain) NSTextField* textField; +@property (nonatomic) NSTextField* textField; @end diff --git a/Frameworks/OakTextView/src/LiveSearchView.mm b/Frameworks/OakTextView/src/LiveSearchView.mm index 8540c205..1c430243 100644 --- a/Frameworks/OakTextView/src/LiveSearchView.mm +++ b/Frameworks/OakTextView/src/LiveSearchView.mm @@ -2,7 +2,7 @@ #import @interface LiveSearchView () -@property (nonatomic, retain) NSView* divider; +@property (nonatomic) NSView* divider; @end @implementation LiveSearchView @@ -12,7 +12,7 @@ { self.divider = OakCreateHorizontalLine([NSColor colorWithCalibratedWhite:0.500 alpha:1], [NSColor colorWithCalibratedWhite:0.750 alpha:1]); - self.textField = [[[NSTextField alloc] initWithFrame:NSZeroRect] autorelease]; + self.textField = [[NSTextField alloc] initWithFrame:NSZeroRect]; self.textField.focusRingType = NSFocusRingTypeNone; NSDictionary* views = @{ @@ -33,13 +33,6 @@ return self; } -- (void)dealloc -{ - self.divider = nil; - self.textField = nil; - [super dealloc]; -} - - (BOOL)isFlipped { return YES; @@ -56,10 +49,10 @@ NSColor* middleColor = [NSColor colorWithDeviceWhite:223/255.0 alpha:1]; int angle = 270; - NSGradient* aGradient = [[[NSGradient alloc] initWithColorsAndLocations: + NSGradient* aGradient = [[NSGradient alloc] initWithColorsAndLocations: cornerColor, 0.0, middleColor, 0.5, - cornerColor, 1.0, nil] autorelease]; + cornerColor, 1.0, nil]; NSRect bounds = NSMakeRect(self.bounds.origin.x, self.bounds.origin.y+1, self.bounds.size.width, self.bounds.size.height-1); [aGradient drawInRect:bounds angle:angle]; diff --git a/Frameworks/OakTextView/src/OTVStatusBar.h b/Frameworks/OakTextView/src/OTVStatusBar.h index 59d6bdcd..464b5d0e 100644 --- a/Frameworks/OakTextView/src/OTVStatusBar.h +++ b/Frameworks/OakTextView/src/OTVStatusBar.h @@ -8,11 +8,11 @@ @interface OTVStatusBar : OakGradientView - (void)showBundlesMenu:(id)sender; - (void)setCaretPosition:(std::string const&)range; -@property (nonatomic, copy) NSString* grammarName; -@property (nonatomic, copy) NSString* symbolName; -@property (nonatomic, assign) BOOL isMacroRecording; -@property (nonatomic, assign) BOOL softTabs; -@property (nonatomic, assign) int32_t tabSize; +@property (nonatomic) NSString* grammarName; +@property (nonatomic) NSString* symbolName; +@property (nonatomic) BOOL isMacroRecording; +@property (nonatomic) BOOL softTabs; +@property (nonatomic) int32_t tabSize; -@property (nonatomic, assign) id delegate; +@property (nonatomic, weak) id delegate; @end diff --git a/Frameworks/OakTextView/src/OTVStatusBar.mm b/Frameworks/OakTextView/src/OTVStatusBar.mm index 3420135e..e08718aa 100644 --- a/Frameworks/OakTextView/src/OTVStatusBar.mm +++ b/Frameworks/OakTextView/src/OTVStatusBar.mm @@ -31,7 +31,7 @@ static NSPopUpButton* OakCreatePopUpButton (NSString* initialItem = nil) [res setFont:[NSFont controlContentFontOfSize:[NSFont smallSystemFontSize]]]; if(initialItem) - [[res cell] setMenuItem:[[[NSMenuItem alloc] initWithTitle:initialItem action:@selector(nop:) keyEquivalent:@""] autorelease]]; + [[res cell] setMenuItem:[[NSMenuItem alloc] initWithTitle:initialItem action:@selector(nop:) keyEquivalent:@""]]; return res; } @@ -63,14 +63,14 @@ static NSImageView* OakCreateImageView (NSImage* image) text::range_t caretPosition; } @property (nonatomic) CGFloat recordingTime; -@property (nonatomic, retain) NSTimer* recordingTimer; +@property (nonatomic) NSTimer* recordingTimer; -@property (nonatomic, retain) NSTextField* selectionField; -@property (nonatomic, retain) NSPopUpButton* grammarPopUp; -@property (nonatomic, retain) NSPopUpButton* tabSizePopUp; -@property (nonatomic, retain) NSPopUpButton* bundleItemsPopUp; -@property (nonatomic, retain) NSPopUpButton* symbolPopUp; -@property (nonatomic, retain) NSButton* macroRecordingButton; +@property (nonatomic) NSTextField* selectionField; +@property (nonatomic) NSPopUpButton* grammarPopUp; +@property (nonatomic) NSPopUpButton* tabSizePopUp; +@property (nonatomic) NSPopUpButton* bundleItemsPopUp; +@property (nonatomic) NSPopUpButton* symbolPopUp; +@property (nonatomic) NSButton* macroRecordingButton; @end @implementation OTVStatusBar @@ -92,7 +92,7 @@ static NSImageView* OakCreateImageView (NSImage* image) // = Wrap/Clip Bundles PopUp = // =========================== - NSMenuItem* item = [[[NSMenuItem alloc] initWithTitle:@"" action:@selector(nop:) keyEquivalent:@""] autorelease]; + NSMenuItem* item = [[NSMenuItem alloc] initWithTitle:@"" action:@selector(nop:) keyEquivalent:@""]; item.image = [NSImage imageNamed:NSImageNameActionTemplate]; [[self.bundleItemsPopUp cell] setUsesItemFromMenu:NO]; [[self.bundleItemsPopUp cell] setMenuItem:item]; @@ -232,15 +232,13 @@ static NSImageView* OakCreateImageView (NSImage* image) - (void)setGrammarName:(NSString*)newGrammarName { - [_grammarName release]; - _grammarName = [newGrammarName copy]; + _grammarName = newGrammarName; self.grammarPopUp.title = newGrammarName ?: @"(no grammar)"; } - (void)setSymbolName:(NSString*)newSymbolName { - [_symbolName release]; - _symbolName = [newSymbolName copy]; + _symbolName = newSymbolName; self.symbolPopUp.title = newSymbolName ?: @"Symbols";; } @@ -249,8 +247,7 @@ static NSImageView* OakCreateImageView (NSImage* image) if(_recordingTimer != aTimer) { [_recordingTimer invalidate]; - [_recordingTimer release]; - _recordingTimer = [aTimer retain]; + _recordingTimer = aTimer; } } @@ -295,18 +292,6 @@ static NSImageView* OakCreateImageView (NSImage* image) - (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; - - self.selectionField = nil; - self.grammarPopUp = nil; - self.tabSizePopUp = nil; - self.bundleItemsPopUp = nil; - self.symbolPopUp = nil; - self.macroRecordingButton = nil; - - self.grammarName = nil; - self.symbolName = nil; self.recordingTimer = nil; - - [super dealloc]; } @end diff --git a/Frameworks/OakTextView/src/OakChoiceMenu.h b/Frameworks/OakTextView/src/OakChoiceMenu.h index 58d2d715..6ba04b68 100644 --- a/Frameworks/OakTextView/src/OakChoiceMenu.h +++ b/Frameworks/OakTextView/src/OakChoiceMenu.h @@ -13,8 +13,8 @@ extern NSUInteger const OakChoiceMenuKeyMovement; NSUInteger keyAction; NSPoint topLeftPosition; } -@property (nonatomic, retain) NSArray* choices; -@property (nonatomic, assign) NSUInteger choiceIndex; +@property (nonatomic) NSArray* choices; +@property (nonatomic) NSUInteger choiceIndex; @property (nonatomic, readonly) NSString* selectedChoice; - (void)showAtTopLeftPoint:(NSPoint)aPoint forView:(NSView*)aView; - (BOOL)isVisible; diff --git a/Frameworks/OakTextView/src/OakChoiceMenu.mm b/Frameworks/OakTextView/src/OakChoiceMenu.mm index 3f829bb5..2011b973 100644 --- a/Frameworks/OakTextView/src/OakChoiceMenu.mm +++ b/Frameworks/OakTextView/src/OakChoiceMenu.mm @@ -29,11 +29,7 @@ enum action_t { kActionNop, kActionTab, kActionReturn, kActionCancel, kActionMov - (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; - - [tableView release]; - self.window = nil; - self.choices = nil; - [super dealloc]; + self.window = nil; } - (void)sizeToFit @@ -60,8 +56,7 @@ enum action_t { kActionNop, kActionTab, kActionReturn, kActionCancel, kActionMov return; [[window parentWindow] removeChildWindow:window]; - [window release]; - window = [aWindow retain]; + window = aWindow; } - (void)viewBoundsDidChange:(NSNotification*)aNotification @@ -82,8 +77,7 @@ enum action_t { kActionNop, kActionTab, kActionReturn, kActionCancel, kActionMov id oldSelection = self.selectedChoice; self.choiceIndex = NSNotFound; - [choices autorelease]; - choices = [newChoices retain]; + choices = newChoices; [tableView reloadData]; self.choiceIndex = [choices indexOfObject:oldSelection]; @@ -129,7 +123,7 @@ enum action_t { kActionNop, kActionTab, kActionReturn, kActionCancel, kActionMov window.ignoresMouseEvents = YES; tableView = [[NSTableView alloc] initWithFrame:NSZeroRect]; - [tableView addTableColumn:[[[NSTableColumn alloc] initWithIdentifier:@"mainColumn"] autorelease]]; + [tableView addTableColumn:[[NSTableColumn alloc] initWithIdentifier:@"mainColumn"]]; tableView.headerView = nil; tableView.focusRingType = NSFocusRingTypeNone; tableView.autoresizingMask = NSViewWidthSizable|NSViewHeightSizable; @@ -139,7 +133,7 @@ enum action_t { kActionNop, kActionTab, kActionReturn, kActionCancel, kActionMov // tableView.delegate = self; [tableView reloadData]; - NSScrollView* scrollView = [[[NSScrollView alloc] initWithFrame:NSZeroRect] autorelease]; + NSScrollView* scrollView = [[NSScrollView alloc] initWithFrame:NSZeroRect]; scrollView.hasVerticalScroller = YES; scrollView.hasHorizontalScroller = NO; scrollView.autohidesScrollers = YES; @@ -202,7 +196,7 @@ enum action_t { kActionNop, kActionTab, kActionReturn, kActionCancel, kActionMov - (void)doCommandBySelector:(SEL)aSelector { if([self respondsToSelector:aSelector]) - [self performSelector:aSelector withObject:self]; + [super doCommandBySelector:aSelector]; } - (void)insertText:(id)aString { } diff --git a/Frameworks/OakTextView/src/OakDocumentView.mm b/Frameworks/OakTextView/src/OakDocumentView.mm index 0f4e67b7..1bb055f6 100644 --- a/Frameworks/OakTextView/src/OakDocumentView.mm +++ b/Frameworks/OakTextView/src/OakDocumentView.mm @@ -111,10 +111,10 @@ private: if([[NSUserDefaults standardUserDefaults] boolForKey:@"DocumentView Disable Line Numbers"]) [gutterView setVisibility:NO forColumnWithIdentifier:GVLineNumbersColumnIdentifier]; - gutterDividerView = [OakCreateViewWithColor() retain]; + gutterDividerView = OakCreateViewWithColor(); [self addSubview:gutterDividerView]; - statusDividerView = [OakCreateHorizontalLine([NSColor colorWithCalibratedWhite:0.500 alpha:1], [NSColor colorWithCalibratedWhite:0.750 alpha:1]) retain]; + statusDividerView = OakCreateHorizontalLine([NSColor colorWithCalibratedWhite:0.500 alpha:1], [NSColor colorWithCalibratedWhite:0.750 alpha:1]); [self addSubview:statusDividerView]; statusBar = [[OTVStatusBar alloc] initWithFrame:NSZeroRect]; @@ -169,7 +169,7 @@ private: - (NSImage*)gutterImage:(NSString*)aName { - if(NSImage* res = [[[NSImage imageNamed:aName inSameBundleAsClass:[self class]] copy] autorelease]) + if(NSImage* res = [[NSImage imageNamed:aName inSameBundleAsClass:[self class]] copy]) { // We use capHeight instead of x-height since most fonts have the numbers // extend to this height, so centering around the x-height would look off @@ -274,19 +274,6 @@ private: self.filterWindowController = nil; self.symbolChooser = nil; - - [gutterScrollView release]; - [gutterView release]; - [gutterDividerView release]; - [gutterImages release]; - [gutterHoverImages release]; - [gutterPressedImages release]; - [textScrollView release]; - [textView release]; - [statusBar release]; - [topAuxiliaryViews release]; - [bottomAuxiliaryViews release]; - [super dealloc]; } - (document::document_ptr const&)document @@ -344,7 +331,7 @@ private: { NSImage* whiteIBeamImage = [NSImage imageNamed:@"IBeam white" inSameBundleAsClass:[self class]]; [whiteIBeamImage setSize:[[[NSCursor IBeamCursor] image] size]]; - [textView setIbeamCursor:[[[NSCursor alloc] initWithImage:whiteIBeamImage hotSpot:NSMakePoint(4, 9)] autorelease]]; + [textView setIbeamCursor:[[NSCursor alloc] initWithImage:whiteIBeamImage hotSpot:NSMakePoint(4, 9)]]; [textScrollView setScrollerKnobStyle:NSScrollerKnobStyleLight]; } else @@ -590,7 +577,7 @@ private: continue; NSMenuItem* menuItem = [bundleItemsMenu addItemWithTitle:[NSString stringWithCxxString:pair.first] action:NULL keyEquivalent:@""]; - menuItem.submenu = [[[NSMenu alloc] initWithTitle:[NSString stringWithCxxString:pair.second->uuid()]] autorelease]; + menuItem.submenu = [[NSMenu alloc] initWithTitle:[NSString stringWithCxxString:pair.second->uuid()]]; menuItem.submenu.delegate = [BundleMenuDelegate sharedInstance]; if(selectedGrammar) diff --git a/Frameworks/OakTextView/src/OakPasteboardWrapper.mm b/Frameworks/OakTextView/src/OakPasteboardWrapper.mm index bb1e48f9..6b0870fc 100644 --- a/Frameworks/OakTextView/src/OakPasteboardWrapper.mm +++ b/Frameworks/OakTextView/src/OakPasteboardWrapper.mm @@ -19,7 +19,7 @@ static clipboard_t::entry_ptr to_entry (OakPasteboardEntry* src, BOOL includeFin return clipboard_t::entry_ptr(); std::map map; - plist::dictionary_t const& plist = plist::convert(src.options); + plist::dictionary_t const& plist = plist::convert((__bridge CFDictionaryRef)src.options); iterate(pair, plist) plist::get_key_path(plist, pair->first, map[pair->first]); @@ -36,18 +36,17 @@ struct oak_pasteboard_t : clipboard_t { oak_pasteboard_t (NSString* pboardName) { - pasteboard = [[OakPasteboard pasteboardWithName:pboardName] retain]; + pasteboard = [OakPasteboard pasteboardWithName:pboardName]; includeFindOptions = [pboardName isEqualToString:NSFindPboard]; } - ~oak_pasteboard_t () { [pasteboard release]; } bool empty () const { return false; } entry_ptr previous () { return to_entry([pasteboard previous], includeFindOptions); } entry_ptr current () const { return to_entry([pasteboard current], includeFindOptions); } entry_ptr next () { return to_entry([pasteboard next], includeFindOptions); } - void push_back (entry_ptr entry) { [pasteboard addEntry:[OakPasteboardEntry pasteboardEntryWithString:[NSString stringWithCxxString:entry->content()] andOptions:(NSDictionary*)((CFDictionaryRef)cf::wrap(entry->options()))]]; } + void push_back (entry_ptr entry) { [pasteboard addEntry:[OakPasteboardEntry pasteboardEntryWithString:[NSString stringWithCxxString:entry->content()] andOptions:(__bridge NSDictionary*)((CFDictionaryRef)cf::wrap(entry->options()))]]; } private: OakPasteboard* pasteboard; BOOL includeFindOptions; diff --git a/Frameworks/OakTextView/src/OakTextView.h b/Frameworks/OakTextView/src/OakTextView.h index c8bda3e6..24be691b 100644 --- a/Frameworks/OakTextView/src/OakTextView.h +++ b/Frameworks/OakTextView/src/OakTextView.h @@ -95,22 +95,22 @@ PUBLIC @interface OakTextView : OakView } - (void)setDocument:(document::document_ptr const&)aDocument; -@property (nonatomic, assign) id delegate; -@property (nonatomic, assign) theme_ptr const& theme; -@property (nonatomic, retain) NSCursor* ibeamCursor; -@property (nonatomic, retain) NSFont* font; -@property (nonatomic, assign) BOOL antiAlias; -@property (nonatomic, assign) size_t tabSize; -@property (nonatomic, assign) BOOL showInvisibles; -@property (nonatomic, assign) BOOL softWrap; -@property (nonatomic, assign) BOOL softTabs; +@property (nonatomic, weak) id delegate; +@property (nonatomic) theme_ptr const& theme; +@property (nonatomic) NSCursor* ibeamCursor; +@property (nonatomic) NSFont* font; +@property (nonatomic) BOOL antiAlias; +@property (nonatomic) size_t tabSize; +@property (nonatomic) BOOL showInvisibles; +@property (nonatomic) BOOL softWrap; +@property (nonatomic) BOOL softTabs; @property (nonatomic, readonly) BOOL continuousIndentCorrections; @property (nonatomic, readonly) BOOL hasMultiLineSelection; @property (nonatomic, readonly) BOOL hasSelection; -@property (nonatomic, retain) NSString* selectionString; +@property (nonatomic) NSString* selectionString; -@property (nonatomic, assign) BOOL isMacroRecording; +@property (nonatomic) BOOL isMacroRecording; - (GVLineRecord const&)lineRecordForPosition:(CGFloat)yPos; - (GVLineRecord const&)lineFragmentForLine:(NSUInteger)aLine column:(NSUInteger)aColumn; diff --git a/Frameworks/OakTextView/src/OakTextView.mm b/Frameworks/OakTextView/src/OakTextView.mm index 79b8d5aa..07768cb1 100644 --- a/Frameworks/OakTextView/src/OakTextView.mm +++ b/Frameworks/OakTextView/src/OakTextView.mm @@ -62,16 +62,16 @@ NSString* const kUserDefaultsDisableAntiAliasKey = @"disableAntiAlias"; - (NSRange)nsRangeForRange:(ng::range_t const&)range; - (ng::range_t const&)rangeForNSRange:(NSRange)nsRange; @property (nonatomic, readonly) ng::ranges_t const& markedRanges; -@property (nonatomic, retain) NSDate* optionDownDate; -@property (nonatomic, retain) OakTimer* initiateDragTimer; -@property (nonatomic, retain) OakTimer* dragScrollTimer; -@property (nonatomic, assign) BOOL showDragCursor; -@property (nonatomic, assign) BOOL showColumnSelectionCursor; -@property (nonatomic, retain) OakChoiceMenu* choiceMenu; -@property (nonatomic, assign) NSUInteger refreshNestCount; -@property (nonatomic, retain) LiveSearchView* liveSearchView; -@property (nonatomic, copy) NSString* liveSearchString; -@property (nonatomic, assign) ng::ranges_t const& liveSearchRanges; +@property (nonatomic) NSDate* optionDownDate; +@property (nonatomic) OakTimer* initiateDragTimer; +@property (nonatomic) OakTimer* dragScrollTimer; +@property (nonatomic) BOOL showDragCursor; +@property (nonatomic) BOOL showColumnSelectionCursor; +@property (nonatomic) OakChoiceMenu* choiceMenu; +@property (nonatomic) NSUInteger refreshNestCount; +@property (nonatomic) LiveSearchView* liveSearchView; +@property (nonatomic) NSString* liveSearchString; +@property (nonatomic) ng::ranges_t const& liveSearchRanges; @end static std::vector items_for_tab_expansion (ng::buffer_t const& buffer, ng::ranges_t const& ranges, std::string const& scopeAttributes, ng::range_t* range) @@ -252,7 +252,7 @@ static std::string shell_quote (std::vector paths) find_operation_t findOperation; find::options_t findOptions; } -@property (nonatomic, retain) OakTextView* textView; +@property (nonatomic) OakTextView* textView; @property (nonatomic, readonly) find_operation_t findOperation; @property (nonatomic, readonly) find::options_t findOptions; @end @@ -271,15 +271,9 @@ static std::string shell_quote (std::vector paths) return self; } -- (void)dealloc -{ - [textView release]; - [super dealloc]; -} - + (id)findServerWithTextView:(OakTextView*)aTextView operation:(find_operation_t)anOperation options:(find::options_t)someOptions { - return [[[self alloc] initWithTextView:aTextView operation:anOperation options:someOptions] autorelease]; + return [[self alloc] initWithTextView:aTextView operation:anOperation options:someOptions]; } - (NSString*)findString { return [[OakPasteboard pasteboardWithName:NSFindPboard] current].string; } @@ -336,7 +330,7 @@ static std::string shell_quote (std::vector paths) citerate(rect, layout->rects_for_ranges(ranges)) [clip appendBezierPath:[NSBezierPath bezierPathWithRect:NSOffsetRect(*rect, -NSMinX(srcRect), -NSMinY(srcRect))]]; - NSImage* image = [[[NSImage alloc] initWithSize:NSMakeSize(std::max(NSWidth(srcRect), 1), std::max(NSHeight(srcRect), 1))] autorelease]; + NSImage* image = [[NSImage alloc] initWithSize:NSMakeSize(std::max(NSWidth(srcRect), 1), std::max(NSHeight(srcRect), 1))]; [image setFlipped:[self isFlipped]]; [image lockFocus]; [clip addClip]; @@ -461,8 +455,8 @@ static std::string shell_quote (std::vector paths) showInvisibles = settings.get(kSettingsShowInvisiblesKey, false); antiAlias = ![[NSUserDefaults standardUserDefaults] boolForKey:kUserDefaultsDisableAntiAliasKey]; - spellingDotImage = [[NSImage imageNamed:@"SpellingDot" inSameBundleAsClass:[self class]] retain]; - foldingDotsImage = [[NSImage imageNamed:@"FoldingDots" inSameBundleAsClass:[self class]] retain]; + spellingDotImage = [NSImage imageNamed:@"SpellingDot" inSameBundleAsClass:[self class]]; + foldingDotsImage = [NSImage imageNamed:@"FoldingDots" inSameBundleAsClass:[self class]]; [self registerForDraggedTypes:[[self class] dropTypes]]; @@ -475,11 +469,7 @@ static std::string shell_quote (std::vector paths) - (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; - [liveSearchString release]; [self setDocument:document::document_ptr()]; - [spellingDotImage release]; - [foldingDotsImage release]; - [super dealloc]; } - (void)documentWillSave:(NSNotification*)aNotification @@ -609,7 +599,7 @@ doScroll: if(!choiceVector.empty()) { choiceMenu = [OakChoiceMenu new]; - choiceMenu.choices = (NSArray*)((CFArrayRef)cf::wrap(choiceVector)); + choiceMenu.choices = (__bridge NSArray*)((CFArrayRef)cf::wrap(choiceVector)); std::string const& currentChoice = editor->placeholder_content(); for(size_t i = choiceVector.size(); i-- > 0; ) @@ -816,7 +806,7 @@ doScroll: CFRelease(str); } - return [(NSAttributedString*)res autorelease]; + return (NSAttributedString*)CFBridgingRelease(res); } - (NSRect)firstRectForCharacterRange:(NSRange)theRange @@ -866,8 +856,7 @@ doScroll: // ATTR(VisibleCharacterRange), ]]; - set = [set setByAddingObjectsFromArray:[super accessibilityAttributeNames]]; - attributes = [[set allObjects] retain]; + attributes = [[set setByAddingObjectsFromArray:[super accessibilityAttributeNames]] allObjects]; } return attributes; } @@ -955,8 +944,7 @@ doScroll: // PATTR(AttributedStringForRange), ]]; - set = [set setByAddingObjectsFromArray:[super accessibilityParameterizedAttributeNames]]; - attributes = [[set allObjects] retain]; + attributes = [[set setByAddingObjectsFromArray:[super accessibilityParameterizedAttributeNames]] allObjects]; } return attributes; } @@ -1320,7 +1308,7 @@ static void update_menu_key_equivalents (NSMenu* menu, action_to_key_t const& ac std::vector newChoices = editor->choices(); newChoices.erase(std::remove_if(newChoices.begin(), newChoices.end(), [&newPrefix](std::string const& str) { return str.find(newPrefix) != 0; }), newChoices.end()); - choiceMenu.choices = (NSArray*)((CFArrayRef)cf::wrap(newChoices)); + choiceMenu.choices = (__bridge NSArray*)((CFArrayRef)cf::wrap(newChoices)); bool didEdit = oldPrefix != newPrefix; bool didDelete = didEdit && oldPrefix.find(newPrefix) == 0; @@ -1497,7 +1485,7 @@ static void update_menu_key_equivalents (NSMenu* menu, action_to_key_t const& ac - (NSMenu*)contextMenuWithMisspelledWord:(NSString*)aWord { - NSMenu* menu = [[[NSMenu alloc] initWithTitle:@""] autorelease]; + NSMenu* menu = [[NSMenu alloc] initWithTitle:@""]; NSMenuItem* item = nil; if(aWord) @@ -1703,7 +1691,7 @@ static void update_menu_key_equivalents (NSMenu* menu, action_to_key_t const& ac if(!self.liveSearchView) { - self.liveSearchView = [[[LiveSearchView alloc] initWithFrame:NSZeroRect] autorelease]; + self.liveSearchView = [[LiveSearchView alloc] initWithFrame:NSZeroRect]; [documentView addAuxiliaryView:self.liveSearchView atEdge:NSMinYEdge]; self.liveSearchView.nextResponder = self; } @@ -1826,14 +1814,14 @@ static void update_menu_key_equivalents (NSMenu* menu, action_to_key_t const& ac { AUTO_REFRESH; [self recordSelector:_cmd withArgument:someOptions]; - editor->find_dispatch(plist::convert(someOptions)); + editor->find_dispatch(plist::convert((__bridge CFDictionaryRef)someOptions)); } - (void)insertSnippetWithOptions:(NSDictionary*)someOptions // For Dialog popup { AUTO_REFRESH; [self recordSelector:_cmd withArgument:someOptions]; - editor->snippet_dispatch(plist::convert(someOptions), editor->variables(std::map(), to_s([self scopeAttributes]))); + editor->snippet_dispatch(plist::convert((__bridge CFDictionaryRef)someOptions), editor->variables(std::map(), to_s([self scopeAttributes]))); } - (void)undo:(id)anArgument // MACRO? @@ -1936,10 +1924,8 @@ static void update_menu_key_equivalents (NSMenu* menu, action_to_key_t const& ac - (void)setBlinkCaretTimer:(NSTimer*)aValue { - NSTimer* oldBlinkCaretTimer = blinkCaretTimer; - blinkCaretTimer = [aValue retain]; - [oldBlinkCaretTimer invalidate]; - [oldBlinkCaretTimer release]; + [blinkCaretTimer invalidate]; + blinkCaretTimer = aValue; } - (void)resetBlinkCaretTimer @@ -2059,16 +2045,6 @@ static void update_menu_key_equivalents (NSMenu* menu, action_to_key_t const& ac } } -- (void)setWrapColumnSheetDidEnd:(NSAlert*)alert returnCode:(NSInteger)returnCode contextInfo:(void*)info -{ - if(returnCode == NSAlertDefaultReturn) - { - NSTextField* textField = (NSTextField*)[alert accessoryView]; - [self setWrapColumn:std::max([textField integerValue], 10)]; - } - [alert release]; -} - - (void)takeWrapColumnFrom:(id)sender { ASSERT([sender respondsToSelector:@selector(tag)]); @@ -2077,14 +2053,17 @@ static void update_menu_key_equivalents (NSMenu* menu, action_to_key_t const& ac if([sender tag] == NSWrapColumnAskUser) { - NSTextField* textField = [[[NSTextField alloc] initWithFrame:NSZeroRect] autorelease]; + NSTextField* textField = [[NSTextField alloc] initWithFrame:NSZeroRect]; [textField setIntegerValue:wrapColumn == NSWrapColumnWindowWidth ? 80 : wrapColumn]; [textField sizeToFit]; [textField setFrameSize:NSMakeSize(200, NSHeight([textField frame]))]; - NSAlert* alert = [[NSAlert alertWithMessageText:@"Set Wrap Column" defaultButton:@"OK" alternateButton:@"Cancel" otherButton:nil informativeTextWithFormat:@"Specify what column text should wrap at:"] retain]; + NSAlert* alert = [NSAlert alertWithMessageText:@"Set Wrap Column" defaultButton:@"OK" alternateButton:@"Cancel" otherButton:nil informativeTextWithFormat:@"Specify what column text should wrap at:"]; [alert setAccessoryView:textField]; - [alert beginSheetModalForWindow:[self window] modalDelegate:self didEndSelector:@selector(setWrapColumnSheetDidEnd:returnCode:contextInfo:) contextInfo:NULL]; + OakShowAlertForWindow(alert, [self window], ^(NSInteger returnCode){ + if(returnCode == NSAlertDefaultReturn) + [self setWrapColumn:std::max([textField integerValue], 10)]; + }); } else { @@ -2149,7 +2128,6 @@ static void update_menu_key_equivalents (NSMenu* menu, action_to_key_t const& ac if([aSelectionString isEqualToString:selectionString]) return; - [selectionString release]; selectionString = [aSelectionString copy]; NSAccessibilityPostNotification(self, NSAccessibilitySelectedTextChangedNotification); if(UAZoomEnabled()) @@ -2245,8 +2223,7 @@ static void update_menu_key_equivalents (NSMenu* menu, action_to_key_t const& ac if(macroRecordingArray) { D(DBF_OakTextView_Macros, bug("%s\n", to_s(plist::convert(macroRecordingArray)).c_str());); - [[NSUserDefaults standardUserDefaults] setObject:[[macroRecordingArray copy] autorelease] forKey:@"OakMacroManagerScratchMacro"]; - [macroRecordingArray release]; + [[NSUserDefaults standardUserDefaults] setObject:[macroRecordingArray copy] forKey:@"OakMacroManagerScratchMacro"]; macroRecordingArray = nil; } else @@ -2260,7 +2237,7 @@ static void update_menu_key_equivalents (NSMenu* menu, action_to_key_t const& ac D(DBF_OakTextView_Macros, bug("%s\n", to_s(plist::convert([[NSUserDefaults standardUserDefaults] arrayForKey:@"OakMacroManagerScratchMacro"])).c_str());); AUTO_REFRESH; if(NSArray* scratchMacro = [[NSUserDefaults standardUserDefaults] arrayForKey:@"OakMacroManagerScratchMacro"]) - editor->macro_dispatch(plist::convert(@{ @"commands" : scratchMacro }), editor->variables(std::map(), to_s([self scopeAttributes]))); + editor->macro_dispatch(plist::convert((__bridge CFDictionaryRef)@{ @"commands" : scratchMacro }), editor->variables(std::map(), to_s([self scopeAttributes]))); else NSBeep(); } @@ -2521,8 +2498,7 @@ static void update_menu_key_equivalents (NSMenu* menu, action_to_key_t const& ac { if(ibeamCursor != aCursor) { - [ibeamCursor release]; - ibeamCursor = [aCursor retain]; + ibeamCursor = aCursor; [[self window] invalidateCursorRectsForView:self]; } } @@ -2636,7 +2612,7 @@ static void update_menu_key_equivalents (NSMenu* menu, action_to_key_t const& ac ng::ranges_t const ranges = ng::dissect_columnar(document->buffer(), editor->ranges()); NSImage* srcImage = [self imageForRanges:ranges imageRect:&srcRect]; - NSImage* image = [[[NSImage alloc] initWithSize:srcImage.size] autorelease]; + NSImage* image = [[NSImage alloc] initWithSize:srcImage.size]; [image lockFocus]; [srcImage drawAtPoint:NSZeroPoint fromRect:NSZeroRect operation:NSCompositeCopy fraction:0.5]; [image unlockFocus]; diff --git a/Frameworks/OakTextView/target b/Frameworks/OakTextView/target index 807a8577..fde32723 100644 --- a/Frameworks/OakTextView/target +++ b/Frameworks/OakTextView/target @@ -3,5 +3,3 @@ EXPORT = src/OakDocumentView.h src/GutterView.h src/OakTextView.h CP_Resources = resources/* LINK += layout text bundles editor document theme ns plist OakAppKit OakFoundation OakSystem regexp scope settings BundleMenu OakFilterList FRAMEWORKS = Cocoa - -OBJCXX_FLAGS += -fno-objc-arc