├── .gitignore ├── CHANGELOG.md ├── Classes ├── NTYSmartTextView.h └── NTYSmartTextView.m ├── Example ├── .gitignore ├── NTYSmartTextViewExample.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata ├── NTYSmartTextViewExample.xcworkspace │ └── contents.xcworkspacedata ├── NTYSmartTextViewExample │ ├── Base.lproj │ │ ├── MainMenu.xib │ │ └── NTYDocument.xib │ ├── Images.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── NTYDocument.h │ ├── NTYDocument.m │ ├── NTYSmartTextViewExample-Info.plist │ ├── NTYSmartTextViewExample-Prefix.pch │ ├── NTYWindowController.h │ ├── NTYWindowController.m │ ├── en.lproj │ │ ├── Credits.rtf │ │ └── InfoPlist.strings │ └── main.m ├── NTYSmartTextViewExampleTests │ ├── NTYSmartTextViewExampleTests-Info.plist │ ├── NTYSmartTextViewExampleTests.m │ └── en.lproj │ │ └── InfoPlist.strings ├── Podfile └── Podfile.lock ├── LICENSE ├── NTYSmartTextView.podspec ├── README.md ├── Rakefile └── screenshot.gif /.gitignore: -------------------------------------------------------------------------------- 1 | # OS X 2 | .DS_Store 3 | 4 | # Xcode 5 | build/ 6 | *.pbxuser 7 | !default.pbxuser 8 | *.mode1v3 9 | !default.mode1v3 10 | *.mode2v3 11 | !default.mode2v3 12 | *.perspectivev3 13 | !default.perspectivev3 14 | xcuserdata 15 | *.xccheckout 16 | profile 17 | *.moved-aside 18 | DerivedData 19 | *.hmap 20 | *.ipa 21 | 22 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # NTYSmartTextView CHANGELOG 2 | 3 | ## 0.1.0 4 | 5 | Initial release. 6 | -------------------------------------------------------------------------------- /Classes/NTYSmartTextView.h: -------------------------------------------------------------------------------- 1 | // 2 | // NTYSmartTextView.h 3 | // Pods 4 | // 5 | // Created by naoty on 2014/03/25. 6 | // 7 | // 8 | 9 | #import 10 | 11 | @interface NTYSmartTextView : NSTextView 12 | 13 | // Smart Indent 14 | @property (nonatomic) BOOL smartIndentEnabled; 15 | 16 | // Soft Tab 17 | @property (nonatomic) BOOL softTabEnabled; 18 | @property (nonatomic) NSUInteger tabWidth; 19 | 20 | // Auto Pair Completion 21 | @property (nonatomic) BOOL autoPairCompletionEnabled; 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /Classes/NTYSmartTextView.m: -------------------------------------------------------------------------------- 1 | // 2 | // NTYSmartTextView.m 3 | // Pods 4 | // 5 | // Created by naoty on 2014/03/25. 6 | // 7 | // 8 | 9 | #import "NTYSmartTextView.h" 10 | 11 | @interface NTYSmartTextView () 12 | @property (nonatomic, readonly) NSString *currentLine; 13 | @property (nonatomic) NSArray *pairCharacters; 14 | @end 15 | 16 | @implementation NTYSmartTextView 17 | 18 | NSString * const kIndentPatternString = @"^(\\t|\\s)+"; 19 | 20 | - (id)initWithCoder:(NSCoder *)aDecoder 21 | { 22 | self = [super initWithCoder:aDecoder]; 23 | if (self) { 24 | [self setup]; 25 | } 26 | return self; 27 | } 28 | 29 | - (id)initWithFrame:(NSRect)frame 30 | { 31 | self = [super initWithFrame:frame]; 32 | if (self) { 33 | [self setup]; 34 | } 35 | return self; 36 | } 37 | 38 | - (void)drawRect:(NSRect)dirtyRect 39 | { 40 | [super drawRect:dirtyRect]; 41 | } 42 | 43 | - (void)insertNewline:(id)sender 44 | { 45 | NSString *currentLine = self.currentLine; 46 | 47 | [super insertNewline:sender]; 48 | 49 | if (self.smartIndentEnabled) { 50 | NSRegularExpression *pattern = [[NSRegularExpression alloc] initWithPattern:kIndentPatternString options:0 error:nil]; 51 | NSTextCheckingResult *matched = [pattern firstMatchInString:currentLine options:0 range:NSMakeRange(0, currentLine.length)]; 52 | if (matched) { 53 | NSString *indent = [currentLine substringWithRange:matched.range]; 54 | [self insertText:indent]; 55 | } 56 | } 57 | } 58 | 59 | - (void)insertTab:(id)sender 60 | { 61 | if (self.softTabEnabled) { 62 | NSMutableString *softTab = [NSMutableString new]; 63 | for (NSInteger i = 0; i < self.tabWidth; i++) { 64 | [softTab appendString:@" "]; 65 | } 66 | [self insertText:softTab]; 67 | } else { 68 | [super insertTab:sender]; 69 | } 70 | } 71 | 72 | - (void)insertText:(id)aString 73 | { 74 | [super insertText:aString]; 75 | 76 | if (!self.autoPairCompletionEnabled) { 77 | return; 78 | } 79 | 80 | NSString *string = (NSString *)aString; 81 | 82 | if ([string isEqualToString:@"("]) { 83 | [super insertText:@")"]; 84 | [super moveBackward:self]; 85 | } 86 | 87 | if ([string isEqualToString:@"["]) { 88 | [super insertText:@"]"]; 89 | [super moveBackward:self]; 90 | } 91 | 92 | if ([string isEqualToString:@"{"]) { 93 | [super insertText:@"}"]; 94 | [super moveBackward:self]; 95 | } 96 | 97 | if ([string isEqualToString:@"\""]) { 98 | [super insertText:@"\""]; 99 | [super moveBackward:self]; 100 | } 101 | 102 | if ([string isEqualToString:@"'"]) { 103 | [super insertText:@"'"]; 104 | [super moveBackward:self]; 105 | } 106 | 107 | if ([string isEqualToString:@"`"]) { 108 | [super insertText:@"`"]; 109 | [super moveBackward:self]; 110 | } 111 | } 112 | 113 | - (void)deleteBackward:(id)sender 114 | { 115 | if (!self.autoPairCompletionEnabled) { 116 | [super deleteBackward:sender]; 117 | return; 118 | } 119 | 120 | if ([self isStartOrEndOfLine]) { 121 | [super deleteBackward:sender]; 122 | return; 123 | } 124 | 125 | NSRange surroundRange = NSMakeRange(self.selectedRange.location - 1, 2); 126 | NSString *surroundString = [self.string substringWithRange:surroundRange]; 127 | 128 | if ([self.pairCharacters indexOfObject:surroundString] != NSNotFound) { 129 | [super deleteForward:sender]; 130 | [super deleteBackward:sender]; 131 | } else { 132 | [super deleteBackward:sender]; 133 | } 134 | } 135 | 136 | #pragma mark - Private methods 137 | 138 | - (void)setup 139 | { 140 | self.smartIndentEnabled = YES; 141 | self.softTabEnabled = YES; 142 | self.tabWidth = 4; 143 | self.autoPairCompletionEnabled = YES; 144 | 145 | // Disable to enable auto quotes pair completion. 146 | self.automaticQuoteSubstitutionEnabled = !self.autoPairCompletionEnabled; 147 | 148 | self.pairCharacters = @[@"()", @"[]", @"{}", @"\"\"", @"''", @"``"]; 149 | } 150 | 151 | - (NSString *)currentLine 152 | { 153 | NSRange currentLineRange = [self.string lineRangeForRange:self.selectedRange]; 154 | return [self.string substringWithRange:currentLineRange]; 155 | } 156 | 157 | - (BOOL)isEndOfLine 158 | { 159 | NSUInteger lineEnd; 160 | [self.string getLineStart:nil end:&lineEnd contentsEnd:nil forRange:self.selectedRange]; 161 | return self.selectedRange.location == lineEnd; 162 | } 163 | 164 | - (BOOL)isStartOrEndOfLine 165 | { 166 | NSUInteger lineStart, lineEnd; 167 | [self.string getLineStart:&lineStart end:&lineEnd contentsEnd:nil forRange:self.selectedRange]; 168 | return self.selectedRange.location == lineStart || self.selectedRange.location == lineEnd; 169 | } 170 | 171 | @end 172 | -------------------------------------------------------------------------------- /Example/.gitignore: -------------------------------------------------------------------------------- 1 | Pods/ 2 | -------------------------------------------------------------------------------- /Example/NTYSmartTextViewExample.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 3D05613F18E1C28200029E95 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3D05613E18E1C28200029E95 /* Cocoa.framework */; }; 11 | 3D05614918E1C28200029E95 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 3D05614718E1C28200029E95 /* InfoPlist.strings */; }; 12 | 3D05614B18E1C28200029E95 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 3D05614A18E1C28200029E95 /* main.m */; }; 13 | 3D05614F18E1C28200029E95 /* Credits.rtf in Resources */ = {isa = PBXBuildFile; fileRef = 3D05614D18E1C28200029E95 /* Credits.rtf */; }; 14 | 3D05615218E1C28200029E95 /* NTYDocument.m in Sources */ = {isa = PBXBuildFile; fileRef = 3D05615118E1C28200029E95 /* NTYDocument.m */; }; 15 | 3D05615518E1C28200029E95 /* NTYDocument.xib in Resources */ = {isa = PBXBuildFile; fileRef = 3D05615318E1C28200029E95 /* NTYDocument.xib */; }; 16 | 3D05615818E1C28200029E95 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 3D05615618E1C28200029E95 /* MainMenu.xib */; }; 17 | 3D05615A18E1C28200029E95 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 3D05615918E1C28200029E95 /* Images.xcassets */; }; 18 | 3D05616118E1C28200029E95 /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3D05616018E1C28200029E95 /* XCTest.framework */; }; 19 | 3D05616218E1C28200029E95 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3D05613E18E1C28200029E95 /* Cocoa.framework */; }; 20 | 3D05616A18E1C28200029E95 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 3D05616818E1C28200029E95 /* InfoPlist.strings */; }; 21 | 3D05616C18E1C28200029E95 /* NTYSmartTextViewExampleTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 3D05616B18E1C28200029E95 /* NTYSmartTextViewExampleTests.m */; }; 22 | 3D2DB2F218E432A600E8EC49 /* NTYWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 3D2DB2F118E432A600E8EC49 /* NTYWindowController.m */; }; 23 | B130545529B24A12B1DCA588 /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1B5FFD21A7324BEDBC30C508 /* libPods.a */; }; 24 | /* End PBXBuildFile section */ 25 | 26 | /* Begin PBXContainerItemProxy section */ 27 | 3D05616318E1C28200029E95 /* PBXContainerItemProxy */ = { 28 | isa = PBXContainerItemProxy; 29 | containerPortal = 3D05613318E1C28100029E95 /* Project object */; 30 | proxyType = 1; 31 | remoteGlobalIDString = 3D05613A18E1C28200029E95; 32 | remoteInfo = NTYSmartTextViewExample; 33 | }; 34 | /* End PBXContainerItemProxy section */ 35 | 36 | /* Begin PBXFileReference section */ 37 | 1B5FFD21A7324BEDBC30C508 /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; }; 38 | 3D05613B18E1C28200029E95 /* NTYSmartTextViewExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = NTYSmartTextViewExample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 39 | 3D05613E18E1C28200029E95 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; }; 40 | 3D05614118E1C28200029E95 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; }; 41 | 3D05614218E1C28200029E95 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = System/Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; }; 42 | 3D05614318E1C28200029E95 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 43 | 3D05614618E1C28200029E95 /* NTYSmartTextViewExample-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "NTYSmartTextViewExample-Info.plist"; sourceTree = ""; }; 44 | 3D05614818E1C28200029E95 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 45 | 3D05614A18E1C28200029E95 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 46 | 3D05614C18E1C28200029E95 /* NTYSmartTextViewExample-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NTYSmartTextViewExample-Prefix.pch"; sourceTree = ""; }; 47 | 3D05614E18E1C28200029E95 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.rtf; name = en; path = en.lproj/Credits.rtf; sourceTree = ""; }; 48 | 3D05615018E1C28200029E95 /* NTYDocument.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NTYDocument.h; sourceTree = ""; }; 49 | 3D05615118E1C28200029E95 /* NTYDocument.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NTYDocument.m; sourceTree = ""; }; 50 | 3D05615418E1C28200029E95 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/NTYDocument.xib; sourceTree = ""; }; 51 | 3D05615718E1C28200029E95 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; 52 | 3D05615918E1C28200029E95 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 53 | 3D05615F18E1C28200029E95 /* NTYSmartTextViewExampleTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = NTYSmartTextViewExampleTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 54 | 3D05616018E1C28200029E95 /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; }; 55 | 3D05616718E1C28200029E95 /* NTYSmartTextViewExampleTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "NTYSmartTextViewExampleTests-Info.plist"; sourceTree = ""; }; 56 | 3D05616918E1C28200029E95 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 57 | 3D05616B18E1C28200029E95 /* NTYSmartTextViewExampleTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NTYSmartTextViewExampleTests.m; sourceTree = ""; }; 58 | 3D2DB2F018E432A600E8EC49 /* NTYWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NTYWindowController.h; sourceTree = ""; }; 59 | 3D2DB2F118E432A600E8EC49 /* NTYWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NTYWindowController.m; sourceTree = ""; }; 60 | ED3C0FB65F0E46BEB22BFB0A /* Pods.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.xcconfig; path = Pods/Pods.xcconfig; sourceTree = ""; }; 61 | /* End PBXFileReference section */ 62 | 63 | /* Begin PBXFrameworksBuildPhase section */ 64 | 3D05613818E1C28200029E95 /* Frameworks */ = { 65 | isa = PBXFrameworksBuildPhase; 66 | buildActionMask = 2147483647; 67 | files = ( 68 | 3D05613F18E1C28200029E95 /* Cocoa.framework in Frameworks */, 69 | B130545529B24A12B1DCA588 /* libPods.a in Frameworks */, 70 | ); 71 | runOnlyForDeploymentPostprocessing = 0; 72 | }; 73 | 3D05615C18E1C28200029E95 /* Frameworks */ = { 74 | isa = PBXFrameworksBuildPhase; 75 | buildActionMask = 2147483647; 76 | files = ( 77 | 3D05616218E1C28200029E95 /* Cocoa.framework in Frameworks */, 78 | 3D05616118E1C28200029E95 /* XCTest.framework in Frameworks */, 79 | ); 80 | runOnlyForDeploymentPostprocessing = 0; 81 | }; 82 | /* End PBXFrameworksBuildPhase section */ 83 | 84 | /* Begin PBXGroup section */ 85 | 3D05613218E1C28100029E95 = { 86 | isa = PBXGroup; 87 | children = ( 88 | 3D05614418E1C28200029E95 /* NTYSmartTextViewExample */, 89 | 3D05616518E1C28200029E95 /* NTYSmartTextViewExampleTests */, 90 | 3D05613D18E1C28200029E95 /* Frameworks */, 91 | 3D05613C18E1C28200029E95 /* Products */, 92 | ED3C0FB65F0E46BEB22BFB0A /* Pods.xcconfig */, 93 | ); 94 | sourceTree = ""; 95 | }; 96 | 3D05613C18E1C28200029E95 /* Products */ = { 97 | isa = PBXGroup; 98 | children = ( 99 | 3D05613B18E1C28200029E95 /* NTYSmartTextViewExample.app */, 100 | 3D05615F18E1C28200029E95 /* NTYSmartTextViewExampleTests.xctest */, 101 | ); 102 | name = Products; 103 | sourceTree = ""; 104 | }; 105 | 3D05613D18E1C28200029E95 /* Frameworks */ = { 106 | isa = PBXGroup; 107 | children = ( 108 | 3D05613E18E1C28200029E95 /* Cocoa.framework */, 109 | 3D05616018E1C28200029E95 /* XCTest.framework */, 110 | 3D05614018E1C28200029E95 /* Other Frameworks */, 111 | 1B5FFD21A7324BEDBC30C508 /* libPods.a */, 112 | ); 113 | name = Frameworks; 114 | sourceTree = ""; 115 | }; 116 | 3D05614018E1C28200029E95 /* Other Frameworks */ = { 117 | isa = PBXGroup; 118 | children = ( 119 | 3D05614118E1C28200029E95 /* AppKit.framework */, 120 | 3D05614218E1C28200029E95 /* CoreData.framework */, 121 | 3D05614318E1C28200029E95 /* Foundation.framework */, 122 | ); 123 | name = "Other Frameworks"; 124 | sourceTree = ""; 125 | }; 126 | 3D05614418E1C28200029E95 /* NTYSmartTextViewExample */ = { 127 | isa = PBXGroup; 128 | children = ( 129 | 3D05615918E1C28200029E95 /* Images.xcassets */, 130 | 3D05615618E1C28200029E95 /* MainMenu.xib */, 131 | 3D05615018E1C28200029E95 /* NTYDocument.h */, 132 | 3D05615118E1C28200029E95 /* NTYDocument.m */, 133 | 3D05615318E1C28200029E95 /* NTYDocument.xib */, 134 | 3D2DB2F018E432A600E8EC49 /* NTYWindowController.h */, 135 | 3D2DB2F118E432A600E8EC49 /* NTYWindowController.m */, 136 | 3D05614518E1C28200029E95 /* Supporting Files */, 137 | ); 138 | path = NTYSmartTextViewExample; 139 | sourceTree = ""; 140 | }; 141 | 3D05614518E1C28200029E95 /* Supporting Files */ = { 142 | isa = PBXGroup; 143 | children = ( 144 | 3D05614618E1C28200029E95 /* NTYSmartTextViewExample-Info.plist */, 145 | 3D05614718E1C28200029E95 /* InfoPlist.strings */, 146 | 3D05614A18E1C28200029E95 /* main.m */, 147 | 3D05614C18E1C28200029E95 /* NTYSmartTextViewExample-Prefix.pch */, 148 | 3D05614D18E1C28200029E95 /* Credits.rtf */, 149 | ); 150 | name = "Supporting Files"; 151 | sourceTree = ""; 152 | }; 153 | 3D05616518E1C28200029E95 /* NTYSmartTextViewExampleTests */ = { 154 | isa = PBXGroup; 155 | children = ( 156 | 3D05616B18E1C28200029E95 /* NTYSmartTextViewExampleTests.m */, 157 | 3D05616618E1C28200029E95 /* Supporting Files */, 158 | ); 159 | path = NTYSmartTextViewExampleTests; 160 | sourceTree = ""; 161 | }; 162 | 3D05616618E1C28200029E95 /* Supporting Files */ = { 163 | isa = PBXGroup; 164 | children = ( 165 | 3D05616718E1C28200029E95 /* NTYSmartTextViewExampleTests-Info.plist */, 166 | 3D05616818E1C28200029E95 /* InfoPlist.strings */, 167 | ); 168 | name = "Supporting Files"; 169 | sourceTree = ""; 170 | }; 171 | /* End PBXGroup section */ 172 | 173 | /* Begin PBXNativeTarget section */ 174 | 3D05613A18E1C28200029E95 /* NTYSmartTextViewExample */ = { 175 | isa = PBXNativeTarget; 176 | buildConfigurationList = 3D05616F18E1C28200029E95 /* Build configuration list for PBXNativeTarget "NTYSmartTextViewExample" */; 177 | buildPhases = ( 178 | 5A7D371A2E984BFF869EED59 /* Check Pods Manifest.lock */, 179 | 3D05613718E1C28200029E95 /* Sources */, 180 | 3D05613818E1C28200029E95 /* Frameworks */, 181 | 3D05613918E1C28200029E95 /* Resources */, 182 | B24E957D447D49CC9BC946F2 /* Copy Pods Resources */, 183 | ); 184 | buildRules = ( 185 | ); 186 | dependencies = ( 187 | ); 188 | name = NTYSmartTextViewExample; 189 | productName = NTYSmartTextViewExample; 190 | productReference = 3D05613B18E1C28200029E95 /* NTYSmartTextViewExample.app */; 191 | productType = "com.apple.product-type.application"; 192 | }; 193 | 3D05615E18E1C28200029E95 /* NTYSmartTextViewExampleTests */ = { 194 | isa = PBXNativeTarget; 195 | buildConfigurationList = 3D05617218E1C28200029E95 /* Build configuration list for PBXNativeTarget "NTYSmartTextViewExampleTests" */; 196 | buildPhases = ( 197 | 3D05615B18E1C28200029E95 /* Sources */, 198 | 3D05615C18E1C28200029E95 /* Frameworks */, 199 | 3D05615D18E1C28200029E95 /* Resources */, 200 | ); 201 | buildRules = ( 202 | ); 203 | dependencies = ( 204 | 3D05616418E1C28200029E95 /* PBXTargetDependency */, 205 | ); 206 | name = NTYSmartTextViewExampleTests; 207 | productName = NTYSmartTextViewExampleTests; 208 | productReference = 3D05615F18E1C28200029E95 /* NTYSmartTextViewExampleTests.xctest */; 209 | productType = "com.apple.product-type.bundle.unit-test"; 210 | }; 211 | /* End PBXNativeTarget section */ 212 | 213 | /* Begin PBXProject section */ 214 | 3D05613318E1C28100029E95 /* Project object */ = { 215 | isa = PBXProject; 216 | attributes = { 217 | CLASSPREFIX = NTY; 218 | LastUpgradeCheck = 0510; 219 | ORGANIZATIONNAME = "Naoto Kaneko"; 220 | TargetAttributes = { 221 | 3D05615E18E1C28200029E95 = { 222 | TestTargetID = 3D05613A18E1C28200029E95; 223 | }; 224 | }; 225 | }; 226 | buildConfigurationList = 3D05613618E1C28200029E95 /* Build configuration list for PBXProject "NTYSmartTextViewExample" */; 227 | compatibilityVersion = "Xcode 3.2"; 228 | developmentRegion = English; 229 | hasScannedForEncodings = 0; 230 | knownRegions = ( 231 | en, 232 | Base, 233 | ); 234 | mainGroup = 3D05613218E1C28100029E95; 235 | productRefGroup = 3D05613C18E1C28200029E95 /* Products */; 236 | projectDirPath = ""; 237 | projectRoot = ""; 238 | targets = ( 239 | 3D05613A18E1C28200029E95 /* NTYSmartTextViewExample */, 240 | 3D05615E18E1C28200029E95 /* NTYSmartTextViewExampleTests */, 241 | ); 242 | }; 243 | /* End PBXProject section */ 244 | 245 | /* Begin PBXResourcesBuildPhase section */ 246 | 3D05613918E1C28200029E95 /* Resources */ = { 247 | isa = PBXResourcesBuildPhase; 248 | buildActionMask = 2147483647; 249 | files = ( 250 | 3D05615518E1C28200029E95 /* NTYDocument.xib in Resources */, 251 | 3D05615A18E1C28200029E95 /* Images.xcassets in Resources */, 252 | 3D05614918E1C28200029E95 /* InfoPlist.strings in Resources */, 253 | 3D05614F18E1C28200029E95 /* Credits.rtf in Resources */, 254 | 3D05615818E1C28200029E95 /* MainMenu.xib in Resources */, 255 | ); 256 | runOnlyForDeploymentPostprocessing = 0; 257 | }; 258 | 3D05615D18E1C28200029E95 /* Resources */ = { 259 | isa = PBXResourcesBuildPhase; 260 | buildActionMask = 2147483647; 261 | files = ( 262 | 3D05616A18E1C28200029E95 /* InfoPlist.strings in Resources */, 263 | ); 264 | runOnlyForDeploymentPostprocessing = 0; 265 | }; 266 | /* End PBXResourcesBuildPhase section */ 267 | 268 | /* Begin PBXShellScriptBuildPhase section */ 269 | 5A7D371A2E984BFF869EED59 /* Check Pods Manifest.lock */ = { 270 | isa = PBXShellScriptBuildPhase; 271 | buildActionMask = 2147483647; 272 | files = ( 273 | ); 274 | inputPaths = ( 275 | ); 276 | name = "Check Pods Manifest.lock"; 277 | outputPaths = ( 278 | ); 279 | runOnlyForDeploymentPostprocessing = 0; 280 | shellPath = /bin/sh; 281 | shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; 282 | showEnvVarsInLog = 0; 283 | }; 284 | B24E957D447D49CC9BC946F2 /* Copy Pods Resources */ = { 285 | isa = PBXShellScriptBuildPhase; 286 | buildActionMask = 2147483647; 287 | files = ( 288 | ); 289 | inputPaths = ( 290 | ); 291 | name = "Copy Pods Resources"; 292 | outputPaths = ( 293 | ); 294 | runOnlyForDeploymentPostprocessing = 0; 295 | shellPath = /bin/sh; 296 | shellScript = "\"${SRCROOT}/Pods/Pods-resources.sh\"\n"; 297 | showEnvVarsInLog = 0; 298 | }; 299 | /* End PBXShellScriptBuildPhase section */ 300 | 301 | /* Begin PBXSourcesBuildPhase section */ 302 | 3D05613718E1C28200029E95 /* Sources */ = { 303 | isa = PBXSourcesBuildPhase; 304 | buildActionMask = 2147483647; 305 | files = ( 306 | 3D2DB2F218E432A600E8EC49 /* NTYWindowController.m in Sources */, 307 | 3D05615218E1C28200029E95 /* NTYDocument.m in Sources */, 308 | 3D05614B18E1C28200029E95 /* main.m in Sources */, 309 | ); 310 | runOnlyForDeploymentPostprocessing = 0; 311 | }; 312 | 3D05615B18E1C28200029E95 /* Sources */ = { 313 | isa = PBXSourcesBuildPhase; 314 | buildActionMask = 2147483647; 315 | files = ( 316 | 3D05616C18E1C28200029E95 /* NTYSmartTextViewExampleTests.m in Sources */, 317 | ); 318 | runOnlyForDeploymentPostprocessing = 0; 319 | }; 320 | /* End PBXSourcesBuildPhase section */ 321 | 322 | /* Begin PBXTargetDependency section */ 323 | 3D05616418E1C28200029E95 /* PBXTargetDependency */ = { 324 | isa = PBXTargetDependency; 325 | target = 3D05613A18E1C28200029E95 /* NTYSmartTextViewExample */; 326 | targetProxy = 3D05616318E1C28200029E95 /* PBXContainerItemProxy */; 327 | }; 328 | /* End PBXTargetDependency section */ 329 | 330 | /* Begin PBXVariantGroup section */ 331 | 3D05614718E1C28200029E95 /* InfoPlist.strings */ = { 332 | isa = PBXVariantGroup; 333 | children = ( 334 | 3D05614818E1C28200029E95 /* en */, 335 | ); 336 | name = InfoPlist.strings; 337 | sourceTree = ""; 338 | }; 339 | 3D05614D18E1C28200029E95 /* Credits.rtf */ = { 340 | isa = PBXVariantGroup; 341 | children = ( 342 | 3D05614E18E1C28200029E95 /* en */, 343 | ); 344 | name = Credits.rtf; 345 | sourceTree = ""; 346 | }; 347 | 3D05615318E1C28200029E95 /* NTYDocument.xib */ = { 348 | isa = PBXVariantGroup; 349 | children = ( 350 | 3D05615418E1C28200029E95 /* Base */, 351 | ); 352 | name = NTYDocument.xib; 353 | sourceTree = ""; 354 | }; 355 | 3D05615618E1C28200029E95 /* MainMenu.xib */ = { 356 | isa = PBXVariantGroup; 357 | children = ( 358 | 3D05615718E1C28200029E95 /* Base */, 359 | ); 360 | name = MainMenu.xib; 361 | sourceTree = ""; 362 | }; 363 | 3D05616818E1C28200029E95 /* InfoPlist.strings */ = { 364 | isa = PBXVariantGroup; 365 | children = ( 366 | 3D05616918E1C28200029E95 /* en */, 367 | ); 368 | name = InfoPlist.strings; 369 | sourceTree = ""; 370 | }; 371 | /* End PBXVariantGroup section */ 372 | 373 | /* Begin XCBuildConfiguration section */ 374 | 3D05616D18E1C28200029E95 /* Debug */ = { 375 | isa = XCBuildConfiguration; 376 | buildSettings = { 377 | ALWAYS_SEARCH_USER_PATHS = NO; 378 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 379 | CLANG_CXX_LIBRARY = "libc++"; 380 | CLANG_ENABLE_MODULES = YES; 381 | CLANG_ENABLE_OBJC_ARC = YES; 382 | CLANG_WARN_BOOL_CONVERSION = YES; 383 | CLANG_WARN_CONSTANT_CONVERSION = YES; 384 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 385 | CLANG_WARN_EMPTY_BODY = YES; 386 | CLANG_WARN_ENUM_CONVERSION = YES; 387 | CLANG_WARN_INT_CONVERSION = YES; 388 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 389 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 390 | COPY_PHASE_STRIP = NO; 391 | GCC_C_LANGUAGE_STANDARD = gnu99; 392 | GCC_DYNAMIC_NO_PIC = NO; 393 | GCC_ENABLE_OBJC_EXCEPTIONS = YES; 394 | GCC_OPTIMIZATION_LEVEL = 0; 395 | GCC_PREPROCESSOR_DEFINITIONS = ( 396 | "DEBUG=1", 397 | "$(inherited)", 398 | ); 399 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 400 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 401 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 402 | GCC_WARN_UNDECLARED_SELECTOR = YES; 403 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 404 | GCC_WARN_UNUSED_FUNCTION = YES; 405 | GCC_WARN_UNUSED_VARIABLE = YES; 406 | MACOSX_DEPLOYMENT_TARGET = 10.9; 407 | ONLY_ACTIVE_ARCH = YES; 408 | SDKROOT = macosx; 409 | }; 410 | name = Debug; 411 | }; 412 | 3D05616E18E1C28200029E95 /* Release */ = { 413 | isa = XCBuildConfiguration; 414 | buildSettings = { 415 | ALWAYS_SEARCH_USER_PATHS = NO; 416 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 417 | CLANG_CXX_LIBRARY = "libc++"; 418 | CLANG_ENABLE_MODULES = YES; 419 | CLANG_ENABLE_OBJC_ARC = YES; 420 | CLANG_WARN_BOOL_CONVERSION = YES; 421 | CLANG_WARN_CONSTANT_CONVERSION = YES; 422 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 423 | CLANG_WARN_EMPTY_BODY = YES; 424 | CLANG_WARN_ENUM_CONVERSION = YES; 425 | CLANG_WARN_INT_CONVERSION = YES; 426 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 427 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 428 | COPY_PHASE_STRIP = YES; 429 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 430 | ENABLE_NS_ASSERTIONS = NO; 431 | GCC_C_LANGUAGE_STANDARD = gnu99; 432 | GCC_ENABLE_OBJC_EXCEPTIONS = YES; 433 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 434 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 435 | GCC_WARN_UNDECLARED_SELECTOR = YES; 436 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 437 | GCC_WARN_UNUSED_FUNCTION = YES; 438 | GCC_WARN_UNUSED_VARIABLE = YES; 439 | MACOSX_DEPLOYMENT_TARGET = 10.9; 440 | SDKROOT = macosx; 441 | }; 442 | name = Release; 443 | }; 444 | 3D05617018E1C28200029E95 /* Debug */ = { 445 | isa = XCBuildConfiguration; 446 | baseConfigurationReference = ED3C0FB65F0E46BEB22BFB0A /* Pods.xcconfig */; 447 | buildSettings = { 448 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 449 | COMBINE_HIDPI_IMAGES = YES; 450 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 451 | GCC_PREFIX_HEADER = "NTYSmartTextViewExample/NTYSmartTextViewExample-Prefix.pch"; 452 | INFOPLIST_FILE = "NTYSmartTextViewExample/NTYSmartTextViewExample-Info.plist"; 453 | PRODUCT_NAME = "$(TARGET_NAME)"; 454 | WRAPPER_EXTENSION = app; 455 | }; 456 | name = Debug; 457 | }; 458 | 3D05617118E1C28200029E95 /* Release */ = { 459 | isa = XCBuildConfiguration; 460 | baseConfigurationReference = ED3C0FB65F0E46BEB22BFB0A /* Pods.xcconfig */; 461 | buildSettings = { 462 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 463 | COMBINE_HIDPI_IMAGES = YES; 464 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 465 | GCC_PREFIX_HEADER = "NTYSmartTextViewExample/NTYSmartTextViewExample-Prefix.pch"; 466 | INFOPLIST_FILE = "NTYSmartTextViewExample/NTYSmartTextViewExample-Info.plist"; 467 | PRODUCT_NAME = "$(TARGET_NAME)"; 468 | WRAPPER_EXTENSION = app; 469 | }; 470 | name = Release; 471 | }; 472 | 3D05617318E1C28200029E95 /* Debug */ = { 473 | isa = XCBuildConfiguration; 474 | buildSettings = { 475 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/NTYSmartTextViewExample.app/Contents/MacOS/NTYSmartTextViewExample"; 476 | COMBINE_HIDPI_IMAGES = YES; 477 | FRAMEWORK_SEARCH_PATHS = ( 478 | "$(DEVELOPER_FRAMEWORKS_DIR)", 479 | "$(inherited)", 480 | ); 481 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 482 | GCC_PREFIX_HEADER = "NTYSmartTextViewExample/NTYSmartTextViewExample-Prefix.pch"; 483 | GCC_PREPROCESSOR_DEFINITIONS = ( 484 | "DEBUG=1", 485 | "$(inherited)", 486 | ); 487 | INFOPLIST_FILE = "NTYSmartTextViewExampleTests/NTYSmartTextViewExampleTests-Info.plist"; 488 | PRODUCT_NAME = "$(TARGET_NAME)"; 489 | TEST_HOST = "$(BUNDLE_LOADER)"; 490 | WRAPPER_EXTENSION = xctest; 491 | }; 492 | name = Debug; 493 | }; 494 | 3D05617418E1C28200029E95 /* Release */ = { 495 | isa = XCBuildConfiguration; 496 | buildSettings = { 497 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/NTYSmartTextViewExample.app/Contents/MacOS/NTYSmartTextViewExample"; 498 | COMBINE_HIDPI_IMAGES = YES; 499 | FRAMEWORK_SEARCH_PATHS = ( 500 | "$(DEVELOPER_FRAMEWORKS_DIR)", 501 | "$(inherited)", 502 | ); 503 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 504 | GCC_PREFIX_HEADER = "NTYSmartTextViewExample/NTYSmartTextViewExample-Prefix.pch"; 505 | INFOPLIST_FILE = "NTYSmartTextViewExampleTests/NTYSmartTextViewExampleTests-Info.plist"; 506 | PRODUCT_NAME = "$(TARGET_NAME)"; 507 | TEST_HOST = "$(BUNDLE_LOADER)"; 508 | WRAPPER_EXTENSION = xctest; 509 | }; 510 | name = Release; 511 | }; 512 | /* End XCBuildConfiguration section */ 513 | 514 | /* Begin XCConfigurationList section */ 515 | 3D05613618E1C28200029E95 /* Build configuration list for PBXProject "NTYSmartTextViewExample" */ = { 516 | isa = XCConfigurationList; 517 | buildConfigurations = ( 518 | 3D05616D18E1C28200029E95 /* Debug */, 519 | 3D05616E18E1C28200029E95 /* Release */, 520 | ); 521 | defaultConfigurationIsVisible = 0; 522 | defaultConfigurationName = Release; 523 | }; 524 | 3D05616F18E1C28200029E95 /* Build configuration list for PBXNativeTarget "NTYSmartTextViewExample" */ = { 525 | isa = XCConfigurationList; 526 | buildConfigurations = ( 527 | 3D05617018E1C28200029E95 /* Debug */, 528 | 3D05617118E1C28200029E95 /* Release */, 529 | ); 530 | defaultConfigurationIsVisible = 0; 531 | defaultConfigurationName = Release; 532 | }; 533 | 3D05617218E1C28200029E95 /* Build configuration list for PBXNativeTarget "NTYSmartTextViewExampleTests" */ = { 534 | isa = XCConfigurationList; 535 | buildConfigurations = ( 536 | 3D05617318E1C28200029E95 /* Debug */, 537 | 3D05617418E1C28200029E95 /* Release */, 538 | ); 539 | defaultConfigurationIsVisible = 0; 540 | defaultConfigurationName = Release; 541 | }; 542 | /* End XCConfigurationList section */ 543 | }; 544 | rootObject = 3D05613318E1C28100029E95 /* Project object */; 545 | } 546 | -------------------------------------------------------------------------------- /Example/NTYSmartTextViewExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Example/NTYSmartTextViewExample.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Example/NTYSmartTextViewExample/Base.lproj/MainMenu.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 | 512 | 513 | 514 | 515 | 516 | 517 | 518 | 519 | 520 | 521 | 522 | 523 | 524 | 525 | 526 | 527 | 528 | 529 | Default 530 | 531 | 532 | 533 | 534 | 535 | 536 | Left to Right 537 | 538 | 539 | 540 | 541 | 542 | 543 | Right to Left 544 | 545 | 546 | 547 | 548 | 549 | 550 | 551 | 552 | 553 | 554 | Default 555 | 556 | 557 | 558 | 559 | 560 | 561 | Left to Right 562 | 563 | 564 | 565 | 566 | 567 | 568 | Right to Left 569 | 570 | 571 | 572 | 573 | 574 | 575 | 576 | 577 | 578 | 579 | 580 | 581 | 582 | 583 | 584 | 585 | 586 | 587 | 588 | 589 | 590 | 591 | 592 | 593 | 594 | 595 | 596 | 597 | 598 | 599 | 600 | 601 | 602 | 603 | 604 | 605 | 606 | 607 | 608 | 609 | 610 | 611 | 612 | 613 | 614 | 615 | 616 | 617 | 618 | 619 | 620 | 621 | 622 | 623 | 624 | 625 | 626 | 627 | 628 | 629 | 630 | 631 | 632 | 633 | 634 | 635 | 636 | 637 | 638 | 639 | 640 | 641 | 642 | 643 | 644 | 645 | 646 | 647 | 648 | 649 | 650 | 651 | 652 | 653 | 654 | 655 | 656 | 657 | 658 | 659 | 660 | 661 | 662 | -------------------------------------------------------------------------------- /Example/NTYSmartTextViewExample/Base.lproj/NTYDocument.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /Example/NTYSmartTextViewExample/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "mac", 5 | "size" : "16x16", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "mac", 10 | "size" : "16x16", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "mac", 15 | "size" : "32x32", 16 | "scale" : "1x" 17 | }, 18 | { 19 | "idiom" : "mac", 20 | "size" : "32x32", 21 | "scale" : "2x" 22 | }, 23 | { 24 | "idiom" : "mac", 25 | "size" : "128x128", 26 | "scale" : "1x" 27 | }, 28 | { 29 | "idiom" : "mac", 30 | "size" : "128x128", 31 | "scale" : "2x" 32 | }, 33 | { 34 | "idiom" : "mac", 35 | "size" : "256x256", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "mac", 40 | "size" : "256x256", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "mac", 45 | "size" : "512x512", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "mac", 50 | "size" : "512x512", 51 | "scale" : "2x" 52 | } 53 | ], 54 | "info" : { 55 | "version" : 1, 56 | "author" : "xcode" 57 | } 58 | } -------------------------------------------------------------------------------- /Example/NTYSmartTextViewExample/NTYDocument.h: -------------------------------------------------------------------------------- 1 | // 2 | // NTYDocument.h 3 | // NTYSmartTextViewExample 4 | // 5 | // Created by naoty on 2014/03/25. 6 | // Copyright (c) 2014年 Naoto Kaneko. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NTYDocument : NSDocument 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Example/NTYSmartTextViewExample/NTYDocument.m: -------------------------------------------------------------------------------- 1 | // 2 | // NTYDocument.m 3 | // NTYSmartTextViewExample 4 | // 5 | // Created by naoty on 2014/03/25. 6 | // Copyright (c) 2014年 Naoto Kaneko. All rights reserved. 7 | // 8 | 9 | #import "NTYDocument.h" 10 | #import "NTYWindowController.h" 11 | 12 | @implementation NTYDocument 13 | 14 | - (id)init 15 | { 16 | self = [super init]; 17 | if (self) { 18 | // Add your subclass-specific initialization here. 19 | } 20 | return self; 21 | } 22 | 23 | - (void)makeWindowControllers 24 | { 25 | NTYWindowController *windowController = [[NTYWindowController alloc] initWithWindowNibName:@"NTYDocument"]; 26 | [self addWindowController:windowController]; 27 | } 28 | 29 | - (void)windowControllerDidLoadNib:(NSWindowController *)aController 30 | { 31 | [super windowControllerDidLoadNib:aController]; 32 | // Add any code here that needs to be executed once the windowController has loaded the document's window. 33 | } 34 | 35 | + (BOOL)autosavesInPlace 36 | { 37 | return YES; 38 | } 39 | 40 | - (NSData *)dataOfType:(NSString *)typeName error:(NSError **)outError 41 | { 42 | // Insert code here to write your document to data of the specified type. If outError != NULL, ensure that you create and set an appropriate error when returning nil. 43 | // You can also choose to override -fileWrapperOfType:error:, -writeToURL:ofType:error:, or -writeToURL:ofType:forSaveOperation:originalContentsURL:error: instead. 44 | NSException *exception = [NSException exceptionWithName:@"UnimplementedMethod" reason:[NSString stringWithFormat:@"%@ is unimplemented", NSStringFromSelector(_cmd)] userInfo:nil]; 45 | @throw exception; 46 | return nil; 47 | } 48 | 49 | - (BOOL)readFromData:(NSData *)data ofType:(NSString *)typeName error:(NSError **)outError 50 | { 51 | // Insert code here to read your document from the given data of the specified type. If outError != NULL, ensure that you create and set an appropriate error when returning NO. 52 | // You can also choose to override -readFromFileWrapper:ofType:error: or -readFromURL:ofType:error: instead. 53 | // If you override either of these, you should also override -isEntireFileLoaded to return NO if the contents are lazily loaded. 54 | NSException *exception = [NSException exceptionWithName:@"UnimplementedMethod" reason:[NSString stringWithFormat:@"%@ is unimplemented", NSStringFromSelector(_cmd)] userInfo:nil]; 55 | @throw exception; 56 | return YES; 57 | } 58 | 59 | @end 60 | -------------------------------------------------------------------------------- /Example/NTYSmartTextViewExample/NTYSmartTextViewExample-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDocumentTypes 8 | 9 | 10 | CFBundleTypeExtensions 11 | 12 | mydoc 13 | 14 | CFBundleTypeIconFile 15 | 16 | CFBundleTypeName 17 | DocumentType 18 | CFBundleTypeOSTypes 19 | 20 | ???? 21 | 22 | CFBundleTypeRole 23 | Editor 24 | NSDocumentClass 25 | NTYDocument 26 | 27 | 28 | CFBundleExecutable 29 | ${EXECUTABLE_NAME} 30 | CFBundleIconFile 31 | 32 | CFBundleIdentifier 33 | naoty.${PRODUCT_NAME:rfc1034identifier} 34 | CFBundleInfoDictionaryVersion 35 | 6.0 36 | CFBundleName 37 | ${PRODUCT_NAME} 38 | CFBundlePackageType 39 | APPL 40 | CFBundleShortVersionString 41 | 1.0 42 | CFBundleSignature 43 | ???? 44 | CFBundleVersion 45 | 1 46 | LSMinimumSystemVersion 47 | ${MACOSX_DEPLOYMENT_TARGET} 48 | NSHumanReadableCopyright 49 | Copyright © 2014年 Naoto Kaneko. All rights reserved. 50 | NSMainNibFile 51 | MainMenu 52 | NSPrincipalClass 53 | NSApplication 54 | 55 | 56 | -------------------------------------------------------------------------------- /Example/NTYSmartTextViewExample/NTYSmartTextViewExample-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header 3 | // 4 | // The contents of this file are implicitly included at the beginning of every source file. 5 | // 6 | 7 | #ifdef __OBJC__ 8 | #import 9 | #endif 10 | -------------------------------------------------------------------------------- /Example/NTYSmartTextViewExample/NTYWindowController.h: -------------------------------------------------------------------------------- 1 | // 2 | // NTYWindowController.h 3 | // NTYSmartTextViewExample 4 | // 5 | // Created by naoty on 2014/03/27. 6 | // Copyright (c) 2014年 Naoto Kaneko. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NTYWindowController : NSWindowController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Example/NTYSmartTextViewExample/NTYWindowController.m: -------------------------------------------------------------------------------- 1 | // 2 | // NTYWindowController.m 3 | // NTYSmartTextViewExample 4 | // 5 | // Created by naoty on 2014/03/27. 6 | // Copyright (c) 2014年 Naoto Kaneko. All rights reserved. 7 | // 8 | 9 | #import "NTYWindowController.h" 10 | #import "NTYSmartTextView.h" 11 | 12 | @interface NTYWindowController () 13 | @property (nonatomic) IBOutlet NTYSmartTextView *textView; 14 | @end 15 | 16 | @implementation NTYWindowController 17 | 18 | - (id)initWithWindow:(NSWindow *)window 19 | { 20 | self = [super initWithWindow:window]; 21 | if (self) { 22 | } 23 | return self; 24 | } 25 | 26 | - (void)windowDidLoad 27 | { 28 | [super windowDidLoad]; 29 | self.textView.font = [NSFont fontWithName:@"Monaco" size:18]; 30 | } 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /Example/NTYSmartTextViewExample/en.lproj/Credits.rtf: -------------------------------------------------------------------------------- 1 | {\rtf0\ansi{\fonttbl\f0\fswiss Helvetica;} 2 | {\colortbl;\red255\green255\blue255;} 3 | \paperw9840\paperh8400 4 | \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural 5 | 6 | \f0\b\fs24 \cf0 Engineering: 7 | \b0 \ 8 | Some people\ 9 | \ 10 | 11 | \b Human Interface Design: 12 | \b0 \ 13 | Some other people\ 14 | \ 15 | 16 | \b Testing: 17 | \b0 \ 18 | Hopefully not nobody\ 19 | \ 20 | 21 | \b Documentation: 22 | \b0 \ 23 | Whoever\ 24 | \ 25 | 26 | \b With special thanks to: 27 | \b0 \ 28 | Mom\ 29 | } 30 | -------------------------------------------------------------------------------- /Example/NTYSmartTextViewExample/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /Example/NTYSmartTextViewExample/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // NTYSmartTextViewExample 4 | // 5 | // Created by naoty on 2014/03/25. 6 | // Copyright (c) 2014年 Naoto Kaneko. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, const char * argv[]) 12 | { 13 | return NSApplicationMain(argc, argv); 14 | } 15 | -------------------------------------------------------------------------------- /Example/NTYSmartTextViewExampleTests/NTYSmartTextViewExampleTests-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | naoty.${PRODUCT_NAME:rfc1034identifier} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | BNDL 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /Example/NTYSmartTextViewExampleTests/NTYSmartTextViewExampleTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // NTYSmartTextViewExampleTests.m 3 | // NTYSmartTextViewExampleTests 4 | // 5 | // Created by naoty on 2014/03/25. 6 | // Copyright (c) 2014年 Naoto Kaneko. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NTYSmartTextViewExampleTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation NTYSmartTextViewExampleTests 16 | 17 | - (void)setUp 18 | { 19 | [super setUp]; 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | } 22 | 23 | - (void)tearDown 24 | { 25 | // Put teardown code here. This method is called after the invocation of each test method in the class. 26 | [super tearDown]; 27 | } 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /Example/NTYSmartTextViewExampleTests/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /Example/Podfile: -------------------------------------------------------------------------------- 1 | pod "NTYSmartTextView", path: "../NTYSmartTextView.podspec" 2 | -------------------------------------------------------------------------------- /Example/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - NTYSmartTextView (0.1.0) 3 | 4 | DEPENDENCIES: 5 | - NTYSmartTextView (from `../NTYSmartTextView.podspec`) 6 | 7 | EXTERNAL SOURCES: 8 | NTYSmartTextView: 9 | :path: ../NTYSmartTextView.podspec 10 | 11 | SPEC CHECKSUMS: 12 | NTYSmartTextView: db9dbc9c7765494b40e9c51868fdca8259189d67 13 | 14 | COCOAPODS: 0.29.0 15 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 Naoto Kaneko 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /NTYSmartTextView.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "NTYSmartTextView" 3 | s.version = "0.2.0" 4 | s.summary = "NSTextView with smart features" 5 | s.description = <<-DESC 6 | NSTextView with following smart features 7 | * Smart indent 8 | * Soft tab 9 | * Auto pair completion 10 | DESC 11 | s.homepage = "https://github.com/naoty/NTYSmartTextView" 12 | s.license = "MIT" 13 | s.author = { "Naoto Kaneko" => "naoty.k@gmail.com" } 14 | s.source = { :git => "https://github.com/naoty/NTYSmartTextView.git", :tag => s.version.to_s } 15 | s.screenshot = "https://raw.githubusercontent.com/naoty/NTYSmartTextView/master/screenshot.gif" 16 | s.social_media_url = "https://twitter.com/naoty_k" 17 | 18 | s.platform = :osx 19 | s.requires_arc = true 20 | 21 | s.source_files = "Classes" 22 | end 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NTYSmartTextView 2 | 3 | [![Version](http://cocoapod-badges.herokuapp.com/v/NTYSmartTextView/badge.png)](http://cocoadocs.org/docsets/NTYSmartTextView) 4 | [![Platform](http://cocoapod-badges.herokuapp.com/p/NTYSmartTextView/badge.png)](http://cocoadocs.org/docsets/NTYSmartTextView) 5 | 6 | ![Screenshot](./screenshot.gif) 7 | 8 | ## Features 9 | 10 | - Smart indent: Keep the width of indent when breaking line. 11 | - Soft tab: Input spaces instead of tabs by entering TAB key. 12 | - Auto pair completion: Automatically complete closing braces and quotes. 13 | 14 | ## Installation 15 | 16 | NTYSmartTextView is available through [CocoaPods](http://cocoapods.org), to install 17 | it simply add the following line to your Podfile: 18 | 19 | ```rb 20 | platform :osx 21 | pod "NTYSmartTextView" 22 | ``` 23 | 24 | ## Usage 25 | 26 | At Xib, set the custom view of a text view to `NTYSmartTextView`. By default, above features is enabled. If you want to change th default configurations, change properties as follows. 27 | 28 | ### Smart indent 29 | 30 | ```objective-c 31 | self.textView.smartIndentEnabled = NO; 32 | ``` 33 | 34 | ### Soft tab 35 | 36 | ```objective-c 37 | self.textView.softTabEnabled = NO; 38 | 39 | // You also can change the width of soft tab from 4. 40 | self.textView.tabWidth = 2; 41 | ``` 42 | 43 | ### Auto pair completion 44 | 45 | ```objective-c 46 | self.textView.autoPairCompletionEnabled = NO; 47 | ``` 48 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | desc "Runs the specs [EMPTY]" 2 | task :spec do 3 | # Provide your own implementation 4 | end 5 | 6 | task :version do 7 | git_remotes = `git remote`.strip.split("\n") 8 | 9 | if git_remotes.count > 0 10 | puts "-- fetching version number from github" 11 | sh 'git fetch' 12 | 13 | remote_version = remote_spec_version 14 | end 15 | 16 | if remote_version.nil? 17 | puts "There is no current released version. You're about to release a new Pod." 18 | version = "0.0.1" 19 | else 20 | puts "The current released version of your pod is " + remote_spec_version.to_s() 21 | version = suggested_version_number 22 | end 23 | 24 | puts "Enter the version you want to release (" + version + ") " 25 | new_version_number = $stdin.gets.strip 26 | if new_version_number == "" 27 | new_version_number = version 28 | end 29 | 30 | replace_version_number(new_version_number) 31 | end 32 | 33 | desc "Release a new version of the Pod" 34 | task :release do 35 | 36 | puts "* Running version" 37 | sh "rake version" 38 | 39 | unless ENV['SKIP_CHECKS'] 40 | if `git symbolic-ref HEAD 2>/dev/null`.strip.split('/').last != 'master' 41 | $stderr.puts "[!] You need to be on the `master' branch in order to be able to do a release." 42 | exit 1 43 | end 44 | 45 | if `git tag`.strip.split("\n").include?(spec_version) 46 | $stderr.puts "[!] A tag for version `#{spec_version}' already exists. Change the version in the podspec" 47 | exit 1 48 | end 49 | 50 | puts "You are about to release `#{spec_version}`, is that correct? [y/n]" 51 | exit if $stdin.gets.strip.downcase != 'y' 52 | end 53 | 54 | puts "* Running specs" 55 | sh "rake spec" 56 | 57 | puts "* Linting the podspec" 58 | sh "pod lib lint" 59 | 60 | # Then release 61 | sh "git commit #{podspec_path} CHANGELOG.md -m 'Release #{spec_version}'" 62 | sh "git tag -a #{spec_version} -m 'Release #{spec_version}'" 63 | sh "git push origin master" 64 | sh "git push origin --tags" 65 | sh "pod push master #{podspec_path}" 66 | end 67 | 68 | # @return [Pod::Version] The version as reported by the Podspec. 69 | # 70 | def spec_version 71 | require 'cocoapods' 72 | spec = Pod::Specification.from_file(podspec_path) 73 | spec.version 74 | end 75 | 76 | # @return [Pod::Version] The version as reported by the Podspec from remote. 77 | # 78 | def remote_spec_version 79 | require 'cocoapods-core' 80 | 81 | if spec_file_exist_on_remote? 82 | remote_spec = eval(`git show origin/master:#{podspec_path}`) 83 | remote_spec.version 84 | else 85 | nil 86 | end 87 | end 88 | 89 | # @return [Bool] If the remote repository has a copy of the podpesc file or not. 90 | # 91 | def spec_file_exist_on_remote? 92 | test_condition = `if git rev-parse --verify --quiet origin/master:#{podspec_path} >/dev/null; 93 | then 94 | echo 'true' 95 | else 96 | echo 'false' 97 | fi` 98 | 99 | 'true' == test_condition.strip 100 | end 101 | 102 | # @return [String] The relative path of the Podspec. 103 | # 104 | def podspec_path 105 | podspecs = Dir.glob('*.podspec') 106 | if podspecs.count == 1 107 | podspecs.first 108 | else 109 | raise "Could not select a podspec" 110 | end 111 | end 112 | 113 | # @return [String] The suggested version number based on the local and remote version numbers. 114 | # 115 | def suggested_version_number 116 | if spec_version != remote_spec_version 117 | spec_version.to_s() 118 | else 119 | next_version(spec_version).to_s() 120 | end 121 | end 122 | 123 | # @param [Pod::Version] version 124 | # the version for which you need the next version 125 | # 126 | # @note It is computed by bumping the last component of the versino string by 1. 127 | # 128 | # @return [Pod::Version] The version that comes next after the version supplied. 129 | # 130 | def next_version(version) 131 | version_components = version.to_s().split("."); 132 | last = (version_components.last.to_i() + 1).to_s 133 | version_components[-1] = last 134 | Pod::Version.new(version_components.join(".")) 135 | end 136 | 137 | # @param [String] new_version_number 138 | # the new version number 139 | # 140 | # @note This methods replaces the version number in the podspec file with a new version number. 141 | # 142 | # @return void 143 | # 144 | def replace_version_number(new_version_number) 145 | text = File.read(podspec_path) 146 | text.gsub!(/(s.version( )*= ")#{spec_version}(")/, "\\1#{new_version_number}\\3") 147 | File.open(podspec_path, "w") { |file| file.puts text } 148 | end -------------------------------------------------------------------------------- /screenshot.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/naoty/NTYSmartTextView/80554faf55d622f09967a6ef41ce75f4631d9fc6/screenshot.gif --------------------------------------------------------------------------------