From d85cab6ebee0c619b48489fe81ad2cea5fb0b6c1 Mon Sep 17 00:00:00 2001 From: 1024jp <1024jp@wolfrosch.com> Date: Mon, 2 Mar 2015 01:47:49 +0900 Subject: [PATCH 01/20] Update version to 2.1.2-alpha --- CotEditor/Info.plist | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CotEditor/Info.plist b/CotEditor/Info.plist index 0194854646..aeff9b35a5 100644 --- a/CotEditor/Info.plist +++ b/CotEditor/Info.plist @@ -953,11 +953,11 @@ CFBundlePackageType APPL CFBundleShortVersionString - 2.1.1 + 2.1.2 dev CFBundleSignature cEd1 CFBundleVersion - 2.1.1 + 2.1.2-alpha LSApplicationCategoryType public.app-category.productivity NSAppleScriptEnabled From 21591eae105ff5f5009c1a920482dcd40926f717 Mon Sep 17 00:00:00 2001 From: 1024jp <1024jp@wolfrosch.com> Date: Mon, 2 Mar 2015 01:50:01 +0900 Subject: [PATCH 02/20] Change unnecessary atomic properties to nonatomic --- CotEditor/Sources/CEDocument.m | 4 ++-- CotEditor/Sources/CESyntaxParser.m | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/CotEditor/Sources/CEDocument.m b/CotEditor/Sources/CEDocument.m index 4f30308393..47541484c5 100644 --- a/CotEditor/Sources/CEDocument.m +++ b/CotEditor/Sources/CEDocument.m @@ -55,8 +55,8 @@ @interface CEDocument () @property (nonatomic) CEPrintPanelAccessoryController *printPanelAccessoryController; -@property (atomic) BOOL needsShowUpdateAlertWithBecomeKey; -@property (atomic, getter=isRevertingForExternalFileUpdate) BOOL revertingForExternalFileUpdate; +@property (nonatomic) BOOL needsShowUpdateAlertWithBecomeKey; +@property (nonatomic, getter=isRevertingForExternalFileUpdate) BOOL revertingForExternalFileUpdate; @property (nonatomic) BOOL didAlertNotWritable; // 文書が読み込み専用のときにその警告を表示したかどうか @property (nonatomic, copy) NSString *fileContentString; // string that is read from the document file @property (nonatomic) CEODBEventSender *ODBEventSender; diff --git a/CotEditor/Sources/CESyntaxParser.m b/CotEditor/Sources/CESyntaxParser.m index c3fe020194..dd769a8d76 100644 --- a/CotEditor/Sources/CESyntaxParser.m +++ b/CotEditor/Sources/CESyntaxParser.m @@ -65,11 +65,11 @@ @interface CESyntaxParser () @property (nonatomic) CELayoutManager *layoutManager; @property (nonatomic) BOOL hasSyntaxHighlighting; -@property (atomic, copy) NSDictionary *coloringDictionary; -@property (atomic, copy) NSDictionary *simpleWordsCharacterSets; -@property (atomic, copy) NSDictionary *pairedQuoteTypes; // dict for quote pair to extract with comment -@property (atomic, copy) NSArray *cacheColorings; // extracted results cache of the last whole string coloring -@property (atomic, copy) NSString *cacheHash; // MD5 hash +@property (nonatomic, copy) NSDictionary *coloringDictionary; +@property (nonatomic, copy) NSDictionary *simpleWordsCharacterSets; +@property (nonatomic, copy) NSDictionary *pairedQuoteTypes; // dict for quote pair to extract with comment +@property (nonatomic, copy) NSArray *cacheColorings; // extracted results cache of the last whole string coloring +@property (nonatomic, copy) NSString *cacheHash; // MD5 hash @property (atomic) CEIndicatorSheetController *indicatorController; From 02f2d176572b1cd0af2c3b0e791ee6ee3383df86 Mon Sep 17 00:00:00 2001 From: 1024jp <1024jp@wolfrosch.com> Date: Mon, 2 Mar 2015 19:22:55 +0900 Subject: [PATCH 03/20] Add "Cyrillic (Windows)" to encoding list (close #360) --- CHANGELOG.md | 9 +++++++++ CotEditor/Sources/constants.m | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7df916493e..64ea582db3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,15 @@ Change Log ========================== +2.1.2 +-------------------------- + +### Additions/Changes + +- Add “Cyrillic (Windows)” to the encoding list. + + + 2.1.1 -------------------------- diff --git a/CotEditor/Sources/constants.m b/CotEditor/Sources/constants.m index 59237e3f00..dc4ca44cc2 100644 --- a/CotEditor/Sources/constants.m +++ b/CotEditor/Sources/constants.m @@ -453,6 +453,7 @@ BOOL CEIsAlmostEqualCGFloats(CGFloat float1, CGFloat float2) { kCFStringEncodingISOLatinGreek, // Greek (ISO 8859-7) kCFStringEncodingMacCyrillic, // Cyrillic (Mac OS) kCFStringEncodingISOLatinCyrillic, // Cyrillic (ISO 8859-5) + kCFStringEncodingWindowsCyrillic, // Cyrillic (Windows) kCFStringEncodingMacCentralEurRoman, // Central European (Mac OS) kCFStringEncodingMacTurkish, // Turkish (Mac OS) kCFStringEncodingMacIcelandic, // Icelandic (Mac OS) @@ -470,7 +471,6 @@ BOOL CEIsAlmostEqualCGFloats(CGFloat float1, CGFloat float2) { kCFStringEncodingNonLossyASCII, // Non-lossy ASCII kCFStringEncodingInvalidId, // ---------- - // Encodings available 10.4 and later (CotEditor added in 0.8.0) kCFStringEncodingUTF16BE, // Unicode (UTF-16BE) kCFStringEncodingUTF16LE, // Unicode (UTF-16LE) kCFStringEncodingUTF32, // Unicode (UTF-32) @@ -492,6 +492,7 @@ BOOL CEIsAlmostEqualCGFloats(CGFloat float1, CGFloat float2) { kCFStringEncodingISOLatinGreek, // Greek (ISO 8859-7) kCFStringEncodingMacCyrillic, // Cyrillic (Mac OS) kCFStringEncodingISOLatinCyrillic, // Cyrillic (ISO 8859-5) + kCFStringEncodingWindowsCyrillic, // Cyrillic (Windows) kCFStringEncodingMacCentralEurRoman, // Central European (Mac OS) kCFStringEncodingISOLatin2, // Central European (ISO Latin 2) kCFStringEncodingISOLatin3, // Western (ISO Latin 3) From 5bc7de28f91cd11713a5d8917313bf31129a23e6 Mon Sep 17 00:00:00 2001 From: 1024jp <1024jp@wolfrosch.com> Date: Tue, 3 Mar 2015 03:47:15 +0900 Subject: [PATCH 04/20] Avoid sending ODB Editor notification on autosaving --- CotEditor/Sources/CEDocument.m | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CotEditor/Sources/CEDocument.m b/CotEditor/Sources/CEDocument.m index 47541484c5..619cefddbe 100644 --- a/CotEditor/Sources/CEDocument.m +++ b/CotEditor/Sources/CEDocument.m @@ -247,7 +247,9 @@ - (BOOL)writeSafelyToURL:(NSURL *)url ofType:(NSString *)typeName forSaveOperati [self getFileAttributes]; // 外部エディタプロトコル(ODB Editor Suite)のファイル更新通知送信 - [[self ODBEventSender] sendModifiedEventWithURL:url operation:saveOperation]; + if (saveOperation != NSAutosaveElsewhereOperation) { + [[self ODBEventSender] sendModifiedEventWithURL:url operation:saveOperation]; + } // changeCountを更新 [self updateChangeCountWithToken:token forSaveOperation:saveOperation]; From 98b587fe359c0d3ca9f8001eccb100221ae99095 Mon Sep 17 00:00:00 2001 From: 1024jp <1024jp@wolfrosch.com> Date: Tue, 3 Mar 2015 03:54:06 +0900 Subject: [PATCH 05/20] Save backup files always in NSAutosavedInformationDirectory (close #362) --- CHANGELOG.md | 1 + CotEditor/Sources/CEDocument.m | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 64ea582db3..ad7d042abb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ Change Log ### Additions/Changes +- Change please to create backup files (Now, backup files are always created in `~/Library/Autosave Information/`). - Add “Cyrillic (Windows)” to the encoding list. diff --git a/CotEditor/Sources/CEDocument.m b/CotEditor/Sources/CEDocument.m index 619cefddbe..cf49944854 100644 --- a/CotEditor/Sources/CEDocument.m +++ b/CotEditor/Sources/CEDocument.m @@ -224,6 +224,29 @@ - (NSData *)dataOfType:(NSString *)typeName error:(NSError *__autoreleasing *)ou } +// ------------------------------------------------------ +/// modify place to create backup file +- (void)saveToURL:(NSURL *)url ofType:(NSString *)typeName forSaveOperation:(NSSaveOperationType)saveOperation completionHandler:(void (^)(NSError *))completionHandler +// ------------------------------------------------------ +{ + // save backup file always in `~/Library/Autosaved Information/` direcotory + // (The default backup URL is the same directory as the fileURL.) + if (saveOperation == NSAutosaveElsewhereOperation && [self fileURL]) { + NSURL *autosaveDirectoryURL = [[NSFileManager defaultManager] URLForDirectory:NSAutosavedInformationDirectory + inDomain:NSUserDomainMask + appropriateForURL:nil + create:YES + error:nil]; + NSString *baseFileName = [[self fileURL] lastPathComponent]; + NSString *fileName = [NSString stringWithFormat:@"%@ (%p)", [baseFileName stringByDeletingPathExtension], self]; // append a unique string to avoid overwriting another backup file with the same file name. + + url = [[autosaveDirectoryURL URLByAppendingPathComponent:fileName] URLByAppendingPathExtension:[baseFileName pathExtension]]; + } + + [super saveToURL:url ofType:typeName forSaveOperation:saveOperation completionHandler:completionHandler]; +} + + // ------------------------------------------------------ /// ファイルの保存(保存処理で包括的に呼ばれる) - (BOOL)writeSafelyToURL:(NSURL *)url ofType:(NSString *)typeName forSaveOperation:(NSSaveOperationType)saveOperation error:(NSError *__autoreleasing *)outError From 847c636154eb4faf147a92fe55e1c73ac92cd6f1 Mon Sep 17 00:00:00 2001 From: 1024jp <1024jp@wolfrosch.com> Date: Tue, 3 Mar 2015 16:43:13 +0900 Subject: [PATCH 06/20] Fix a typo in CHANGELOG --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ad7d042abb..0a4e205756 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ Change Log ### Additions/Changes -- Change please to create backup files (Now, backup files are always created in `~/Library/Autosave Information/`). +- Change place to create backup files (Now, backup files are always created in `~/Library/Autosave Information/`). - Add “Cyrillic (Windows)” to the encoding list. From 661387d0f56aa01526f0a34303dac9ffb1aa4645 Mon Sep 17 00:00:00 2001 From: 1024jp <1024jp@wolfrosch.com> Date: Thu, 5 Mar 2015 01:03:56 +0900 Subject: [PATCH 07/20] Use NSTextView subclass in find panel (close #363) --- CHANGELOG.md | 3 + CotEditor/Base.lproj/FindPanel.xib | 192 +++++++++++------- CotEditor/CotEditor.xcodeproj/project.pbxproj | 18 +- CotEditor/Sources/CEFindPanelTextClipView.h | 35 ++++ ...tFieldCell.m => CEFindPanelTextClipView.m} | 20 +- ...dTextFieldCell.h => CEFindPanelTextView.h} | 6 +- CotEditor/Sources/CEFindPanelTextView.m | 138 +++++++++++++ CotEditor/ja.lproj/FindPanel.strings | 8 +- CotEditor/zh-Hans.lproj/FindPanel.strings | 8 +- 9 files changed, 325 insertions(+), 103 deletions(-) create mode 100644 CotEditor/Sources/CEFindPanelTextClipView.h rename CotEditor/Sources/{CEFindTextFieldCell.m => CEFindPanelTextClipView.m} (76%) rename CotEditor/Sources/{CEFindTextFieldCell.h => CEFindPanelTextView.h} (90%) create mode 100644 CotEditor/Sources/CEFindPanelTextView.m diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a4e205756..a03e367421 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,9 @@ Change Log ### Additions/Changes - Change place to create backup files (Now, backup files are always created in `~/Library/Autosave Information/`). +- Improve find panel: + - Add scroll bars to the text fields. + - Now, “Swap Yen and backslash keys” option is also applied to the fields in the find panel. - Add “Cyrillic (Windows)” to the encoding list. diff --git a/CotEditor/Base.lproj/FindPanel.xib b/CotEditor/Base.lproj/FindPanel.xib index 882cde4e1b..27b9898553 100644 --- a/CotEditor/Base.lproj/FindPanel.xib +++ b/CotEditor/Base.lproj/FindPanel.xib @@ -15,7 +15,7 @@ - + @@ -27,48 +27,89 @@ - - - - - - - - - - - - - Replace - - - - - - - + + + + + + + + + + + + + + + + + + + + + Find + + + + + + + + + + - + - - - - - - - - - - - - Find - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Replace + + + + + + + + + + + + + + + + + + - - + + + + + + + - - - - - - + - - - - - - + + + + + + + - - - + @@ -657,7 +697,7 @@ - + diff --git a/CotEditor/CotEditor.xcodeproj/project.pbxproj b/CotEditor/CotEditor.xcodeproj/project.pbxproj index 7832dc2d15..2d1ef537bd 100644 --- a/CotEditor/CotEditor.xcodeproj/project.pbxproj +++ b/CotEditor/CotEditor.xcodeproj/project.pbxproj @@ -24,7 +24,6 @@ 25B2C24407FA68D100F4EFC7 /* CEBorderView.m in Sources */ = {isa = PBXBuildFile; fileRef = 25B2C24207FA68D100F4EFC7 /* CEBorderView.m */; }; 25B2C24D07FA6BC400F4EFC7 /* CETextView.m in Sources */ = {isa = PBXBuildFile; fileRef = 25B2C24B07FA6BC400F4EFC7 /* CETextView.m */; }; 2A009ACB1A57BA8B00C3D542 /* CETextFinder.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A009ACA1A57BA8B00C3D542 /* CETextFinder.m */; }; - 2A009ACE1A587B3100C3D542 /* CEFindTextFieldCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A009ACD1A587B3100C3D542 /* CEFindTextFieldCell.m */; }; 2A009AD11A58ED1D00C3D542 /* CEFindResultViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A009AD01A58ED1D00C3D542 /* CEFindResultViewController.m */; }; 2A009ADA1A5AAE8000C3D542 /* CEFindPanelSplitView.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A009AD91A5AAE8000C3D542 /* CEFindPanelSplitView.m */; }; 2A07202B18E0E1C2006F3A43 /* CEPrintPanelAccessoryController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A07202A18E0E1C2006F3A43 /* CEPrintPanelAccessoryController.m */; }; @@ -123,6 +122,8 @@ 2AD318C31A462C30001B8112 /* CEIntegrationPaneController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2AD318C21A462C30001B8112 /* CEIntegrationPaneController.m */; }; 2AD4599B19DDCF6600A20FBB /* CEScriptMenuItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 2AD4599A19DDCF6600A20FBB /* CEScriptMenuItem.m */; }; 2AD5322A19779FD000A925CA /* CELineHeightTransformer.m in Sources */ = {isa = PBXBuildFile; fileRef = 2AD5322919779FD000A925CA /* CELineHeightTransformer.m */; }; + 2AD67C241AA7285F0078BB95 /* CEFindPanelTextView.m in Sources */ = {isa = PBXBuildFile; fileRef = 2AD67C231AA7285F0078BB95 /* CEFindPanelTextView.m */; }; + 2AD67C2A1AA75E7F0078BB95 /* CEFindPanelTextClipView.m in Sources */ = {isa = PBXBuildFile; fileRef = 2AD67C291AA75E7F0078BB95 /* CEFindPanelTextClipView.m */; }; 2AD84CAA1966314100DE49BD /* CEODBEventSender.m in Sources */ = {isa = PBXBuildFile; fileRef = 2AD84CA91966314100DE49BD /* CEODBEventSender.m */; }; 2AE2E9D519D2CF00000D66A9 /* CEEncodingManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 2AE2E9D419D2CF00000D66A9 /* CEEncodingManager.m */; }; 2AE356461A86D32500E29FEF /* CEClipView.m in Sources */ = {isa = PBXBuildFile; fileRef = 2AE356451A86D32500E29FEF /* CEClipView.m */; }; @@ -246,8 +247,6 @@ 25B2C24B07FA6BC400F4EFC7 /* CETextView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = CETextView.m; sourceTree = ""; }; 2A009AC91A57BA8B00C3D542 /* CETextFinder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CETextFinder.h; sourceTree = ""; }; 2A009ACA1A57BA8B00C3D542 /* CETextFinder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CETextFinder.m; sourceTree = ""; }; - 2A009ACC1A587B3100C3D542 /* CEFindTextFieldCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CEFindTextFieldCell.h; sourceTree = ""; }; - 2A009ACD1A587B3100C3D542 /* CEFindTextFieldCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CEFindTextFieldCell.m; sourceTree = ""; }; 2A009ACF1A58ED1D00C3D542 /* CEFindResultViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CEFindResultViewController.h; sourceTree = ""; }; 2A009AD01A58ED1D00C3D542 /* CEFindResultViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CEFindResultViewController.m; sourceTree = ""; }; 2A009AD81A5AAE7F00C3D542 /* CEFindPanelSplitView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CEFindPanelSplitView.h; sourceTree = ""; }; @@ -484,6 +483,10 @@ 2AD488721A085D8B00B795CB /* ja */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ja; path = ja.lproj/SyntaxEditSheet.strings; sourceTree = ""; }; 2AD5322819779FD000A925CA /* CELineHeightTransformer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CELineHeightTransformer.h; sourceTree = ""; }; 2AD5322919779FD000A925CA /* CELineHeightTransformer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CELineHeightTransformer.m; sourceTree = ""; }; + 2AD67C221AA7285F0078BB95 /* CEFindPanelTextView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CEFindPanelTextView.h; sourceTree = ""; }; + 2AD67C231AA7285F0078BB95 /* CEFindPanelTextView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CEFindPanelTextView.m; sourceTree = ""; }; + 2AD67C281AA75E7F0078BB95 /* CEFindPanelTextClipView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CEFindPanelTextClipView.h; sourceTree = ""; }; + 2AD67C291AA75E7F0078BB95 /* CEFindPanelTextClipView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CEFindPanelTextClipView.m; sourceTree = ""; }; 2AD84CA81966314100DE49BD /* CEODBEventSender.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CEODBEventSender.h; sourceTree = ""; }; 2AD84CA91966314100DE49BD /* CEODBEventSender.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CEODBEventSender.m; sourceTree = ""; }; 2AE2E9D319D2CF00000D66A9 /* CEEncodingManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CEEncodingManager.h; sourceTree = ""; }; @@ -605,8 +608,8 @@ children = ( 2A009AD81A5AAE7F00C3D542 /* CEFindPanelSplitView.h */, 2A009AD91A5AAE8000C3D542 /* CEFindPanelSplitView.m */, - 2A009ACC1A587B3100C3D542 /* CEFindTextFieldCell.h */, - 2A009ACD1A587B3100C3D542 /* CEFindTextFieldCell.m */, + 2AD67C281AA75E7F0078BB95 /* CEFindPanelTextClipView.h */, + 2AD67C291AA75E7F0078BB95 /* CEFindPanelTextClipView.m */, ); name = Views; sourceTree = ""; @@ -1038,6 +1041,8 @@ 2A7CF2421A5747EC00D09249 /* CEFindPanelController.m */, 2A009ACF1A58ED1D00C3D542 /* CEFindResultViewController.h */, 2A009AD01A58ED1D00C3D542 /* CEFindResultViewController.m */, + 2AD67C221AA7285F0078BB95 /* CEFindPanelTextView.h */, + 2AD67C231AA7285F0078BB95 /* CEFindPanelTextView.m */, 2A009ADB1A5AB96F00C3D542 /* Views */, ); name = "Text Finder"; @@ -1413,6 +1418,7 @@ 8CB0122E07CA0EFA00221EDC /* CEToolbarController.m in Sources */, 258D708A07D456DF0062A3E5 /* CETextSelection.m in Sources */, 8CC1925707E2D84500B54AE4 /* CEDocument+ScriptingSupport.m in Sources */, + 2AD67C241AA7285F0078BB95 /* CEFindPanelTextView.m in Sources */, 2A63122E19C2D30C0088C5C6 /* CEThemeViewController.m in Sources */, 8CC1961D07E2E54E00B54AE4 /* CEScriptManager.m in Sources */, 2AACC9591942A82900E3FF63 /* CEIndicatorSheetController.m in Sources */, @@ -1430,10 +1436,10 @@ 2A07202B18E0E1C2006F3A43 /* CEPrintPanelAccessoryController.m in Sources */, 2A3A759419E77D66001DAB88 /* CEMigrationWindowController.m in Sources */, 2A51793A1A40A3B500A3F852 /* CEShortcutKeyField.m in Sources */, + 2AD67C2A1AA75E7F0078BB95 /* CEFindPanelTextClipView.m in Sources */, 2A7846DE18FE0C0C006BDF00 /* CETheme.m in Sources */, 2A68F93818FB04F400673440 /* CEMenuItemCell.m in Sources */, 2AB432711912AF7200835004 /* CEGlyphPopoverController.m in Sources */, - 2A009ACE1A587B3100C3D542 /* CEFindTextFieldCell.m in Sources */, 2AE356461A86D32500E29FEF /* CEClipView.m in Sources */, 2AFFB71B18D7F18300118477 /* CEGoToSheetController.m in Sources */, 2A3FB2AD18ECEFF200D9CB2C /* CESyntaxEditSheetController.m in Sources */, diff --git a/CotEditor/Sources/CEFindPanelTextClipView.h b/CotEditor/Sources/CEFindPanelTextClipView.h new file mode 100644 index 0000000000..51553074f4 --- /dev/null +++ b/CotEditor/Sources/CEFindPanelTextClipView.h @@ -0,0 +1,35 @@ +/* + ============================================================================== + CEFindPanelTextClipView + + CotEditor + http://coteditor.com + + Created on 2015-03-05 by 1024jp + encoding="UTF-8" + ------------------------------------------------------------------------------ + + © 2015 1024jp + + This program is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License as published by the Free Software + Foundation; either version 2 of the License, or (at your option) any later + version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + this program; if not, write to the Free Software Foundation, Inc., 59 Temple + Place - Suite 330, Boston, MA 02111-1307, USA. + + ============================================================================== + */ + +@import Cocoa; + + +@interface CEFindPanelTextClipView : NSClipView + +@end diff --git a/CotEditor/Sources/CEFindTextFieldCell.m b/CotEditor/Sources/CEFindPanelTextClipView.m similarity index 76% rename from CotEditor/Sources/CEFindTextFieldCell.m rename to CotEditor/Sources/CEFindPanelTextClipView.m index 46e43fea6b..ed7d339aa7 100644 --- a/CotEditor/Sources/CEFindTextFieldCell.m +++ b/CotEditor/Sources/CEFindPanelTextClipView.m @@ -1,11 +1,11 @@ /* ============================================================================== - CEFindTextFieldCell + CEFindPanelTextClipView CotEditor http://coteditor.com - Created on 2015-01-03 by 1024jp + Created on 2015-03-05 by 1024jp encoding="UTF-8" ------------------------------------------------------------------------------ @@ -27,24 +27,24 @@ ============================================================================== */ -#import "CEFindTextFieldCell.h" +#import "CEFindPanelTextClipView.h" -@implementation CEFindTextFieldCell +@implementation CEFindPanelTextClipView #pragma mark Superclass Methods // ------------------------------------------------------ -/// add left padding for history popup -- (NSRect)drawingRectForBounds:(NSRect)theRect +/// add left padding for popup button +- (void)setFrame:(NSRect)frame // ------------------------------------------------------ { - const CGFloat padding = 28; + const CGFloat padding = 28.0; - theRect.size.width -= padding; - theRect.origin.x += padding; + frame.origin.x += padding; + frame.size.width -= padding; - return [super drawingRectForBounds:theRect]; + [super setFrame:frame]; } @end diff --git a/CotEditor/Sources/CEFindTextFieldCell.h b/CotEditor/Sources/CEFindPanelTextView.h similarity index 90% rename from CotEditor/Sources/CEFindTextFieldCell.h rename to CotEditor/Sources/CEFindPanelTextView.h index 08b009edc0..26f9dfbb05 100644 --- a/CotEditor/Sources/CEFindTextFieldCell.h +++ b/CotEditor/Sources/CEFindPanelTextView.h @@ -1,11 +1,11 @@ /* ============================================================================== - CEFindTextFieldCell + CEFindPanelTextView CotEditor http://coteditor.com - Created on 2015-01-03 by 1024jp + Created on 2015-03-04 by 1024jp encoding="UTF-8" ------------------------------------------------------------------------------ @@ -30,6 +30,6 @@ @import Cocoa; -@interface CEFindTextFieldCell : NSTextFieldCell +@interface CEFindPanelTextView : NSTextView @end diff --git a/CotEditor/Sources/CEFindPanelTextView.m b/CotEditor/Sources/CEFindPanelTextView.m new file mode 100644 index 0000000000..f0d33f3958 --- /dev/null +++ b/CotEditor/Sources/CEFindPanelTextView.m @@ -0,0 +1,138 @@ +/* + ============================================================================== + CEFindPanelTextView + + CotEditor + http://coteditor.com + + Created on 2015-03-04 by 1024jp + encoding="UTF-8" + ------------------------------------------------------------------------------ + + © 2015 1024jp + + This program is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License as published by the Free Software + Foundation; either version 2 of the License, or (at your option) any later + version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + this program; if not, write to the Free Software Foundation, Inc., 59 Temple + Place - Suite 330, Boston, MA 02111-1307, USA. + + ============================================================================== + */ + +#import "CEFindPanelTextView.h" +#import "CEFindPanelController.h" +#import "constants.h" + + +@interface CEFindPanelTextView () + +@property (nonatomic) IBOutlet CEFindPanelController *findPanelController; + +@end + + + + +#pragma mark - + +@implementation CEFindPanelTextView + +#pragma mark Superclass Methods + +// ------------------------------------------------------ +/// initialize instance +- (instancetype)initWithCoder:(NSCoder *)coder +// ------------------------------------------------------ +{ + self = [super initWithCoder:coder]; + if (self) { + // set system font (standard NSTextField behavior) + NSFont *font = [NSFont systemFontOfSize:[NSFont systemFontSize]]; + [self setFont:font]; + + // set inset a bit like NSTextField (horizontal inset is added in CEFindPanelTextClipView) + [self setTextContainerInset:NSMakeSize(0.0, 2.0)]; + + // avoid wrapping + [[self textContainer] setWidthTracksTextView:NO]; + [[self textContainer] setContainerSize:NSMakeSize(CGFLOAT_MAX, CGFLOAT_MAX)]; + [self setHorizontallyResizable:YES]; + } + return self; +} + + +// ------------------------------------------------------ +/// view is on focus +- (BOOL)becomeFirstResponder +// ------------------------------------------------------ +{ + // select whole string on focus (standard NSTextField behavior) + [self setSelectedRange:NSMakeRange(0, [[self string] length])]; + + return [super becomeFirstResponder]; +} + + +// ------------------------------------------------------ +/// view dismiss focus +- (BOOL)resignFirstResponder +// ------------------------------------------------------ +{ + // clear current selection (standard NSTextField behavior) + [self setSelectedRange:NSMakeRange(0, 0)]; + return [super resignFirstResponder]; +} + + +// ------------------------------------------------------ +/// swap '¥' with '\' if needed +- (void)insertText:(id)aString replacementRange:(NSRange)replacementRange +// ------------------------------------------------------ +{ + NSString *string = ([aString isKindOfClass:[NSAttributedString class]]) ? [aString string] : aString; + + // swap '¥' with '\' if needed + if ([[NSUserDefaults standardUserDefaults] boolForKey:CEDefaultSwapYenAndBackSlashKey] && ([string length] == 1)) { + NSString *yen = [NSString stringWithCharacters:&kYenMark length:1]; + + if ([string isEqualToString:@"\\"]) { + string = yen; + } else if ([string isEqualToString:yen]) { + string = @"\\"; + } + } + + [super insertText:string replacementRange:replacementRange]; +} + + +// ------------------------------------------------------ +/// jump to the next responder with tab key (standard NSTextField behavior) +- (void)insertTab:(id)sender +// ------------------------------------------------------ +{ + [[self window] makeFirstResponder:[self nextKeyView]]; +} + + +// ------------------------------------------------------ +/// perform Find Next with return +- (void)insertNewline:(id)sender +// ------------------------------------------------------ +{ + // -> do nothing if no findpanelController is connected (standard NSTextField behavior) + if ([self findPanelController]) { + [[self findPanelController] findNext:self]; + } +} + +@end diff --git a/CotEditor/ja.lproj/FindPanel.strings b/CotEditor/ja.lproj/FindPanel.strings index 7ca0da7c52..88c2bc23c4 100644 --- a/CotEditor/ja.lproj/FindPanel.strings +++ b/CotEditor/ja.lproj/FindPanel.strings @@ -15,10 +15,10 @@ /* Class = "NSPanel"; title = "Find & Replace"; ObjectID = "Wal-Sg-6d6"; */ "Wal-Sg-6d6.title" = "検索と置換"; -/* Class = "IBBindingConnection"; ibShadowedIsNilPlaceholder = "Find"; ObjectID = "KFJ-K2-zGh"; */ -"KFJ-K2-zGh.ibShadowedIsNilPlaceholder" = "検索"; -/* Class = "IBBindingConnection"; ibShadowedIsNilPlaceholder = "Replace"; ObjectID = "rCp-kT-O6b"; */ -"rCp-kT-O6b.ibShadowedIsNilPlaceholder" = "置換"; +/* Class = "IBBindingConnection"; ibShadowedIsNilPlaceholder = "Find"; ObjectID = "oNs-q5-oCH"; */ +"oNs-q5-oCH.ibShadowedIsNilPlaceholder" = "検索"; +/* Class = "IBBindingConnection"; ibShadowedIsNilPlaceholder = "Replace"; ObjectID = "zd8-iN-ws4"; */ +"zd8-iN-ws4.ibShadowedIsNilPlaceholder" = "置換"; /* Class = "NSButtonCell"; title = "Regular Expression"; ObjectID = "brT-HP-GVL"; */ "brT-HP-GVL.title" = "正規表現"; diff --git a/CotEditor/zh-Hans.lproj/FindPanel.strings b/CotEditor/zh-Hans.lproj/FindPanel.strings index 3c9931c443..150dfd08f6 100644 --- a/CotEditor/zh-Hans.lproj/FindPanel.strings +++ b/CotEditor/zh-Hans.lproj/FindPanel.strings @@ -16,10 +16,10 @@ /* Class = "NSPanel"; title = "Find & Replace"; ObjectID = "Wal-Sg-6d6"; */ "Wal-Sg-6d6.title" = "查找 & 替换"; -/* Class = "IBBindingConnection"; ibShadowedIsNilPlaceholder = "Find"; ObjectID = "KFJ-K2-zGh"; */ -"KFJ-K2-zGh.ibShadowedIsNilPlaceholder" = "查找"; -/* Class = "IBBindingConnection"; ibShadowedIsNilPlaceholder = "Replace"; ObjectID = "rCp-kT-O6b"; */ -"rCp-kT-O6b.ibShadowedIsNilPlaceholder" = "替换"; +/* Class = "IBBindingConnection"; ibShadowedIsNilPlaceholder = "Find"; ObjectID = "oNs-q5-oCH"; */ +"oNs-q5-oCH.ibShadowedIsNilPlaceholder" = "查找"; +/* Class = "IBBindingConnection"; ibShadowedIsNilPlaceholder = "Replace"; ObjectID = "zd8-iN-ws4"; */ +"zd8-iN-ws4.ibShadowedIsNilPlaceholder" = "替换"; /* Class = "NSButtonCell"; title = "Regular Expression"; ObjectID = "brT-HP-GVL"; */ "brT-HP-GVL.title" = "正则表达式"; From 2732985c09215880f4d8eae19cf1fd08c0ca6524 Mon Sep 17 00:00:00 2001 From: 1024jp <1024jp@wolfrosch.com> Date: Thu, 5 Mar 2015 01:04:15 +0900 Subject: [PATCH 08/20] Remove escape character option from find panel (#363) --- CHANGELOG.md | 1 + CotEditor/Base.lproj/FindPanel.xib | 18 ---------------- CotEditor/Sources/CEFindPanelController.m | 25 +++-------------------- CotEditor/Sources/CETextFinder.m | 1 - CotEditor/Sources/constants.h | 1 - CotEditor/Sources/constants.m | 1 - CotEditor/ja.lproj/FindPanel.strings | 5 ----- CotEditor/zh-Hans.lproj/FindPanel.strings | 5 ----- 8 files changed, 4 insertions(+), 53 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a03e367421..18c653ff09 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ Change Log - Improve find panel: - Add scroll bars to the text fields. - Now, “Swap Yen and backslash keys” option is also applied to the fields in the find panel. + - Remove “Escape Character” option for regular expression search. - Add “Cyrillic (Windows)” to the encoding list. diff --git a/CotEditor/Base.lproj/FindPanel.xib b/CotEditor/Base.lproj/FindPanel.xib index 27b9898553..dc995a9e62 100644 --- a/CotEditor/Base.lproj/FindPanel.xib +++ b/CotEditor/Base.lproj/FindPanel.xib @@ -238,24 +238,6 @@ - - - - - - - - - - - - - - - - - - diff --git a/CotEditor/Sources/CEFindPanelController.m b/CotEditor/Sources/CEFindPanelController.m index 7da4fedd47..827438af51 100644 --- a/CotEditor/Sources/CEFindPanelController.m +++ b/CotEditor/Sources/CEFindPanelController.m @@ -37,6 +37,7 @@ // constants static const CGFloat kDefaultResultViewHeight = 200.0; static const NSUInteger kMaxHistorySize = 20; +static NSString *const kEscapeCharacter = @"\\"; @interface CEFindPanelController () @@ -48,7 +49,6 @@ @interface CEFindPanelController () Date: Thu, 5 Mar 2015 03:21:51 +0900 Subject: [PATCH 09/20] Add ability to draw invisibles to find panel fields --- CHANGELOG.md | 1 + CotEditor/CotEditor.xcodeproj/project.pbxproj | 6 + CotEditor/Sources/CEFindPanelLayoutManager.h | 35 ++++ CotEditor/Sources/CEFindPanelLayoutManager.m | 180 ++++++++++++++++++ CotEditor/Sources/CEFindPanelTextView.m | 5 + 5 files changed, 227 insertions(+) create mode 100644 CotEditor/Sources/CEFindPanelLayoutManager.h create mode 100644 CotEditor/Sources/CEFindPanelLayoutManager.m diff --git a/CHANGELOG.md b/CHANGELOG.md index 18c653ff09..b5b26ce57c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ Change Log - Change place to create backup files (Now, backup files are always created in `~/Library/Autosave Information/`). - Improve find panel: - Add scroll bars to the text fields. + - Show invisible characters in text fields. - Now, “Swap Yen and backslash keys” option is also applied to the fields in the find panel. - Remove “Escape Character” option for regular expression search. - Add “Cyrillic (Windows)” to the encoding list. diff --git a/CotEditor/CotEditor.xcodeproj/project.pbxproj b/CotEditor/CotEditor.xcodeproj/project.pbxproj index 2d1ef537bd..d67e08e037 100644 --- a/CotEditor/CotEditor.xcodeproj/project.pbxproj +++ b/CotEditor/CotEditor.xcodeproj/project.pbxproj @@ -124,6 +124,7 @@ 2AD5322A19779FD000A925CA /* CELineHeightTransformer.m in Sources */ = {isa = PBXBuildFile; fileRef = 2AD5322919779FD000A925CA /* CELineHeightTransformer.m */; }; 2AD67C241AA7285F0078BB95 /* CEFindPanelTextView.m in Sources */ = {isa = PBXBuildFile; fileRef = 2AD67C231AA7285F0078BB95 /* CEFindPanelTextView.m */; }; 2AD67C2A1AA75E7F0078BB95 /* CEFindPanelTextClipView.m in Sources */ = {isa = PBXBuildFile; fileRef = 2AD67C291AA75E7F0078BB95 /* CEFindPanelTextClipView.m */; }; + 2AD67C2F1AA7651B0078BB95 /* CEFindPanelLayoutManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 2AD67C2E1AA7651B0078BB95 /* CEFindPanelLayoutManager.m */; }; 2AD84CAA1966314100DE49BD /* CEODBEventSender.m in Sources */ = {isa = PBXBuildFile; fileRef = 2AD84CA91966314100DE49BD /* CEODBEventSender.m */; }; 2AE2E9D519D2CF00000D66A9 /* CEEncodingManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 2AE2E9D419D2CF00000D66A9 /* CEEncodingManager.m */; }; 2AE356461A86D32500E29FEF /* CEClipView.m in Sources */ = {isa = PBXBuildFile; fileRef = 2AE356451A86D32500E29FEF /* CEClipView.m */; }; @@ -487,6 +488,8 @@ 2AD67C231AA7285F0078BB95 /* CEFindPanelTextView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CEFindPanelTextView.m; sourceTree = ""; }; 2AD67C281AA75E7F0078BB95 /* CEFindPanelTextClipView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CEFindPanelTextClipView.h; sourceTree = ""; }; 2AD67C291AA75E7F0078BB95 /* CEFindPanelTextClipView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CEFindPanelTextClipView.m; sourceTree = ""; }; + 2AD67C2D1AA7651B0078BB95 /* CEFindPanelLayoutManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CEFindPanelLayoutManager.h; sourceTree = ""; }; + 2AD67C2E1AA7651B0078BB95 /* CEFindPanelLayoutManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CEFindPanelLayoutManager.m; sourceTree = ""; }; 2AD84CA81966314100DE49BD /* CEODBEventSender.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CEODBEventSender.h; sourceTree = ""; }; 2AD84CA91966314100DE49BD /* CEODBEventSender.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CEODBEventSender.m; sourceTree = ""; }; 2AE2E9D319D2CF00000D66A9 /* CEEncodingManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CEEncodingManager.h; sourceTree = ""; }; @@ -1043,6 +1046,8 @@ 2A009AD01A58ED1D00C3D542 /* CEFindResultViewController.m */, 2AD67C221AA7285F0078BB95 /* CEFindPanelTextView.h */, 2AD67C231AA7285F0078BB95 /* CEFindPanelTextView.m */, + 2AD67C2D1AA7651B0078BB95 /* CEFindPanelLayoutManager.h */, + 2AD67C2E1AA7651B0078BB95 /* CEFindPanelLayoutManager.m */, 2A009ADB1A5AB96F00C3D542 /* Views */, ); name = "Text Finder"; @@ -1437,6 +1442,7 @@ 2A3A759419E77D66001DAB88 /* CEMigrationWindowController.m in Sources */, 2A51793A1A40A3B500A3F852 /* CEShortcutKeyField.m in Sources */, 2AD67C2A1AA75E7F0078BB95 /* CEFindPanelTextClipView.m in Sources */, + 2AD67C2F1AA7651B0078BB95 /* CEFindPanelLayoutManager.m in Sources */, 2A7846DE18FE0C0C006BDF00 /* CETheme.m in Sources */, 2A68F93818FB04F400673440 /* CEMenuItemCell.m in Sources */, 2AB432711912AF7200835004 /* CEGlyphPopoverController.m in Sources */, diff --git a/CotEditor/Sources/CEFindPanelLayoutManager.h b/CotEditor/Sources/CEFindPanelLayoutManager.h new file mode 100644 index 0000000000..3a2d1cbcf3 --- /dev/null +++ b/CotEditor/Sources/CEFindPanelLayoutManager.h @@ -0,0 +1,35 @@ +/* + ============================================================================== + CEFindPanelLayoutManager + + CotEditor + http://coteditor.com + + Created on 2015-03-04 by 1024jp + encoding="UTF-8" + ------------------------------------------------------------------------------ + + © 2015 1024jp + + This program is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License as published by the Free Software + Foundation; either version 2 of the License, or (at your option) any later + version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + this program; if not, write to the Free Software Foundation, Inc., 59 Temple + Place - Suite 330, Boston, MA 02111-1307, USA. + + ============================================================================== + */ + +@import Cocoa; + + +@interface CEFindPanelLayoutManager : NSLayoutManager + +@end diff --git a/CotEditor/Sources/CEFindPanelLayoutManager.m b/CotEditor/Sources/CEFindPanelLayoutManager.m new file mode 100644 index 0000000000..d30d80babf --- /dev/null +++ b/CotEditor/Sources/CEFindPanelLayoutManager.m @@ -0,0 +1,180 @@ +/* + ============================================================================== + CEFindPanelLayoutManager + + CotEditor + http://coteditor.com + + Created on 2015-03-04 by 1024jp + encoding="UTF-8" + ------------------------------------------------------------------------------ + + © 2015 1024jp + + This program is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License as published by the Free Software + Foundation; either version 2 of the License, or (at your option) any later + version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + this program; if not, write to the Free Software Foundation, Inc., 59 Temple + Place - Suite 330, Boston, MA 02111-1307, USA. + + ============================================================================== + */ + +#import "CEFindPanelLayoutManager.h" +#import "CEUtils.h" +#import "constants.h" + + +// constants +static const CGFloat kLineSpacing = 4.0; + + +@interface CEFindPanelLayoutManager () + +@property (nonatomic, copy) NSDictionary *invisibleAttributes; + +@end + + + + +#pragma mark - + +@implementation CEFindPanelLayoutManager + + +#pragma mark Superclass Methods + +// ------------------------------------------------------ +/// initialize instance +- (instancetype)init +// ------------------------------------------------------ +{ + self = [super init]; + if (self) { + [self setUsesScreenFonts:YES]; + } + return self; +} + +// ------------------------------------------------------ +/// show invisible characters +- (void)drawGlyphsForGlyphRange:(NSRange)glyphsToShow atPoint:(NSPoint)origin +// ------------------------------------------------------ +{ + NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; + BOOL showInvisibles = YES; + + if (showInvisibles) { + NSTextView *textView = [self firstTextView]; + NSString *completeStr = [[self textStorage] string]; + NSUInteger lengthToRedraw = NSMaxRange(glyphsToShow); + NSSize size = [textView textContainerInset]; + + NSColor *color; + if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_9) { + color = [NSColor tertiaryLabelColor]; + } else { + color = [NSColor colorWithCalibratedWhite:0.0 alpha:0.25]; + } + + NSFont *font = [[self firstTextView] font]; + font = [font screenFont] ? : font; + NSFont *fullwidthFont = [[NSFont fontWithName:@"HiraKakuProN-W3" size:[font pointSize]] screenFont] ? : font; + NSDictionary *attributes = @{NSFontAttributeName: font, + NSForegroundColorAttributeName: color}; + NSDictionary *fullwidthAttributes = @{NSFontAttributeName: fullwidthFont, + NSForegroundColorAttributeName: color}; + + BOOL showsSpace = [defaults boolForKey:CEDefaultShowInvisibleSpaceKey]; + BOOL showsTab = [defaults boolForKey:CEDefaultShowInvisibleTabKey]; + BOOL showsNewLine = [defaults boolForKey:CEDefaultShowInvisibleNewLineKey]; + BOOL showsFullwidthSpace = [defaults boolForKey:CEDefaultShowInvisibleFullwidthSpaceKey]; + BOOL showsOtherInvisibles = [defaults boolForKey:CEDefaultShowOtherInvisibleCharsKey]; + + unichar spaceCharacter = [CEUtils invisibleSpaceChar:[defaults integerForKey:CEDefaultInvisibleSpaceKey]]; + NSAttributedString *space = [[NSAttributedString alloc] initWithString:[NSString stringWithCharacters:&spaceCharacter length:1] + attributes:attributes]; + + unichar tabCharacter = [CEUtils invisibleTabChar:[defaults integerForKey:CEDefaultInvisibleTabKey]]; + NSAttributedString *tab = [[NSAttributedString alloc] initWithString:[NSString stringWithCharacters:&tabCharacter length:1] + attributes:attributes]; + + unichar newLineCharacter = [CEUtils invisibleNewLineChar:[defaults integerForKey:CEDefaultInvisibleNewLineKey]]; + NSAttributedString *newLine = [[NSAttributedString alloc] initWithString:[NSString stringWithCharacters:&newLineCharacter length:1] + attributes:attributes]; + + unichar fullwidthSpaceCharacter = [CEUtils invisibleFullwidthSpaceChar:[defaults integerForKey:CEDefaultInvisibleFullwidthSpaceKey]]; + NSAttributedString *fullwidthSpace = [[NSAttributedString alloc] initWithString:[NSString stringWithCharacters:&fullwidthSpaceCharacter length:1] + attributes:fullwidthAttributes]; + + for (NSUInteger glyphIndex = glyphsToShow.location; glyphIndex < lengthToRedraw; glyphIndex++) { + NSUInteger charIndex = [self characterIndexForGlyphAtIndex:glyphIndex]; + unichar character = [completeStr characterAtIndex:charIndex]; + + if (showsSpace && ((character == ' ') || (character == 0x00A0))) { + NSPoint pointToDraw = [self pointToDrawGlyphAtIndex:glyphIndex adjust:size]; + [space drawAtPoint:pointToDraw]; + + } else if (showsTab && (character == '\t')) { + NSPoint pointToDraw = [self pointToDrawGlyphAtIndex:glyphIndex adjust:size]; + [tab drawAtPoint:pointToDraw]; + + } else if (showsNewLine && (character == '\n')) { + NSPoint pointToDraw = [self pointToDrawGlyphAtIndex:glyphIndex adjust:size]; + [newLine drawAtPoint:pointToDraw]; + + } else if (showsFullwidthSpace && (character == 0x3000)) { // Fullwidth-space (JP) + NSPoint pointToDraw = [self pointToDrawGlyphAtIndex:glyphIndex adjust:size]; + [fullwidthSpace drawAtPoint:pointToDraw]; + + } else if (showsOtherInvisibles && ([self glyphAtIndex:glyphIndex] == NSControlGlyph)) { + NSFont *replaceFont = [NSFont fontWithName:@"Lucida Grande" size:[font pointSize]]; + NSGlyph replaceGlyph = [replaceFont glyphWithName:@"replacement"]; + NSUInteger charLength = CFStringIsSurrogateHighCharacter(character) ? 2 : 1; + NSRange charRange = NSMakeRange(charIndex, charLength); + NSString *baseStr = [completeStr substringWithRange:charRange]; + NSGlyphInfo *glyphInfo = [NSGlyphInfo glyphInfoWithGlyph:replaceGlyph forFont:replaceFont baseString:baseStr]; + + if (glyphInfo) { + NSDictionary *replaceAttrs = @{NSGlyphInfoAttributeName: glyphInfo, + NSFontAttributeName: replaceFont, + NSForegroundColorAttributeName: color}; + NSDictionary *attrs = [[self textStorage] attributesAtIndex:charIndex effectiveRange:NULL]; + if (attrs[NSGlyphInfoAttributeName] == nil) { + [[self textStorage] addAttributes:replaceAttrs range:charRange]; + } + } + } + } + } + + [super drawGlyphsForGlyphRange:glyphsToShow atPoint:origin]; +} + + + +#pragma mark Private Methods + +//------------------------------------------------------ +/// calculate point to draw invisible character +- (NSPoint)pointToDrawGlyphAtIndex:(NSUInteger)glyphIndex adjust:(NSSize)size +//------------------------------------------------------ +{ + NSPoint drawPoint = [self locationForGlyphAtIndex:glyphIndex]; + NSRect theGlyphRect = [self lineFragmentRectForGlyphAtIndex:glyphIndex effectiveRange:NULL]; + + drawPoint.x += size.width; + drawPoint.y = theGlyphRect.origin.y + size.height; + + return drawPoint; +} + +@end diff --git a/CotEditor/Sources/CEFindPanelTextView.m b/CotEditor/Sources/CEFindPanelTextView.m index f0d33f3958..e055e89c1d 100644 --- a/CotEditor/Sources/CEFindPanelTextView.m +++ b/CotEditor/Sources/CEFindPanelTextView.m @@ -28,6 +28,7 @@ */ #import "CEFindPanelTextView.h" +#import "CEFindPanelLayoutManager.h" #import "CEFindPanelController.h" #import "constants.h" @@ -65,6 +66,10 @@ - (instancetype)initWithCoder:(NSCoder *)coder [[self textContainer] setWidthTracksTextView:NO]; [[self textContainer] setContainerSize:NSMakeSize(CGFLOAT_MAX, CGFLOAT_MAX)]; [self setHorizontallyResizable:YES]; + + // set subclassed layout manager for invisible characters + CEFindPanelLayoutManager *layoutManager = [[CEFindPanelLayoutManager alloc] init]; + [[self textContainer] replaceLayoutManager:layoutManager]; } return self; } From 831eb36a82b93fbf94a2e63e87074525a90ea4b7 Mon Sep 17 00:00:00 2001 From: 1024jp <1024jp@wolfrosch.com> Date: Thu, 5 Mar 2015 04:50:16 +0900 Subject: [PATCH 10/20] Adjust text drawing position in find panel fields --- CotEditor/Sources/CEFindPanelLayoutManager.m | 33 +++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/CotEditor/Sources/CEFindPanelLayoutManager.m b/CotEditor/Sources/CEFindPanelLayoutManager.m index d30d80babf..9ef8316a79 100644 --- a/CotEditor/Sources/CEFindPanelLayoutManager.m +++ b/CotEditor/Sources/CEFindPanelLayoutManager.m @@ -32,13 +32,10 @@ #import "constants.h" -// constants -static const CGFloat kLineSpacing = 4.0; - - @interface CEFindPanelLayoutManager () @property (nonatomic, copy) NSDictionary *invisibleAttributes; +@property (nonatomic) CGFloat fontSize; @end @@ -59,6 +56,7 @@ - (instancetype)init { self = [super init]; if (self) { + _fontSize = [NSFont systemFontSize]; [self setUsesScreenFonts:YES]; } return self; @@ -160,6 +158,33 @@ - (void)drawGlyphsForGlyphRange:(NSRange)glyphsToShow atPoint:(NSPoint)origin } +// ------------------------------------------------------ +/// fix vertical glyph location for mixed font +- (NSPoint)locationForGlyphAtIndex:(NSUInteger)glyphIndex +// ------------------------------------------------------ +{ + NSPoint point = [super locationForGlyphAtIndex:glyphIndex]; + point.y = [[NSFont systemFontOfSize:[self fontSize]] ascender]; + + return point; +} + + +// ------------------------------------------------------ +/// fix line height for mixed font +- (void)setLineFragmentRect:(NSRect)fragmentRect forGlyphRange:(NSRange)glyphRange usedRect:(NSRect)usedRect +// ------------------------------------------------------ +{ + static const CGFloat kLineSpacing = 4.0; + CGFloat lineHeight = [self fontSize] + kLineSpacing; + + fragmentRect.size.height = lineHeight; + usedRect.size.height = lineHeight; + + [super setLineFragmentRect:fragmentRect forGlyphRange:glyphRange usedRect:usedRect]; +} + + #pragma mark Private Methods From fbfb43ee49d81437731c952ad346e73194f1a176 Mon Sep 17 00:00:00 2001 From: 1024jp <1024jp@wolfrosch.com> Date: Thu, 5 Mar 2015 04:50:32 +0900 Subject: [PATCH 11/20] Clean up CEFindPanelLayoutManager class --- CotEditor/Sources/CEFindPanelLayoutManager.m | 35 ++++++++++---------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/CotEditor/Sources/CEFindPanelLayoutManager.m b/CotEditor/Sources/CEFindPanelLayoutManager.m index 9ef8316a79..c1f5cd4102 100644 --- a/CotEditor/Sources/CEFindPanelLayoutManager.m +++ b/CotEditor/Sources/CEFindPanelLayoutManager.m @@ -34,7 +34,6 @@ @interface CEFindPanelLayoutManager () -@property (nonatomic, copy) NSDictionary *invisibleAttributes; @property (nonatomic) CGFloat fontSize; @end @@ -68,13 +67,13 @@ - (void)drawGlyphsForGlyphRange:(NSRange)glyphsToShow atPoint:(NSPoint)origin // ------------------------------------------------------ { NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; - BOOL showInvisibles = YES; + BOOL showInvisibles = [defaults boolForKey:CEDefaultShowInvisiblesKey]; if (showInvisibles) { NSTextView *textView = [self firstTextView]; NSString *completeStr = [[self textStorage] string]; NSUInteger lengthToRedraw = NSMaxRange(glyphsToShow); - NSSize size = [textView textContainerInset]; + NSSize inset = [textView textContainerInset]; NSColor *color; if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_9) { @@ -85,9 +84,9 @@ - (void)drawGlyphsForGlyphRange:(NSRange)glyphsToShow atPoint:(NSPoint)origin NSFont *font = [[self firstTextView] font]; font = [font screenFont] ? : font; - NSFont *fullwidthFont = [[NSFont fontWithName:@"HiraKakuProN-W3" size:[font pointSize]] screenFont] ? : font; NSDictionary *attributes = @{NSFontAttributeName: font, NSForegroundColorAttributeName: color}; + NSFont *fullwidthFont = [[NSFont fontWithName:@"HiraKakuProN-W3" size:[font pointSize]] screenFont] ? : font; NSDictionary *fullwidthAttributes = @{NSFontAttributeName: fullwidthFont, NSForegroundColorAttributeName: color}; @@ -97,20 +96,20 @@ - (void)drawGlyphsForGlyphRange:(NSRange)glyphsToShow atPoint:(NSPoint)origin BOOL showsFullwidthSpace = [defaults boolForKey:CEDefaultShowInvisibleFullwidthSpaceKey]; BOOL showsOtherInvisibles = [defaults boolForKey:CEDefaultShowOtherInvisibleCharsKey]; - unichar spaceCharacter = [CEUtils invisibleSpaceChar:[defaults integerForKey:CEDefaultInvisibleSpaceKey]]; - NSAttributedString *space = [[NSAttributedString alloc] initWithString:[NSString stringWithCharacters:&spaceCharacter length:1] + unichar spaceChar = [CEUtils invisibleSpaceChar:[defaults integerForKey:CEDefaultInvisibleSpaceKey]]; + NSAttributedString *space = [[NSAttributedString alloc] initWithString:[NSString stringWithCharacters:&spaceChar length:1] attributes:attributes]; - unichar tabCharacter = [CEUtils invisibleTabChar:[defaults integerForKey:CEDefaultInvisibleTabKey]]; - NSAttributedString *tab = [[NSAttributedString alloc] initWithString:[NSString stringWithCharacters:&tabCharacter length:1] + unichar tabChar = [CEUtils invisibleTabChar:[defaults integerForKey:CEDefaultInvisibleTabKey]]; + NSAttributedString *tab = [[NSAttributedString alloc] initWithString:[NSString stringWithCharacters:&tabChar length:1] attributes:attributes]; - unichar newLineCharacter = [CEUtils invisibleNewLineChar:[defaults integerForKey:CEDefaultInvisibleNewLineKey]]; - NSAttributedString *newLine = [[NSAttributedString alloc] initWithString:[NSString stringWithCharacters:&newLineCharacter length:1] + unichar newLineChar = [CEUtils invisibleNewLineChar:[defaults integerForKey:CEDefaultInvisibleNewLineKey]]; + NSAttributedString *newLine = [[NSAttributedString alloc] initWithString:[NSString stringWithCharacters:&newLineChar length:1] attributes:attributes]; - unichar fullwidthSpaceCharacter = [CEUtils invisibleFullwidthSpaceChar:[defaults integerForKey:CEDefaultInvisibleFullwidthSpaceKey]]; - NSAttributedString *fullwidthSpace = [[NSAttributedString alloc] initWithString:[NSString stringWithCharacters:&fullwidthSpaceCharacter length:1] + unichar fullwidthSpaceChar = [CEUtils invisibleFullwidthSpaceChar:[defaults integerForKey:CEDefaultInvisibleFullwidthSpaceKey]]; + NSAttributedString *fullwidthSpace = [[NSAttributedString alloc] initWithString:[NSString stringWithCharacters:&fullwidthSpaceChar length:1] attributes:fullwidthAttributes]; for (NSUInteger glyphIndex = glyphsToShow.location; glyphIndex < lengthToRedraw; glyphIndex++) { @@ -118,19 +117,19 @@ - (void)drawGlyphsForGlyphRange:(NSRange)glyphsToShow atPoint:(NSPoint)origin unichar character = [completeStr characterAtIndex:charIndex]; if (showsSpace && ((character == ' ') || (character == 0x00A0))) { - NSPoint pointToDraw = [self pointToDrawGlyphAtIndex:glyphIndex adjust:size]; + NSPoint pointToDraw = [self pointToDrawGlyphAtIndex:glyphIndex adjust:inset]; [space drawAtPoint:pointToDraw]; } else if (showsTab && (character == '\t')) { - NSPoint pointToDraw = [self pointToDrawGlyphAtIndex:glyphIndex adjust:size]; + NSPoint pointToDraw = [self pointToDrawGlyphAtIndex:glyphIndex adjust:inset]; [tab drawAtPoint:pointToDraw]; } else if (showsNewLine && (character == '\n')) { - NSPoint pointToDraw = [self pointToDrawGlyphAtIndex:glyphIndex adjust:size]; + NSPoint pointToDraw = [self pointToDrawGlyphAtIndex:glyphIndex adjust:inset]; [newLine drawAtPoint:pointToDraw]; } else if (showsFullwidthSpace && (character == 0x3000)) { // Fullwidth-space (JP) - NSPoint pointToDraw = [self pointToDrawGlyphAtIndex:glyphIndex adjust:size]; + NSPoint pointToDraw = [self pointToDrawGlyphAtIndex:glyphIndex adjust:inset]; [fullwidthSpace drawAtPoint:pointToDraw]; } else if (showsOtherInvisibles && ([self glyphAtIndex:glyphIndex] == NSControlGlyph)) { @@ -194,10 +193,10 @@ - (NSPoint)pointToDrawGlyphAtIndex:(NSUInteger)glyphIndex adjust:(NSSize)size //------------------------------------------------------ { NSPoint drawPoint = [self locationForGlyphAtIndex:glyphIndex]; - NSRect theGlyphRect = [self lineFragmentRectForGlyphAtIndex:glyphIndex effectiveRange:NULL]; + NSPoint lineOrigin = [self lineFragmentRectForGlyphAtIndex:glyphIndex effectiveRange:NULL].origin; drawPoint.x += size.width; - drawPoint.y = theGlyphRect.origin.y + size.height; + drawPoint.y = lineOrigin.y + size.height; return drawPoint; } From f0d7d75dcf1a29ebe704451e5a06cbee1a6fb48a Mon Sep 17 00:00:00 2001 From: 1024jp <1024jp@wolfrosch.com> Date: Thu, 5 Mar 2015 18:46:25 +0900 Subject: [PATCH 12/20] Fix showing find panel on "Use Selection" actions (fix #365) --- CHANGELOG.md | 5 +++++ CotEditor/Sources/CEFindPanelController.m | 2 -- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b5b26ce57c..aa42dba95a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,11 @@ Change Log - Add “Cyrillic (Windows)” to the encoding list. +### Fixes + +- Fix an issue where unwanted find panel was shown when perform “Use Selection for Find” or “Use Selection for Replace” action. + + 2.1.1 -------------------------- diff --git a/CotEditor/Sources/CEFindPanelController.m b/CotEditor/Sources/CEFindPanelController.m index 827438af51..22c74cc86e 100644 --- a/CotEditor/Sources/CEFindPanelController.m +++ b/CotEditor/Sources/CEFindPanelController.m @@ -383,7 +383,6 @@ - (IBAction)useSelectionForFind:(id)sender if (selectedString) { [self setFindString:selectedString]; - [self showFindPanel:sender]; } else { NSBeep(); } @@ -399,7 +398,6 @@ - (IBAction)useSelectionForReplace:(id)sender if (selectedString) { [self setReplacementString:selectedString]; - [self showFindPanel:sender]; } else { NSBeep(); } From 13d1b094c91f50fdeaa701c1f19d417145db1b51 Mon Sep 17 00:00:00 2001 From: 1024jp <1024jp@wolfrosch.com> Date: Thu, 5 Mar 2015 20:46:51 +0900 Subject: [PATCH 13/20] Optimize cot command --- CHANGELOG.md | 1 + CotEditor/cot/cot.m | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aa42dba95a..7872f3b42e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ Change Log - Now, “Swap Yen and backslash keys” option is also applied to the fields in the find panel. - Remove “Escape Character” option for regular expression search. - Add “Cyrillic (Windows)” to the encoding list. +- Optimize launching speed of `cot` command-line tool. ### Fixes diff --git a/CotEditor/cot/cot.m b/CotEditor/cot/cot.m index 3339063dab..7b99e41a2f 100644 --- a/CotEditor/cot/cot.m +++ b/CotEditor/cot/cot.m @@ -143,7 +143,7 @@ int main(int argc, const char * argv[]) } // read piped text if exists - NSString *input; + NSString *input = nil; if (!isatty(fileno(stdin))) { NSFileHandle *inputHandler = [NSFileHandle fileHandleWithStandardInput]; NSData *data = [inputHandler availableData]; @@ -195,10 +195,12 @@ int main(int argc, const char * argv[]) [[CotEditor documents] addObject:document]; } - document = document ? : [[CotEditor documents] firstObject]; - // jump to location - if (document && (arguments[kLineOption] || arguments[kColumnOption])) { + if (arguments[kLineOption] || arguments[kColumnOption]) { + document = document ? : [[CotEditor documents] firstObject]; + + if (!document) { exit(0); } + NSInteger line = [arguments[kLineOption] integerValue]; // 1 based NSInteger column = [arguments[kColumnOption] integerValue]; From 744b4058c4a924d6da816d3b7c82283db52fc6cb Mon Sep 17 00:00:00 2001 From: 1024jp <1024jp@wolfrosch.com> Date: Thu, 5 Mar 2015 05:55:44 +0900 Subject: [PATCH 14/20] Use fileCoordinator on file locking (#364) --- CHANGELOG.md | 3 ++- CotEditor/Sources/CEDocument.m | 46 ++++++++++++++++------------------ 2 files changed, 24 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7872f3b42e..4e2ff4d796 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,7 @@ Change Log - Improve find panel: - Add scroll bars to the text fields. - Show invisible characters in text fields. - - Now, “Swap Yen and backslash keys” option is also applied to the fields in the find panel. + - Now, “Swap Yen and backslash keys” option is also applied to the fields in the find panel. - Remove “Escape Character” option for regular expression search. - Add “Cyrillic (Windows)” to the encoding list. - Optimize launching speed of `cot` command-line tool. @@ -19,6 +19,7 @@ Change Log ### Fixes +- Fix an issue where application could hang up on saving backup file. - Fix an issue where unwanted find panel was shown when perform “Use Selection for Find” or “Use Selection for Replace” action. diff --git a/CotEditor/Sources/CEDocument.m b/CotEditor/Sources/CEDocument.m index cf49944854..58a8c4b032 100644 --- a/CotEditor/Sources/CEDocument.m +++ b/CotEditor/Sources/CEDocument.m @@ -1521,33 +1521,31 @@ - (BOOL)canUnlockFileAtURL:(NSURL *)url isLocked:(BOOL *)isLocked lockAgain:(BOO // ------------------------------------------------------ { __block BOOL isFinderLocked = NO; - BOOL success = NO; + __block BOOL success = NO; NSError *error = nil; NSFileManager *fileManager = [NSFileManager defaultManager]; - @synchronized(self) { - NSFileCoordinator *coordinator = [[NSFileCoordinator alloc] initWithFilePresenter:self]; - [coordinator coordinateReadingItemAtURL:url options:NSFileCoordinatorReadingWithoutChanges - error:&error - byAccessor:^(NSURL *newURL) - { - isFinderLocked = [[fileManager attributesOfItemAtPath:[newURL path] error:nil] fileIsImmutable]; - }]; - - if (isFinderLocked) { - // unlock file once - success = [fileManager setAttributes:@{NSFileImmutable:@NO} ofItemAtPath:[url path] error:nil]; - if (success) { - // lock file again if needed - if (lockAgain) { - [fileManager setAttributes:@{NSFileImmutable:@YES} ofItemAtPath:[url path] error:nil]; - } - } - } else { - // no-lock file is always treated as success - success = YES; - } - } + NSFileCoordinator *coordinator = [[NSFileCoordinator alloc] initWithFilePresenter:self]; + [coordinator coordinateWritingItemAtURL:url options:0 + error:&error + byAccessor:^(NSURL *newURL) + { + isFinderLocked = [[fileManager attributesOfItemAtPath:[newURL path] error:nil] fileIsImmutable]; + + if (isFinderLocked) { + // unlock file once + success = [fileManager setAttributes:@{NSFileImmutable:@NO} ofItemAtPath:[newURL path] error:nil]; + if (success) { + // lock file again if needed + if (lockAgain) { + [fileManager setAttributes:@{NSFileImmutable:@YES} ofItemAtPath:[newURL path] error:nil]; + } + } + } else { + // no-lock file is always treated as success + success = YES; + } + }]; if (isLocked) { *isLocked = isFinderLocked; From 22647e1a4a5debc5c75910fe81e37ac6ec4f2e49 Mon Sep 17 00:00:00 2001 From: 1024jp <1024jp@wolfrosch.com> Date: Thu, 5 Mar 2015 05:57:54 +0900 Subject: [PATCH 15/20] Use fileCoordinator on document reading/writing (#364) --- CotEditor/Sources/CEDocument.m | 76 ++++++++++++++++++++-------------- 1 file changed, 44 insertions(+), 32 deletions(-) diff --git a/CotEditor/Sources/CEDocument.m b/CotEditor/Sources/CEDocument.m index 58a8c4b032..8967328542 100644 --- a/CotEditor/Sources/CEDocument.m +++ b/CotEditor/Sources/CEDocument.m @@ -1106,23 +1106,30 @@ - (void)applyLineEndingToView - (NSData *)forceReadDataFromURL:(NSURL *)url // ------------------------------------------------------ { - NSData *data = nil; - NSString *convertedPath = @([[url path] UTF8String]); - NSTask *task = [[NSTask alloc] init]; - - @synchronized(self) { - [task setLaunchPath:@"/usr/libexec/authopen"]; - [task setArguments:@[convertedPath]]; - [task setStandardOutput:[NSPipe pipe]]; - - [task launch]; - data = [NSData dataWithData:[[[task standardOutput] fileHandleForReading] readDataToEndOfFile]]; - [task waitUntilExit]; - } + __block BOOL success = NO; + __block NSData *data = nil; - int status = [task terminationStatus]; + NSFileCoordinator *coordinator = [[NSFileCoordinator alloc] initWithFilePresenter:self]; + [coordinator coordinateReadingItemAtURL:url options:0 + error:nil + byAccessor:^(NSURL *newURL) + { + NSString *convertedPath = @([[newURL path] UTF8String]); + NSTask *task = [[NSTask alloc] init]; + + [task setLaunchPath:@"/usr/libexec/authopen"]; + [task setArguments:@[convertedPath]]; + [task setStandardOutput:[NSPipe pipe]]; + + [task launch]; + data = [NSData dataWithData:[[[task standardOutput] fileHandleForReading] readDataToEndOfFile]]; + [task waitUntilExit]; + + int status = [task terminationStatus]; + success = (status == 0); + }]; - return (status == 0) ? data : nil; + return success ? data : nil; } @@ -1400,7 +1407,7 @@ - (BOOL)acceptSaveDocumentWithIANACharSetName - (BOOL)forceWriteToURL:(NSURL *)url ofType:(NSString *)typeName forSaveOperation:(NSSaveOperationType)saveOperation // ------------------------------------------------------ { - BOOL success = NO; + __block BOOL success = NO; NSData *data = [self dataOfType:typeName error:nil]; if (!data) { return NO; } @@ -1423,25 +1430,31 @@ - (BOOL)forceWriteToURL:(NSURL *)url ofType:(NSString *)typeName forSaveOperatio return NO; } + NSFileCoordinator *coordinator = [[NSFileCoordinator alloc] initWithFilePresenter:self]; + // "authopen" コマンドを使って保存 - NSString *convertedPath = @([[url path] UTF8String]); - NSTask *task = [[NSTask alloc] init]; - - [task setLaunchPath:@"/usr/libexec/authopen"]; - [task setArguments:@[@"-c", @"-w", convertedPath]]; - [task setStandardInput:[NSPipe pipe]]; - - [task launch]; - [[[task standardInput] fileHandleForWriting] writeData:data]; - [[[task standardInput] fileHandleForWriting] closeFile]; - [task waitUntilExit]; - - int status = [task terminationStatus]; - success = (status == 0); + [coordinator coordinateWritingItemAtURL:url options:0 + error:nil + byAccessor:^(NSURL *newURL) + { + NSString *convertedPath = @([[newURL path] UTF8String]); + NSTask *task = [[NSTask alloc] init]; + + [task setLaunchPath:@"/usr/libexec/authopen"]; + [task setArguments:@[@"-c", @"-w", convertedPath]]; + [task setStandardInput:[NSPipe pipe]]; + + [task launch]; + [[[task standardInput] fileHandleForWriting] writeData:data]; + [[[task standardInput] fileHandleForWriting] closeFile]; + [task waitUntilExit]; + + int status = [task terminationStatus]; + success = (status == 0); + }]; if (success) { // クリエータなどを設定 - NSFileCoordinator *coordinator = [[NSFileCoordinator alloc] initWithFilePresenter:self]; [coordinator coordinateWritingItemAtURL:url options:0 error:nil byAccessor:^(NSURL *newURL) @@ -1458,7 +1471,6 @@ - (BOOL)forceWriteToURL:(NSURL *)url ofType:(NSString *)typeName forSaveOperatio // Finder Lock がかかってたなら、再びかける if (isFinderLockOn) { __block BOOL lockSuccess = NO; - NSFileCoordinator *coordinator = [[NSFileCoordinator alloc] initWithFilePresenter:self]; [coordinator coordinateWritingItemAtURL:url options:0 error:nil byAccessor:^(NSURL *newURL) From f7703cba262d21a7e093d185b6dca390514e1416 Mon Sep 17 00:00:00 2001 From: 1024jp <1024jp@wolfrosch.com> Date: Fri, 6 Mar 2015 02:08:53 +0900 Subject: [PATCH 16/20] Disable automatic text substitutions in find panel fields --- CotEditor/Sources/CEFindPanelTextView.m | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CotEditor/Sources/CEFindPanelTextView.m b/CotEditor/Sources/CEFindPanelTextView.m index e055e89c1d..e2bf31fae5 100644 --- a/CotEditor/Sources/CEFindPanelTextView.m +++ b/CotEditor/Sources/CEFindPanelTextView.m @@ -67,6 +67,15 @@ - (instancetype)initWithCoder:(NSCoder *)coder [[self textContainer] setContainerSize:NSMakeSize(CGFLOAT_MAX, CGFLOAT_MAX)]; [self setHorizontallyResizable:YES]; + // disable automatic text substitutions + if ([self respondsToSelector:@selector(setAutomaticQuoteSubstitutionEnabled:)]) { // only on OS X 10.9 and later + [self setAutomaticQuoteSubstitutionEnabled:NO]; + [self setAutomaticDashSubstitutionEnabled:NO]; + } + [self setAutomaticTextReplacementEnabled:NO]; + [self setAutomaticSpellingCorrectionEnabled:NO]; + [self setSmartInsertDeleteEnabled:NO]; + // set subclassed layout manager for invisible characters CEFindPanelLayoutManager *layoutManager = [[CEFindPanelLayoutManager alloc] init]; [[self textContainer] replaceLayoutManager:layoutManager]; From a46a1941db4ef5b065e0c642ac524ca3f155eb01 Mon Sep 17 00:00:00 2001 From: 1024jp <1024jp@wolfrosch.com> Date: Fri, 6 Mar 2015 13:14:32 +0900 Subject: [PATCH 17/20] Tweak file coordinator option --- CotEditor/Sources/CEDocument.m | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/CotEditor/Sources/CEDocument.m b/CotEditor/Sources/CEDocument.m index 8967328542..ee689bd712 100644 --- a/CotEditor/Sources/CEDocument.m +++ b/CotEditor/Sources/CEDocument.m @@ -1538,13 +1538,18 @@ - (BOOL)canUnlockFileAtURL:(NSURL *)url isLocked:(BOOL *)isLocked lockAgain:(BOO NSFileManager *fileManager = [NSFileManager defaultManager]; NSFileCoordinator *coordinator = [[NSFileCoordinator alloc] initWithFilePresenter:self]; - [coordinator coordinateWritingItemAtURL:url options:0 + [coordinator coordinateReadingItemAtURL:url options:NSFileCoordinatorReadingWithoutChanges error:&error byAccessor:^(NSURL *newURL) { isFinderLocked = [[fileManager attributesOfItemAtPath:[newURL path] error:nil] fileIsImmutable]; - - if (isFinderLocked) { + }]; + + if (isFinderLocked) { + [coordinator coordinateWritingItemAtURL:url options:0 + error:&error + byAccessor:^(NSURL *newURL) + { // unlock file once success = [fileManager setAttributes:@{NSFileImmutable:@NO} ofItemAtPath:[newURL path] error:nil]; if (success) { @@ -1553,11 +1558,11 @@ - (BOOL)canUnlockFileAtURL:(NSURL *)url isLocked:(BOOL *)isLocked lockAgain:(BOO [fileManager setAttributes:@{NSFileImmutable:@YES} ofItemAtPath:[newURL path] error:nil]; } } - } else { - // no-lock file is always treated as success - success = YES; - } - }]; + }]; + } else { + // no-lock file is always treated as success + success = YES; + } if (isLocked) { *isLocked = isFinderLocked; From f8d14827d6e8dce46c4ae3dcd7b68830b7852103 Mon Sep 17 00:00:00 2001 From: 1024jp <1024jp@wolfrosch.com> Date: Mon, 9 Mar 2015 15:07:32 +0900 Subject: [PATCH 18/20] Update release notes (#366) --- .../Resources/en.lproj/pgs/releasenotes.html | 36 ++++++++++++++++++ .../Resources/ja.lproj/pgs/releasenotes.html | 37 +++++++++++++++++++ 2 files changed, 73 insertions(+) diff --git a/CotEditor/CotEditor.help/Contents/Resources/en.lproj/pgs/releasenotes.html b/CotEditor/CotEditor.help/Contents/Resources/en.lproj/pgs/releasenotes.html index 85ede0f818..aad264a338 100644 --- a/CotEditor/CotEditor.help/Contents/Resources/en.lproj/pgs/releasenotes.html +++ b/CotEditor/CotEditor.help/Contents/Resources/en.lproj/pgs/releasenotes.html @@ -23,6 +23,42 @@

