aboutsummaryrefslogtreecommitdiffstats
path: root/Source/CMTextView.m
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2009-04-20 14:01:50 +0000
committerBibiko <bibiko@eva.mpg.de>2009-04-20 14:01:50 +0000
commit6e83f452684330b881cc2d57c57ea981934ba18a (patch)
tree78b076f3cd9d3c51bdba92c30cd54888fb3a9aca /Source/CMTextView.m
parentf821d5595b90517b20243610233dcf45f7f02d73 (diff)
downloadsequelpro-6e83f452684330b881cc2d57c57ea981934ba18a.tar.gz
sequelpro-6e83f452684330b881cc2d57c57ea981934ba18a.tar.bz2
sequelpro-6e83f452684330b881cc2d57c57ea981934ba18a.zip
• added selectLineNumber:x to CMTextView to be able to select the line x
• added error highlighting of the first mentioned error - if a "near message" error is provided select that message otherwise select the entire error line and scrolls to it - if no "at line x" and no "near message" is given do nothing - if a selection was given and the user pressed "runAll" destroy the selection before error checking; if no error was found reconstruct that selection (to be able to distinguish between "runSelection" and "runAll" plus selection) * changed slightly the trigger for syntax highlighting/auto-uppercasing for better scrollToRange behaviour
Diffstat (limited to 'Source/CMTextView.m')
-rw-r--r--Source/CMTextView.m32
1 files changed, 32 insertions, 0 deletions
diff --git a/Source/CMTextView.m b/Source/CMTextView.m
index a19edb25..b6bb1229 100644
--- a/Source/CMTextView.m
+++ b/Source/CMTextView.m
@@ -194,6 +194,38 @@ YY_BUFFER_STATE yy_scan_string (const char *);
}
}
+
+/*
+ * Selects the line lineNumber relatively to a selection (if given) and scrolls to it
+ */
+- (void) selectLineNumber:(unsigned int)lineNumber ignoreLeadingNewLines:(BOOL)ignLeadingNewLines
+{
+ NSRange selRange;
+ NSArray *lineRanges;
+ if([self selectedRange].length)
+ lineRanges = [[[self string] substringWithRange:[self selectedRange]] lineRangesForRange:NSMakeRange(0, [self selectedRange].length)];
+ else
+ lineRanges = [[self string] lineRangesForRange:NSMakeRange(0, [[self string] length])];
+ int offset = 0;
+ if(ignLeadingNewLines) // ignore leading empty lines
+ {
+ int arrayCount = [lineRanges count];
+ int i;
+ for (i = 0; i < arrayCount; i++) {
+ if(NSRangeFromString([lineRanges objectAtIndex:i]).length > 0)
+ break;
+ offset++;
+ }
+ }
+ selRange = NSRangeFromString([lineRanges objectAtIndex:lineNumber-1+offset]);
+
+ // adjust selRange if a selection was given
+ if([self selectedRange].length)
+ selRange.location += [self selectedRange].location;
+ [self setSelectedRange:selRange];
+ [self scrollRangeToVisible:selRange];
+}
+
/*
* Handle some keyDown events in order to provide autopairing functionality (if enabled).
*/