aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPBundleHTMLOutputController.m
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2011-01-14 10:16:04 +0000
committerBibiko <bibiko@eva.mpg.de>2011-01-14 10:16:04 +0000
commite4afc0cda57f53dbbb5020a88d85777385cbc941 (patch)
tree8ce697f1acd9f43f3fd98beb35dfc6aa2df7b690 /Source/SPBundleHTMLOutputController.m
parenteec292b2a6a348f061630bebc5bfd7d39aa57ea0 (diff)
downloadsequelpro-e4afc0cda57f53dbbb5020a88d85777385cbc941.tar.gz
sequelpro-e4afc0cda57f53dbbb5020a88d85777385cbc941.tar.bz2
sequelpro-e4afc0cda57f53dbbb5020a88d85777385cbc941.zip
• fixed issue to highlight the correct current query after undoing, i.e. do not using the cache
• added SP_SELECTED_TEXT_RANGE shell variable for Bundle support of scope Input Text • added 'insertText', 'setText', 'setSelectedTextRange' JavaScript functions to window.system bridge
Diffstat (limited to 'Source/SPBundleHTMLOutputController.m')
-rw-r--r--Source/SPBundleHTMLOutputController.m72
1 files changed, 71 insertions, 1 deletions
diff --git a/Source/SPBundleHTMLOutputController.m b/Source/SPBundleHTMLOutputController.m
index 7ba67403..12af6bcf 100644
--- a/Source/SPBundleHTMLOutputController.m
+++ b/Source/SPBundleHTMLOutputController.m
@@ -364,6 +364,12 @@
return @"run";
if (aSelector == @selector(getShellEnvironmentForName:))
return @"getShellEnvironmentForName";
+ if (aSelector == @selector(insertText:))
+ return @"insertText";
+ if (aSelector == @selector(setText:))
+ return @"setText";
+ if (aSelector == @selector(setSelectedTextRange:))
+ return @"setSelectedTextRange";
if (aSelector == @selector(makeHTMLOutputWindowKeyWindow))
return @"makeHTMLOutputWindowKeyWindow";
if (aSelector == @selector(closeHTMLOutputWindow))
@@ -378,6 +384,15 @@
if (selector == @selector(getShellEnvironmentForName:)) {
return NO;
}
+ if (selector == @selector(insertText:)) {
+ return NO;
+ }
+ if (selector == @selector(setText:)) {
+ return NO;
+ }
+ if (selector == @selector(setSelectedTextRange:)) {
+ return NO;
+ }
if (selector == @selector(makeHTMLOutputWindowKeyWindow)) {
return NO;
}
@@ -394,6 +409,15 @@
if (strcmp(property, "getShellEnvironmentForName") == 0) {
return NO;
}
+ if (strcmp(property, "insertText") == 0) {
+ return NO;
+ }
+ if (strcmp(property, "setText") == 0) {
+ return NO;
+ }
+ if (strcmp(property, "setSelectedTextRange") == 0) {
+ return NO;
+ }
if (strcmp(property, "makeHTMLOutputWindowKeyWindow") == 0) {
return NO;
}
@@ -447,7 +471,7 @@
/**
* JavaScript window.system.makeHTMLOutputWindowKeyWindow() function
- * to make the HTML output window the first responder
+ * to close the HTML window
*/
- (void)closeHTMLOutputWindow
{
@@ -455,6 +479,52 @@
}
/**
+ * JavaScript window.system.insertText(text) function
+ * to insert text into the first responder
+ */
+- (void)insertText:(NSString*)text
+{
+ id firstResponder = [[NSApp keyWindow] firstResponder];
+ if([firstResponder isKindOfClass:[NSTextView class]]) {
+ [firstResponder insertText:text];
+ return;
+ }
+ NSBeep();
+}
+
+/**
+ * JavaScript window.system.setText(text) function
+ * to set the content of the first responder to text
+ */
+- (void)setText:(NSString*)text
+{
+ id firstResponder = [[NSApp keyWindow] firstResponder];
+ if([firstResponder isKindOfClass:[NSTextView class]]) {
+ [firstResponder setSelectedRange:NSMakeRange(0, [[firstResponder string] length])];
+ [firstResponder insertText:text];
+ return;
+ }
+ NSBeep();
+}
+
+/**
+ * JavaScript window.system.setSelectedRange({location,length}) function
+ * to set the selection range of the first responder
+ */
+- (void)setSelectedTextRange:(NSString*)range
+{
+ id firstResponder = [[NSApp keyWindow] firstResponder];
+ if([firstResponder isKindOfClass:[NSTextView class]]) {
+ NSRange theRange = NSIntersectionRange(NSRangeFromString(range), NSMakeRange(0, [[firstResponder string] length]));
+ if(theRange.location != NSNotFound) {
+ [firstResponder setSelectedRange:theRange];
+ }
+ return;
+ }
+ NSBeep();
+}
+
+/**
* JavaScript window.system.run('a_command'|new Array('a_command', 'uuid')) function
* to return the result of the BASH command a_command
*/