Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(mac): change indentation of source code to equal standard two spaces #11432

Merged
merged 4 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
418 changes: 209 additions & 209 deletions mac/Keyman4Mac/Keyman4Mac/AppDelegate.m

Large diffs are not rendered by default.

46 changes: 23 additions & 23 deletions mac/Keyman4Mac/Keyman4Mac/KMBarView.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,29 @@
@implementation KMBarView

- (void)drawRect:(NSRect)rect {
CGContextRef context = (CGContextRef)[[NSGraphicsContext currentContext] CGContext];
NSRect rect1 = NSMakeRect(0, 0, rect.size.width*0.56, rect.size.height);
NSRect rect2 = NSMakeRect(rect1.size.width, 0, rect.size.width*0.23, rect.size.height);
NSRect rect3 = NSMakeRect(rect2.origin.x + rect2.size.width, 0, rect.size.width*0.21, rect.size.height);
CGContextSetFillColorWithColor(context, [NSColor colorWithRed:1.0 green:104.0/255.0 blue:38.0/255.0 alpha:1.0].CGColor);
CGContextBeginPath(context);
CGContextAddRect(context, rect1);
CGContextClosePath(context);
CGContextDrawPath(context, kCGPathFill);
CGContextSetFillColorWithColor(context, [NSColor colorWithRed:200.0/255.0 green:0.0 blue:54.0/255.0 alpha:1.0].CGColor);
CGContextBeginPath(context);
CGContextAddRect(context, rect2);
CGContextClosePath(context);
CGContextDrawPath(context, kCGPathFill);
CGContextSetFillColorWithColor(context, [NSColor colorWithRed:74.0/255.0 green:186.0/255.0 blue:208.0/255.0 alpha:1.0].CGColor);
CGContextBeginPath(context);
CGContextAddRect(context, rect3);
CGContextClosePath(context);
CGContextDrawPath(context, kCGPathFill);
CGContextRef context = (CGContextRef)[[NSGraphicsContext currentContext] CGContext];

NSRect rect1 = NSMakeRect(0, 0, rect.size.width*0.56, rect.size.height);
NSRect rect2 = NSMakeRect(rect1.size.width, 0, rect.size.width*0.23, rect.size.height);
NSRect rect3 = NSMakeRect(rect2.origin.x + rect2.size.width, 0, rect.size.width*0.21, rect.size.height);

CGContextSetFillColorWithColor(context, [NSColor colorWithRed:1.0 green:104.0/255.0 blue:38.0/255.0 alpha:1.0].CGColor);
CGContextBeginPath(context);
CGContextAddRect(context, rect1);
CGContextClosePath(context);
CGContextDrawPath(context, kCGPathFill);

CGContextSetFillColorWithColor(context, [NSColor colorWithRed:200.0/255.0 green:0.0 blue:54.0/255.0 alpha:1.0].CGColor);
CGContextBeginPath(context);
CGContextAddRect(context, rect2);
CGContextClosePath(context);
CGContextDrawPath(context, kCGPathFill);

CGContextSetFillColorWithColor(context, [NSColor colorWithRed:74.0/255.0 green:186.0/255.0 blue:208.0/255.0 alpha:1.0].CGColor);
CGContextBeginPath(context);
CGContextAddRect(context, rect3);
CGContextClosePath(context);
CGContextDrawPath(context, kCGPathFill);
}

@end
2 changes: 1 addition & 1 deletion mac/Keyman4Mac/Keyman4Mac/main.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
#import <Cocoa/Cocoa.h>

int main(int argc, const char * argv[]) {
return NSApplicationMain(argc, argv);
return NSApplicationMain(argc, argv);
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
@implementation NSString (SuppMethods)

- (BOOL)startsWith:(NSString *)str {
return [[self lowercaseString] hasPrefix:[str lowercaseString]];
return [[self lowercaseString] hasPrefix:[str lowercaseString]];
}

@end
70 changes: 35 additions & 35 deletions mac/Keyman4MacIM/Keyman4MacIM/Categories/NSWindow+SuppMethods.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,50 +11,50 @@
@implementation NSWindow (SuppMethods)

- (void)centerInParent {
if (self.parentWindow == nil) {
[self center];
return;
}
NSRect cFrame = self.frame;
NSRect pFrame = self.parentWindow.frame;
CGFloat x = pFrame.origin.x + (NSWidth(pFrame) - NSWidth(cFrame))/2;
CGFloat y = pFrame.origin.y + (NSHeight(pFrame) - NSHeight(cFrame))/2;
[self setFrameOrigin:NSMakePoint(x, y)];
if (self.parentWindow == nil) {
[self center];
return;
}

NSRect cFrame = self.frame;
NSRect pFrame = self.parentWindow.frame;
CGFloat x = pFrame.origin.x + (NSWidth(pFrame) - NSWidth(cFrame))/2;
CGFloat y = pFrame.origin.y + (NSHeight(pFrame) - NSHeight(cFrame))/2;
[self setFrameOrigin:NSMakePoint(x, y)];
}

- (void)centerInWindow:(NSWindow *)window {
if (window == nil) {
[self center];
return;
}
NSRect sFrame = self.frame;
NSRect wFrame = window.frame;
CGFloat x = wFrame.origin.x + (NSWidth(wFrame) - NSWidth(sFrame))/2;
CGFloat y = wFrame.origin.y + (NSHeight(wFrame) - NSHeight(sFrame))/2;
[self setFrameOrigin:NSMakePoint(x, y)];
if (window == nil) {
[self center];
return;
}

NSRect sFrame = self.frame;
NSRect wFrame = window.frame;
CGFloat x = wFrame.origin.x + (NSWidth(wFrame) - NSWidth(sFrame))/2;
CGFloat y = wFrame.origin.y + (NSHeight(wFrame) - NSHeight(sFrame))/2;
[self setFrameOrigin:NSMakePoint(x, y)];
}

- (void)addViewToTitleBar:(NSView *)viewToAdd positionX:(CGFloat)x {
viewToAdd.frame = NSMakeRect(x, NSHeight([self.contentView frame]), NSWidth(viewToAdd.frame), self.titleBarHeight);
NSUInteger mask = 0;
if(x > NSWidth(self.frame)/2.0) {
mask |= NSViewMinXMargin;
}
else {
mask |= NSViewMaxXMargin;
}
[viewToAdd setAutoresizingMask:mask|NSViewMinYMargin];
[[self.contentView superview] addSubview:viewToAdd];
viewToAdd.frame = NSMakeRect(x, NSHeight([self.contentView frame]), NSWidth(viewToAdd.frame), self.titleBarHeight);

NSUInteger mask = 0;
if(x > NSWidth(self.frame)/2.0) {
mask |= NSViewMinXMargin;
}
else {
mask |= NSViewMaxXMargin;
}

[viewToAdd setAutoresizingMask:mask|NSViewMinYMargin];
[[self.contentView superview] addSubview:viewToAdd];
}

- (CGFloat)titleBarHeight {
NSRect sFrame = [self.contentView superview].frame;
NSRect cFrame = [self.contentView frame];
return NSHeight(sFrame) - NSHeight(cFrame);
NSRect sFrame = [self.contentView superview].frame;
NSRect cFrame = [self.contentView frame];
return NSHeight(sFrame) - NSHeight(cFrame);
}

@end
34 changes: 17 additions & 17 deletions mac/Keyman4MacIM/Keyman4MacIM/KMAboutWindow/KMAboutBGView.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,26 @@ @implementation KMAboutBGView
// topFill origin=(0,252) size=(66,450)
// botFill origin=(0,0) size=(252,450)
- (void)drawRect:(NSRect)rect {
NSRect topFill, botFill;
topFill = rect;
botFill = rect;
// NSLog(@"rect origin x %f y %f size h %f w %f", rect.origin.x, rect.origin.y, rect.size.height, rect.size.width);
NSView *topImgView = [self viewWithTag:1];
// NSLog(@"topImgView origin x %f y %f size h %f w %f before", topImgView.frame.origin.x, topImgView.frame.origin.y, topImgView.frame.size.height, topImgView.frame.size.width);
NSInteger imgOriginHeightDelta = topImgView.frame.origin.y - rect.origin.y;
topFill.origin.y += imgOriginHeightDelta;
topFill.size.height -= imgOriginHeightDelta;
botFill.size.height = imgOriginHeightDelta;
// NSLog(@"topFill origin x %f y %f size h %f w %f after raising to imgHeight %ld", topFill.origin.x, topFill.origin.y, topFill.size.height, topFill.size.width, imgOriginHeightDelta);
// NSLog(@"botFill origin x %f y %f size h %f w %f after reducing by imgHeight %ld", botFill.origin.x, botFill.origin.y, botFill.size.height, botFill.size.width, imgOriginHeightDelta);
[[NSColor whiteColor] setFill];
NSRectFillUsingOperation(topFill, NSCompositingOperationSourceOver);
[[NSColor windowBackgroundColor] setFill];
NSRectFillUsingOperation(botFill, NSCompositingOperationSourceOver);
NSRect topFill, botFill;
topFill = rect;
botFill = rect;
// NSLog(@"rect origin x %f y %f size h %f w %f", rect.origin.x, rect.origin.y, rect.size.height, rect.size.width);
NSView *topImgView = [self viewWithTag:1];
// NSLog(@"topImgView origin x %f y %f size h %f w %f before", topImgView.frame.origin.x, topImgView.frame.origin.y, topImgView.frame.size.height, topImgView.frame.size.width);
NSInteger imgOriginHeightDelta = topImgView.frame.origin.y - rect.origin.y;
topFill.origin.y += imgOriginHeightDelta;
topFill.size.height -= imgOriginHeightDelta;
botFill.size.height = imgOriginHeightDelta;
// NSLog(@"topFill origin x %f y %f size h %f w %f after raising to imgHeight %ld", topFill.origin.x, topFill.origin.y, topFill.size.height, topFill.size.width, imgOriginHeightDelta);
// NSLog(@"botFill origin x %f y %f size h %f w %f after reducing by imgHeight %ld", botFill.origin.x, botFill.origin.y, botFill.size.height, botFill.size.width, imgOriginHeightDelta);
[[NSColor whiteColor] setFill];
NSRectFillUsingOperation(topFill, NSCompositingOperationSourceOver);
[[NSColor windowBackgroundColor] setFill];
NSRectFillUsingOperation(botFill, NSCompositingOperationSourceOver);
}

- (BOOL)mouseDownCanMoveWindow {
return YES;
return YES;
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
@implementation KMAboutWindow

- (BOOL)isMovableByWindowBackground {
return YES;
return YES;
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -22,73 +22,73 @@ @interface KMAboutWindowController ()
@implementation KMAboutWindowController

- (KMInputMethodAppDelegate *)AppDelegate {
return (KMInputMethodAppDelegate *)[NSApp delegate];
return (KMInputMethodAppDelegate *)[NSApp delegate];
}

- (void)windowDidLoad {
[super windowDidLoad];
// Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
[self.window setBackgroundColor:[NSColor whiteColor]];

KeymanVersionInfo versionInfo = [[self AppDelegate] versionInfo];
NSString *versionString = NSLocalizedString(@"version-label-text", nil);
[self.versionLabel setStringValue:[NSString localizedStringWithFormat:versionString, versionInfo.versionWithTag]];

[super windowDidLoad];

// Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
[self.window setBackgroundColor:[NSColor whiteColor]];
KeymanVersionInfo versionInfo = [[self AppDelegate] versionInfo];
NSString *versionString = NSLocalizedString(@"version-label-text", nil);
[self.versionLabel setStringValue:[NSString localizedStringWithFormat:versionString, versionInfo.versionWithTag]];
NSMutableString *copyrightInfo = [[NSMutableString alloc] initWithString: [[[NSBundle mainBundle] infoDictionary] objectForKey:@"NSHumanReadableCopyright"]];
[self.copyrightLabel setStringValue:copyrightInfo];

NSTrackingArea *trackingArea = [[NSTrackingArea alloc] initWithRect:[self.licenseButton bounds]
options:NSTrackingMouseEnteredAndExited | NSTrackingActiveAlways
owner:self
userInfo:nil];
[self.licenseButton addTrackingArea:trackingArea];
[self setLicenseButtonTitle:self.licenseButton.title underlined:NO];
[self.copyrightLabel setStringValue:copyrightInfo];
NSTrackingArea *trackingArea = [[NSTrackingArea alloc] initWithRect:[self.licenseButton bounds]
options:NSTrackingMouseEnteredAndExited | NSTrackingActiveAlways
owner:self
userInfo:nil];
[self.licenseButton addTrackingArea:trackingArea];
[self setLicenseButtonTitle:self.licenseButton.title underlined:NO];
}

- (IBAction)configAction:(id)sender {
// Using `showConfigurationWindow` instead of `showPreferences:` because `showPreferences:` is missing in
// High Sierra (10.13.1 - 10.13.3). See: https://bugreport.apple.com/web/?problemID=35422518
// rrb: where Apple's API is broken (10.13.1-10.13.3) call our workaround, otherwise, call showPreferences
u_int16_t systemVersion = [KMOSVersion SystemVersion];
if ([KMOSVersion Version_10_13_1] <= systemVersion && systemVersion <= [KMOSVersion Version_10_13_3]) // between 10.13.1 and 10.13.3 inclusive
{
NSLog(@"About Box: calling workaround instead of showPreferences (sys ver %x)", systemVersion);
[self.AppDelegate showConfigurationWindow]; // call our workaround
}
else
{
NSLog(@"About Box: calling Apple's showPreferences (sys ver %x)", systemVersion);
[self.AppDelegate.inputController showPreferences:sender]; // call Apple API
}
[self close];
// Using `showConfigurationWindow` instead of `showPreferences:` because `showPreferences:` is missing in
// High Sierra (10.13.1 - 10.13.3). See: https://bugreport.apple.com/web/?problemID=35422518
// rrb: where Apple's API is broken (10.13.1-10.13.3) call our workaround, otherwise, call showPreferences
u_int16_t systemVersion = [KMOSVersion SystemVersion];
if ([KMOSVersion Version_10_13_1] <= systemVersion && systemVersion <= [KMOSVersion Version_10_13_3]) // between 10.13.1 and 10.13.3 inclusive
{
NSLog(@"About Box: calling workaround instead of showPreferences (sys ver %x)", systemVersion);
[self.AppDelegate showConfigurationWindow]; // call our workaround
}
else
{
NSLog(@"About Box: calling Apple's showPreferences (sys ver %x)", systemVersion);
[self.AppDelegate.inputController showPreferences:sender]; // call Apple API
}
[self close];
}

- (IBAction)closeAction:(id)sender {
[self close];
[self close];
}

- (IBAction)licenseAction:(id)sender {
[[NSWorkspace sharedWorkspace] openURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"keyman-for-mac-os-license" ofType:@"html"]]];
[[NSWorkspace sharedWorkspace] openURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"keyman-for-mac-os-license" ofType:@"html"]]];
}

