aboutsummaryrefslogtreecommitdiffstats
path: root/Source/CMTextView.m
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-02-01 16:59:08 +0000
committerBibiko <bibiko@eva.mpg.de>2010-02-01 16:59:08 +0000
commita410164c7227eb3825a86b1502feaea497e796c1 (patch)
tree878a0ec7182e0a587e122781f57965cf7767811a /Source/CMTextView.m
parentc3f6e3a108a017aa20ac645d5d6d9e75adca33b8 (diff)
downloadsequelpro-a410164c7227eb3825a86b1502feaea497e796c1.tar.gz
sequelpro-a410164c7227eb3825a86b1502feaea497e796c1.tar.bz2
sequelpro-a410164c7227eb3825a86b1502feaea497e796c1.zip
• CMTextView: switch off syntax highlighting if text buffer size is larger than SP_SYNTAX_HILITE_BIAS (has to be improved)
• added SPFieldMapperController
Diffstat (limited to 'Source/CMTextView.m')
-rw-r--r--Source/CMTextView.m30
1 files changed, 24 insertions, 6 deletions
diff --git a/Source/CMTextView.m b/Source/CMTextView.m
index 46ce0227..5ba0f3e9 100644
--- a/Source/CMTextView.m
+++ b/Source/CMTextView.m
@@ -788,12 +788,35 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
[[NSPrintInfo sharedPrintInfo] setHorizontallyCentered:NO];
[[NSPrintInfo sharedPrintInfo] setVerticallyCentered:NO];
+ NSRange r = NSMakeRange(0, [[self string] length]);
+
+ // Remove all colors before printing for large text buffer
+ if(r.length > SP_SYNTAX_HILITE_BIAS) {
+ // Cancel all doSyntaxHighlighting requests
+ [NSObject cancelPreviousPerformRequestsWithTarget:self
+ selector:@selector(doSyntaxHighlighting)
+ object:nil];
+ [[self textStorage] removeAttribute:NSForegroundColorAttributeName range:r];
+ [[self textStorage] removeAttribute:kLEXToken range:r];
+ [[self textStorage] ensureAttributesAreFixedInRange:r];
+
+ }
+ [[self textStorage] ensureAttributesAreFixedInRange:r];
+
// Setup the print operation with the print info and view
NSPrintOperation *printOperation = [NSPrintOperation printOperationWithView:self printInfo:[NSPrintInfo sharedPrintInfo]];
+
+ // Order out print sheet
[printOperation runOperationModalForWindow:[self window] delegate:nil didRunSelector:NULL contextInfo:NULL];
}
+- (void)printOperationDidRun:(NSPrintOperation *)printOperation success:(BOOL)success contextInfo:(void *)contextInfo
+{
+ // Refresh syntax highlighting
+ [self performSelector:@selector(doSyntaxHighlighting) withObject:nil afterDelay:0.01];
+}
+
/*
* Search for the current selection or current word in the MySQL Help
*/
@@ -2744,7 +2767,7 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
NSUInteger strlength = [selfstr length];
NSRange textRange;
-
+
// If text larger than SP_TEXT_SIZE_TRIGGER_FOR_PARTLY_PARSING
// do highlighting partly (max SP_SYNTAX_HILITE_BIAS*2).
// The approach is to take the middle position of the current view port
@@ -2753,11 +2776,6 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
if(strlength > SP_TEXT_SIZE_TRIGGER_FOR_PARTLY_PARSING)
{
- // Cancel all doSyntaxHighlighting requests
- [NSObject cancelPreviousPerformRequestsWithTarget:self
- selector:@selector(doSyntaxHighlighting)
- object:nil];
-
// Get the text range currently displayed in the view port
NSRect visibleRect = [[[self enclosingScrollView] contentView] documentVisibleRect];
NSRange visibleRange = [[self layoutManager] glyphRangeForBoundingRectWithoutAdditionalLayout:visibleRect inTextContainer:[self textContainer]];