Release Notes

+
+
+

CotEditor 2.1.2

+

release:

+
+ + +
+

Additions/Changes

+ +
    +
  • Change place to create backup files (Now, backup files are always created in ~/Library/Autosave Information/).
  • +
  • Improve find panel:
      +
    • Add scroll bars to the text fields.
    • +
    • Show invisible characters in text fields.
    • +
    • Now, “Swap ¥ and \ keys” option is also applied to the fields in the find panel.
    • +
    • Remove “Escape Character” option for regular expression search.
    • +
  • +
  • Add “Cyrillic (Windows)” to the encoding list.
  • +
  • Optimize launching speed of cot command-line tool.
  • +
+
+ + +
+

Fixes

+ +
    +
  • Fix an issue where application could hang up on saving backup file.
  • +
  • Fix an issue where unwanted find panel was shown when perform “Use Selection for Find” or “Use Selection for Replace” action.
  • +
+
+
+ + +

CotEditor 2.1.1

diff --git a/CotEditor/CotEditor.help/Contents/Resources/ja.lproj/pgs/releasenotes.html b/CotEditor/CotEditor.help/Contents/Resources/ja.lproj/pgs/releasenotes.html index e35fa6a283..0ad550bbe0 100644 --- a/CotEditor/CotEditor.help/Contents/Resources/ja.lproj/pgs/releasenotes.html +++ b/CotEditor/CotEditor.help/Contents/Resources/ja.lproj/pgs/releasenotes.html @@ -23,6 +23,42 @@

