aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-01-27 17:48:11 +0000
committerBibiko <bibiko@eva.mpg.de>2010-01-27 17:48:11 +0000
commit98d651758a14f1675a605000cd1813d7fc64695a (patch)
treed8e5595d6ffdfab8fda7aaebea2f7017d56c6df5 /Source
parent5c01336855fde8694dfe2c9060c7e8f43b61d950 (diff)
downloadsequelpro-98d651758a14f1675a605000cd1813d7fc64695a.tar.gz
sequelpro-98d651758a14f1675a605000cd1813d7fc64695a.tar.bz2
sequelpro-98d651758a14f1675a605000cd1813d7fc64695a.zip
• improved the graphical representation of text macro snippets
Diffstat (limited to 'Source')
-rw-r--r--Source/CMTextView.h2
-rw-r--r--Source/CMTextView.m25
-rw-r--r--Source/CustomQuery.m2
3 files changed, 22 insertions, 7 deletions
diff --git a/Source/CMTextView.h b/Source/CMTextView.h
index ab7ed1af..96028a5e 100644
--- a/Source/CMTextView.h
+++ b/Source/CMTextView.h
@@ -103,4 +103,6 @@ static inline void NSMutableAttributedStringAddAttributeValueRange (NSMutableAtt
- (NSUInteger)characterIndexOfPoint:(NSPoint)aPoint;
- (void)insertFileContentOfFile:(NSString *)aPath;
+- (BOOL)isSnippetMode;
+
@end
diff --git a/Source/CMTextView.m b/Source/CMTextView.m
index eb2abff4..cadd71c4 100644
--- a/Source/CMTextView.m
+++ b/Source/CMTextView.m
@@ -1125,6 +1125,15 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
}
+/*
+ * Return YES if user interacts with snippets (is needed mainly for suppressing
+ * the highlighting of the current query)
+ */
+- (BOOL)isSnippetMode
+{
+ return (snippetControlCounter > -1) ? YES : NO;
+}
+
#pragma mark -
#pragma mark event management
@@ -2865,24 +2874,28 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
- (void)drawRect:(NSRect)rect {
- [super drawRect:rect];
-
// Highlight snippets coming from the Query Favorite text macro
if(snippetControlCounter > -1) {
NSInteger i;
- [[NSColor colorWithCalibratedRed:0.0 green:0.5 blue:0.0 alpha:0.1] setFill];
for(i=0; i<snippetControlMax; i++) {
if(snippetControlArray[i][0] > -1) {
NSRange glRange = [[self layoutManager] glyphRangeForCharacterRange:NSMakeRange(snippetControlArray[i][0],snippetControlArray[i][1]) actualCharacterRange:NULL];
if(glRange.length) {
NSRect boundingRect = [[self layoutManager] boundingRectForGlyphRange:glRange inTextContainer:[self textContainer]];
- boundingRect = NSInsetRect(boundingRect, 0, 2);
- NSBezierPath *aBezierPath = [NSBezierPath bezierPathWithRoundedRect:boundingRect xRadius:4 yRadius:15];
+ boundingRect = NSInsetRect(boundingRect, -4, -1);
+ NSBezierPath *aBezierPath = [NSBezierPath bezierPathWithRoundedRect:boundingRect xRadius:5 yRadius:10];
+ [[NSColor colorWithCalibratedRed:1.0 green:1. blue:0.0 alpha:0.4] setFill];
+ [aBezierPath fill];
+ boundingRect = NSInsetRect(boundingRect, 2, 2);
+ aBezierPath = [NSBezierPath bezierPathWithRoundedRect:boundingRect xRadius:5 yRadius:10];
+ [[NSColor colorWithCalibratedRed:1.0 green:1. blue:1.0 alpha:0.8] setFill];
[aBezierPath fill];
}
}
}
}
+ [super drawRect:rect];
+
}
@@ -3051,7 +3064,7 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
NSInteger changeInLength = [textStore changeInLength];
NSInteger i;
- // Remove any fully nested snippets relative to the current snippet which is was edited
+ // Remove any fully nested snippets relative to the current snippet which was edited
if(snippetControlArray[i][0] > -1 && i != snippetControlMax) {
NSInteger currentSnippetLocation = snippetControlArray[currentSnippetIndex][0];
NSInteger currentSnippetMaxRange = snippetControlArray[currentSnippetIndex][0] + snippetControlArray[currentSnippetIndex][1];
diff --git a/Source/CustomQuery.m b/Source/CustomQuery.m
index a02da041..6f8afecf 100644
--- a/Source/CustomQuery.m
+++ b/Source/CustomQuery.m
@@ -2046,7 +2046,7 @@
// Highlight by setting a background color the current query
// if nothing is selected
- if(qRange.length && !currentSelection.length) {
+ if(qRange.length && !currentSelection.length && ![textView isSnippetMode]) {
if([prefs boolForKey:SPCustomQueryHighlightCurrentQuery]) {
[[textView textStorage] addAttribute: NSBackgroundColorAttributeName
value: [NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPCustomQueryEditorHighlightQueryColor]]