On Oct 4, 2008, at 3:43 PM, Christiaan Hofman wrote:
I see that too and fixed it. Thanks.
thanks...
BTW, what dod you do about the aliens?
Diff against yesterday's svn head is attached. Debugging indicated that PDFKit returns characters in the Unicode private use area, which of course can't be displayed. There are some cases in the find table that don't seem to go through -[PDFSelection contextString], and I haven't yet figured out why.
Index: PDFSelection_SKExtensions.m
===================================================================
--- PDFSelection_SKExtensions.m (revision 4734)
+++ PDFSelection_SKExtensions.m (working copy)
@@ -58,10 +58,41 @@
return [pages count] ? [[pages objectAtIndex:0] displayLabel] : nil;
}
+static NSCharacterSet *privateUseCharacterSet()
+{
+ static NSCharacterSet *charset = nil;
+ if (nil == charset) {
+ // supplementary private use B
+ NSMutableCharacterSet *mcs = [NSMutableCharacterSet
characterSetWithRange:NSMakeRange(0x100000, 0x10FFFF-0x100000)];
+ // supplementary private use A
+ [mcs addCharactersInRange:NSMakeRange(0xF0000, 0xFFFFF-0xF0000)];
+ // private use area
+ [mcs addCharactersInRange:NSMakeRange(0xE000, 0xF8FF-0xE000)];
+ charset = [mcs copy];
+ }
+ return charset;
+}
+
+static NSString *stringByRemovingAliens(NSString *string)
+{
+ NSCharacterSet *charset = privateUseCharacterSet();
+ if ([string rangeOfCharacterFromSet:charset].length) {
+ NSMutableString *ms = [[string mutableCopy] autorelease];
+ NSRange r = [ms rangeOfCharacterFromSet:charset];
+ while (r.length) {
+ [ms deleteCharactersInRange:r];
+ r = [ms rangeOfCharacterFromSet:charset];
+ }
+ return ms;
+ }
+ return string;
+}
+
- (NSAttributedString *)contextString {
PDFSelection *extendedSelection = [self copy]; // see remark in
-tableViewSelectionDidChange:
NSMutableAttributedString *attributedSample;
- NSString *searchString = [[self string]
stringByCollapsingWhitespaceAndNewlinesAndRemovingSurroundingWhitespaceAndNewlines];
+ NSString *searchString = stringByRemovingAliens([self string]);
+ searchString = [searchString
stringByCollapsingWhitespaceAndNewlinesAndRemovingSurroundingWhitespaceAndNewlines];
NSString *sample;
NSMutableString *attributedString;
NSString *ellipse = [NSString stringWithFormat:@"%C",
ELLIPSIS_CHARACTER];
@@ -75,7 +106,8 @@
[extendedSelection extendSelectionAtEnd:50];
// get the cleaned string
- sample = [[extendedSelection string]
stringByCollapsingWhitespaceAndNewlinesAndRemovingSurroundingWhitespaceAndNewlines];
+ sample = stringByRemovingAliens([extendedSelection string]);
+ sample = [sample
stringByCollapsingWhitespaceAndNewlinesAndRemovingSurroundingWhitespaceAndNewlines];
// Finally, create attributed string.
attributedSample = [[NSMutableAttributedString alloc]
initWithString:sample];
Index: SKMainWindowController_UI.m
===================================================================
--- SKMainWindowController_UI.m (revision 4734)
+++ SKMainWindowController_UI.m (working copy)
@@ -642,7 +642,7 @@
}
- (NSString *)outlineView:(NSOutlineView *)ov toolTipForCell:(NSCell *)cell
rect:(NSRectPointer)rect tableColumn:(NSTableColumn *)tableColumn item:(id)item
mouseLocation:(NSPoint)mouseLocation {
- if ([ov isEqual:noteOutlineView] && [[tableColumn identifier]
isEqualToString:@"note"]) {
+ if (floor(NSAppKitVersionNumber) <= NSAppKitVersionNumber10_4 && [ov
isEqual:noteOutlineView] && [[tableColumn identifier] isEqualToString:@"note"])
{
return [item string];
}
return nil;
Index: SkimNotes/PDFAnnotation_SKNExtensions.m
===================================================================
--- SkimNotes/PDFAnnotation_SKNExtensions.m (revision 4734)
+++ SkimNotes/PDFAnnotation_SKNExtensions.m (working copy)
@@ -227,14 +227,49 @@
else [SkimNotes removeObject:self];
}
+static NSCharacterSet *privateUseCharacterSet()
+{
+ static NSCharacterSet *charset = nil;
+ if (nil == charset) {
+ // supplementary private use B
+ NSMutableCharacterSet *mcs = [NSMutableCharacterSet
characterSetWithRange:NSMakeRange(0x100000, 0x10FFFF-0x100000)];
+ // supplementary private use A
+ [mcs addCharactersInRange:NSMakeRange(0xF0000, 0xFFFFF-0xF0000)];
+ // private use area
+ [mcs addCharactersInRange:NSMakeRange(0xE000, 0xF8FF-0xE000)];
+ charset = [mcs copy];
+ }
+ return charset;
+}
+
+static NSString *stringByRemovingAliens(NSString *string)
+{
+ NSCharacterSet *charset = privateUseCharacterSet();
+ if ([string rangeOfCharacterFromSet:charset].length) {
+ NSMutableString *ms = [[string mutableCopy] autorelease];
+ NSRange r = [ms rangeOfCharacterFromSet:charset];
+ while (r.length) {
+ [ms deleteCharactersInRange:r];
+ r = [ms rangeOfCharacterFromSet:charset];
+ }
+ return ms;
+ }
+ return string;
+}
+
- (NSString *)string {
- return [self contents];
+ return stringByRemovingAliens([self contents]);
}
- (void)setString:(NSString *)newString {
[self setContents:newString];
}
+// override private method so the string can be cleaned properly
+- (NSString *)toolTip {
+ return [self string];
+}
+
@end
#pragma mark -
smime.p7s
Description: S/MIME cryptographic signature
------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________ Skim-app-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/skim-app-users
