From 890247960876e8dd987dd44ec98da4300b6a0fd3 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Sat, 30 Jan 2010 22:29:34 +0000 Subject: =?UTF-8?q?=E2=80=A2=20CMTextView's=20colours=20are=20set=20via=20?= =?UTF-8?q?observer,=20live=20changed=20in=20editable=20textviews=20?= =?UTF-8?q?=E2=80=A2=20added=20Preference=20setting=20"Table=20font"=20in?= =?UTF-8?q?=20"Table"=20pane=20to=20set=20the=20table=20font/size=20for=20?= =?UTF-8?q?all=20result=20tables=20(Content,=20Custom=20Query)=20=E2=80=A2?= =?UTF-8?q?=C2=A0added=20to=20SPTableView=20the=20method=20setFont:=20?= =?UTF-8?q?=E2=80=A2=20fixed=20the=20initialisation=20of=20vars=20in=20CMT?= =?UTF-8?q?extView=20(fixes=20the=20displaying=20of=20create=20syntax)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/CMTextView.m | 88 ++++++++++++++++++++++++++++++++--------------------- 1 file changed, 53 insertions(+), 35 deletions(-) (limited to 'Source/CMTextView.m') diff --git a/Source/CMTextView.m b/Source/CMTextView.m index e025296c..5afd08cb 100644 --- a/Source/CMTextView.m +++ b/Source/CMTextView.m @@ -169,6 +169,19 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) prefs = [[NSUserDefaults standardUserDefaults] retain]; + [self setQueryHiliteColor:[NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPCustomQueryEditorHighlightQueryColor]]]; + [self setQueryEditorBackgroundColor:[NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPCustomQueryEditorBackgroundColor]]]; + [self setCommentColor:[NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPCustomQueryEditorCommentColor]]]; + [self setQuoteColor:[NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPCustomQueryEditorQuoteColor]]]; + [self setKeywordColor:[NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPCustomQueryEditorSQLKeywordColor]]]; + [self setBacktickColor:[NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPCustomQueryEditorBacktickColor]]]; + [self setNumericColor:[NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPCustomQueryEditorNumericColor]]]; + [self setVariableColor:[NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPCustomQueryEditorVariableColor]]]; + [self setOtherTextColor:[NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPCustomQueryEditorTextColor]]]; + [self setTextColor:[self otherTextColor]]; + [self setInsertionPointColor:[self otherTextColor]]; + [self setShouldHiliteQuery:[prefs boolForKey:SPCustomQueryHighlightCurrentQuery]]; + // Register observers for the when editor background colors preference changes [prefs addObserver:self forKeyPath:SPCustomQueryEditorBackgroundColor options:NSKeyValueObservingOptionNew context:NULL]; [prefs addObserver:self forKeyPath:SPCustomQueryEditorHighlightQueryColor options:NSKeyValueObservingOptionNew context:NULL]; @@ -205,32 +218,32 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) [self setNeedsDisplay:YES]; } else if ([keyPath isEqualToString:SPCustomQueryEditorCommentColor]) { [self setCommentColor:[NSUnarchiver unarchiveObjectWithData:[change objectForKey:NSKeyValueChangeNewKey]]]; - if([[self string] length]<100000) + if([[self string] length]<100000 && [self isEditable]) [self performSelector:@selector(doSyntaxHighlighting) withObject:nil afterDelay:0.1]; } else if ([keyPath isEqualToString:SPCustomQueryEditorQuoteColor]) { [self setQuoteColor:[NSUnarchiver unarchiveObjectWithData:[change objectForKey:NSKeyValueChangeNewKey]]]; - if([[self string] length]<100000) + if([[self string] length]<100000 && [self isEditable]) [self performSelector:@selector(doSyntaxHighlighting) withObject:nil afterDelay:0.1]; } else if ([keyPath isEqualToString:SPCustomQueryEditorSQLKeywordColor]) { [self setKeywordColor:[NSUnarchiver unarchiveObjectWithData:[change objectForKey:NSKeyValueChangeNewKey]]]; - if([[self string] length]<100000) + if([[self string] length]<100000 && [self isEditable]) [self performSelector:@selector(doSyntaxHighlighting) withObject:nil afterDelay:0.1]; } else if ([keyPath isEqualToString:SPCustomQueryEditorBacktickColor]) { [self setBacktickColor:[NSUnarchiver unarchiveObjectWithData:[change objectForKey:NSKeyValueChangeNewKey]]]; - if([[self string] length]<100000) + if([[self string] length]<100000 && [self isEditable]) [self performSelector:@selector(doSyntaxHighlighting) withObject:nil afterDelay:0.1]; } else if ([keyPath isEqualToString:SPCustomQueryEditorNumericColor]) { [self setNumericColor:[NSUnarchiver unarchiveObjectWithData:[change objectForKey:NSKeyValueChangeNewKey]]]; - if([[self string] length]<100000) + if([[self string] length]<100000 && [self isEditable]) [self performSelector:@selector(doSyntaxHighlighting) withObject:nil afterDelay:0.1]; } else if ([keyPath isEqualToString:SPCustomQueryEditorVariableColor]) { [self setVariableColor:[NSUnarchiver unarchiveObjectWithData:[change objectForKey:NSKeyValueChangeNewKey]]]; - if([[self string] length]<100000) + if([[self string] length]<100000 && [self isEditable]) [self performSelector:@selector(doSyntaxHighlighting) withObject:nil afterDelay:0.1]; } else if ([keyPath isEqualToString:SPCustomQueryEditorTextColor]) { [self setOtherTextColor:[NSUnarchiver unarchiveObjectWithData:[change objectForKey:NSKeyValueChangeNewKey]]]; [self setTextColor:[self otherTextColor]]; - if([[self string] length]<100000) + if([[self string] length]<100000 && [self isEditable]) [self performSelector:@selector(doSyntaxHighlighting) withObject:nil afterDelay:0.1]; } } @@ -2981,37 +2994,42 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) [[self queryEditorBackgroundColor] setFill]; NSRectFill(rect); - // Highlightes the current query if set in the Pref and no snippet session - // and if nothing is selected in the text view - if ([self shouldHiliteQuery] && snippetControlCounter<=-1 && ![self selectedRange].length) { - NSUInteger rectCount; - [[self textStorage] ensureAttributesAreFixedInRange:[self queryRange]]; - NSRectArray queryRects = [[self layoutManager] rectArrayForCharacterRange: [self queryRange] - withinSelectedCharacterRange: [self queryRange] - inTextContainer: [self textContainer] - rectCount: &rectCount ]; - [[self queryHiliteColor] setFill]; - NSRectFillList(queryRects, rectCount); - } + if([[self delegate] isKindOfClass:[CustomQuery class]]) { + + // Highlightes the current query if set in the Pref and no snippet session + // and if nothing is selected in the text view + if ([self shouldHiliteQuery] && snippetControlCounter<=-1 && ![self selectedRange].length) { + NSUInteger rectCount; + [[self textStorage] ensureAttributesAreFixedInRange:[self queryRange]]; + NSRectArray queryRects = [[self layoutManager] rectArrayForCharacterRange: [self queryRange] + withinSelectedCharacterRange: [self queryRange] + inTextContainer: [self textContainer] + rectCount: &rectCount ]; + [[self queryHiliteColor] setFill]; + NSRectFillList(queryRects, rectCount); + } - // Highlight snippets coming from the Query Favorite text macro - if(snippetControlCounter > -1) { - for(NSUInteger i=0; i -1) { - // choose the colors for the snippet parts - if(i == currentSnippetIndex) { - [[NSColor colorWithCalibratedRed:1.0 green:0.6 blue:0.0 alpha:0.4] setFill]; - [[NSColor colorWithCalibratedRed:1.0 green:0.6 blue:0.0 alpha:0.8] setStroke]; - } else { - [[NSColor colorWithCalibratedRed:1.0 green:0.8 blue:0.2 alpha:0.2] setFill]; - [[NSColor colorWithCalibratedRed:1.0 green:0.8 blue:0.2 alpha:0.5] setStroke]; + // Highlight snippets coming from the Query Favorite text macro + if(snippetControlCounter > -1) { + for(NSUInteger i=0; i -1) { + // choose the colors for the snippet parts + if(i == currentSnippetIndex) { + [[NSColor colorWithCalibratedRed:1.0 green:0.6 blue:0.0 alpha:0.4] setFill]; + [[NSColor colorWithCalibratedRed:1.0 green:0.6 blue:0.0 alpha:0.8] setStroke]; + } else { + [[NSColor colorWithCalibratedRed:1.0 green:0.8 blue:0.2 alpha:0.2] setFill]; + [[NSColor colorWithCalibratedRed:1.0 green:0.8 blue:0.2 alpha:0.5] setStroke]; + } + NSBezierPath *snippetPath = [self roundedBezierPathAroundRange: NSMakeRange(snippetControlArray[i][0],snippetControlArray[i][1]) ]; + [snippetPath fill]; + [snippetPath stroke]; } - NSBezierPath *snippetPath = [self roundedBezierPathAroundRange: NSMakeRange(snippetControlArray[i][0],snippetControlArray[i][1]) ]; - [snippetPath fill]; - [snippetPath stroke]; } } + } + [super drawRect:rect]; } @@ -3275,11 +3293,11 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) } /* - * Show only setable modes in the font panel + * Set font panel's valid modes */ - (NSUInteger)validModesForFontPanel:(NSFontPanel *)fontPanel { - return (NSFontPanelFaceModeMask | NSFontPanelSizeModeMask); + return (NSFontPanelSizeModeMask|NSFontPanelCollectionModeMask); } #pragma mark - -- cgit v1.2.3