| Line 675... |
Line 675... |
| 675 |
|
675 |
|
| 676 |
// == Do highlighting partly (max R_SYNTAX_HILITE_BIAS*2 around visibleRange
|
676 |
// == Do highlighting partly (max R_SYNTAX_HILITE_BIAS*2 around visibleRange
|
| 677 |
// by considering entire lines).
|
677 |
// by considering entire lines).
|
| 678 |
|
678 |
|
| 679 |
// Get the text range currently displayed in the view port
|
679 |
// Get the text range currently displayed in the view port
|
| 680 |
NSRect visibleRect = [[[self enclosingScrollView] contentView] documentVisibleRect];
|
680 |
NSRect visibleRect = [scrollView documentVisibleRect];
|
| 681 |
NSRange visibleRange = [[self layoutManager] glyphRangeForBoundingRectWithoutAdditionalLayout:visibleRect inTextContainer:[self textContainer]];
|
681 |
NSRange visibleRange = [[self layoutManager] glyphRangeForBoundingRectWithoutAdditionalLayout:visibleRect inTextContainer:[self textContainer]];
|
| 682 |
|
682 |
|
| 683 |
if(!visibleRange.length) {
|
683 |
if(!visibleRange.length) {
|
| 684 |
isSyntaxHighlighting = NO;
|
684 |
isSyntaxHighlighting = NO;
|
| 685 |
return;
|
685 |
return;
|
| Line 720... |
Line 720... |
| 720 |
|
720 |
|
| 721 |
[theTextStorage beginEditing];
|
721 |
[theTextStorage beginEditing];
|
| 722 |
|
722 |
|
| 723 |
NSColor *tokenColor = nil;
|
723 |
NSColor *tokenColor = nil;
|
| 724 |
|
724 |
|
| 725 |
size_t tokenEnd, token;
|
725 |
size_t token;
|
| 726 |
NSRange tokenRange;
|
726 |
NSRange tokenRange;
|
| 727 |
|
727 |
|
| 728 |
// first remove the old colors and kQuote
|
728 |
// first remove the old colors and kQuote
|
| 729 |
// [theTextStorage removeAttribute:NSForegroundColorAttributeName range:textRange];
|
729 |
// [theTextStorage removeAttribute:NSForegroundColorAttributeName range:textRange];
|
| 730 |
// mainly for suppressing auto-pairing in
|
730 |
// mainly for suppressing auto-pairing in
|
| 731 |
[theTextStorage removeAttribute:kLEXToken range:textRange];
|
731 |
// [theTextStorage removeAttribute:kLEXToken range:textRange];
|
| 732 |
|
732 |
|
| 733 |
// initialise flex
|
733 |
// initialise flex
|
| 734 |
yyuoffset = textRange.location; yyuleng = 0;
|
734 |
yyuoffset = textRange.location; yyuleng = 0;
|
| 735 |
|
735 |
|
| 736 |
if([[self delegate] isRdDocument]) {
|
736 |
if([[self delegate] isRdDocument]) {
|
| Line 769... |
Line 769... |
| 769 |
// otherwise a bug in the lex code could cause the the TextView to crash
|
769 |
// otherwise a bug in the lex code could cause the the TextView to crash
|
| 770 |
// NOTE Disabled for testing purposes for speed it up
|
770 |
// NOTE Disabled for testing purposes for speed it up
|
| 771 |
tokenRange = NSIntersectionRange(tokenRange, textRange);
|
771 |
tokenRange = NSIntersectionRange(tokenRange, textRange);
|
| 772 |
if (!tokenRange.length) continue;
|
772 |
if (!tokenRange.length) continue;
|
| 773 |
|
773 |
|
| 774 |
// If the current token is marked as SQL keyword, uppercase it if required.
|
- |
|
| 775 |
tokenEnd = NSMaxRange(tokenRange) - 1;
|
- |
|
| 776 |
|
- |
|
| 777 |
NSMutableAttributedStringAddAttributeValueRange(theTextStorage, NSForegroundColorAttributeName, tokenColor, tokenRange);
|
774 |
NSMutableAttributedStringAddAttributeValueRange(theTextStorage, NSForegroundColorAttributeName, tokenColor, tokenRange);
|
| 778 |
|
775 |
|
| 779 |
// Add an attribute to be used in the auto-pairing (keyDown:)
|
776 |
// Add an attribute to be used in the auto-pairing (keyDown:)
|
| 780 |
// to disable auto-pairing if caret is inside of any token found by lex.
|
777 |
// to disable auto-pairing if caret is inside of any token found by lex.
|
| 781 |
// For discussion: maybe change it later (only for quotes not keywords?)
|
778 |
// For discussion: maybe change it later (only for quotes not keywords?)
|
| 782 |
if(token < 6)
|
779 |
// if(token < 6)
|
| 783 |
NSMutableAttributedStringAddAttributeValueRange(theTextStorage, kLEXToken, kLEXTokenValue, tokenRange);
|
780 |
// NSMutableAttributedStringAddAttributeValueRange(theTextStorage, kLEXToken, kLEXTokenValue, tokenRange);
|
| 784 |
|
781 |
|
| 785 |
|
782 |
|
| 786 |
// Add an attribute to be used to distinguish quotes from keywords etc.
|
783 |
// Add an attribute to be used to distinguish quotes from keywords etc.
|
| 787 |
// used e.g. in completion suggestions
|
784 |
// used e.g. in completion suggestions
|
| 788 |
else if(token < 4)
|
785 |
// else if(token < 4)
|
| 789 |
NSMutableAttributedStringAddAttributeValueRange(theTextStorage, kQuote, kQuoteValue, tokenRange);
|
786 |
// NSMutableAttributedStringAddAttributeValueRange(theTextStorage, kQuote, kQuoteValue, tokenRange);
|
| 790 |
|
787 |
|
| 791 |
}
|
788 |
}
|
| 792 |
|
789 |
|
| 793 |
} else {
|
790 |
} else {
|
| 794 |
|
791 |
|
| Line 830... |
Line 827... |
| 830 |
// otherwise a bug in the lex code could cause the the TextView to crash
|
827 |
// otherwise a bug in the lex code could cause the the TextView to crash
|
| 831 |
// NOTE Disabled for testing purposes for speed it up
|
828 |
// NOTE Disabled for testing purposes for speed it up
|
| 832 |
tokenRange = NSIntersectionRange(tokenRange, textRange);
|
829 |
tokenRange = NSIntersectionRange(tokenRange, textRange);
|
| 833 |
if (!tokenRange.length) continue;
|
830 |
if (!tokenRange.length) continue;
|
| 834 |
|
831 |
|
| 835 |
// If the current token is marked as SQL keyword, uppercase it if required.
|
- |
|
| 836 |
tokenEnd = NSMaxRange(tokenRange) - 1;
|
- |
|
| 837 |
|
- |
|
| 838 |
NSMutableAttributedStringAddAttributeValueRange(theTextStorage, NSForegroundColorAttributeName, tokenColor, tokenRange);
|
832 |
NSMutableAttributedStringAddAttributeValueRange(theTextStorage, NSForegroundColorAttributeName, tokenColor, tokenRange);
|
| 839 |
|
833 |
|
| 840 |
// Add an attribute to be used in the auto-pairing (keyDown:)
|
834 |
// Add an attribute to be used in the auto-pairing (keyDown:)
|
| 841 |
// to disable auto-pairing if caret is inside of any token found by lex.
|
835 |
// to disable auto-pairing if caret is inside of any token found by lex.
|
| 842 |
// For discussion: maybe change it later (only for quotes not keywords?)
|
836 |
// For discussion: maybe change it later (only for quotes not keywords?)
|
| 843 |
if(token < 6)
|
837 |
// if(token < 6)
|
| 844 |
NSMutableAttributedStringAddAttributeValueRange(theTextStorage, kLEXToken, kLEXTokenValue, tokenRange);
|
838 |
// NSMutableAttributedStringAddAttributeValueRange(theTextStorage, kLEXToken, kLEXTokenValue, tokenRange);
|
| 845 |
|
839 |
|
| 846 |
|
840 |
|
| 847 |
// Add an attribute to be used to distinguish quotes from keywords etc.
|
841 |
// Add an attribute to be used to distinguish quotes from keywords etc.
|
| 848 |
// used e.g. in completion suggestions
|
842 |
// used e.g. in completion suggestions
|
| 849 |
else if(token < 4)
|
843 |
// if(token < 4)
|
| 850 |
NSMutableAttributedStringAddAttributeValueRange(theTextStorage, kQuote, kQuoteValue, tokenRange);
|
844 |
// NSMutableAttributedStringAddAttributeValueRange(theTextStorage, kQuote, kQuoteValue, tokenRange);
|
| 851 |
|
845 |
|
| 852 |
|
846 |
|
| 853 |
}
|
847 |
}
|
| 854 |
}
|
848 |
}
|
| 855 |
|
849 |
|