do not change font on highlight, just the background: thus storing the old font attributes becomes needless

This commit is contained in:
Riccardo Mottola 2021-11-23 01:22:54 +01:00
parent a0856faf21
commit 01a3a61b2e
2 changed files with 0 additions and 27 deletions

View file

@ -79,11 +79,6 @@
// NSNotFound means not set
NSUInteger highlighted_chars[2];
// the stored font attributes of the highlit character, so
// that they can be restored later on when the character is un-highlit
// A pair is assumed to have the same attributes
NSColor *previousFont;
// This is used to protect that -textViewDidChangeSelection: invocations
// don't do anything when the text view changing, because this causes
// further changes to the text view and infinite recursive invocations

View file

@ -219,8 +219,6 @@
ASSIGN(backgroundColor, [NSColor whiteColor]);
ASSIGN(readOnlyColor, [NSColor lightGrayColor]);
previousFont = nil;
highlighted_chars[0] = NSNotFound;
highlighted_chars[1] = NSNotFound;
@ -1376,18 +1374,6 @@ NSUInteger FindDelimiterInString(NSString * string,
NSRange r = NSMakeRange(highlighted_chars[i], 1);
// restore the character's color and font attributes
if (previousFont != nil)
{
[textStorage addAttribute:NSFontAttributeName
value:previousFont
range:r];
}
else
{
[textStorage removeAttribute:NSFontAttributeName range:r];
}
[textStorage addAttribute:NSBackgroundColorAttributeName
value:textBackgroundColor
range:r];
@ -1414,14 +1400,6 @@ NSUInteger FindDelimiterInString(NSString * string,
NSAssert(textStorage, @"textstorage can't be nil");
// store the previous character's attributes
ASSIGN(previousFont, [textStorage attribute:NSFontAttributeName
atIndex:r.location
effectiveRange:NULL]);
[textStorage addAttribute:NSFontAttributeName
value:highlightFont
range:r];
[textStorage addAttribute:NSBackgroundColorAttributeName
value:highlightColor
range:r];