aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2009-07-15 17:33:28 +0000
committerBibiko <bibiko@eva.mpg.de>2009-07-15 17:33:28 +0000
commit6380481880bf44e8f50a47e606a6c8357c71afa5 (patch)
tree67e1ffbd0913ede532c546806de7e9b481461b09 /Source
parentc213d86c13973d280e43bb4c5c380e72c50b703e (diff)
downloadsequelpro-6380481880bf44e8f50a47e606a6c8357c71afa5.tar.gz
sequelpro-6380481880bf44e8f50a47e606a6c8357c71afa5.tar.bz2
sequelpro-6380481880bf44e8f50a47e606a6c8357c71afa5.zip
• Comment current Query/Selection
- changed comment string to "-- " - fixed bug in uncomment - added gear menu item -- TODO: change menu item title according to selection/current query (coming soon)
Diffstat (limited to 'Source')
-rw-r--r--Source/CMTextView.m5
-rw-r--r--Source/CustomQuery.h1
-rw-r--r--Source/CustomQuery.m20
3 files changed, 17 insertions, 9 deletions
diff --git a/Source/CMTextView.m b/Source/CMTextView.m
index 27fb0dab..3720a521 100644
--- a/Source/CMTextView.m
+++ b/Source/CMTextView.m
@@ -531,11 +531,6 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
[self makeTextSizeSmaller];
return;
}
- if([charactersIgnMod isEqualToString:@"/"])
- {
- [[[[self window] delegate] valueForKeyPath:@"customQueryInstance"] commentOutQuery];
- return;
- }
}
// Only process for character autopairing if autopairing is enabled and a single character is being added.
diff --git a/Source/CustomQuery.h b/Source/CustomQuery.h
index 56f56f0d..9d6ea2df 100644
--- a/Source/CustomQuery.h
+++ b/Source/CustomQuery.h
@@ -63,6 +63,7 @@
IBOutlet NSMenuItem *autopairMenuItem;
IBOutlet NSMenuItem *autohelpMenuItem;
IBOutlet NSMenuItem *autouppercaseKeywordsMenuItem;
+ IBOutlet NSMenuItem *commentCurrentQueryOrSelectionMenuItem;
IBOutlet NSWindow *helpWebViewWindow;
IBOutlet WebView *helpWebView;
diff --git a/Source/CustomQuery.m b/Source/CustomQuery.m
index 00834f80..59be27f8 100644
--- a/Source/CustomQuery.m
+++ b/Source/CustomQuery.m
@@ -212,6 +212,12 @@
[textView shiftSelectionLeft];
}
+ // "Comment Current Query/Selection" menu item - Add or remove "-- " for each line
+ // in the current query or selection
+ if (sender == commentCurrentQueryOrSelectionMenuItem) {
+ [self commentOutQuery];
+ }
+
// "Completion List" menu item - used to autocomplete. Uses a different shortcut to avoid the menu button flickering
// on normal autocomplete usage.
if (sender == completionListMenuItem) {
@@ -927,6 +933,9 @@
[textView setSelectedRange:currentQueryRange];
}
+/*
+ * Add or remove "-- " for each line in the current query or selection
+ */
- (void)commentOutQuery
{
@@ -945,11 +954,14 @@
workingRange = currentQueryRange;
NSMutableString *n = [NSMutableString string];
- [n setString:[NSString stringWithFormat:@"# %@", [[textView string] substringWithRange:workingRange]]];
- [n replaceOccurrencesOfRegex:@"\\n(?=.)" withString:@"\n# "];
- [n replaceOccurrencesOfRegex:@"\\n# # " withString:@"\n"];
- [n replaceOccurrencesOfRegex:@"^# # " withString:@""];
+ [n setString:[NSString stringWithFormat:@"-- %@", [[textView string] substringWithRange:workingRange]]];
+ [n replaceOccurrencesOfRegex:@"\\n(?=.)" withString:@"\n-- "];
+ // comment out if at least one line is already commented out
+ if(!([n isMatchedByRegex:@"(\\n-- --|^-- --)"] && [n isMatchedByRegex:@"(\\n-- |^-- )(?!-)"])) {
+ [n replaceOccurrencesOfRegex:@"\\n-- -- " withString:@"\n"];
+ [n replaceOccurrencesOfRegex:@"^-- -- " withString:@""];
+ }
[textView setSelectedRange:workingRange];
[textView insertText:n];