aboutsummaryrefslogtreecommitdiffstats
path: root/Source/CMTextView.m
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2009-06-04 17:42:04 +0000
committerBibiko <bibiko@eva.mpg.de>2009-06-04 17:42:04 +0000
commit6d3980063a2a37d7c3310a9808312b358ebdb2d3 (patch)
treedbcb6de00b028a4b6630f03ec403cfa9d28cd179 /Source/CMTextView.m
parent4763ed6268a0c384cbd8ebbb8a324111cb7cc99d (diff)
downloadsequelpro-6d3980063a2a37d7c3310a9808312b358ebdb2d3.tar.gz
sequelpro-6d3980063a2a37d7c3310a9808312b358ebdb2d3.tar.bz2
sequelpro-6d3980063a2a37d7c3310a9808312b358ebdb2d3.zip
• fixed: suppress highlighting of the current query if something is selected
• added: "Select Active Query ^Y" context menu item to the Custom Query Editor
Diffstat (limited to 'Source/CMTextView.m')
-rw-r--r--Source/CMTextView.m30
1 files changed, 28 insertions, 2 deletions
diff --git a/Source/CMTextView.m b/Source/CMTextView.m
index 0a38712f..e519a146 100644
--- a/Source/CMTextView.m
+++ b/Source/CMTextView.m
@@ -63,6 +63,7 @@ YY_BUFFER_STATE yy_scan_string (const char *);
#define SP_CQ_SEARCH_IN_MYSQL_HELP_MENU_ITEM_TAG 1000
#define SP_CQ_COPY_AS_RTF_MENU_ITEM_TAG 1001
+#define SP_CQ_SELECT_CURRENT_QUERY_MENU_ITEM_TAG 1002
#define SP_SYNTAX_HILITE_BIAS 2000
@@ -429,6 +430,10 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
}
}
+- (void) selectCurrentQuery
+{
+ [[[[self window] delegate] valueForKeyPath:@"customQueryInstance"] selectCurrentQuery];
+}
/*
* Selects the line lineNumber relatively to a selection (if given) and scrolls to it
@@ -534,12 +539,18 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
[self copyAsRTF];
return;
}
- if([charactersIgnMod isEqualToString:@"h"]) // ^C copy as RTF
+ if([charactersIgnMod isEqualToString:@"h"]) // ^H show MySQL Help
if(curFlags==(NSControlKeyMask))
{
[self showMySQLHelpForCurrentWord:self];
return;
}
+ if([charactersIgnMod isEqualToString:@"y"]) // ⇧⌘A select current query
+ if(curFlags==(NSControlKeyMask))
+ {
+ [self selectCurrentQuery];
+ return;
+ }
if(curFlags & NSCommandKeyMask) {
if([charactersIgnMod isEqualToString:@"+"]) // increase text size by 1; ⌘+ and numpad +
{
@@ -2310,6 +2321,7 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
// Add the menu items for
// - MySQL Help for Word/Selection
// - Copy as RTF
+ // - Select Active Query
// if it doesn't yet exist
NSMenu *menu = [[self class] defaultMenu];
@@ -2330,6 +2342,16 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
[copyAsRTFMenuItem setKeyEquivalentModifierMask:NSControlKeyMask];
[menu insertItem:copyAsRTFMenuItem atIndex:2];
}
+ if ([[[self class] defaultMenu] itemWithTag:SP_CQ_SELECT_CURRENT_QUERY_MENU_ITEM_TAG] == nil)
+ {
+ NSMenuItem *selectCurrentQueryMenuItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Select Active Query", @"Select Active Query") action:@selector(selectCurrentQuery) keyEquivalent:@"q"];
+ [selectCurrentQueryMenuItem setTag:SP_CQ_SELECT_CURRENT_QUERY_MENU_ITEM_TAG];
+ [selectCurrentQueryMenuItem setKeyEquivalentModifierMask:NSControlKeyMask];
+ [menu insertItem:selectCurrentQueryMenuItem atIndex:4];
+ }
+ // Hide "Select Active Query" if self is not editable
+ [[menu itemAtIndex:4] setHidden:![self isEditable]];
+
return menu;
}
@@ -2347,7 +2369,11 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
// Enable Copy as RTF if soemthing is selected
if ([menuItem action] == @selector(copyAsRTF)) {
return ([self selectedRange].length>0);
- }
+ }
+ // Validate Select Active Query
+ if ([menuItem action] == @selector(selectCurrentQuery)) {
+ return ([self isEditable]);
+ }
return YES;
}