From: <ama...@us...> - 2006-08-23 18:43:57
|
Revision: 7551 Author: amaxwell Date: 2006-08-23 11:43:47 -0700 (Wed, 23 Aug 2006) ViewCVS: http://svn.sourceforge.net/bibdesk/?rev=7551&view=rev Log Message: ----------- restore check for delimiter character in invalidating range extend invalidated range; the next newline is no longer sufficient Modified Paths: -------------- trunk/bibdesk/BDSKErrorEditor.m Modified: trunk/bibdesk/BDSKErrorEditor.m =================================================================== --- trunk/bibdesk/BDSKErrorEditor.m 2006-08-23 17:47:10 UTC (rev 7550) +++ trunk/bibdesk/BDSKErrorEditor.m 2006-08-23 18:43:47 UTC (rev 7551) @@ -304,31 +304,25 @@ if(delimSet == nil) delimSet = [[NSCharacterSet characterSetWithCharactersInString:@"@{}"] retain]; - static NSMutableCharacterSet *newlineSet = nil; - if(newlineSet == nil){ - newlineSet = (NSMutableCharacterSet *)CFCharacterSetCreateMutableCopy(CFAllocatorGetDefault(), CFCharacterSetGetPredefined(kCFCharacterSetWhitespace)); - CFCharacterSetInvert((CFMutableCharacterSetRef)newlineSet); // no whitespace in this one, but it also has all letters... - CFCharacterSetIntersect((CFMutableCharacterSetRef)newlineSet, CFCharacterSetGetPredefined(kCFCharacterSetWhitespaceAndNewline)); - } - NSString *string = [textStorage string]; + + // see if we need to extend the range; coloring won't change unless this is a delimiter + if([string rangeOfCharacterFromSet:delimSet].length == 0) + return proposedRange; + + NSCharacterSet *newlineSet = [NSCharacterSet newlineCharacterSet]; NSColor *quotedColor = [NSColor brownColor]; unsigned start = proposedRange.location; - unsigned end = NSMaxRange(proposedRange); // quoted text can have multiple lines - do{ + do { start = [string rangeOfCharacterFromSet:newlineSet options:NSBackwardsSearch|NSLiteralSearch range:NSMakeRange(0, start)].location; if(start == NSNotFound) start = 0; } while (start > 0 && [textStorage attribute:NSForegroundColorAttributeName atIndex:start - 1 effectiveRange:NULL] == quotedColor); - - end = NSMaxRange([string rangeOfCharacterFromSet:newlineSet options:NSLiteralSearch range:NSMakeRange(end, [string length] - end)]); - if(end == NSNotFound) - end = [string length]; - - return NSMakeRange(start, end - start); + + return NSMakeRange(start, [string length] - start); } #define SetColor(color, start, length) [textStorage addAttribute:NSForegroundColorAttributeName value:color range:NSMakeRange(editedRange.location + start, length)]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |