From 0ec8237b81d68d8e8c4d74126e04adfc6176a934 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=8B=BC=E8=8C=B9=E5=A4=8F=E8=8A=B1?= <383347469@qq.com>
Date: Wed, 20 Nov 2013 16:01:11 +0800
Subject: [PATCH 1/3] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E5=88=B0=E6=9C=80?=
=?UTF-8?q?=E6=96=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../project.xcworkspace/contents.xcworkspacedata | 7 +++++++
1 file changed, 7 insertions(+)
create mode 100644 KSImageNamed.xcodeproj/project.xcworkspace/contents.xcworkspacedata
diff --git a/KSImageNamed.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/KSImageNamed.xcodeproj/project.xcworkspace/contents.xcworkspacedata
new file mode 100644
index 0000000..8a78bd0
--- /dev/null
+++ b/KSImageNamed.xcodeproj/project.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,7 @@
+
+
+
+
+
From 76b574c809d3d6f5144a47041741ebe7a8087e7c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=8B=BC=E8=8C=B9=E5=A4=8F=E8=8A=B1?= <383347469@qq.com>
Date: Wed, 24 Jun 2015 17:59:26 +0800
Subject: [PATCH 2/3] =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=9C=A8@"=20"=E5=86=85?=
=?UTF-8?q?=E5=BC=B9=E5=87=BA=E5=9B=BE=E7=89=87=E6=8F=90=E7=A4=BA,?=
=?UTF-8?q?=E5=B9=B6=E5=85=A8=E8=87=AA=E5=8A=A8=E4=BF=9D=E5=AD=98.=20?=
=?UTF-8?q?=E6=AF=94=E5=A6=82@"guid=5F568"=20=E6=9C=80=E5=90=8E=E8=87=AA?=
=?UTF-8?q?=E5=8A=A8=E5=8F=98=E4=B8=BA@"guid=5F480"?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
...DVTTextCompletionController+KSImageNamed.m | 23 +++++++++++++++++--
KSImageNamed/KSImageNamed-Info.plist | 2 ++
KSImageNamed/KSImageNamed.m | 10 ++++++--
.../KSImageNamedIndexCompletionItem.h | 1 +
.../KSImageNamedIndexCompletionItem.m | 12 ++++++++--
KSImageNamed/KSImageNamedPreviewWindow.m | 2 +-
KSImageNamed/XcodeMisc.h | 1 +
7 files changed, 44 insertions(+), 7 deletions(-)
diff --git a/KSImageNamed/DVTTextCompletionController+KSImageNamed.m b/KSImageNamed/DVTTextCompletionController+KSImageNamed.m
index e6cef5a..20ffe62 100644
--- a/KSImageNamed/DVTTextCompletionController+KSImageNamed.m
+++ b/KSImageNamed/DVTTextCompletionController+KSImageNamed.m
@@ -21,17 +21,36 @@ + (void)load
- (BOOL)swizzle_acceptCurrentCompletion
{
- BOOL success = [self swizzle_acceptCurrentCompletion];
+ NSRange selectedRange = [[self textView] selectedRange];
+
+ id item = nil;
+ if ([self.textView.textStorage respondsToSelector:@selector(sourceModelItemAtCharacterIndex:)]) {
+ item = [self.textView.textStorage sourceModelItemAtCharacterIndex:selectedRange.location]; //-2.插入时会增加@"
+ } else {
+ item = [[self.textView.textStorage sourceModelService] sourceModelItemAtCharacterIndex:selectedRange.location];
+ }
+ NSRange itemRange = [item range];
+// NSLog(@"替换前,itemRange: %@ selectRange:%@",NSStringFromRange(itemRange),NSStringFromRange(selectedRange));
+ NSString *itemString = [[self.textView.textStorage string] substringWithRange:itemRange];
+// NSLog(@"替换前,itemString:%@",itemString);
+
+ BOOL success = [self swizzle_acceptCurrentCompletion];
+
if (success) {
@try {
NSRange range = [[self textView] selectedRange];
+
+ if ([itemString hasPrefix:@"@\""]&&[itemString hasSuffix:@"\""]){
+ [self.textView insertText:@"" replacementRange:NSMakeRange(range.location, itemRange.location+itemRange.length-range.location+1+2)];
+ [self.textView insertText:@"" replacementRange:NSMakeRange(itemRange.location, 2)];
+ }
for (NSString *nextClassAndMethod in [[KSImageNamed sharedPlugin] completionStringsForType:KSImageNamedCompletionStringTypeClassAndMethod]) {
//If an autocomplete causes imageNamed: to get inserted, remove the token and immediately pop up autocomplete
if (range.location > [nextClassAndMethod length]) {
NSString *insertedString = [[[self textView] string] substringWithRange:NSMakeRange(range.location - [nextClassAndMethod length], [nextClassAndMethod length])];
-
+// NSLog(@"准备插入替换.....%@,%@",insertedString,nextClassAndMethod);
if ([insertedString isEqualToString:nextClassAndMethod]) {
[[self textView] insertText:@"" replacementRange:range];
[self _showCompletionsAtCursorLocationExplicitly:YES];
diff --git a/KSImageNamed/KSImageNamed-Info.plist b/KSImageNamed/KSImageNamed-Info.plist
index 87e74c2..fe9fada 100644
--- a/KSImageNamed/KSImageNamed-Info.plist
+++ b/KSImageNamed/KSImageNamed-Info.plist
@@ -58,6 +58,8 @@
AD68E85B-441B-4301-B564-A45E4919A6AD
C4A681B0-4A26-480E-93EC-1218098B9AA0
A16FF353-8441-459E-A50C-B071F53F51B7
+ 9F75337B-21B4-4ADC-B558-F9CADF7073A7
+ E969541F-E6F9-4D25-8158-72DC3545A6C6
diff --git a/KSImageNamed/KSImageNamed.m b/KSImageNamed/KSImageNamed.m
index 8ca3b93..fb05efb 100644
--- a/KSImageNamed/KSImageNamed.m
+++ b/KSImageNamed/KSImageNamed.m
@@ -228,8 +228,12 @@ - (NSArray *)_imageCompletionsForIndex:(id)index
NSString *normalFileName;
BOOL skip = NO;
BOOL is2x = NO;
+ BOOL is3x = NO;
- if ([imageName hasSuffix:@"@2x"]) {
+ if ([imageName hasSuffix:@"@3x"]) {
+ normalFileName = [[imageName substringToIndex:[imageName length] - 3] stringByAppendingFormat:@".%@", [fileName pathExtension]];
+ is3x = YES;
+ }else if ([imageName hasSuffix:@"@2x"]) {
normalFileName = [[imageName substringToIndex:[imageName length] - 3] stringByAppendingFormat:@".%@", [fileName pathExtension]];
is2x = YES;
} else if ([imageName hasSuffix:@"@2x~ipad"]) {
@@ -243,7 +247,9 @@ - (NSArray *)_imageCompletionsForIndex:(id)index
KSImageNamedIndexCompletionItem *existingCompletionItem = [imageCompletionItems objectForKey:normalFileName];
if (existingCompletionItem) {
- if (is2x) {
+ if (is3x) {
+ existingCompletionItem.has2x = YES;
+ }else if (is2x) {
existingCompletionItem.has2x = YES;
} else {
existingCompletionItem.has1x = YES;
diff --git a/KSImageNamed/KSImageNamedIndexCompletionItem.h b/KSImageNamed/KSImageNamedIndexCompletionItem.h
index 68a92c6..8a6fb1b 100644
--- a/KSImageNamed/KSImageNamedIndexCompletionItem.h
+++ b/KSImageNamed/KSImageNamedIndexCompletionItem.h
@@ -101,6 +101,7 @@
@property(nonatomic, strong, readonly) NSString *fileName;
@property(nonatomic, assign) BOOL has1x;
@property(nonatomic, assign) BOOL has2x;
+@property(nonatomic, assign) BOOL has3x;
@property(nonatomic, assign, getter=isInAssetCatalog, readonly) BOOL inAssetCatalog;
- (id)initWithFileURL:(NSURL *)fileURL includeExtension:(BOOL)includeExtension;
diff --git a/KSImageNamed/KSImageNamedIndexCompletionItem.m b/KSImageNamed/KSImageNamedIndexCompletionItem.m
index 2b03807..c9d976b 100644
--- a/KSImageNamed/KSImageNamedIndexCompletionItem.m
+++ b/KSImageNamed/KSImageNamedIndexCompletionItem.m
@@ -122,12 +122,20 @@ - (NSString *)displayText
{
NSString *displayFormat = @"%@ (%@)";
- if (self.has1x && self.has2x) {
+ if (self.has1x && self.has2x && self.has3x) {
+ displayFormat = @"%@ (%@, 1x and 2x and 3x)";
+ }if (self.has2x && self.has3x) {
+ displayFormat = @"%@ (%@, 2x and 3x)";
+ }if (self.has1x && self.has3x) {
+ displayFormat = @"%@ (%@, 1x and 3x)";
+ }else if (self.has1x && self.has2x) {
displayFormat = @"%@ (%@, 1x and 2x)";
} else if (self.has1x) {
displayFormat = @"%@ (%@, 1x only)";
} else if (self.has2x) {
displayFormat = @"%@ (%@, 2x only)";
+ }else if (self.has3x){
+ displayFormat = @"%@ (%@, 3x only)";
}
return [NSString stringWithFormat:displayFormat, [self _imageNamedText], [[self fileURL] pathExtension]];
@@ -138,7 +146,7 @@ - (NSString *)_fileName
NSString *fileName = [[self fileURL] lastPathComponent];
NSString *imageName = [fileName stringByDeletingPathExtension];
- if ([imageName hasSuffix:@"@2x"]) {
+ if ([imageName hasSuffix:@"@2x"] || [imageName hasSuffix:@"@3x"]) {
fileName = [[imageName substringToIndex:[imageName length] - 3] stringByAppendingFormat:@".%@", [fileName pathExtension]];
} else if ([imageName hasSuffix:@"@2x~ipad"]) {
//2x iPad images need to be handled separately since (image~ipad and image@2x~ipad are valid pairs)
diff --git a/KSImageNamed/KSImageNamedPreviewWindow.m b/KSImageNamed/KSImageNamedPreviewWindow.m
index 1bc9ad1..7370214 100644
--- a/KSImageNamed/KSImageNamedPreviewWindow.m
+++ b/KSImageNamed/KSImageNamedPreviewWindow.m
@@ -94,7 +94,7 @@ - (void)_updateDisplay
}
//Crash on multi monitors(Display) becuase some time value is in -ve
- NSPoint tempPoint = CGPointMake(abs(_frameTopRightPoint.x), abs(_frameTopRightPoint.y));
+ NSPoint tempPoint = CGPointMake(fabs(_frameTopRightPoint.x), fabs(_frameTopRightPoint.y));
//if image doesn't fit screen, scale by even factors until it does
while ((tempPoint.y < (_image.size.height / factor)) || (tempPoint.x < (_image.size.width / factor))) {
diff --git a/KSImageNamed/XcodeMisc.h b/KSImageNamed/XcodeMisc.h
index cd6bebc..c0e22a7 100644
--- a/KSImageNamed/XcodeMisc.h
+++ b/KSImageNamed/XcodeMisc.h
@@ -69,6 +69,7 @@
- (id)stringConstantAtLocation:(unsigned long long)arg1; //DVTSourceModel
- (id)previousItem; //DVTSourceModelItem
+- (id)nextItem;
- (id)_listWindowController; //DVTTextCompletionSession
@end
From e07e36d4f6f7fe1f42cd8820c05ecdb84ef0ee03 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=8B=BC=E8=8C=B9=E5=A4=8F=E8=8A=B1?= <383347469@qq.com>
Date: Wed, 24 Jun 2015 18:13:51 +0800
Subject: [PATCH 3/3] =?UTF-8?q?=E5=90=88=E5=B9=B6dev=E5=88=86=E6=94=AF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../xcshareddata/KSImageNamed.xccheckout | 41 +++++++++++++++++++
1 file changed, 41 insertions(+)
create mode 100644 KSImageNamed.xcodeproj/project.xcworkspace/xcshareddata/KSImageNamed.xccheckout
diff --git a/KSImageNamed.xcodeproj/project.xcworkspace/xcshareddata/KSImageNamed.xccheckout b/KSImageNamed.xcodeproj/project.xcworkspace/xcshareddata/KSImageNamed.xccheckout
new file mode 100644
index 0000000..0688c88
--- /dev/null
+++ b/KSImageNamed.xcodeproj/project.xcworkspace/xcshareddata/KSImageNamed.xccheckout
@@ -0,0 +1,41 @@
+
+
+
+
+ IDESourceControlProjectFavoriteDictionaryKey
+
+ IDESourceControlProjectIdentifier
+ 38EA5A0B-F27C-46AF-84C4-880AF2D73FBE
+ IDESourceControlProjectName
+ KSImageNamed
+ IDESourceControlProjectOriginsDictionary
+
+ C2F7F2B06ED7506D9B6499106F8DB5F0850044C7
+ https://github.com/musiczone/KSImageNamed-Xcode.git
+
+ IDESourceControlProjectPath
+ KSImageNamed.xcodeproj
+ IDESourceControlProjectRelativeInstallPathDictionary
+
+ C2F7F2B06ED7506D9B6499106F8DB5F0850044C7
+ ../..
+
+ IDESourceControlProjectURL
+ https://github.com/musiczone/KSImageNamed-Xcode.git
+ IDESourceControlProjectVersion
+ 111
+ IDESourceControlProjectWCCIdentifier
+ C2F7F2B06ED7506D9B6499106F8DB5F0850044C7
+ IDESourceControlProjectWCConfigurations
+
+
+ IDESourceControlRepositoryExtensionIdentifierKey
+ public.vcs.git
+ IDESourceControlWCCIdentifierKey
+ C2F7F2B06ED7506D9B6499106F8DB5F0850044C7
+ IDESourceControlWCCName
+ KSImageNamed-Xcode
+
+
+
+