diff options
author | Bibiko <bibiko@eva.mpg.de> | 2009-06-05 19:29:41 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2009-06-05 19:29:41 +0000 |
commit | 1f938f1b54551a8418315301f7c5a2bca080e04d (patch) | |
tree | e2aab0666e2c53f00b1a3290676758f3e1e2d72d /Source/CustomQuery.m | |
parent | 7b5f4d96727a505b67b7970e0b4f2ca1de0394a2 (diff) | |
download | sequelpro-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/CustomQuery.m')
-rw-r--r-- | Source/CustomQuery.m | 23 |
1 files changed, 19 insertions, 4 deletions
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); } |