Skip to content

Commit db00aa4

Browse files
committed
Swift format
1 parent b29d0d0 commit db00aa4

33 files changed

+1614
-1346
lines changed

ColorSet.xcodeproj/project.pbxproj

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
archiveVersion = 1;
44
classes = {
55
};
6-
objectVersion = 50;
6+
objectVersion = 54;
77
objects = {
88

99
/* Begin PBXBuildFile section */
@@ -413,9 +413,10 @@
413413
buildPhases = (
414414
0543AE5E20DC33BC00284E99 /* Sources */,
415415
0543AE5F20DC33BC00284E99 /* Frameworks */,
416-
0509122120E55AE4009EF90C /* ShellScript */,
416+
0509122120E55AE4009EF90C /* Run Script */,
417417
0543AE6020DC33BC00284E99 /* Resources */,
418418
0509121620E55A8A009EF90C /* CopyFiles */,
419+
0587465F28E2E10B00861788 /* Swift Format */,
419420
);
420421
buildRules = (
421422
);
@@ -434,7 +435,7 @@
434435
isa = PBXProject;
435436
attributes = {
436437
LastSwiftUpdateCheck = 1020;
437-
LastUpgradeCheck = 0940;
438+
LastUpgradeCheck = 1400;
438439
ORGANIZATIONNAME = "XS-Labs";
439440
TargetAttributes = {
440441
0543AE6120DC33BC00284E99 = {
@@ -517,19 +518,40 @@
517518
/* End PBXResourcesBuildPhase section */
518519

519520
/* Begin PBXShellScriptBuildPhase section */
520-
0509122120E55AE4009EF90C /* ShellScript */ = {
521+
0509122120E55AE4009EF90C /* Run Script */ = {
521522
isa = PBXShellScriptBuildPhase;
523+
alwaysOutOfDate = 1;
522524
buildActionMask = 2147483647;
523525
files = (
524526
);
525527
inputPaths = (
526528
);
529+
name = "Run Script";
527530
outputPaths = (
528531
);
529532
runOnlyForDeploymentPostprocessing = 0;
530533
shellPath = /bin/sh;
531534
shellScript = "#!/bin/bash\nif [ \"${CONFIGURATION}\" = \"Release\" ]; then\n plist=\"ColorSet/Info.plist\"\n rev=$(git rev-list `git branch | grep -e \"^*\" | cut -d' ' -f 2` | wc -l)\n /usr/libexec/PlistBuddy -c \"Set :CFBundleVersion $rev\" \"$plist\"\nfi\n";
532535
};
536+
0587465F28E2E10B00861788 /* Swift Format */ = {
537+
isa = PBXShellScriptBuildPhase;
538+
alwaysOutOfDate = 1;
539+
buildActionMask = 2147483647;
540+
files = (
541+
);
542+
inputFileListPaths = (
543+
);
544+
inputPaths = (
545+
);
546+
name = "Swift Format";
547+
outputFileListPaths = (
548+
);
549+
outputPaths = (
550+
);
551+
runOnlyForDeploymentPostprocessing = 0;
552+
shellPath = /bin/sh;
553+
shellScript = "if [ -d \"$SRCROOT/Submodules/cgl\" ] && [ \"${CONFIGURATION}\" = \"Debug\" ]; then\n make -f $SRCROOT/Submodules/cgl/Makefile mit\nfi\n";
554+
};
533555
/* End PBXShellScriptBuildPhase section */
534556

535557
/* Begin PBXSourcesBuildPhase section */

ColorSet.xcodeproj/xcshareddata/xcschemes/ColorSet.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1120"
3+
LastUpgradeVersion = "1400"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

ColorSet.xcodeproj/xcshareddata/xcschemes/Documentation.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1130"
3+
LastUpgradeVersion = "1400"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

ColorSet/Classes/AboutWindowController.swift

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
/*******************************************************************************
22
* The MIT License (MIT)
3-
*
4-
* Copyright (c) 2018 Jean-David Gadina - www.imazing.com
5-
*
3+
*
4+
* Copyright (c) 2022, DigiDNA
5+
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
7-
* of this software and associated documentation files (the "Software"), to deal
7+
* of this software and associated documentation files (the Software), to deal
88
* in the Software without restriction, including without limitation the rights
99
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1010
* copies of the Software, and to permit persons to whom the Software is
1111
* furnished to do so, subject to the following conditions:
12-
*
12+
*
1313
* The above copyright notice and this permission notice shall be included in
1414
* all copies or substantial portions of the Software.
15-
*
16-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
*
16+
* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1717
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1818
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1919
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
@@ -29,27 +29,27 @@ public class AboutWindowController: NSWindowController
2929
@objc private dynamic var name: String?
3030
@objc private dynamic var version: String?
3131
@objc private dynamic var copyright: String?
32-
32+
3333
public override var windowNibName: NSNib.Name?
3434
{
3535
return NSNib.Name( NSStringFromClass( type( of: self ) ) )
3636
}
37-
38-
override public func windowDidLoad()
37+
38+
public override func windowDidLoad()
3939
{
4040
super.windowDidLoad()
41-
41+
4242
let version = Bundle.main.object( forInfoDictionaryKey: "CFBundleShortVersionString" ) as? String ?? "0.0.0"
43-
43+
4444
if let build = Bundle.main.object( forInfoDictionaryKey: "CFBundleVersion" ) as? String
4545
{
46-
self.version = "\(version) (\(build))"
46+
self.version = "\( version ) (\( build ))"
4747
}
4848
else
4949
{
5050
self.version = version
5151
}
52-
52+
5353
self.name = Bundle.main.object( forInfoDictionaryKey: "CFBundleName" ) as? String
5454
self.copyright = Bundle.main.object( forInfoDictionaryKey: "NSHumanReadableCopyright" ) as? String
5555
}

ColorSet/Classes/ApplicationDelegate.swift

Lines changed: 61 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
/*******************************************************************************
22
* The MIT License (MIT)
3-
*
4-
* Copyright (c) 2018 Jean-David Gadina - www.imazing.com
5-
*
3+
*
4+
* Copyright (c) 2022, DigiDNA
5+
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
7-
* of this software and associated documentation files (the "Software"), to deal
7+
* of this software and associated documentation files (the Software), to deal
88
* in the Software without restriction, including without limitation the rights
99
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1010
* copies of the Software, and to permit persons to whom the Software is
1111
* furnished to do so, subject to the following conditions:
12-
*
12+
*
1313
* The above copyright notice and this permission notice shall be included in
1414
* all copies or substantial portions of the Software.
15-
*
16-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
*
16+
* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1717
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1818
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1919
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
@@ -30,7 +30,7 @@ class ApplicationDelegate: NSResponder, NSApplicationDelegate
3030
{
3131
private var controllers = [ NSWindowController ]()
3232
private var aboutWindowController: NSWindowController?
33-
33+
3434
func applicationDidFinishLaunching( _ notification: Notification )
3535
{
3636
DispatchQueue.main.asyncAfter( deadline: .now() + .milliseconds( 500 ) )
@@ -40,134 +40,142 @@ class ApplicationDelegate: NSResponder, NSApplicationDelegate
4040
self.newDocument( nil )
4141
}
4242
}
43-
44-
NotificationCenter.default.addObserver( self, selector: #selector( windowWillClose( _: ) ), name: NSWindow.willCloseNotification, object: nil )
45-
43+
44+
NotificationCenter.default.addObserver( self, selector: #selector( self.windowWillClose( _: ) ), name: NSWindow.willCloseNotification, object: nil )
45+
4646
#if DEBUG
47-
UserDefaults.standard.register( defaults: [ "NSApplicationCrashOnExceptions" : true ] )
47+
UserDefaults.standard.register( defaults: [ "NSApplicationCrashOnExceptions": true ] )
4848
#endif
4949
}
5050

5151
func applicationWillTerminate( _ notification: Notification )
5252
{}
53-
54-
@IBAction public func newDocument( _ sender: Any? )
53+
54+
@IBAction
55+
public func newDocument( _ sender: Any? )
5556
{
5657
let controller = MainWindowController()
57-
58+
5859
controller.window?.center()
5960
controller.window?.makeKeyAndOrderFront( sender )
60-
61+
6162
self.controllers.append( controller )
6263
}
63-
64-
@IBAction public func showAboutWindow( _ sender: Any? )
64+
65+
@IBAction
66+
public func showAboutWindow( _ sender: Any? )
6567
{
66-
if( self.aboutWindowController == nil )
68+
if self.aboutWindowController == nil
6769
{
6870
self.aboutWindowController = AboutWindowController()
69-
71+
7072
self.aboutWindowController?.window?.layoutIfNeeded()
7173
self.aboutWindowController?.window?.center()
7274
}
73-
75+
7476
self.aboutWindowController?.window?.makeKeyAndOrderFront( sender )
7577
}
76-
78+
7779
func application( _ sender: NSApplication, openFile filename: String ) -> Bool
7880
{
7981
return self.open( url: URL( fileURLWithPath: filename ) )
8082
}
81-
82-
@IBAction public func openDocument( _ sender: Any? )
83+
84+
@IBAction
85+
public func openDocument( _ sender: Any? )
8386
{
8487
let panel = NSOpenPanel()
85-
88+
8689
panel.canChooseDirectories = false
8790
panel.canChooseFiles = true
8891
panel.canCreateDirectories = false
8992
panel.allowsMultipleSelection = false
9093
panel.allowedFileTypes = [ "colorset" ]
91-
94+
9295
let r = panel.runModal()
93-
94-
if( r != .OK )
96+
97+
if r != .OK
9598
{
9699
return
97100
}
98-
99-
guard let url = panel.url else
101+
102+
guard let url = panel.url
103+
else
100104
{
101105
return
102106
}
103-
104-
let _ = self.open( url: url )
107+
108+
_ = self.open( url: url )
105109
}
106-
110+
107111
private func open( url: URL ) -> Bool
108112
{
109-
guard let set = ColorSet( url: url ) else
113+
guard let set = ColorSet( url: url )
114+
else
110115
{
111116
let alert = NSAlert()
112117
alert.messageText = "Load error"
113118
alert.informativeText = "Invalid data format"
114-
119+
115120
alert.runModal()
116-
121+
117122
return false
118123
}
119-
124+
120125
var colors = [ ColorItem ]()
121-
126+
122127
for p in set.colors
123128
{
124-
guard let color = p.value.color else
129+
guard let color = p.value.color
130+
else
125131
{
126132
continue
127133
}
128-
134+
129135
let item = ColorItem()
130136
item.name = p.key
131137
item.color = color
132138
item.variant = p.value.variant
133-
139+
134140
for lp in p.value.lightnesses
135141
{
136142
let lightness = LightnessPairItem( base: item )
137-
143+
138144
lightness.lightness1.lightness = lp.lightness1.lightness
139145
lightness.lightness1.name = lp.lightness1.name
140146
lightness.lightness2.lightness = lp.lightness2.lightness
141147
lightness.lightness2.name = lp.lightness2.name
142-
148+
143149
item.lightnessPairs.append( lightness )
144150
}
145-
151+
146152
colors.append( item )
147153
}
148-
154+
149155
let controller = MainWindowController( colors: colors, format: set.format )
150156
controller.url = url
151-
157+
152158
controller.window?.center()
153159
controller.window?.makeKeyAndOrderFront( nil )
154-
160+
155161
self.controllers.append( controller )
156-
162+
157163
return true
158164
}
159-
160-
@objc private func windowWillClose( _ notification: Notification )
165+
166+
@objc
167+
private func windowWillClose( _ notification: Notification )
161168
{
162169
self.controllers.removeAll
163170
{
164171
c in
165-
166-
guard let window = notification.object as? NSWindow else
172+
173+
guard let window = notification.object as? NSWindow
174+
else
167175
{
168176
return false
169177
}
170-
178+
171179
return c.window == window
172180
}
173181
}

0 commit comments

Comments
 (0)