aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPTextViewAdditions.m
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2010-12-08 19:03:47 +0000
committerstuconnolly <stuart02@gmail.com>2010-12-08 19:03:47 +0000
commit61e398816badc49b301a6ae70c3697d581258cfb (patch)
treecca1e18f88c42556b4a5e48c1e685cb2b6574b78 /Source/SPTextViewAdditions.m
parent3fccc9c751cded1360aa22796ed3c6d700fd04c1 (diff)
parent5b88ac6a6d0c02b1b51f295cf79e84b61c1f1bd5 (diff)
downloadsequelpro-61e398816badc49b301a6ae70c3697d581258cfb.tar.gz
sequelpro-61e398816badc49b301a6ae70c3697d581258cfb.tar.bz2
sequelpro-61e398816badc49b301a6ae70c3697d581258cfb.zip
Bring outline view branch up to date with trunk (r2976:2988).
Diffstat (limited to 'Source/SPTextViewAdditions.m')
-rw-r--r--Source/SPTextViewAdditions.m48
1 files changed, 44 insertions, 4 deletions
diff --git a/Source/SPTextViewAdditions.m b/Source/SPTextViewAdditions.m
index 10f3f2e5..6ca111b5 100644
--- a/Source/SPTextViewAdditions.m
+++ b/Source/SPTextViewAdditions.m
@@ -527,7 +527,8 @@
NSString *inputAction = @"";
NSString *inputFallBackAction = @"";
NSError *err = nil;
- NSString *bundleInputFilePath = [NSString stringWithFormat:@"%@_%@", SPBundleTaskInputFilePath, [NSString stringWithNewUUID]];
+ NSString *uuid = [NSString stringWithNewUUID];
+ NSString *bundleInputFilePath = [NSString stringWithFormat:@"%@_%@", SPBundleTaskInputFilePath, uuid];
NSRange currentWordRange, currentSelectionRange, currentLineRange, currentQueryRange;
@@ -573,8 +574,9 @@
}
NSMutableDictionary *env = [NSMutableDictionary dictionary];
- [env setObject:[infoPath stringByDeletingLastPathComponent] forKey:@"SP_BUNDLE_PATH"];
- [env setObject:bundleInputFilePath forKey:@"SP_BUNDLE_INPUT_FILE"];
+ [env setObject:[infoPath stringByDeletingLastPathComponent] forKey:SPBundleShellVariableBundlePath];
+ [env setObject:bundleInputFilePath forKey:SPBundleShellVariableInputFilePath];
+ [env setObject:SPBundleScopeInputField forKey:SPBundleShellVariableScope];
if(selfIsQueryEditor && [[self delegate] currentQueryRange].length)
[env setObject:[[self string] substringWithRange:[[self delegate] currentQueryRange]] forKey:@"SP_CURRENT_QUERY"];
@@ -609,15 +611,53 @@
contextInfo:[NSDictionary dictionaryWithObjectsAndKeys:
([cmdData objectForKey:SPBundleFileNameKey])?:@"-", @"name",
NSLocalizedString(@"Input Field", @"input field menu item label"), @"scope",
+ uuid, SPBundleFileInternalexecutionUUID,
nil]
error:&err];
[[NSFileManager defaultManager] removeItemAtPath:bundleInputFilePath error:nil];
+ NSString *action = [[cmdData objectForKey:SPBundleFileOutputActionKey] lowercaseString];
+
+ // Redirect due exit code
+ if(err != nil) {
+ if([err code] == SPBundleRedirectActionNone) {
+ action = SPBundleOutputActionNone;
+ err = nil;
+ }
+ else if([err code] == SPBundleRedirectActionReplaceSection) {
+ action = SPBundleOutputActionReplaceSelection;
+ err = nil;
+ }
+ else if([err code] == SPBundleRedirectActionReplaceContent) {
+ action = SPBundleOutputActionReplaceContent;
+ err = nil;
+ }
+ else if([err code] == SPBundleRedirectActionInsertAsText) {
+ action = SPBundleOutputActionInsertAsText;
+ err = nil;
+ }
+ else if([err code] == SPBundleRedirectActionInsertAsSnippet) {
+ action = SPBundleOutputActionInsertAsSnippet;
+ err = nil;
+ }
+ else if([err code] == SPBundleRedirectActionShowAsHTML) {
+ action = SPBundleOutputActionShowAsHTML;
+ err = nil;
+ }
+ else if([err code] == SPBundleRedirectActionShowAsTextTooltip) {
+ action = SPBundleOutputActionShowAsTextTooltip;
+ err = nil;
+ }
+ else if([err code] == SPBundleRedirectActionShowAsHTMLTooltip) {
+ action = SPBundleOutputActionShowAsHTMLTooltip;
+ err = nil;
+ }
+ }
+
if(err == nil && output) {
if([cmdData objectForKey:SPBundleFileOutputActionKey] && [[cmdData objectForKey:SPBundleFileOutputActionKey] length]
&& ![[cmdData objectForKey:SPBundleFileOutputActionKey] isEqualToString:SPBundleOutputActionNone]) {
- NSString *action = [[cmdData objectForKey:SPBundleFileOutputActionKey] lowercaseString];
if([action isEqualToString:SPBundleOutputActionShowAsTextTooltip]) {
[SPTooltip showWithObject:output];