リリースノート

+
+
+

CotEditor 2.1.2

+

リリース:

+
+ + +
+

機能改善/仕様変更

+ +
    +
  • バックアップファイルの作成場所を変更 (バックアップファイルは常に ~/Library/Autosave Information/ に作成されるようになりました)
  • +
  • 検索パネルの改良:
      +
    • テキストフィールドにスクロールバーを追加
    • +
    • テキストフィールドで不可視文字を表示
    • +
    • 環境設定の「“¥”と“\”のキーを入れ替える」オプションが検索パネルのテキストフィールドにも適用されるように改良
    • +
    • 正規表現検索の「エスケープ文字」オプションを削除
    • +
  • +
  • 取り扱えるエンコーディングに「キリル文字 (Windows)」を追加<
  • +
  • cot コマンドの呼び出しパフォーマンスを改善
  • +
+
+ + +
+

バグフィックス

+ +
    +
  • 「選択範囲を検索に使用」もしくは「選択範囲を置換に使用」アクションで検索パネルが表示された不具合を修正
  • +
  • バックアップファイル作成時にアプリケーションがハングすることがあった不具合を修正
  • +
+
+
+ + +

CotEditor 2.1.1

@@ -42,6 +78,7 @@

バグフィックス

+

CotEditor 2.1.0

