-
Notifications
You must be signed in to change notification settings - Fork 386
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
61 changed files
with
1,300 additions
and
3,588 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,3 +21,4 @@ Pods | |
|
||
/video/ | ||
/video | ||
/ignore |
Binary file not shown.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>CFBundleDevelopmentRegion</key> | ||
<string>en</string> | ||
<key>CFBundleDisplayName</key> | ||
<string>XAlign</string> | ||
<key>CFBundleExecutable</key> | ||
<string>$(EXECUTABLE_NAME)</string> | ||
<key>CFBundleIdentifier</key> | ||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> | ||
<key>CFBundleInfoDictionaryVersion</key> | ||
<string>6.0</string> | ||
<key>CFBundleName</key> | ||
<string>XAlign</string> | ||
<key>CFBundlePackageType</key> | ||
<string>XPC!</string> | ||
<key>CFBundleShortVersionString</key> | ||
<string>1.0</string> | ||
<key>CFBundleVersion</key> | ||
<string>201611092325</string> | ||
<key>LSMinimumSystemVersion</key> | ||
<string>$(MACOSX_DEPLOYMENT_TARGET)</string> | ||
<key>NSExtension</key> | ||
<dict> | ||
<key>NSExtensionAttributes</key> | ||
<dict> | ||
<key>XCSourceEditorCommandDefinitions</key> | ||
<array> | ||
<dict> | ||
<key>XCSourceEditorCommandClassName</key> | ||
<string>SourceEditorCommand</string> | ||
<key>XCSourceEditorCommandIdentifier</key> | ||
<string>$(PRODUCT_BUNDLE_IDENTIFIER).SourceEditorCommand</string> | ||
<key>XCSourceEditorCommandName</key> | ||
<string>Auto Align</string> | ||
</dict> | ||
</array> | ||
<key>XCSourceEditorExtensionPrincipalClass</key> | ||
<string>SourceEditorExtension</string> | ||
</dict> | ||
<key>NSExtensionPointIdentifier</key> | ||
<string>com.apple.dt.Xcode.extension.source-editor</string> | ||
</dict> | ||
<key>NSHumanReadableCopyright</key> | ||
<string>Copyright © 2016 QFish. All rights reserved.</string> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// | ||
// SourceEditorCommand.h | ||
// SourceEditorExtension | ||
// | ||
// Created by QFish on 03/11/2016. | ||
// Copyright © 2016 QFish. All rights reserved. | ||
// | ||
|
||
#import <XcodeKit/XcodeKit.h> | ||
|
||
@interface SourceEditorCommand : NSObject <XCSourceEditorCommand> | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// | ||
// SourceEditorCommand.m | ||
// SourceEditorExtension | ||
// | ||
// Created by QFish on 03/11/2016. | ||
// Copyright © 2016 QFish. All rights reserved. | ||
// | ||
|
||
#import "SourceEditorCommand.h" | ||
#import "XAlignPattern.h" | ||
#import "NSString+XAlign.h" | ||
|
||
@implementation SourceEditorCommand | ||
|
||
- (void)performCommandWithInvocation:(XCSourceEditorCommandInvocation *)invocation completionHandler:(void (^)(NSError * _Nullable nilOrError))completionHandler | ||
{ | ||
// Implement your command here, invoking the completion handler when done. Pass it nil on success, and an NSError on failure. | ||
|
||
if ([invocation.commandIdentifier hasSuffix:@"SourceEditorCommand"]) | ||
{ | ||
[[self class] autoAlign:invocation]; | ||
} | ||
|
||
completionHandler(nil); | ||
} | ||
|
||
+ (void)autoAlign:(XCSourceEditorCommandInvocation *)invocation | ||
{ | ||
NSMutableArray * selections = [NSMutableArray array]; | ||
|
||
for ( XCSourceTextRange *range in invocation.buffer.selections ) | ||
{ | ||
for ( NSInteger i = range.start.line; i < range.end.line ; i++) | ||
{ | ||
[selections addObject:invocation.buffer.lines[i]]; | ||
} | ||
} | ||
|
||
NSString * selectedString = [selections componentsJoinedByString:@""]; | ||
|
||
NSArray * patternGroup = [XAlignPatternManager patternGroupMatchWithString:selectedString]; | ||
|
||
if ( !patternGroup ) | ||
return; | ||
|
||
NSString * alignedString = [selectedString stringByAligningWithPatterns:patternGroup]; | ||
|
||
NSArray * result = [alignedString componentsSeparatedByString:@"\n"]; | ||
|
||
for ( XCSourceTextRange *range in invocation.buffer.selections ) | ||
{ | ||
for ( NSInteger i = range.start.line, j=0; i < range.end.line ; i++, j++ ) | ||
{ | ||
invocation.buffer.lines[i] = result[j]; | ||
} | ||
} | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>com.apple.security.app-sandbox</key> | ||
<true/> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// | ||
// SourceEditorExtension.h | ||
// SourceEditorExtension | ||
// | ||
// Created by QFish on 03/11/2016. | ||
// Copyright © 2016 QFish. All rights reserved. | ||
// | ||
|
||
#import <XcodeKit/XcodeKit.h> | ||
|
||
@interface SourceEditorExtension : NSObject <XCSourceEditorExtension> | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// | ||
// SourceEditorExtension.m | ||
// SourceEditorExtension | ||
// | ||
// Created by QFish on 03/11/2016. | ||
// Copyright © 2016 QFish. All rights reserved. | ||
// | ||
|
||
#import "SourceEditorExtension.h" | ||
#import "XAlignPattern.h" | ||
|
||
@implementation SourceEditorExtension | ||
|
||
- (void)extensionDidFinishLaunching | ||
{ | ||
// If your extension needs to do any work at launch, implement this optional method. | ||
[XAlignPatternManager launch]; | ||
} | ||
|
||
//- (NSArray <NSDictionary <XCSourceEditorCommandDefinitionKey, id> *> *)commandDefinitions | ||
//{ | ||
// // If your extension needs to return a collection of command definitions that differs from those in its Info.plist, implement this optional property getter. | ||
// return @[]; | ||
//} | ||
|
||
@end |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.