diff options
author | Bibiko <bibiko@eva.mpg.de> | 2010-12-12 13:32:48 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2010-12-12 13:32:48 +0000 |
commit | e8f4c4a9e16b0747647cc914c13d7597800b108d (patch) | |
tree | de3b19850afe7b07c5d84e0321e5bbb63fde8877 /Source/SPBundleHTMLOutputController.m | |
parent | e3a67c9070a9c331c68503be481a6eda18402d96 (diff) | |
download | sequelpro-e8f4c4a9e16b0747647cc914c13d7597800b108d.tar.gz sequelpro-e8f4c4a9e16b0747647cc914c13d7597800b108d.tar.bz2 sequelpro-e8f4c4a9e16b0747647cc914c13d7597800b108d.zip |
• HTML output window's JavaScript support
- changed the approach to make the HTML output window the key window; now it could be done directly via a JavaScript command: window.system.makeHTMLOutputWindowKeyWindow()
- added the chance to ask Sequel Pro via JavaScript for run-time shell variables via window.system.getShellEnvironmentForName('shell_var_name')
• more usage of constants
Diffstat (limited to 'Source/SPBundleHTMLOutputController.m')
-rw-r--r-- | Source/SPBundleHTMLOutputController.m | 46 |
1 files changed, 39 insertions, 7 deletions
diff --git a/Source/SPBundleHTMLOutputController.m b/Source/SPBundleHTMLOutputController.m index 365c15a3..1e002ab8 100644 --- a/Source/SPBundleHTMLOutputController.m +++ b/Source/SPBundleHTMLOutputController.m @@ -328,6 +328,10 @@ { if (aSelector == @selector(run:)) return @"run"; + if (aSelector == @selector(getShellEnvironmentForName:)) + return @"getShellEnvironmentForName"; + if (aSelector == @selector(makeHTMLOutputWindowKeyWindow)) + return @"makeHTMLOutputWindowKeyWindow"; return @""; } @@ -335,6 +339,12 @@ if (selector == @selector(run:)) { return NO; } + if (selector == @selector(getShellEnvironmentForName:)) { + return NO; + } + if (selector == @selector(makeHTMLOutputWindowKeyWindow)) { + return NO; + } return YES; } @@ -342,13 +352,41 @@ if (strcmp(property, "run") == 0) { return NO; } + if (strcmp(property, "getShellEnvironmentForName") == 0) { + return NO; + } + if (strcmp(property, "makeHTMLOutputWindowKeyWindow") == 0) { + return NO; + } return YES; } -- (void) windowScriptObjectAvailable:(WebScriptObject*)webScriptObject { +- (void)windowScriptObjectAvailable:(WebScriptObject*)webScriptObject { [webScriptObject setValue:self forKey:@"system"]; } +/** + * JavaScript window.system.getShellEnvironmentForName('a_key') function to + * return the value for key keyName + */ +- (NSString *)getShellEnvironmentForName:(NSString*)keyName +{ + return [[[NSApp delegate] shellEnvironment] objectForKey:keyName]; +} + +/** + * JavaScript window.system.makeHTMLOutputWindowKeyWindow() function + * to make the HTML output window the first responder + */ +- (void)makeHTMLOutputWindowKeyWindow +{ + [[self window] makeKeyAndOrderFront:nil]; +} + +/** + * JavaScript window.system.run('a_command'|new Array('a_command', 'uuid')) function + * to return the result of the BASH command a_command + */ - (NSString *)run:(id)call { @@ -376,12 +414,6 @@ if(!command) return @"No JavaScript command found."; - // Check for internal commands passed via JavaScript - if([command isEqualToString:@"_SP_self_makeKeyWindow"]) { - [[self window] makeKeyAndOrderFront:nil]; - return @""; - } - NSString *output = nil; if(uuid == nil) output = [command runBashCommandWithEnvironment:nil atCurrentDirectoryPath:nil error:&err]; |