| Line 77... |
Line 77... |
| 77 |
|
77 |
|
| 78 |
- (void)showHelpUsingFile: (NSString *)file topic: (NSString*) topic
|
78 |
- (void)showHelpUsingFile: (NSString *)file topic: (NSString*) topic
|
| 79 |
{
|
79 |
{
|
| 80 |
if (!file) return;
|
80 |
if (!file) return;
|
| 81 |
if (!topic) topic=@"<unknown>";
|
81 |
if (!topic) topic=@"<unknown>";
|
| 82 |
#if R_VERSION < R_Version(2, 10, 0)
|
- |
|
| 83 |
NSString *url = [NSString stringWithFormat:@"file://%@",file];
|
- |
|
| 84 |
SLog(@"HelpManager.showHelpUsingFile:\"%@\", topic=%@, URL=%@", file, topic, url);
|
- |
|
| 85 |
#else
|
- |
|
| 86 |
NSString *url = nil;
|
82 |
NSString *url = nil;
|
| 87 |
if ([file hasPrefix:@"http://"])
|
83 |
if ([file hasPrefix:@"http://"])
|
| 88 |
url = file;
|
84 |
url = file;
|
| 89 |
else {
|
85 |
else {
|
| 90 |
int port = [[RController sharedController] helpServerPort];
|
86 |
int port = [[RController sharedController] helpServerPort];
|
| Line 96... |
Line 92... |
| 96 |
if ([file hasPrefix:home])
|
92 |
if ([file hasPrefix:home])
|
| 97 |
file = [file substringFromIndex:[home length]];
|
93 |
file = [file substringFromIndex:[home length]];
|
| 98 |
url = [NSString stringWithFormat:@"http://127.0.0.1:%d%@", port, file];
|
94 |
url = [NSString stringWithFormat:@"http://127.0.0.1:%d%@", port, file];
|
| 99 |
}
|
95 |
}
|
| 100 |
SLog(@"HelpManager.showHelpUsingFile:\"%@\", topic=%@, URL=%@", file, topic, url);
|
96 |
SLog(@"HelpManager.showHelpUsingFile:\"%@\", topic=%@, URL=%@", file, topic, url);
|
| 101 |
#endif
|
- |
|
| 102 |
if(url != nil) {
|
97 |
if(url != nil) {
|
| 103 |
if ([Preferences flagForKey:kExternalHelp withDefault:NO])
|
98 |
if ([Preferences flagForKey:kExternalHelp withDefault:NO])
|
| 104 |
[[REngine mainEngine] executeString:[NSString stringWithFormat:@"browseURL(\"%@\")", url]];
|
99 |
[[REngine mainEngine] executeString:[NSString stringWithFormat:@"browseURL(\"%@\")", url]];
|
| 105 |
else {
|
100 |
else {
|
| 106 |
[[HelpView mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]];
|
101 |
[[HelpView mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]];
|
| Line 137... |
Line 132... |
| 137 |
[[REngine mainEngine] executeString:[NSString stringWithFormat:@"print(help.search(\"%@\"))", searchString]];
|
132 |
[[REngine mainEngine] executeString:[NSString stringWithFormat:@"print(help.search(\"%@\"))", searchString]];
|
| 138 |
return;
|
133 |
return;
|
| 139 |
}
|
134 |
}
|
| 140 |
|
135 |
|
| 141 |
REngine *re = [REngine mainEngine];
|
136 |
REngine *re = [REngine mainEngine];
|
| 142 |
#if R_VERSION < R_Version(2, 10, 0)
|
- |
|
| 143 |
RSEXP *x= [re evaluateString:[NSString stringWithFormat:@"as.character(help(\"%@\", htmlhelp=TRUE))",searchString]];
|
- |
|
| 144 |
#else
|
- |
|
| 145 |
RSEXP *x= [re evaluateString:[NSString stringWithFormat:@"as.character(help(\"%@\", help_type='html'))",searchString]];
|
137 |
RSEXP *x= [re evaluateString:[NSString stringWithFormat:@"as.character(help(\"%@\", help_type='html'))",searchString]];
|
| 146 |
#endif
|
- |
|
| 147 |
if ((x==nil) || ([x string]==NULL)) {
|
138 |
if ((x==nil) || ([x string]==NULL)) {
|
| 148 |
NSString *topicString = [NSString stringWithFormat:@"Topic: %@", searchString];
|
139 |
NSString *topicString = [NSString stringWithFormat:@"Topic: %@", searchString];
|
| 149 |
int res = NSRunInformationalAlertPanel(NLS(@"Can't find help for topic, would you like to expand the search?"), topicString, NLS(@"No"), NLS(@"Yes"), nil);
|
140 |
int res = NSRunInformationalAlertPanel(NLS(@"Can't find help for topic, would you like to expand the search?"), topicString, NLS(@"No"), NLS(@"Yes"), nil);
|
| 150 |
if (!res)
|
141 |
if (!res)
|
| 151 |
[[REngine mainEngine] executeString:[NSString stringWithFormat:@"print(help.search(\"%@\"))", searchString]];
|
142 |
[[REngine mainEngine] executeString:[NSString stringWithFormat:@"print(help.search(\"%@\"))", searchString]];
|
| Line 160... |
Line 151... |
| 160 |
}
|
151 |
}
|
| 161 |
}
|
152 |
}
|
| 162 |
}
|
153 |
}
|
| 163 |
return;
|
154 |
return;
|
| 164 |
}
|
155 |
}
|
| 165 |
#if R_VERSION < R_Version(2, 10, 0)
|
- |
|
| 166 |
NSString *url = [NSString stringWithFormat:@"file://%@",[x string]];
|
- |
|
| 167 |
if(url != nil)
|
- |
|
| 168 |
[[HelpView mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]];
|
- |
|
| 169 |
|
- |
|
| 170 |
[helpWindow makeKeyAndOrderFront:self];
|
- |
|
| 171 |
[x release];
|
- |
|
| 172 |
#else
|
- |
|
| 173 |
[x release];
|
156 |
[x release];
|
| 174 |
[re executeString:[NSString stringWithFormat:@"print(help(\"%@\", help_type='html'))",searchString]];
|
157 |
[re executeString:[NSString stringWithFormat:@"print(help(\"%@\", help_type='html'))",searchString]];
|
| 175 |
#endif
|
- |
|
| 176 |
}
|
158 |
}
|
| 177 |
|
159 |
|
| 178 |
- (NSWindow*) window
|
160 |
- (NSWindow*) window
|
| 179 |
{
|
161 |
{
|
| 180 |
return helpWindow;
|
162 |
return helpWindow;
|