aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2009-06-05 19:29:41 +0000
committerBibiko <bibiko@eva.mpg.de>2009-06-05 19:29:41 +0000
commit1f938f1b54551a8418315301f7c5a2bca080e04d (patch)
treee2aab0666e2c53f00b1a3290676758f3e1e2d72d /Source
parent7b5f4d96727a505b67b7970e0b4f2ca1de0394a2 (diff)
downloadsequelpro-1f938f1b54551a8418315301f7c5a2bca080e04d.tar.gz
sequelpro-1f938f1b54551a8418315301f7c5a2bca080e04d.tar.bz2
sequelpro-1f938f1b54551a8418315301f7c5a2bca080e04d.zip
• added to Editor Preferences:
- "Query Background" color - checkbox "Highlight Current Query"
Diffstat (limited to 'Source')
-rw-r--r--Source/CustomQuery.h1
-rw-r--r--Source/CustomQuery.m23
-rw-r--r--Source/SPPreferenceController.m1
3 files changed, 21 insertions, 4 deletions
diff --git a/Source/CustomQuery.h b/Source/CustomQuery.h
index 87f739ae..0be5dc0d 100644
--- a/Source/CustomQuery.h
+++ b/Source/CustomQuery.h
@@ -80,6 +80,7 @@
NSString *usedQuery;
NSRange currentQueryRange;
NSArray *currentQueryRanges;
+ BOOL hasBackgroundAttribute;
NSString *mySQLversion;
int queryStartPosition;
diff --git a/Source/CustomQuery.m b/Source/CustomQuery.m
index 099757a4..4d1d684d 100644
--- a/Source/CustomQuery.m
+++ b/Source/CustomQuery.m
@@ -906,6 +906,8 @@
queryFavorites = [[NSMutableArray array] retain];
}
+ hasBackgroundAttribute = NO;
+
// Set up the interface
// Bind backgroundColor
[textView setAllowsDocumentBackgroundColorChange:YES];
@@ -933,6 +935,7 @@
[autouppercaseKeywordsMenuItem setState:([prefs boolForKey:@"CustomQueryAutoUppercaseKeywords"]?NSOnState:NSOffState)];
[textView setAutouppercaseKeywords:[prefs boolForKey:@"CustomQueryAutoUppercaseKeywords"]];
[queryFavoritesView registerForDraggedTypes:[NSArray arrayWithObjects:@"SequelProPasteboard", nil]];
+
while ( (column = [enumerator nextObject]) )
{
if ( [prefs boolForKey:@"UseMonospacedFonts"] ) {
@@ -1264,8 +1267,16 @@
// Ensure that the notification is from the custom query text view
if ( [aNotification object] != textView ) return;
- // Remove all background color attributes
- [[textView textStorage] removeAttribute:NSBackgroundColorAttributeName range:NSMakeRange(0,[[textView string] length])];
+ // Remove all background color attributes for highlighting the current query
+ if([prefs boolForKey:@"CustomQueryHighlightCurrentQuery"]) {
+ [[textView textStorage] removeAttribute:NSBackgroundColorAttributeName range:NSMakeRange(0,[[textView string] length])];
+ } else {
+ // ensure that we do it only once
+ if(hasBackgroundAttribute) {
+ [[textView textStorage] removeAttribute:NSBackgroundColorAttributeName range:NSMakeRange(0,[[textView string] length])];
+ hasBackgroundAttribute = NO;
+ }
+ }
BOOL isLookBehind = YES;
NSRange currentSelection = [textView selectedRange];
@@ -1275,10 +1286,14 @@
// Highlight by setting a background color the current query
// if nothing is selected
if(qRange.length && !currentSelection.length) {
- [[textView textStorage] addAttribute: NSBackgroundColorAttributeName
- value: [NSColor colorWithDeviceRed:0.95 green:0.95 blue:0.95 alpha:1]
+ if([prefs boolForKey:@"CustomQueryHighlightCurrentQuery"]) {
+ [[textView textStorage] addAttribute: NSBackgroundColorAttributeName
+ value: [NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:@"CustomQueryEditorHighlightQueryColor"]]
range: qRange ];
+ hasBackgroundAttribute = YES;
+ }
currentQueryRange = qRange;
+
} else {
currentQueryRange = NSMakeRange(0, 0);
}
diff --git a/Source/SPPreferenceController.m b/Source/SPPreferenceController.m
index b6395c3c..0d77a63f 100644
--- a/Source/SPPreferenceController.m
+++ b/Source/SPPreferenceController.m
@@ -820,6 +820,7 @@
[prefs setObject:[NSArchiver archivedDataWithRootObject:[NSColor colorWithDeviceRed:0.000 green:0.000 blue:0.658 alpha:1.000]] forKey:@"CustomQueryEditorBacktickColor"];
[prefs setObject:[NSArchiver archivedDataWithRootObject:[NSColor colorWithDeviceRed:0.506 green:0.263 blue:0.000 alpha:1.000]] forKey:@"CustomQueryEditorNumericColor"];
[prefs setObject:[NSArchiver archivedDataWithRootObject:[NSColor colorWithDeviceRed:0.500 green:0.500 blue:0.500 alpha:1.000]] forKey:@"CustomQueryEditorVariableColor"];
+ [prefs setObject:[NSArchiver archivedDataWithRootObject:[NSColor colorWithDeviceRed:0.950 green:0.950 blue:0.950 alpha:1.000]] forKey:@"CustomQueryEditorHighlightQueryColor"];
[prefs setObject:[NSArchiver archivedDataWithRootObject:[NSColor blackColor]] forKey:@"CustomQueryEditorTextColor"];
[prefs setObject:[NSArchiver archivedDataWithRootObject:[NSColor blackColor]] forKey:@"CustomQueryEditorCaretColor"];
[prefs setObject:[NSArchiver archivedDataWithRootObject:[NSColor whiteColor]] forKey:@"CustomQueryEditorBackgroundColor"];