aboutsummaryrefslogtreecommitdiffstats
path: root/Source/CMTextView.m
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-01-27 14:30:28 +0000
committerBibiko <bibiko@eva.mpg.de>2010-01-27 14:30:28 +0000
commit5c01336855fde8694dfe2c9060c7e8f43b61d950 (patch)
tree57930469d2e8134a4f529385cc3b26eaf8f15f92 /Source/CMTextView.m
parentb36564545f2290e7e41a794c33783e6ce322bbcc (diff)
downloadsequelpro-5c01336855fde8694dfe2c9060c7e8f43b61d950.tar.gz
sequelpro-5c01336855fde8694dfe2c9060c7e8f43b61d950.tar.bz2
sequelpro-5c01336855fde8694dfe2c9060c7e8f43b61d950.zip
• query favorite snippet session (text macro)
- draw a bezier path around defined snippets to group them graphically (test phase) - allow the user to go into a snippet by using the mouse
Diffstat (limited to 'Source/CMTextView.m')
-rw-r--r--Source/CMTextView.m50
1 files changed, 49 insertions, 1 deletions
diff --git a/Source/CMTextView.m b/Source/CMTextView.m
index fe1af726..eb2abff4 100644
--- a/Source/CMTextView.m
+++ b/Source/CMTextView.m
@@ -1092,8 +1092,33 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
}
}
}
+ // If caret is not inside the current snippet range check if caret is inside of
+ // another defined snippet; if so set currentSnippetIndex to it (this allows to use the
+ // mouse to activate another snippet). If the caret is inside of overlapped snippets (nested)
+ // then select this snippet which has the smallest length.
if(!isCaretInsideASnippet && foundSnippetIndices[currentSnippetIndex] == 1) {
isCaretInsideASnippet = YES;
+ } else {
+ NSInteger index = -1;
+ NSInteger smallestLength = -1;
+ for(i=0; i<snippetControlMax; i++) {
+ if(foundSnippetIndices[i] == 1) {
+ if(index == -1) {
+ index = i;
+ smallestLength = snippetControlArray[i][1];
+ } else {
+ if(smallestLength > snippetControlArray[i][1]) {
+ index = i;
+ smallestLength = snippetControlArray[i][1];
+ }
+ }
+ }
+ }
+ // Reset the active snippet
+ if(index > -1 && smallestLength > -1) {
+ currentSnippetIndex = index;
+ isCaretInsideASnippet = YES;
+ }
}
return isCaretInsideASnippet;
@@ -2838,6 +2863,29 @@ 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];
+ [aBezierPath fill];
+ }
+ }
+ }
+ }
+}
+
+
#pragma mark -
#pragma mark context menu
@@ -2996,7 +3044,7 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
// Re-calculate snippet ranges if snippet session is active
if(snippetControlCounter > -1 && !snippetWasJustInserted) {
-
+
if([self checkForCaretInsideSnippet]) {
NSInteger editStartPosition = [textStore editedRange].location;