Skip to content

Commit 0356538

Browse files
committed
Chore (macOS): use simplified syntax
1 parent a3a4f0a commit 0356538

File tree

6 files changed

+24
-24
lines changed

6 files changed

+24
-24
lines changed

src/detection/cursor/cursor_apple.m

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
static void appendColor(FFstrbuf* str, NSDictionary* color)
66
{
7-
int r = (int) (((NSNumber*) [color valueForKey:@"red"]).doubleValue * 255);
8-
int g = (int) (((NSNumber*) [color valueForKey:@"green"]).doubleValue * 255);
9-
int b = (int) (((NSNumber*) [color valueForKey:@"blue"]).doubleValue * 255);
10-
int a = (int) (((NSNumber*) [color valueForKey:@"alpha"]).doubleValue * 255);
7+
int r = (int) (((NSNumber*) color[@"red"]).doubleValue * 255);
8+
int g = (int) (((NSNumber*) color[@"green"]).doubleValue * 255);
9+
int b = (int) (((NSNumber*) color[@"blue"]).doubleValue * 255);
10+
int a = (int) (((NSNumber*) color[@"alpha"]).doubleValue * 255);
1111

1212
if (r == 255 && g == 255 && b == 255 && a == 255)
1313
ffStrbufAppendS(str, "White");
@@ -32,19 +32,19 @@ void ffDetectCursor(FFCursorResult* result)
3232
NSDictionary* color;
3333

3434
ffStrbufAppendS(&result->theme, "Fill - ");
35-
if ((color = [dict valueForKey:@"cursorFill"]))
35+
if ((color = dict[@"cursorFill"]))
3636
appendColor(&result->theme, color);
3737
else
3838
ffStrbufAppendS(&result->theme, "Black");
3939

4040
ffStrbufAppendS(&result->theme, ", Outline - ");
4141

42-
if ((color = [dict valueForKey:@"cursorOutline"]))
42+
if ((color = dict[@"cursorOutline"]))
4343
appendColor(&result->theme, color);
4444
else
4545
ffStrbufAppendS(&result->theme, "White");
4646

47-
NSNumber* mouseDriverCursorSize = [dict valueForKey:@"mouseDriverCursorSize"];
47+
NSNumber* mouseDriverCursorSize = dict[@"mouseDriverCursorSize"];
4848
if (mouseDriverCursorSize)
4949
ffStrbufAppendF(&result->size, "%d", (int) (mouseDriverCursorSize.doubleValue * 32));
5050
else

src/detection/monitor/monitor_apple.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ static bool detectHdrSupportWithNSScreen(FFDisplayResult* display)
2929
for (NSScreen* screen in NSScreen.screens)
3030
{
3131
if (screen == mainScreen) continue;
32-
NSNumber* screenNumber = [screen.deviceDescription valueForKey:@"NSScreenNumber"];
32+
NSNumber* screenNumber = screen.deviceDescription[@"NSScreenNumber"];
3333
if (screenNumber && screenNumber.longValue == (long) display->id)
3434
{
3535
#ifdef MAC_OS_X_VERSION_10_15

src/detection/os/os_apple.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ static void parseSystemVersion(FFOSResult* os)
1919

2020
NSString* value;
2121

22-
if((value = [dict valueForKey:@"ProductName"]))
22+
if((value = dict[@"ProductName"]))
2323
ffStrbufInitS(&os->name, value.UTF8String);
24-
if((value = [dict valueForKey:@"ProductUserVisibleVersion"]))
24+
if((value = dict[@"ProductUserVisibleVersion"]))
2525
ffStrbufInitS(&os->version, value.UTF8String);
26-
if((value = [dict valueForKey:@"ProductBuildVersion"]))
26+
if((value = dict[@"ProductBuildVersion"]))
2727
ffStrbufInitS(&os->buildID, value.UTF8String);
2828
}
2929

src/detection/terminalfont/terminalfont_apple.m

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,23 @@ static void detectIterm2(FFTerminalFontResult* terminalFont)
2626
return;
2727
}
2828

29-
for(NSDictionary* bookmark in [dict valueForKey:@"New Bookmarks"])
29+
for(NSDictionary* bookmark in dict[@"New Bookmarks"])
3030
{
31-
if(![[bookmark valueForKey:@"Name"] isEqualToString:@(profile)])
31+
if(![bookmark[@"Name"] isEqualToString:@(profile)])
3232
continue;
3333

34-
NSString* normalFont = [bookmark valueForKey:@"Normal Font"];
34+
NSString* normalFont = bookmark[@"Normal Font"];
3535
if(!normalFont)
3636
{
3737
ffStrbufAppendF(&terminalFont->error, "`Normal Font` key in profile `%s` doesn't exist", profile);
3838
return;
3939
}
4040
ffFontInitWithSpace(&terminalFont->font, normalFont.UTF8String);
4141

42-
NSNumber* useNonAsciiFont = [bookmark valueForKey:@"Use Non-ASCII Font"];
42+
NSNumber* useNonAsciiFont = bookmark[@"Use Non-ASCII Font"];
4343
if(useNonAsciiFont.boolValue)
4444
{
45-
NSString* nonAsciiFont = [bookmark valueForKey:@"Non Ascii Font"];
45+
NSString* nonAsciiFont = bookmark[@"Non Ascii Font"];
4646
if (nonAsciiFont)
4747
ffFontInitWithSpace(&terminalFont->fallback, nonAsciiFont.UTF8String);
4848
}
@@ -78,13 +78,13 @@ static void detectWarpTerminal(FFTerminalFontResult* terminalFont)
7878
return;
7979
}
8080

81-
NSString* fontName = [dict valueForKey:@"FontName"];
81+
NSString* fontName = dict[@"FontName"];
8282
if(!fontName)
8383
fontName = @"Hack";
8484
else
8585
fontName = [fontName stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"\""]];
8686

