diff options
author | Neil Hodgson <nyamatongwe@gmail.com> | 2017-06-07 17:58:21 +1000 |
---|---|---|
committer | Neil Hodgson <nyamatongwe@gmail.com> | 2017-06-07 17:58:21 +1000 |
commit | 37508011503a9e6b451759197754bbd04869a230 (patch) | |
tree | 8db18d640e39d061cb7a8dc31c39f7bdb5c26cc2 | |
parent | 2abb46176072c6f83767f6cb5c1c95401232c061 (diff) | |
download | scintilla-mirror-37508011503a9e6b451759197754bbd04869a230.tar.gz |
Use property dot syntax.
Part of modernization.
-rw-r--r-- | cocoa/InfoBar.mm | 62 | ||||
-rw-r--r-- | cocoa/PlatCocoa.mm | 70 | ||||
-rw-r--r-- | cocoa/ScintillaCocoa.mm | 130 | ||||
-rw-r--r-- | cocoa/ScintillaView.mm | 114 |
4 files changed, 188 insertions, 188 deletions
diff --git a/cocoa/InfoBar.mm b/cocoa/InfoBar.mm index 8c2df550a..7f86ad697 100644 --- a/cocoa/InfoBar.mm +++ b/cocoa/InfoBar.mm @@ -89,7 +89,7 @@ NSString* path = [bundle pathForResource: @"info_bar_bg" ofType: @"tiff" inDirectory: nil]; mBackground = [[NSImage alloc] initWithContentsOfFile: path]; - if (![mBackground isValid]) + if (!mBackground.valid) NSLog(@"Background image for info bar is invalid."); mScaleFactor = 1.0; @@ -122,7 +122,7 @@ [self setCaretPosition: location]; break; case IBNStatusChanged: - [mStatusTextLabel setStringValue: message]; + mStatusTextLabel.stringValue = message; break; } } @@ -157,8 +157,8 @@ static float BarFontSize = 10.0; mZoomPopup = [[NSPopUpButton alloc] initWithFrame: NSMakeRect(0.0, 0.0, 1.0, 1.0) pullsDown: NO]; // No border or background please. - [[mZoomPopup cell] setBordered: NO]; - [[mZoomPopup cell] setArrowPosition: NSPopUpArrowAtBottom]; + [mZoomPopup.cell setBordered: NO]; + [mZoomPopup.cell setArrowPosition: NSPopUpArrowAtBottom]; // Fill it. for (unsigned count = 0; count < numberOfDefaultItems; count++) @@ -171,11 +171,11 @@ static float BarFontSize = 10.0; [mZoomPopup selectItemAtIndex: DefaultScaleMenuSelectedItemIndex]; // Hook it up. - [mZoomPopup setTarget: self]; - [mZoomPopup setAction: @selector(zoomItemAction:)]; + mZoomPopup.target = self; + mZoomPopup.action = @selector(zoomItemAction:); // Set a suitable font. - [mZoomPopup setFont: [NSFont menuBarFontOfSize: BarFontSize]]; + mZoomPopup.font = [NSFont menuBarFontOfSize: BarFontSize]; // Make sure the popup is big enough to fit the cells. [mZoomPopup sizeToFit]; @@ -196,11 +196,11 @@ static float BarFontSize = 10.0; [mCaretPositionLabel setEditable: NO]; [mCaretPositionLabel setSelectable: NO]; [mCaretPositionLabel setDrawsBackground: NO]; - [mCaretPositionLabel setFont: [NSFont menuBarFontOfSize: BarFontSize]]; + mCaretPositionLabel.font = [NSFont menuBarFontOfSize: BarFontSize]; - NSTextFieldCell* cell = [mCaretPositionLabel cell]; - [cell setPlaceholderString: @"0:0"]; - [cell setAlignment: NSCenterTextAlignment]; + NSTextFieldCell* cell = mCaretPositionLabel.cell; + cell.placeholderString = @"0:0"; + cell.alignment = NSCenterTextAlignment; [self addSubview: mCaretPositionLabel]; @@ -211,10 +211,10 @@ static float BarFontSize = 10.0; [mStatusTextLabel setEditable: NO]; [mStatusTextLabel setSelectable: NO]; [mStatusTextLabel setDrawsBackground: NO]; - [mStatusTextLabel setFont: [NSFont menuBarFontOfSize: BarFontSize]]; + mStatusTextLabel.font = [NSFont menuBarFontOfSize: BarFontSize]; - cell = [mStatusTextLabel cell]; - [cell setPlaceholderString: @""]; + cell = mStatusTextLabel.cell; + cell.placeholderString = @""; [self addSubview: mStatusTextLabel]; @@ -248,7 +248,7 @@ static float BarFontSize = 10.0; if (mDisplayMask & IBShowZoom) { - verticalLineRect = [mZoomPopup frame]; + verticalLineRect = mZoomPopup.frame; verticalLineRect.origin.x += verticalLineRect.size.width + 1.0; verticalLineRect.size.width = 1.0; if (NSIntersectsRect(rect, verticalLineRect)) @@ -260,7 +260,7 @@ static float BarFontSize = 10.0; if (mDisplayMask & IBShowCaretPosition) { - verticalLineRect = [mCaretPositionLabel frame]; + verticalLineRect = mCaretPositionLabel.frame; verticalLineRect.origin.x += verticalLineRect.size.width + 1.0; verticalLineRect.size.width = 1.0; if (NSIntersectsRect(rect, verticalLineRect)) @@ -285,7 +285,7 @@ static float BarFontSize = 10.0; */ - (void) setFrame: (NSRect) newFrame { - [super setFrame: newFrame]; + super.frame = newFrame; [self positionSubViews]; } @@ -293,12 +293,12 @@ static float BarFontSize = 10.0; - (void) positionSubViews { - NSRect currentBounds = {{0, 0}, {0, [self frame].size.height}}; + NSRect currentBounds = {{0, 0}, {0, self.frame.size.height}}; if (mDisplayMask & IBShowZoom) { [mZoomPopup setHidden: NO]; - currentBounds.size.width = [mZoomPopup frame].size.width; - [mZoomPopup setFrame: currentBounds]; + currentBounds.size.width = mZoomPopup.frame.size.width; + mZoomPopup.frame = currentBounds; currentBounds.origin.x += currentBounds.size.width + 1; // Add 1 for the separator. } else @@ -307,8 +307,8 @@ static float BarFontSize = 10.0; if (mDisplayMask & IBShowCaretPosition) { [mCaretPositionLabel setHidden: NO]; - currentBounds.size.width = [mCaretPositionLabel frame].size.width; - [mCaretPositionLabel setFrame: currentBounds]; + currentBounds.size.width = mCaretPositionLabel.frame.size.width; + mCaretPositionLabel.frame = currentBounds; currentBounds.origin.x += currentBounds.size.width + 1; } else @@ -318,8 +318,8 @@ static float BarFontSize = 10.0; { // The status text always takes the rest of the available space. [mStatusTextLabel setHidden: NO]; - currentBounds.size.width = [self frame].size.width - currentBounds.origin.x; - [mStatusTextLabel setFrame: currentBounds]; + currentBounds.size.width = self.frame.size.width - currentBounds.origin.x; + mStatusTextLabel.frame = currentBounds; } else [mStatusTextLabel setHidden: YES]; @@ -358,7 +358,7 @@ static float BarFontSize = 10.0; } else { - [self setScaleFactor: [selectedFactorObject floatValue] adjustPopup: NO]; + [self setScaleFactor: selectedFactorObject.floatValue adjustPopup: NO]; } } @@ -412,7 +412,7 @@ static float BarFontSize = 10.0; mCurrentCaretX = newX; mCurrentCaretY = newY; - [mCaretPositionLabel setStringValue: [NSString stringWithFormat: @"%d:%d", newX, newY]]; + mCaretPositionLabel.stringValue = [NSString stringWithFormat: @"%d:%d", newX, newY]; } } @@ -423,18 +423,18 @@ static float BarFontSize = 10.0; */ - (void) sizeToFit { - NSRect frame = [self frame]; + NSRect frame = self.frame; frame.size.width = 0; if (mDisplayMask & IBShowZoom) - frame.size.width += [mZoomPopup frame].size.width; + frame.size.width += mZoomPopup.frame.size.width; if (mDisplayMask & IBShowCaretPosition) - frame.size.width += [mCaretPositionLabel frame].size.width; + frame.size.width += mCaretPositionLabel.frame.size.width; if (mDisplayMask & IBShowStatusText) - frame.size.width += [mStatusTextLabel frame].size.width; + frame.size.width += mStatusTextLabel.frame.size.width; - [self setFrame: frame]; + self.frame = frame; } @end diff --git a/cocoa/PlatCocoa.mm b/cocoa/PlatCocoa.mm index aaf714e52..2908bb206 100644 --- a/cocoa/PlatCocoa.mm +++ b/cocoa/PlatCocoa.mm @@ -1112,14 +1112,14 @@ Window::~Window() bool Window::HasFocus() { NSView* container = (__bridge NSView *)(wid); - return [[container window] firstResponder] == container; + return container.window.firstResponder == container; } //-------------------------------------------------------------------------------------------------- static CGFloat ScreenMax() { - return NSMaxY([[NSScreen mainScreen] frame]); + return NSMaxY([NSScreen mainScreen].frame); } //-------------------------------------------------------------------------------------------------- @@ -1135,15 +1135,15 @@ PRectangle Window::GetPosition() { // NSView NSView* view = idWin; - win = [view window]; - rect = [view convertRect: [view bounds] toView: nil]; + win = view.window; + rect = [view convertRect: view.bounds toView: nil]; rect = [win convertRectToScreen:rect]; } else { // NSWindow win = idWin; - rect = [win frame]; + rect = win.frame; } CGFloat screenHeight = ScreenMax(); // Invert screen positions to match Scintilla @@ -1170,8 +1170,8 @@ void Window::SetPosition(PRectangle rc) // Moves this view inside the parent view NSRect nsrc = NSMakeRect(rc.left, rc.bottom, rc.Width(), rc.Height()); NSView* view = idWin; - nsrc = [[view window] convertRectFromScreen:nsrc]; - [view setFrame: nsrc]; + nsrc = [view.window convertRectFromScreen:nsrc]; + view.frame = nsrc; } else { @@ -1247,7 +1247,7 @@ void Window::InvalidateAll() { // NSWindow NSWindow* win = idWin; - container = [win contentView]; + container = win.contentView; container.needsDisplay = YES; } container.needsDisplay = YES; @@ -1273,7 +1273,7 @@ void Window::InvalidateRectangle(PRectangle rc) { // NSWindow NSWindow* win = idWin; - container = [win contentView]; + container = win.contentView; } [container setNeedsDisplayInRect: PRectangleToNSRect(rc)]; } @@ -1316,7 +1316,7 @@ void Window::SetTitle(const char* s) { NSWindow* win = idWin; NSString* sTitle = @(s); - [win setTitle:sTitle]; + win.title = sTitle; } } } @@ -1331,15 +1331,15 @@ PRectangle Window::GetMonitorRect(Point) if ([idWin isKindOfClass: [NSView class]]) { NSView* view = idWin; - idWin = [view window]; + idWin = view.window; } if ([idWin isKindOfClass: [NSWindow class]]) { PRectangle rcPosition = GetPosition(); NSWindow* win = idWin; - NSScreen* screen = [win screen]; - NSRect rect = [screen visibleFrame]; + NSScreen* screen = win.screen; + NSRect rect = screen.visibleFrame; CGFloat screenHeight = rect.origin.y + rect.size.height; // Invert screen positions to match Scintilla PRectangle rcWork( @@ -1430,7 +1430,7 @@ NSObject #pragma unused(aTableView) if (!box) return nil; - if ([(NSString*)[aTableColumn identifier] isEqualToString: @"icon"]) + if ([(NSString*)aTableColumn.identifier isEqualToString: @"icon"]) { return box->ImageForRow(rowIndex); } @@ -1617,26 +1617,26 @@ void ListBoxImpl::Create(Window& /*parent*/, int /*ctrlID*/, Scintilla::Point pt [scroller setHasVerticalScroller:YES]; table = [[NSTableView alloc] initWithFrame: scRect]; [table setHeaderView:nil]; - [scroller setDocumentView: table]; + scroller.documentView = table; colIcon = [[NSTableColumn alloc] initWithIdentifier:@"icon"]; - [colIcon setWidth: 20]; + colIcon.width = 20; [colIcon setEditable:NO]; [colIcon setHidden:YES]; NSImageCell* imCell = [[NSImageCell alloc] init]; - [colIcon setDataCell:imCell]; + colIcon.dataCell = imCell; [table addTableColumn:colIcon]; colText = [[NSTableColumn alloc] initWithIdentifier:@"name"]; - [colText setResizingMask:NSTableColumnAutoresizingMask]; + colText.resizingMask = NSTableColumnAutoresizingMask; [colText setEditable:NO]; [table addTableColumn:colText]; ds = [[AutoCompletionDataSource alloc] init]; - [ds setBox:this]; - [table setDataSource: ds]; // Weak reference - [scroller setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable]; - [[winLB contentView] addSubview: scroller]; + ds.box = this; + table.dataSource = ds; // Weak reference + scroller.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable; + [winLB.contentView addSubview: scroller]; - [table setTarget:ds]; - [table setDoubleAction:@selector(doubleClick:)]; + table.target = ds; + table.doubleAction = @selector(doubleClick:); table.selectionHighlightStyle = NSTableViewSelectionHighlightStyleSourceList; wid = (__bridge_retained WindowID)winLB; } @@ -1649,9 +1649,9 @@ void ListBoxImpl::SetFont(Font& font_) font.Release(); font.SetID(new QuartzTextStyle(*style)); NSFont *pfont = (__bridge NSFont *)style->getFontRef(); - [[colText dataCell] setFont: pfont]; - CGFloat itemHeight = ceil([pfont boundingRectForFont].size.height); - [table setRowHeight:itemHeight]; + [colText.dataCell setFont: pfont]; + CGFloat itemHeight = ceil(pfont.boundingRectForFont.size.height); + table.rowHeight = itemHeight; } void ListBoxImpl::SetAverageCharWidth(int width) @@ -1675,7 +1675,7 @@ PRectangle ListBoxImpl::GetDesiredRect() rcDesired = GetPosition(); // There appears to be an extra pixel above and below the row contents - CGFloat itemHeight = [table rowHeight] + 2; + CGFloat itemHeight = table.rowHeight + 2; int rows = Length(); if ((rows == 0) || (rows > desiredVisibleRows)) @@ -1703,10 +1703,10 @@ PRectangle ListBoxImpl::GetDesiredRect() int ListBoxImpl::CaretFromEdge() { - if ([colIcon isHidden]) + if (colIcon.hidden) return 3; else - return 6 + static_cast<int>([colIcon width]); + return 6 + static_cast<int>(colIcon.width); } void ListBoxImpl::ReleaseViews() @@ -1736,7 +1736,7 @@ void ListBoxImpl::Append(char* s, int type) if (width > maxItemWidth) { maxItemWidth = width; - [colText setWidth: maxItemWidth]; + colText.width = maxItemWidth; } NSImage *img = images[@(type)]; if (img) @@ -1746,7 +1746,7 @@ void ListBoxImpl::Append(char* s, int type) { [colIcon setHidden: NO]; maxIconWidth = widthIcon; - [colIcon setWidth: maxIconWidth]; + colIcon.width = maxIconWidth; } } } @@ -1797,7 +1797,7 @@ void ListBoxImpl::Select(int n) int ListBoxImpl::GetSelection() { - return static_cast<int>([table selectedRow]); + return static_cast<int>(table.selectedRow); } int ListBoxImpl::Find(const char* prefix) @@ -1922,7 +1922,7 @@ void Window::Destroy() - (void) handleCommand: (NSMenuItem*) sender { - owner->HandleCommand([sender tag]); + owner->HandleCommand(sender.tag); } //-------------------------------------------------------------------------------------------------- @@ -2015,7 +2015,7 @@ ColourDesired Platform::ChromeHighlight() const char *Platform::DefaultFont() { NSString* name = [[NSUserDefaults standardUserDefaults] stringForKey: @"NSFixedPitchFont"]; - return [name UTF8String]; + return name.UTF8String; } //-------------------------------------------------------------------------------------------------- diff --git a/cocoa/ScintillaCocoa.mm b/cocoa/ScintillaCocoa.mm index eb871f448..3fa0904bb 100644 --- a/cocoa/ScintillaCocoa.mm +++ b/cocoa/ScintillaCocoa.mm @@ -230,7 +230,7 @@ const CGFloat paddingHighlightY = 2; } - (void) animateMatch: (CGPoint)ptText bounce:(BOOL)bounce { - if (!self.sFind || ![self.sFind length]) { + if (!self.sFind || !(self.sFind).length) { [self hideMatch]; return; } @@ -282,10 +282,10 @@ const CGFloat paddingHighlightY = 2; animFade.toValue = @0.0f; CAAnimationGroup *group = [CAAnimationGroup animation]; - [group setDuration:0.5]; + group.duration = 0.5; group.removedOnCompletion = NO; group.fillMode = kCAFillModeForwards; - [group setAnimations:@[animBounce, animFade]]; + group.animations = @[animBounce, animFade]; [self addAnimation:group forKey:@"animateFound"]; } @@ -652,10 +652,10 @@ std::string ScintillaCocoa::CaseMapString(const std::string &s, int caseMapping) switch (caseMapping) { case cmUpper: - sMapped = [(__bridge NSString *)cfsVal uppercaseString]; + sMapped = ((__bridge NSString *)cfsVal).uppercaseString; break; case cmLower: - sMapped = [(__bridge NSString *)cfsVal lowercaseString]; + sMapped = ((__bridge NSString *)cfsVal).lowercaseString; break; default: sMapped = (__bridge NSString *)cfsVal; @@ -684,7 +684,7 @@ void ScintillaCocoa::CancelModes() { */ NSScrollView* ScintillaCocoa::ScrollContainer() const { NSView* container = (__bridge NSView*)(wMain.GetID()); - return static_cast<NSScrollView*>([[container superview] superview]); + return static_cast<NSScrollView*>(container.superview.superview); } //-------------------------------------------------------------------------------------------------- @@ -705,7 +705,7 @@ SCIContentView* ScintillaCocoa::ContentView() Scintilla::Point ScintillaCocoa::GetVisibleOriginInMain() const { NSScrollView *scrollView = ScrollContainer(); - NSRect contentRect = [[scrollView contentView] bounds]; + NSRect contentRect = scrollView.contentView.bounds; return Point(static_cast<XYPOSITION>(contentRect.origin.x), static_cast<XYPOSITION>(contentRect.origin.y)); } @@ -719,7 +719,7 @@ Scintilla::Point ScintillaCocoa::GetVisibleOriginInMain() const PRectangle ScintillaCocoa::GetClientRectangle() const { NSScrollView *scrollView = ScrollContainer(); - NSSize size = [[scrollView contentView] bounds].size; + NSSize size = scrollView.contentView.bounds.size; Point origin = GetVisibleOriginInMain(); return PRectangle(origin.x, origin.y, static_cast<XYPOSITION>(origin.x+size.width), static_cast<XYPOSITION>(origin.y + size.height)); @@ -734,7 +734,7 @@ PRectangle ScintillaCocoa::GetClientDrawingRectangle() { #if MAC_OS_X_VERSION_MAX_ALLOWED > 1080 NSView *content = ContentView(); if ([content respondsToSelector: @selector(setPreparedContentRect:)]) { - NSRect rcPrepared = [content preparedContentRect]; + NSRect rcPrepared = content.preparedContentRect; if (!NSIsEmptyRect(rcPrepared)) return NSRectToPRectangle(rcPrepared); } @@ -776,7 +776,7 @@ void ScintillaCocoa::DiscardOverdraw() // If running on 10.9, reset prepared area to visible area NSView *content = ContentView(); if ([content respondsToSelector: @selector(setPreparedContentRect:)]) { - content.preparedContentRect = [content visibleRect]; + content.preparedContentRect = content.visibleRect; } #endif } @@ -857,7 +857,7 @@ sptr_t ScintillaCocoa::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPar break; case SCI_GRABFOCUS: - [[ContentView() window] makeFirstResponder:ContentView()]; + [ContentView().window makeFirstResponder:ContentView()]; break; case SCI_SETBUFFEREDDRAW: @@ -962,7 +962,7 @@ void ScintillaCocoa::FineTickerStart(TickReason reason, int millis, int toleranc repeats: YES]; if (tolerance && [fineTimer respondsToSelector: @selector(setTolerance:)]) { - [fineTimer setTolerance: tolerance / 1000.0]; + fineTimer.tolerance = tolerance / 1000.0; } timers[reason] = fineTimer; [NSRunLoop.currentRunLoop addTimer: fineTimer forMode: NSDefaultRunLoopMode]; @@ -1114,14 +1114,14 @@ void ScintillaCocoa::CTPaint(void* gc, NSRect rc) { - (void) drawRect: (NSRect) needsDisplayInRect { if (sci) { - CGContextRef context = (CGContextRef) [[NSGraphicsContext currentContext] graphicsPort]; + CGContextRef context = (CGContextRef) [NSGraphicsContext currentContext].graphicsPort; sci->CTPaint(context, needsDisplayInRect); } } - (void) mouseDown: (NSEvent *) event { if (sci) { - sci->CallTipMouseDown([event locationInWindow]); + sci->CallTipMouseDown(event.locationInWindow); } } @@ -1135,7 +1135,7 @@ void ScintillaCocoa::CTPaint(void* gc, NSRect rc) { @end void ScintillaCocoa::CallTipMouseDown(NSPoint pt) { - NSRect rectBounds = [(__bridge NSView *)(ct.wDraw.GetID()) bounds]; + NSRect rectBounds = ((__bridge NSView *)(ct.wDraw.GetID())).bounds; Point location(static_cast<XYPOSITION>(pt.x), static_cast<XYPOSITION>(rectBounds.size.height - pt.y)); ct.MouseClick(location); @@ -1144,7 +1144,7 @@ void ScintillaCocoa::CallTipMouseDown(NSPoint pt) { static bool HeightDifferent(WindowID wCallTip, PRectangle rc) { NSWindow *callTip = (__bridge NSWindow *)wCallTip; - CGFloat height = NSHeight([callTip frame]); + CGFloat height = NSHeight(callTip.frame); return height != rc.Height(); } @@ -1162,9 +1162,9 @@ void ScintillaCocoa::CreateCallTipWindow(PRectangle rc) { [callTip setHasShadow:YES]; NSRect ctContent = NSMakeRect(0,0, rc.Width(), rc.Height()); CallTipView *caption = [[CallTipView alloc] initWithFrame: ctContent]; - [caption setAutoresizingMask: NSViewWidthSizable | NSViewMaxYMargin]; + caption.autoresizingMask = NSViewWidthSizable | NSViewMaxYMargin; [caption setSci: this]; - [[callTip contentView] addSubview: caption]; + [callTip.contentView addSubview: caption]; [callTip orderFront:caption]; ct.wCallTip = (__bridge_retained WindowID)callTip; ct.wDraw = (__bridge WindowID)caption; @@ -1182,12 +1182,12 @@ void ScintillaCocoa::AddToPopUp(const char *label, int cmd, bool enabled) item = [NSMenuItem separatorItem]; } else { item = [[NSMenuItem alloc] init]; - [item setTitle: @(label)]; + item.title = @(label); } - [item setTarget: menu]; - [item setAction: @selector(handleCommand:)]; - [item setTag: cmd]; - [item setEnabled: enabled]; + item.target = menu; + item.action = @selector(handleCommand:); + item.tag = cmd; + item.enabled = enabled; [menu addItem: item]; } @@ -1451,7 +1451,7 @@ void ScintillaCocoa::StartDrag() [image addRepresentation: bitmap]; NSImage* dragImage = [[NSImage alloc] initWithSize: selectionRectangle.size]; - [dragImage setBackgroundColor: [NSColor clearColor]]; + dragImage.backgroundColor = [NSColor clearColor]; [dragImage lockFocus]; [image drawAtPoint: NSZeroPoint fromRect: NSZeroRect operation: NSCompositeSourceOver fraction: 0.5]; [dragImage unlockFocus]; @@ -1470,7 +1470,7 @@ void ScintillaCocoa::StartDrag() NSDraggingItem *dragItem = [[NSDraggingItem alloc ]initWithPasteboardWriter:pbItem]; NSScrollView *scrollContainer = ScrollContainer(); - NSRect contentRect = [[scrollContainer contentView] bounds]; + NSRect contentRect = scrollContainer.contentView.bounds; NSRect draggingRect = NSOffsetRect(selectionRectangle, contentRect.origin.x, contentRect.origin.y); [dragItem setDraggingFrame:draggingRect contents:dragImage]; NSDraggingSession *dragSession = @@ -1513,11 +1513,11 @@ NSDragOperation ScintillaCocoa::DraggingUpdated(id <NSDraggingInfo> info) NSPasteboard* pasteboard = [info draggingPasteboard]; // Return what type of operation we will perform. Prefer move over copy. - if ([[pasteboard types] containsObject: NSStringPboardType] || - [[pasteboard types] containsObject: ScintillaRecPboardType]) + if ([pasteboard.types containsObject: NSStringPboardType] || + [pasteboard.types containsObject: ScintillaRecPboardType]) return (sourceDragMask & NSDragOperationMove) ? NSDragOperationMove : NSDragOperationCopy; - if ([[pasteboard types] containsObject: NSFilenamesPboardType]) + if ([pasteboard.types containsObject: NSFilenamesPboardType]) return (sourceDragMask & NSDragOperationGeneric); return NSDragOperationNone; } @@ -1544,11 +1544,11 @@ bool ScintillaCocoa::PerformDragOperation(id <NSDraggingInfo> info) { NSPasteboard* pasteboard = [info draggingPasteboard]; - if ([[pasteboard types] containsObject: NSFilenamesPboardType]) + if ([pasteboard.types containsObject: NSFilenamesPboardType]) { NSArray* files = [pasteboard propertyListForType: NSFilenamesPboardType]; for (NSString* uri in files) - NotifyURIDropped([uri UTF8String]); + NotifyURIDropped(uri.UTF8String); } else { @@ -1614,7 +1614,7 @@ bool ScintillaCocoa::GetPasteboardData(NSPasteboard* board, SelectionText* selec { CFStringEncoding encoding = EncodingFromCharacterSet(IsUnicodeMode(), vs.styles[STYLE_DEFAULT].characterSet); - CFRange rangeAll = {0, static_cast<CFIndex>([data length])}; + CFRange rangeAll = {0, static_cast<CFIndex>(data.length)}; CFIndex usedLen = 0; CFStringGetBytes((CFStringRef)data, rangeAll, encoding, '?', false, NULL, 0, &usedLen); @@ -1826,7 +1826,7 @@ bool ScintillaCocoa::SyncPaint(void* gc, PRectangle rc) */ void ScintillaCocoa::PaintMargin(NSRect aRect) { - CGContextRef gc = (CGContextRef) [[NSGraphicsContext currentContext] graphicsPort]; + CGContextRef gc = (CGContextRef) [NSGraphicsContext currentContext].graphicsPort; PRectangle rc = NSRectToPRectangle(aRect); rcPaint = rc; @@ -1889,8 +1889,8 @@ void ScintillaCocoa::SetVerticalScrollPos() { NSScrollView *scrollView = ScrollContainer(); if (scrollView) { - NSClipView *clipView = [scrollView contentView]; - NSRect contentRect = [clipView bounds]; + NSClipView *clipView = scrollView.contentView; + NSRect contentRect = clipView.bounds; [clipView scrollToPoint: NSMakePoint(contentRect.origin.x, topLine * vs.lineHeight)]; [scrollView reflectScrolledClipView:clipView]; } @@ -1912,8 +1912,8 @@ void ScintillaCocoa::SetHorizontalScrollPos() xOffset = maxXOffset; NSScrollView *scrollView = ScrollContainer(); if (scrollView) { - NSClipView * clipView = [scrollView contentView]; - NSRect contentRect = [clipView bounds]; + NSClipView * clipView = scrollView.contentView; + NSRect contentRect = clipView.bounds; [clipView scrollToPoint: NSMakePoint(xOffset, contentRect.origin.y)]; [scrollView reflectScrolledClipView:clipView]; } @@ -1942,11 +1942,11 @@ bool ScintillaCocoa::SetScrollingSize(void) { if (!enteredSetScrollingSize) { enteredSetScrollingSize = true; NSScrollView *scrollView = ScrollContainer(); - NSClipView *clipView = [ScrollContainer() contentView]; - NSRect clipRect = [clipView bounds]; + NSClipView *clipView = ScrollContainer().contentView; + NSRect clipRect = clipView.bounds; CGFloat docHeight = cs.LinesDisplayed() * vs.lineHeight; if (!endAtLastLine) - docHeight += (int([scrollView bounds].size.height / vs.lineHeight)-3) * vs.lineHeight; + docHeight += (int(scrollView.bounds.size.height / vs.lineHeight)-3) * vs.lineHeight; // Allow extra space so that last scroll position places whole line at top int clipExtra = int(clipRect.size.height) % vs.lineHeight; docHeight += clipExtra; @@ -1959,14 +1959,14 @@ bool ScintillaCocoa::SetScrollingSize(void) { if (!showHorizontalScroll) docWidth = clipRect.size.width; NSRect contentRect = {{0, 0}, {docWidth, docHeight}}; - NSRect contentRectNow = [inner frame]; + NSRect contentRectNow = inner.frame; changes = (contentRect.size.width != contentRectNow.size.width) || (contentRect.size.height != contentRectNow.size.height); if (changes) { - [inner setFrame: contentRect]; + inner.frame = contentRect; } - [scrollView setHasVerticalScroller: verticalScrollBarVisible]; - [scrollView setHasHorizontalScroller: showHorizontalScroll]; + scrollView.hasVerticalScroller = verticalScrollBarVisible; + scrollView.hasHorizontalScroller = showHorizontalScroll; SetVerticalScrollPos(); enteredSetScrollingSize = false; } @@ -2230,7 +2230,7 @@ static int TranslateModifierFlags(NSUInteger modifiers) bool ScintillaCocoa::KeyboardInput(NSEvent* event) { // For now filter out function keys. - NSString* input = [event charactersIgnoringModifiers]; + NSString* input = event.charactersIgnoringModifiers; bool handled = false; @@ -2238,7 +2238,7 @@ bool ScintillaCocoa::KeyboardInput(NSEvent* event) for (size_t i = 0; i < input.length; i++) { const UniChar originalKey = [input characterAtIndex: i]; - NSEventModifierFlags modifierFlags = [event modifierFlags]; + NSEventModifierFlags modifierFlags = event.modifierFlags; UniChar key = KeyTranslate(originalKey, modifierFlags); @@ -2397,7 +2397,7 @@ void ScintillaCocoa::MouseEntered(NSEvent* event) WndProc(SCI_SETCURSOR, (long int)SC_CURSORNORMAL, 0); // Mouse location is given in screen coordinates and might also be outside of our bounds. - Point location = ConvertPoint([event locationInWindow]); + Point location = ConvertPoint(event.locationInWindow); ButtonMove(location); } } @@ -2413,22 +2413,22 @@ void ScintillaCocoa::MouseExited(NSEvent* /* event */) void ScintillaCocoa::MouseDown(NSEvent* event) { - Point location = ConvertPoint([event locationInWindow]); - NSTimeInterval time = [event timestamp]; - bool command = ([event modifierFlags] & NSCommandKeyMask) != 0; - bool shift = ([event modifierFlags] & NSShiftKeyMask) != 0; - bool alt = ([event modifierFlags] & NSAlternateKeyMask) != 0; + Point location = ConvertPoint(event.locationInWindow); + NSTimeInterval time = event.timestamp; + bool command = (event.modifierFlags & NSCommandKeyMask) != 0; + bool shift = (event.modifierFlags & NSShiftKeyMask) != 0; + bool alt = (event.modifierFlags & NSAlternateKeyMask) != 0; ButtonDown(Point(location.x, location.y), (int) (time * 1000), shift, command, alt); } void ScintillaCocoa::RightMouseDown(NSEvent *event) { - Point location = ConvertPoint([event locationInWindow]); - NSTimeInterval time = [event timestamp]; - bool command = ([event modifierFlags] & NSCommandKeyMask) != 0; - bool shift = ([event modifierFlags] & NSShiftKeyMask) != 0; - bool alt = ([event modifierFlags] & NSAlternateKeyMask) != 0; + Point location = ConvertPoint(event.locationInWindow); + NSTimeInterval time = event.timestamp; + bool command = (event.modifierFlags & NSCommandKeyMask) != 0; + bool shift = (event.modifierFlags & NSShiftKeyMask) != 0; + bool alt = (event.modifierFlags & NSAlternateKeyMask) != 0; RightButtonDownWithModifiers(Point(location.x, location.y), (int) (time * 1000), ModifierFlags(shift, command, alt)); } @@ -2439,32 +2439,32 @@ void ScintillaCocoa::MouseMove(NSEvent* event) { lastMouseEvent = event; - ButtonMoveWithModifiers(ConvertPoint([event locationInWindow]), TranslateModifierFlags([event modifierFlags])); + ButtonMoveWithModifiers(ConvertPoint(event.locationInWindow), TranslateModifierFlags(event.modifierFlags)); } //-------------------------------------------------------------------------------------------------- void ScintillaCocoa::MouseUp(NSEvent* event) { - NSTimeInterval time = [event timestamp]; - bool control = ([event modifierFlags] & NSControlKeyMask) != 0; + NSTimeInterval time = event.timestamp; + bool control = (event.modifierFlags & NSControlKeyMask) != 0; - ButtonUp(ConvertPoint([event locationInWindow]), (int) (time * 1000), control); + ButtonUp(ConvertPoint(event.locationInWindow), (int) (time * 1000), control); } //-------------------------------------------------------------------------------------------------- void ScintillaCocoa::MouseWheel(NSEvent* event) { - bool command = ([event modifierFlags] & NSCommandKeyMask) != 0; + bool command = (event.modifierFlags & NSCommandKeyMask) != 0; int dY = 0; // In order to make scrolling with larger offset smoother we scroll less lines the larger the // delta value is. - if ([event deltaY] < 0) - dY = -(int) sqrt(-10.0 * [event deltaY]); + if (event.deltaY < 0) + dY = -(int) sqrt(-10.0 * event.deltaY); else - dY = (int) sqrt(10.0 * [event deltaY]); + dY = (int) sqrt(10.0 * event.deltaY); if (command) { @@ -2589,7 +2589,7 @@ void ScintillaCocoa::ShowFindIndicatorForRange(NSRange charRange, BOOL retaining // Content layer is unflipped on 10.9, but the indicator shows wrong unless flipped layerFindIndicator.geometryFlipped = YES; } - [[content layer] addSublayer:layerFindIndicator]; + [content.layer addSublayer:layerFindIndicator]; } [layerFindIndicator removeAnimationForKey:@"animateFound"]; diff --git a/cocoa/ScintillaView.mm b/cocoa/ScintillaView.mm index 26e04e649..df03add5f 100644 --- a/cocoa/ScintillaView.mm +++ b/cocoa/ScintillaView.mm @@ -78,7 +78,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) { [currentCursors addObject: reverseArrowCursor]; } - [self setClientView:[aScrollView documentView]]; + self.clientView = aScrollView.documentView; if ([self respondsToSelector: @selector(setAccessibilityLabel:)]) self.accessibilityLabel = @"Scintilla Margin"; } @@ -88,9 +88,9 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) - (void) setFrame: (NSRect) frame { - [super setFrame: frame]; + super.frame = frame; - [[self window] invalidateCursorRectsForView: self]; + [self.window invalidateCursorRectsForView: self]; } - (CGFloat)requiredThickness @@ -101,8 +101,8 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) - (void)drawHashMarksAndLabelsInRect:(NSRect)aRect { if (owner) { - NSRect contentRect = [[[self scrollView] contentView] bounds]; - NSRect marginRect = [self bounds]; + NSRect contentRect = self.scrollView.contentView.bounds; + NSRect marginRect = self.bounds; // Ensure paint to bottom of view to avoid glitches if (marginRect.size.height > contentRect.size.height) { // Legacy scroll bar mode leaves a poorly painted corner @@ -129,8 +129,8 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) - (void) mouseDown: (NSEvent *) theEvent { - NSClipView *textView = [[self scrollView] contentView]; - [[textView window] makeFirstResponder:textView]; + NSClipView *textView = self.scrollView.contentView; + [textView.window makeFirstResponder:textView]; owner.backend->MouseDown(theEvent); } @@ -170,8 +170,8 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) [super resetCursorRects]; int x = 0; - NSRect marginRect = [self bounds]; - size_t co = [currentCursors count]; + NSRect marginRect = self.bounds; + size_t co = currentCursors.count; for (size_t i=0; i<co; i++) { long cursType = owner.backend->WndProc(SCI_GETMARGINCURSORN, i, 0); @@ -247,7 +247,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) } int opts = (NSTrackingActiveAlways | NSTrackingInVisibleRect | NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved); - trackingArea = [[NSTrackingArea alloc] initWithRect:[self bounds] + trackingArea = [[NSTrackingArea alloc] initWithRect:self.bounds options:opts owner:self userInfo:nil]; @@ -262,7 +262,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) */ - (void) setFrame: (NSRect) frame { - [super setFrame: frame]; + super.frame = frame; mOwner.backend->Resize(); } @@ -278,7 +278,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) mCurrentCursor = cursorFromEnum(eCursor); // Trigger recreation of the cursor rectangle(s). - [[self window] invalidateCursorRectsForView: self]; + [self.window invalidateCursorRectsForView: self]; [mOwner updateMarginCursors]; } @@ -343,7 +343,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) */ - (void) drawRect: (NSRect) rect { - CGContextRef context = (CGContextRef) [[NSGraphicsContext currentContext] graphicsPort]; + CGContextRef context = (CGContextRef) [NSGraphicsContext currentContext].graphicsPort; if (!mOwner.backend->Draw(rect, context)) { dispatch_async(dispatch_get_main_queue(), ^{ @@ -436,7 +436,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) NSString *result = @(text.c_str()); NSMutableAttributedString *asResult = [[NSMutableAttributedString alloc] initWithString:result]; - const NSRange rangeAS = NSMakeRange(0, [asResult length]); + const NSRange rangeAS = NSMakeRange(0, asResult.length); // SCI_GETSTYLEAT reports a signed byte but want an unsigned to index into styles const char styleByte = static_cast<char>([mOwner message: SCI_GETSTYLEAT wParam:posRange.location]); const long style = static_cast<unsigned char>(styleByte); @@ -456,7 +456,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) { const NSRect rectPoint = {point, NSZeroSize}; const NSRect rectInWindow = [self.window convertRectFromScreen:rectPoint]; - const NSRect rectLocal = [[[self superview] superview] convertRect:rectInWindow fromView:nil]; + const NSRect rectLocal = [self.superview.superview convertRect:rectInWindow fromView:nil]; const long position = [mOwner message: SCI_CHARPOSITIONFROMPOINT wParam: rectLocal.origin.x @@ -497,7 +497,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) rect.size.width = [mOwner message: SCI_POINTXFROMPOSITION wParam: 0 lParam: rangeEnd] - rect.origin.x; rect.size.height = [mOwner message: SCI_POINTYFROMPOSITION wParam: 0 lParam: rangeEnd] - rect.origin.y; rect.size.height += [mOwner message: SCI_TEXTHEIGHT wParam: 0 lParam: 0]; - const NSRect rectInWindow = [[[self superview] superview] convertRect:rect toView:nil]; + const NSRect rectInWindow = [self.superview.superview convertRect:rect toView:nil]; const NSRect rectScreen = [self.window convertRectToScreen:rectInWindow]; return rectScreen; @@ -654,7 +654,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) // need to insert newText at each selection, mark each piece of new text and then // select range relative to each insertion. - if ([newText length]) + if (newText.length) { // Switching into composition. mOwner.backend->CompositionStart(); @@ -795,7 +795,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) return proposedVisibleRect; NSRect rc = proposedVisibleRect; // Snap to lines - NSRect contentRect = [self bounds]; + NSRect contentRect = self.bounds; if ((rc.origin.y > 0) && (NSMaxY(rc) < contentRect.size.height)) { // Only snap for positions inside the document - allow outside // for overshoot. @@ -995,7 +995,7 @@ sourceOperationMaskForDraggingContext: (NSDraggingContext) context - (BOOL) validateUserInterfaceItem: (id <NSValidatedUserInterfaceItem>) anItem { - SEL action = [anItem action]; + SEL action = anItem.action; if (action==@selector(undo:)) { return [self canUndo]; } @@ -1182,7 +1182,7 @@ sourceOperationMaskForDraggingContext: (NSDraggingContext) context */ - (NSRect)accessibilityFrameForRange:(NSRange)range { const NSRect rectInView = mOwner.backend->FrameForRange(range); - const NSRect rectInWindow = [[[self superview] superview] convertRect:rectInView toView:nil]; + const NSRect rectInWindow = [self.superview.superview convertRect:rectInView toView:nil]; return [self.window convertRectToScreen:rectInWindow]; } @@ -1221,13 +1221,13 @@ sourceOperationMaskForDraggingContext: (NSDraggingContext) context rect.origin.y += [mOwner message: SCI_TEXTHEIGHT wParam: 0 lParam: 0]; rect.size.width = 1.0; rect.size.height = 1.0; - NSRect rectInWindow = [[[self superview] superview] convertRect:rect toView:nil]; + NSRect rectInWindow = [self.superview.superview convertRect:rect toView:nil]; NSPoint pt = rectInWindow.origin; NSEvent *event = [NSEvent mouseEventWithType: NSRightMouseDown location: pt modifierFlags: 0 timestamp: 0 - windowNumber: [[self window] windowNumber] + windowNumber: self.window.windowNumber context: nil eventNumber: 0 clickCount: 1 @@ -1390,9 +1390,9 @@ sourceOperationMaskForDraggingContext: (NSDraggingContext) context - (void) suspendDrawing: (BOOL) suspend { if (suspend) - [[self window] disableFlushWindow]; + [self.window disableFlushWindow]; else - [[self window] enableFlushWindow]; + [self.window enableFlushWindow]; } //-------------------------------------------------------------------------------------------------- @@ -1497,10 +1497,10 @@ sourceOperationMaskForDraggingContext: (NSDraggingContext) context // (horizontal or vertical). NSRect scrollerRect = NSMakeRect(0, 0, 100, 10); scrollView = [[NSScrollView alloc] initWithFrame: scrollerRect]; - [scrollView setDocumentView: mContent]; + scrollView.documentView = mContent; [scrollView setHasVerticalScroller:YES]; [scrollView setHasHorizontalScroller:YES]; - [scrollView setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable]; + scrollView.autoresizingMask = NSViewWidthSizable|NSViewHeightSizable; //[scrollView setScrollerStyle:NSScrollerStyleLegacy]; //[scrollView setScrollerKnobStyle:NSScrollerKnobStyleDark]; //[scrollView setHorizontalScrollElasticity:NSScrollElasticityNone]; @@ -1508,8 +1508,8 @@ sourceOperationMaskForDraggingContext: (NSDraggingContext) context marginView = [[SCIMarginView alloc] initWithScrollView:scrollView]; marginView.owner = self; - [marginView setRuleThickness:[marginView requiredThickness]]; - [scrollView setVerticalRulerView:marginView]; + marginView.ruleThickness = marginView.requiredThickness; + scrollView.verticalRulerView = marginView; [scrollView setHasHorizontalRuler:NO]; [scrollView setHasVerticalRuler:YES]; [scrollView setRulersVisible:YES]; @@ -1536,13 +1536,13 @@ sourceOperationMaskForDraggingContext: (NSDraggingContext) context [center addObserver:self selector:@selector(windowWillMove:) name:NSWindowWillMoveNotification - object:[self window]]; + object:self.window]; - [[scrollView contentView] setPostsBoundsChangedNotifications:YES]; + [scrollView.contentView setPostsBoundsChangedNotifications:YES]; [center addObserver:self selector:@selector(scrollerAction:) name:NSViewBoundsDidChangeNotification - object:[scrollView contentView]]; + object:scrollView.contentView]; } return self; } @@ -1590,7 +1590,7 @@ sourceOperationMaskForDraggingContext: (NSDraggingContext) context [self positionSubViews]; // Enable also mouse move events for our window (and so this view). - [[self window] setAcceptsMouseMovedEvents: YES]; + [self.window setAcceptsMouseMovedEvents: YES]; } //-------------------------------------------------------------------------------------------------- @@ -1603,9 +1603,9 @@ sourceOperationMaskForDraggingContext: (NSDraggingContext) context CGFloat scrollerWidth = [NSScroller scrollerWidthForControlSize:NSRegularControlSize scrollerStyle:NSScrollerStyleLegacy]; - NSSize size = [self frame].size; + NSSize size = self.frame.size; NSRect barFrame = {{0, size.height - scrollerWidth}, {size.width, scrollerWidth}}; - BOOL infoBarVisible = mInfoBar != nil && ![mInfoBar isHidden]; + BOOL infoBarVisible = mInfoBar != nil && !mInfoBar.hidden; // Horizontal offset of the content. Almost always 0 unless the vertical scroller // is on the left side. @@ -1624,12 +1624,12 @@ sourceOperationMaskForDraggingContext: (NSDraggingContext) context } } - if (!NSEqualRects([scrollView frame], scrollRect)) { - [scrollView setFrame: scrollRect]; + if (!NSEqualRects(scrollView.frame, scrollRect)) { + scrollView.frame = scrollRect; } if (infoBarVisible) - [mInfoBar setFrame: barFrame]; + mInfoBar.frame = barFrame; } //-------------------------------------------------------------------------------------------------- @@ -1642,7 +1642,7 @@ sourceOperationMaskForDraggingContext: (NSDraggingContext) context if (marginView.ruleThickness != width) { marginView.marginWidth = width; - [marginView setRuleThickness:[marginView requiredThickness]]; + marginView.ruleThickness = marginView.requiredThickness; } } @@ -1665,8 +1665,8 @@ sourceOperationMaskForDraggingContext: (NSDraggingContext) context */ - (void) setFrame: (NSRect) newFrame { - NSRect previousFrame = [self frame]; - [super setFrame: newFrame]; + NSRect previousFrame = self.frame; + super.frame = newFrame; [self positionSubViews]; if (!NSEqualRects(previousFrame, newFrame)) { mBackend->Resize(); @@ -1750,7 +1750,7 @@ sourceOperationMaskForDraggingContext: (NSDraggingContext) context */ - (void) setString: (NSString*) aString { - const char* text = [aString UTF8String]; + const char* text = aString.UTF8String; mBackend->WndProc(SCI_SETTEXT, 0, (long) text); } @@ -1758,7 +1758,7 @@ sourceOperationMaskForDraggingContext: (NSDraggingContext) context - (void) insertString: (NSString*) aString atOffset: (int)offset { - const char* text = [aString UTF8String]; + const char* text = aString.UTF8String; mBackend->WndProc(SCI_ADDTEXT, offset, (long) text); } @@ -1786,7 +1786,7 @@ sourceOperationMaskForDraggingContext: (NSDraggingContext) context //-------------------------------------------------------------------------------------------------- - (void) updateMarginCursors { - [[self window] invalidateCursorRectsForView: marginView]; + [self.window invalidateCursorRectsForView: marginView]; } //-------------------------------------------------------------------------------------------------- @@ -1897,11 +1897,11 @@ sourceOperationMaskForDraggingContext: (NSDraggingContext) context */ - (void) setColorProperty: (int) property parameter: (long) parameter value: (NSColor*) value { - if ([value colorSpaceName] != NSDeviceRGBColorSpace) + if (value.colorSpaceName != NSDeviceRGBColorSpace) value = [value colorUsingColorSpaceName: NSDeviceRGBColorSpace]; - long red = static_cast<long>([value redComponent] * 255); - long green = static_cast<long>([value greenComponent] * 255); - long blue = static_cast<long>([value blueComponent] * 255); + long red = static_cast<long>(value.redComponent * 255); + long green = static_cast<long>(value.greenComponent * 255); + long blue = static_cast<long>(value.blueComponent * 255); long color = (blue << 16) + (green << 8) + red; mBackend->WndProc(property, parameter, color); @@ -1915,9 +1915,9 @@ sourceOperationMaskForDraggingContext: (NSDraggingContext) context */ - (void) setColorProperty: (int) property parameter: (long) parameter fromHTML: (NSString*) fromHTML { - if ([fromHTML length] > 3 && [fromHTML characterAtIndex: 0] == '#') + if (fromHTML.length > 3 && [fromHTML characterAtIndex: 0] == '#') { - bool longVersion = [fromHTML length] > 6; + bool longVersion = fromHTML.length > 6; int index = 1; char value[3] = {0, 0, 0}; @@ -1995,7 +1995,7 @@ sourceOperationMaskForDraggingContext: (NSDraggingContext) context */ - (void) setStringProperty: (int) property parameter: (long) parameter value: (NSString*) value { - const char* rawValue = [value UTF8String]; + const char* rawValue = value.UTF8String; mBackend->WndProc(property, parameter, (sptr_t) rawValue); } @@ -2018,8 +2018,8 @@ sourceOperationMaskForDraggingContext: (NSDraggingContext) context */ - (void) setLexerProperty: (NSString*) name value: (NSString*) value { - const char* rawName = [name UTF8String]; - const char* rawValue = [value UTF8String]; + const char* rawName = name.UTF8String; + const char* rawValue = value.UTF8String; mBackend->WndProc(SCI_SETPROPERTY, (sptr_t) rawName, (sptr_t) rawValue); } @@ -2030,7 +2030,7 @@ sourceOperationMaskForDraggingContext: (NSDraggingContext) context */ - (NSString*) getLexerProperty: (NSString*) name { - const char* rawName = [name UTF8String]; + const char* rawName = name.UTF8String; const char* result = (const char*) mBackend->WndProc(SCI_SETPROPERTY, (sptr_t) rawName, 0); return @(result); } @@ -2164,7 +2164,7 @@ sourceOperationMaskForDraggingContext: (NSDraggingContext) context [self getGeneralProperty: SCI_SETSELECTIONSTART parameter: selectionEnd]; [self setGeneralProperty: SCI_SEARCHANCHOR value: 0]; sptr_t result; - const char* textToSearch = [searchText UTF8String]; + const char* textToSearch = searchText.UTF8String; // The following call will also set the selection if something was found. if (backwards) @@ -2250,9 +2250,9 @@ sourceOperationMaskForDraggingContext: (NSDraggingContext) context [self setGeneralProperty: SCI_SETTARGETSTART value: startPosition]; [self setGeneralProperty: SCI_SETTARGETEND value: endPosition]; - const char* textToSearch = [searchText UTF8String]; + const char* textToSearch = searchText.UTF8String; long sourceLength = strlen(textToSearch); // Length in bytes. - const char* replacement = [newText UTF8String]; + const char* replacement = newText.UTF8String; long targetLength = strlen(replacement); // Length in bytes. sptr_t result; @@ -2316,7 +2316,7 @@ sourceOperationMaskForDraggingContext: (NSDraggingContext) context { [self setGeneralProperty: SCI_STYLESETFONT parameter: i - value: (sptr_t)[font UTF8String]]; + value: (sptr_t)font.UTF8String]; [self setGeneralProperty: SCI_STYLESETSIZE parameter: i value: size]; |