• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

テキストエディタ「原稿」の場所


Commit MetaInfo

Revisiond59e8c3131fcb30775202d9901efa704f67caab6 (tree)
Time2012-04-01 15:36:25
Author二鏡 <haliccon@gmai...>
Commiter二鏡

Log Message

スクリプトがタイミングによってコケる事があったのを修正。

Change Summary

Incremental Difference

--- a/Manuscript/MSDocument.mm
+++ b/Manuscript/MSDocument.mm
@@ -33,6 +33,8 @@ static NSString *sDocumentRestoreInfo = @"MSDocumentResotreInfo";
3333 static NSArray *sFontFamilyList;
3434 static NSArray *sLocalizedFamilyList;
3535
36+static NSString *envManuscriptWorkingFile = @"Manuscript_Working_File";
37+
3638 @interface MSDocument ()
3739 @property (readwrite,copy) NSString *_family;
3840 @property (readwrite,copy) NSString *_face;
@@ -411,6 +413,12 @@ static NSArray *sLocalizedFamilyList;
411413 id center = [NSNotificationCenter defaultCenter];
412414 script.writebackMode = item.outputMode;
413415 script.executor = [[MSScriptExecutor alloc] init];
416+ id file = self.fileURL;
417+ if(file)
418+ {
419+ [script.executor setEnvironmentVariable: [file path]
420+ forKey: envManuscriptWorkingFile];
421+ }
414422
415423 // input設定
416424 switch(item.inputMode)
--- a/Manuscript/MSScriptExecutor.h
+++ b/Manuscript/MSScriptExecutor.h
@@ -16,4 +16,5 @@ extern NSString *MSScriptExecutorExecutionDidEndNotification;
1616
1717 - (void)doCommand:(NSURL*)url;
1818 - (void)abortExecution;
19+- (void)setEnvironmentVariable:(id)val forKey:(NSString*)key;
1920 @end
--- a/Manuscript/MSScriptExecutor.m
+++ b/Manuscript/MSScriptExecutor.m
@@ -18,9 +18,28 @@ NSString *MSScriptExecutorExecutionDidEndNotification = @"MSScriptExecutorDidEnd
1818 {
1919 NSTask *_task;
2020 NSMutableData *_readingData;
21+ NSMutableDictionary *_env;
2122 }
2223
2324 @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+
2443 - (void)doCommand:(NSURL*)url
2544 {
2645 // taskを起動してすぐ終了する
@@ -33,12 +52,7 @@ NSString *MSScriptExecutorExecutionDidEndNotification = @"MSScriptExecutorDidEnd
3352 _task = [[NSTask alloc] init];
3453 [_task setLaunchPath: [url path]];
3554
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];
4256
4357 [_task setStandardInput: [NSPipe pipe]];
4458 [_task setStandardOutput: [NSPipe pipe]];
@@ -80,13 +94,17 @@ NSString *MSScriptExecutorExecutionDidEndNotification = @"MSScriptExecutorDidEnd
8094 - (void)_readData:(id)aNotif
8195 {
8296 NSData *data = [[aNotif userInfo] objectForKey: NSFileHandleNotificationDataItem];
97+
8398 if([data length])
99+ {
84100 [_readingData appendData: data];
85-
86- if([_task isRunning])
101+
87102 [[aNotif object] readInBackgroundAndNotify]; // re-buffering
88- else
89- [self _finishExecution];
103+ return; // データが正しく来る限りは読み込みを続ける
104+ }
105+
106+ // データがなければ終了。taskの停止を見ておくべき?
107+ [self _finishExecution];
90108 }
91109
92110 - (void)abortExecution
--- a/Manuscript/MSTextView.mm
+++ b/Manuscript/MSTextView.mm
@@ -670,7 +670,7 @@ static CGFloat cCaretInterval = 0.6;
670670 - (NSString*)selectedString
671671 {
672672 if(inputState.is_selected_range_zero())
673- return nil;
673+ return @"";
674674
675675 id storage = pager_.content.textStorage;
676676 id ret = [[storage mutableString] substringWithRange: inputState.selectedRange];
--- a/Manuscript/Manuscript-Info.plist
+++ b/Manuscript/Manuscript-Info.plist
@@ -52,11 +52,11 @@
5252 <key>CFBundlePackageType</key>
5353 <string>APPL</string>
5454 <key>CFBundleShortVersionString</key>
55- <string>1.2</string>
55+ <string>1.2.1</string>
5656 <key>CFBundleSignature</key>
5757 <string>????</string>
5858 <key>CFBundleVersion</key>
59- <string>3</string>
59+ <string>4</string>
6060 <key>LSApplicationCategoryType</key>
6161 <string>public.app-category.productivity</string>
6262 <key>LSHasLocalizedDisplayName</key>