- (void)mouseEntered:(NSEvent *)theEvent{
[self setLicenseButtonTitle:self.licenseButton.title underlined:YES];
[self setLicenseButtonTitle:self.licenseButton.title underlined:YES];
}

- (void)mouseExited:(NSEvent *)theEvent{
[self setLicenseButtonTitle:self.licenseButton.title underlined:NO];
[self setLicenseButtonTitle:self.licenseButton.title underlined:NO];
}

- (void)setLicenseButtonTitle:(NSString *)title underlined:(BOOL)underlined {
NSMutableAttributedString *aTitle = [[NSMutableAttributedString alloc] initWithString:title];
[aTitle addAttribute:NSFontAttributeName value:[self.licenseButton font] range:NSMakeRange(0, title.length)];
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
[paragraphStyle setAlignment:NSTextAlignmentCenter];
[aTitle addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, title.length)];
if (underlined)
[aTitle addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInt:NSUnderlineStyleSingle] range:NSMakeRange(0, title.length)];
[self.licenseButton setAttributedTitle:aTitle];
NSMutableAttributedString *aTitle = [[NSMutableAttributedString alloc] initWithString:title];
[aTitle addAttribute:NSFontAttributeName value:[self.licenseButton font] range:NSMakeRange(0, title.length)];
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
[paragraphStyle setAlignment:NSTextAlignmentCenter];
[aTitle addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, title.length)];
if (underlined)
[aTitle addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInt:NSUnderlineStyleSingle] range:NSMakeRange(0, title.length)];
[self.licenseButton setAttributedTitle:aTitle];
}

@end
46 changes: 23 additions & 23 deletions mac/Keyman4MacIM/Keyman4MacIM/KMAboutWindow/KMBarView.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,29 @@
@implementation KMBarView

- (void)drawRect:(NSRect)rect {
CGContextRef context = (CGContextRef)[[NSGraphicsContext currentContext] CGContext];
NSRect rect1 = NSMakeRect(0, 0, rect.size.width*0.56, rect.size.height);
NSRect rect2 = NSMakeRect(rect1.size.width, 0, rect.size.width*0.23, rect.size.height);
NSRect rect3 = NSMakeRect(rect2.origin.x + rect2.size.width, 0, rect.size.width*0.21, rect.size.height);
CGContextSetFillColorWithColor(context, [NSColor colorWithSRGBRed:246.0/255.0 green:137.0/255.0 blue:36.0/255.0 alpha:1.0].CGColor);
CGContextBeginPath(context);
CGContextAddRect(context, rect1);
CGContextClosePath(context);
CGContextDrawPath(context, kCGPathFill);
CGContextSetFillColorWithColor(context, [NSColor colorWithSRGBRed:204.0/255.0 green:56.0/255.0 blue:70.0/255.0 alpha:1.0].CGColor);
CGContextBeginPath(context);
CGContextAddRect(context, rect2);
CGContextClosePath(context);
CGContextDrawPath(context, kCGPathFill);
CGContextSetFillColorWithColor(context, [NSColor colorWithSRGBRed:121.0/255.0 green:195.0/255.0 blue:218.0/255.0 alpha:1.0].CGColor);
CGContextBeginPath(context);
CGContextAddRect(context, rect3);
CGContextClosePath(context);
CGContextDrawPath(context, kCGPathFill);
CGContextRef context = (CGContextRef)[[NSGraphicsContext currentContext] CGContext];

NSRect rect1 = NSMakeRect(0, 0, rect.size.width*0.56, rect.size.height);
NSRect rect2 = NSMakeRect(rect1.size.width, 0, rect.size.width*0.23, rect.size.height);
NSRect rect3 = NSMakeRect(rect2.origin.x + rect2.size.width, 0, rect.size.width*0.21, rect.size.height);

CGContextSetFillColorWithColor(context, [NSColor colorWithSRGBRed:246.0/255.0 green:137.0/255.0 blue:36.0/255.0 alpha:1.0].CGColor);
CGContextBeginPath(context);
CGContextAddRect(context, rect1);
CGContextClosePath(context);
CGContextDrawPath(context, kCGPathFill);

CGContextSetFillColorWithColor(context, [NSColor colorWithSRGBRed:204.0/255.0 green:56.0/255.0 blue:70.0/255.0 alpha:1.0].CGColor);
CGContextBeginPath(context);
CGContextAddRect(context, rect2);
CGContextClosePath(context);
CGContextDrawPath(context, kCGPathFill);

CGContextSetFillColorWithColor(context, [NSColor colorWithSRGBRed:121.0/255.0 green:195.0/255.0 blue:218.0/255.0 alpha:1.0].CGColor);
CGContextBeginPath(context);
CGContextAddRect(context, rect3);
CGContextClosePath(context);
CGContextDrawPath(context, kCGPathFill);
}

@end
Loading
Loading