aboutsummaryrefslogtreecommitdiffstats
path: root/Source/CustomQuery.m
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2009-05-07 08:29:42 +0000
committerBibiko <bibiko@eva.mpg.de>2009-05-07 08:29:42 +0000
commit166b844e7a4e84b79d2cfad5cac1d5d8333988f5 (patch)
tree21b9eb5bd92f22e4114688c0aaaf11d231a1efb4 /Source/CustomQuery.m
parent2a4bbd2e425fbbf0ffd20a9c36921778b92963ae (diff)
downloadsequelpro-166b844e7a4e84b79d2cfad5cac1d5d8333988f5.tar.gz
sequelpro-166b844e7a4e84b79d2cfad5cac1d5d8333988f5.tar.bz2
sequelpro-166b844e7a4e84b79d2cfad5cac1d5d8333988f5.zip
• added "Query Editor" preference pane for setting colors, font, and modes (from the CQ's action gear which are still customizable there)
- in addition to the syntax colors it's now possible to change the fore/background color as well • added "Update Help while typing" feature in the Custom Query editor • first trial to improve syntax highlighting for large text in the Custom Query editor - if the text is larger than 10k the highlighting is performed only for the visible text area ±bias (3.5k) - if the user changes the visible area the highlighting follows time-delayed 500ms) to assure user interaction - a test with a 45MB SQL dump worked (of course a tick slowier) -- todo: improve prev/current query detection (mainly the SQLParser) - if the text size is > 6MB the completion list won't show words from the text due to parsing time - if the text size is > 6MB the line numbering will be disabled due to performance issue (improvements should follow) • some tiny clarification changes in the syntax highlighting code • some minor code cosmetics
Diffstat (limited to 'Source/CustomQuery.m')
-rw-r--r--Source/CustomQuery.m48
1 files changed, 28 insertions, 20 deletions
diff --git a/Source/CustomQuery.m b/Source/CustomQuery.m
index 2289b561..5efc0ffc 100644
--- a/Source/CustomQuery.m
+++ b/Source/CustomQuery.m
@@ -190,7 +190,6 @@ closes the sheet
[NSApp stopModal];
}
-
/*
* Perform simple actions (which don't require their own method), triggered by selecting the appropriate menu item
* in the "gear" action menu displayed beneath the cusotm query view.
@@ -228,7 +227,7 @@ closes the sheet
// "Indent new lines" toggle
if (sender == autoindentMenuItem) {
- BOOL enableAutoindent = ([autoindentMenuItem state] == NSOffState);
+ BOOL enableAutoindent = !([autoindentMenuItem state] == NSOffState);
[prefs setBool:enableAutoindent forKey:@"CustomQueryAutoindent"];
[prefs synchronize];
[autoindentMenuItem setState:enableAutoindent?NSOnState:NSOffState];
@@ -237,7 +236,7 @@ closes the sheet
// "Auto-pair characters" toggle
if (sender == autopairMenuItem) {
- BOOL enableAutopair = ([autopairMenuItem state] == NSOffState);
+ BOOL enableAutopair = !([autopairMenuItem state] == NSOffState);
[prefs setBool:enableAutopair forKey:@"CustomQueryAutopair"];
[prefs synchronize];
[autopairMenuItem setState:enableAutopair?NSOnState:NSOffState];
@@ -246,7 +245,7 @@ closes the sheet
// "Auto-help" toggle
if (sender == autohelpMenuItem) {
- BOOL enableAutohelp = ([autohelpMenuItem state] == NSOffState);
+ BOOL enableAutohelp = !([autohelpMenuItem state] == NSOffState);
[prefs setBool:enableAutohelp forKey:@"CustomQueryAutohelp"];
[prefs synchronize];
[autohelpMenuItem setState:enableAutohelp?NSOnState:NSOffState];
@@ -255,7 +254,7 @@ closes the sheet
// "Auto-uppercase keywords" toggle
if (sender == autouppercaseKeywordsMenuItem) {
- BOOL enableAutouppercaseKeywords = ([autouppercaseKeywordsMenuItem state] == NSOffState);
+ BOOL enableAutouppercaseKeywords = !([autouppercaseKeywordsMenuItem state] == NSOffState);
[prefs setBool:enableAutouppercaseKeywords forKey:@"CustomQueryAutouppercaseKeywords"];
[prefs synchronize];
[autouppercaseKeywordsMenuItem setState:enableAutouppercaseKeywords?NSOnState:NSOffState];
@@ -910,8 +909,20 @@ sets the connection (received from TableDocument) and makes things that have to
}
// Set up the interface
- [customQueryView setVerticalMotionCanBeginDrag:NO];
+ // Bind backgroundColor
+ [textView setAllowsDocumentBackgroundColorChange:YES];
+ NSMutableDictionary *bindingOptions = [NSMutableDictionary dictionary];
+ [bindingOptions setObject:NSUnarchiveFromDataTransformerName
+ forKey:@"NSValueTransformerName"];
+ [textView bind: @"backgroundColor"
+ toObject: [NSUserDefaultsController sharedUserDefaultsController]
+ withKeyPath:@"values.CustomQueryEditorBackgroundColor"
+ options:bindingOptions];
[textView setFont:[NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:@"CustomQueryEditorFont"]]];
+ [textView setBackgroundColor:[NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:@"CustomQueryEditorBackgroundColor"]]];
+ [textView setTextColor:[NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:@"CustomQueryEditorTextColor"]]];
+
+ [customQueryView setVerticalMotionCanBeginDrag:NO];
[textView setContinuousSpellCheckingEnabled:NO];
[autoindentMenuItem setState:([prefs boolForKey:@"CustomQueryAutoindent"]?NSOnState:NSOffState)];
[textView setAutoindent:[prefs boolForKey:@"CustomQueryAutoindent"]];
@@ -1343,23 +1354,9 @@ traps enter key and
[runSelectionMenuItem setTitle:NSLocalizedString(@"Run Selected Text", @"Title of action menu item to run selected text in custom query view")];
[runSelectionMenuItem setEnabled:YES];
}
-}
-
-
-/*
- * Save the custom query editor font if it is changed.
- */
-- (void)textViewDidChangeTypingAttributes:(NSNotification *)aNotification
-{
- // Only save the font if prefs have been loaded, ensuring the saved font has been applied once.
- if (prefs) {
- [prefs setObject:[NSArchiver archivedDataWithRootObject:[textView font]] forKey:@"CustomQueryEditorFont"];
- }
}
-
-
#pragma mark -
#pragma mark TableView notifications
@@ -1377,6 +1374,16 @@ traps enter key and
}
}
+/*
+ * Save the custom query editor font if it is changed.
+ */
+- (void)textViewDidChangeTypingAttributes:(NSNotification *)aNotification
+{
+
+ // Only save the font if prefs have been loaded, ensuring the saved font has been applied once.
+ if (prefs)
+ [prefs setObject:[NSArchiver archivedDataWithRootObject:[textView font]] forKey:@"CustomQueryEditorFont"];
+}
#pragma mark -
@@ -1403,6 +1410,7 @@ traps enter key and
*/
- (void)showHelpFor:(NSString *)searchString addToHistory:(BOOL)addToHistory
{
+
NSString * helpString = [self getHTMLformattedMySQLHelpFor:searchString];
// Order out resp. init the Help window if not visible