diff options
Diffstat (limited to 'Source/CMTextView.m')
-rw-r--r-- | Source/CMTextView.m | 30 |
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]]; |