From a410164c7227eb3825a86b1502feaea497e796c1 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Mon, 1 Feb 2010 16:59:08 +0000 Subject: =?UTF-8?q?=E2=80=A2=20CMTextView:=20switch=20off=20syntax=20highl?= =?UTF-8?q?ighting=20if=20text=20buffer=20size=20is=20larger=20than=20SP?= =?UTF-8?q?=5FSYNTAX=5FHILITE=5FBIAS=20(has=20to=20be=20improved)=20?= =?UTF-8?q?=E2=80=A2=20added=20SPFieldMapperController?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/CMTextView.m | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) (limited to 'Source/CMTextView.m') 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]]; -- cgit v1.2.3