87-
NSString* fontSize = [dict valueForKey:@"FontSize"];
87+
NSString* fontSize = dict[@"FontSize"];
8888
if(!fontSize)
8989
fontSize = @"13";
9090

src/detection/wallpaper/wallpaper_apple.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@
1818
NSArray* choices = [dict valueForKeyPath:@"SystemDefault.Desktop.Content.Choices"];
1919
if (choices.count > 0)
2020
{
21-
NSDictionary* choice = [choices objectAtIndex:0];
22-
NSArray* files = [choice valueForKey:@"Files"];
21+
NSDictionary* choice = choices[0];
22+
NSArray* files = choice[@"Files"];
2323
if (files.count > 0)
2424
{
25-
NSString* file = [[files objectAtIndex: 0] valueForKey: @"relative"];
25+
NSString* file = files[0][@"relative"];
2626
ffStrbufAppendS(result, [NSURL URLWithString:file].path.UTF8String);
2727
}
2828
else
2929
{
30-
NSString* provider = [choice valueForKey:@"Provider"];
30+
NSString* provider = choice[@"Provider"];
3131
NSString* builtinPrefix = @"com.apple.wallpaper.choice.";
3232
if ([provider hasPrefix:builtinPrefix])
3333
provider = [provider substringFromIndex:builtinPrefix.length];

src/detection/wmtheme/wmtheme_apple.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ bool ffDetectWmTheme(FFstrbuf* themeOrError)
1515
return false;
1616
}
1717

18-
NSNumber* wmThemeColor = [dict valueForKey:@"AppleAccentColor"];
18+
NSNumber* wmThemeColor = dict[@"AppleAccentColor"];
1919
if(!wmThemeColor)
2020
ffStrbufAppendS(themeOrError, "Multicolor");
2121
else
@@ -34,7 +34,7 @@ bool ffDetectWmTheme(FFstrbuf* themeOrError)
3434
}
3535
}
3636

37-
NSString* wmTheme = [dict valueForKey:@"AppleInterfaceStyle"];
37+
NSString* wmTheme = dict[@"AppleInterfaceStyle"];
3838
ffStrbufAppendF(themeOrError, " (%s)", wmTheme ? wmTheme.UTF8String : "Light");
3939
return true;
4040
}

0 commit comments

Comments
 (0)