テキストエディタ「原稿」の場所
Revision | d59e8c3131fcb30775202d9901efa704f67caab6 (tree) |
---|---|
Time | 2012-04-01 15:36:25 |
Author | 二鏡 <haliccon@gmai...> |
Commiter | 二鏡 |
スクリプトがタイミングによってコケる事があったのを修正。
@@ -33,6 +33,8 @@ static NSString *sDocumentRestoreInfo = @"MSDocumentResotreInfo"; | ||
33 | 33 | static NSArray *sFontFamilyList; |
34 | 34 | static NSArray *sLocalizedFamilyList; |
35 | 35 | |
36 | +static NSString *envManuscriptWorkingFile = @"Manuscript_Working_File"; | |
37 | + | |
36 | 38 | @interface MSDocument () |
37 | 39 | @property (readwrite,copy) NSString *_family; |
38 | 40 | @property (readwrite,copy) NSString *_face; |
@@ -411,6 +413,12 @@ static NSArray *sLocalizedFamilyList; | ||
411 | 413 | id center = [NSNotificationCenter defaultCenter]; |
412 | 414 | script.writebackMode = item.outputMode; |
413 | 415 | script.executor = [[MSScriptExecutor alloc] init]; |
416 | + id file = self.fileURL; | |
417 | + if(file) | |
418 | + { | |
419 | + [script.executor setEnvironmentVariable: [file path] | |
420 | + forKey: envManuscriptWorkingFile]; | |
421 | + } | |
414 | 422 | |
415 | 423 | // input設定 |
416 | 424 | switch(item.inputMode) |
@@ -16,4 +16,5 @@ extern NSString *MSScriptExecutorExecutionDidEndNotification; | ||
16 | 16 | |
17 | 17 | - (void)doCommand:(NSURL*)url; |
18 | 18 | - (void)abortExecution; |
19 | +- (void)setEnvironmentVariable:(id)val forKey:(NSString*)key; | |
19 | 20 | @end |
@@ -18,9 +18,28 @@ NSString *MSScriptExecutorExecutionDidEndNotification = @"MSScriptExecutorDidEnd | ||
18 | 18 | { |
19 | 19 | NSTask *_task; |
20 | 20 | NSMutableData *_readingData; |
21 | + NSMutableDictionary *_env; | |
21 | 22 | } |
22 | 23 | |
23 | 24 | @synthesize input, result; |
25 | +- (id)init | |
26 | +{ | |
27 | + _env = [NSMutableDictionary dictionary]; | |
28 | + | |
29 | + // デフォルト変数 | |
30 | + id locale = [NSLocale currentLocale]; | |
31 | + id lang = [locale objectForKey: NSLocaleIdentifier]; | |
32 | + [_env setValue: lang | |
33 | + forKey: @"LANG"]; | |
34 | + | |
35 | + return self; | |
36 | +} | |
37 | + | |
38 | +- (void)setEnvironmentVariable:(id)val forKey:(NSString*)key | |
39 | +{ | |
40 | + [_env setValue: val forKey: key]; | |
41 | +} | |
42 | + | |
24 | 43 | - (void)doCommand:(NSURL*)url |
25 | 44 | { |
26 | 45 | // taskを起動してすぐ終了する |
@@ -33,12 +52,7 @@ NSString *MSScriptExecutorExecutionDidEndNotification = @"MSScriptExecutorDidEnd | ||
33 | 52 | _task = [[NSTask alloc] init]; |
34 | 53 | [_task setLaunchPath: [url path]]; |
35 | 54 | |
36 | - // 現在のロケールで起動 | |
37 | - id locale = [NSLocale currentLocale]; | |
38 | - id lang = [locale objectForKey: NSLocaleIdentifier]; | |
39 | - id env = [NSDictionary dictionaryWithObjectsAndKeys: | |
40 | - lang, @"LANG", nil]; | |
41 | - [_task setEnvironment: env]; | |
55 | + [_task setEnvironment: _env]; | |
42 | 56 | |
43 | 57 | [_task setStandardInput: [NSPipe pipe]]; |
44 | 58 | [_task setStandardOutput: [NSPipe pipe]]; |
@@ -80,13 +94,17 @@ NSString *MSScriptExecutorExecutionDidEndNotification = @"MSScriptExecutorDidEnd | ||
80 | 94 | - (void)_readData:(id)aNotif |
81 | 95 | { |
82 | 96 | NSData *data = [[aNotif userInfo] objectForKey: NSFileHandleNotificationDataItem]; |
97 | + | |
83 | 98 | if([data length]) |
99 | + { | |
84 | 100 | [_readingData appendData: data]; |
85 | - | |
86 | - if([_task isRunning]) | |
101 | + | |
87 | 102 | [[aNotif object] readInBackgroundAndNotify]; // re-buffering |
88 | - else | |
89 | - [self _finishExecution]; | |
103 | + return; // データが正しく来る限りは読み込みを続ける | |
104 | + } | |
105 | + | |
106 | + // データがなければ終了。taskの停止を見ておくべき? | |
107 | + [self _finishExecution]; | |
90 | 108 | } |
91 | 109 | |
92 | 110 | - (void)abortExecution |
@@ -670,7 +670,7 @@ static CGFloat cCaretInterval = 0.6; | ||
670 | 670 | - (NSString*)selectedString |
671 | 671 | { |
672 | 672 | if(inputState.is_selected_range_zero()) |
673 | - return nil; | |
673 | + return @""; | |
674 | 674 | |
675 | 675 | id storage = pager_.content.textStorage; |
676 | 676 | id ret = [[storage mutableString] substringWithRange: inputState.selectedRange]; |
@@ -52,11 +52,11 @@ | ||
52 | 52 | <key>CFBundlePackageType</key> |
53 | 53 | <string>APPL</string> |
54 | 54 | <key>CFBundleShortVersionString</key> |
55 | - <string>1.2</string> | |
55 | + <string>1.2.1</string> | |
56 | 56 | <key>CFBundleSignature</key> |
57 | 57 | <string>????</string> |
58 | 58 | <key>CFBundleVersion</key> |
59 | - <string>3</string> | |
59 | + <string>4</string> | |
60 | 60 | <key>LSApplicationCategoryType</key> |
61 | 61 | <string>public.app-category.productivity</string> |
62 | 62 | <key>LSHasLocalizedDisplayName</key> |