From bc0b6d973402424823e138dc12a28967078aa43c Mon Sep 17 00:00:00 2001 From: 1024jp <1024jp@wolfrosch.com> Date: Mon, 9 Mar 2015 16:13:06 +0900 Subject: [PATCH 19/20] Update version number to 2.1.2 (#366) --- CotEditor/Info.plist | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CotEditor/Info.plist b/CotEditor/Info.plist index aeff9b35a5..4681155995 100644 --- a/CotEditor/Info.plist +++ b/CotEditor/Info.plist @@ -953,11 +953,11 @@ CFBundlePackageType APPL CFBundleShortVersionString - 2.1.2 dev + 2.1.2 CFBundleSignature cEd1 CFBundleVersion - 2.1.2-alpha + 2.1.2 LSApplicationCategoryType public.app-category.productivity NSAppleScriptEnabled From 0ece2c722f2c9d4bb1075c0b414bca4306d7e96e Mon Sep 17 00:00:00 2001 From: USAMI Kosuke Date: Tue, 10 Mar 2015 21:20:56 +0900 Subject: [PATCH 20/20] Update release date --- .../Contents/Resources/en.lproj/pgs/releasenotes.html | 2 +- .../Contents/Resources/ja.lproj/pgs/releasenotes.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CotEditor/CotEditor.help/Contents/Resources/en.lproj/pgs/releasenotes.html b/CotEditor/CotEditor.help/Contents/Resources/en.lproj/pgs/releasenotes.html index aad264a338..77c1479912 100644 --- a/CotEditor/CotEditor.help/Contents/Resources/en.lproj/pgs/releasenotes.html +++ b/CotEditor/CotEditor.help/Contents/Resources/en.lproj/pgs/releasenotes.html @@ -26,7 +26,7 @@

Release Notes

CotEditor 2.1.2

-

release:

+

release:

diff --git a/CotEditor/CotEditor.help/Contents/Resources/ja.lproj/pgs/releasenotes.html b/CotEditor/CotEditor.help/Contents/Resources/ja.lproj/pgs/releasenotes.html index 0ad550bbe0..67b95bfa99 100644 --- a/CotEditor/CotEditor.help/Contents/Resources/ja.lproj/pgs/releasenotes.html +++ b/CotEditor/CotEditor.help/Contents/Resources/ja.lproj/pgs/releasenotes.html @@ -26,7 +26,7 @@

リリースノート

CotEditor 2.1.2

-

リリース:

+

リリース: