diff --git a/CHDocumentationBrowser.xib b/CHDocumentationBrowser.xib index d3d97f3..55c6463 100644 --- a/CHDocumentationBrowser.xib +++ b/CHDocumentationBrowser.xib @@ -23,13 +23,13 @@ YES - - - + + + + - YES @@ -3316,6 +3316,7 @@ Text Cell + -2 @@ -5722,9 +5723,11 @@ ZQCUhAEqhIQLe0NHU2l6ZT1kZH2aAIOQAAAAAAAAAIaGA 759.IBPluginDependency 760.IBPluginDependency 761.IBPluginDependency + 762.CustomClassName 762.IBPluginDependency 764.IBPluginDependency 765.IBPluginDependency + 766.CustomClassName 766.IBPluginDependency 768.IBPluginDependency 83.IBEditorWindowLastContentRect @@ -5758,7 +5761,7 @@ ZQCUhAEqhIQLe0NHU2l6ZT1kZH2aAIOQAAAAAAAAAIaGA com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin IGKEaseInOutAnimatedView - {{310, 394}, {756, 602}} + {{261, 394}, {756, 602}} com.apple.InterfaceBuilder.CocoaPlugin {{593, 365}, {247, 404}} com.apple.InterfaceBuilder.CocoaPlugin @@ -5796,7 +5799,7 @@ ZQCUhAEqhIQLe0NHU2l6ZT1kZH2aAIOQAAAAAAAAAIaGA {{458, 388}, {166, 60}} com.apple.InterfaceBuilder.CocoaPlugin - {{236, 156}, {830, 530}} + {{187, 156}, {830, 530}} com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -5809,7 +5812,7 @@ ZQCUhAEqhIQLe0NHU2l6ZT1kZH2aAIOQAAAAAAAAAIaGA com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.brandonwalkin.BWToolkit - {{418, 390}, {635, 466}} + {{382, 390}, {635, 466}} com.apple.InterfaceBuilder.CocoaPlugin com.brandonwalkin.BWToolkit com.brandonwalkin.BWToolkit @@ -5849,7 +5852,7 @@ ZQCUhAEqhIQLe0NHU2l6ZT1kZH2aAIOQAAAAAAAAAIaGA - {{824, 452}, {247, 404}} + {{770, 452}, {247, 404}} com.apple.InterfaceBuilder.CocoaPlugin {{1072, 597}, {93, 22}} {{1119, 170}, {187, 242}} @@ -5904,12 +5907,14 @@ ZQCUhAEqhIQLe0NHU2l6ZT1kZH2aAIOQAAAAAAAAAIaGA com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + IGKShyTableView com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + IGKSometimesCenteredTextCell2 com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{431, 51}, {635, 466}} + {{382, 51}, {635, 466}} com.apple.InterfaceBuilder.CocoaPlugin com.brandonwalkin.BWToolkit com.apple.InterfaceBuilder.CocoaPlugin @@ -6075,11 +6080,16 @@ ZQCUhAEqhIQLe0NHU2l6ZT1kZH2aAIOQAAAAAAAAAIaGA IGKSometimesCenteredTextCell NSTextFieldCell - + IBProjectSource IGKSometimesCenteredTextCell.h + + IGKSometimesCenteredTextCell2 + NSTextFieldCell + + IGKTableOfContentsView IGKEaseInOutAnimatedView diff --git a/IGKDocRecordManagedObject.h b/IGKDocRecordManagedObject.h index 84a078e..e319dfd 100644 --- a/IGKDocRecordManagedObject.h +++ b/IGKDocRecordManagedObject.h @@ -9,6 +9,7 @@ #import #import "IGKHTMLGenerator.h" #import "IGKManagedObject.h" +#import "CHSymbolButtonImage.h" //Priorities of different objects when sorting the list in case of a tiebreak. From lowest priority to highest typedef enum { @@ -42,4 +43,6 @@ typedef enum { - (NSString *)xcontainername; - (IGKDocRecordManagedObject *)xcontainer; ++ (CHSymbolButtonImageMask)iconMaskForEntity:(NSString *)entityName isInstanceMethod:(BOOL)instanceMethod; + @end diff --git a/IGKDocRecordManagedObject.m b/IGKDocRecordManagedObject.m index e072b1e..c1b6a5f 100644 --- a/IGKDocRecordManagedObject.m +++ b/IGKDocRecordManagedObject.m @@ -8,7 +8,6 @@ #import "IGKDocRecordManagedObject.h" #import "IGKDocSetManagedObject.h" -#import "CHSymbolButtonImage.h" @interface IGKDocRecordManagedObject () @@ -445,11 +444,14 @@ - (NSImage *)selectedIcon } - (CHSymbolButtonImageMask)iconMask +{ + NSString *entityName = [[self entity] name]; + return [[self class] iconMaskForEntity:entityName isInstanceMethod:[[self valueForSoftKey:@"isInstanceMethod"] boolValue]]; +} ++ (CHSymbolButtonImageMask)iconMaskForEntity:(NSString *)entityName isInstanceMethod:(BOOL)instanceMethod { //FIXME: Maybe it would be better to use an NSDictionary -> NSNumber here instead - NSString *entityName = [[self entity] name]; - if([entityName isEqual:@"ObjCClass"]) return CHSymbolButtonObjcClass; @@ -461,7 +463,7 @@ - (CHSymbolButtonImageMask)iconMask else if([entityName isEqual:@"ObjCMethod"]) { - if ([[self valueForKey:@"isInstanceMethod"] boolValue]) + if (instanceMethod) return CHSymbolButtonObjcMethod; else return CHSymbolButtonObjcMethod | CHSymbolButtonStaticScope; diff --git a/IGKHTMLGenerator.h b/IGKHTMLGenerator.h index d52f4a0..fd654c0 100644 --- a/IGKHTMLGenerator.h +++ b/IGKHTMLGenerator.h @@ -63,6 +63,8 @@ BOOL IGKHTMLDisplayTypeMaskIsSingle(IGKHTMLDisplayTypeMask mask); - (NSString *)html; + (BOOL)containsInDocument:(IGKDocRecordManagedObject *)mo transientObject:(NSManagedObject *)_transientObject displayTypeMask:(IGKHTMLDisplayTypeMask)_displayTypeMask containerName:(NSString *)containerName itemName:(NSString *)itemName ingrcode:(NSString *)ingrcode; ++ (NSString *)extractApplecodeFromHref:(NSString *)href itemName:(NSString **)itemName; ++ (NSString *)applecodeToIngrcode:(NSString *)applecode itemName:(NSString *)itemName; - (id)transientObject; diff --git a/IGKHTMLGenerator.m b/IGKHTMLGenerator.m index a5a43d2..5ea312c 100644 --- a/IGKHTMLGenerator.m +++ b/IGKHTMLGenerator.m @@ -259,39 +259,34 @@ + (BOOL)containsInDocument:(IGKDocRecordManagedObject *)mo transientObject:(NSMa return containsInDocument; } -+ (NSString *)hrefToActualFragment:(IGKDocRecordManagedObject *)mo transientObject:(NSManagedObject *)_transientObject displayTypeMask:(IGKHTMLDisplayTypeMask)_displayTypeMask ++ (NSString *)extractApplecodeFromHref:(NSString *)href itemName:(NSString **)itemName { - NSString *href = [mo valueForKey:@"href"]; - - // NSString.html#//apple_ref/occ/instm/NSString/stringByAppendingPathComponent: - // We need to grab - // the type (cl, instm, etc) - // the container (NSString) - // the item (stringByAppendingPathComponent:) - NSString *regex = @"//apple_ref/(occ|c)/([^/]+)/([^/]+)(/([^/]+))?"; NSArray *captures = [href captureComponentsMatchedByRegex:regex]; if ([captures count] < 4) return nil; NSString *applecode = [captures objectAtIndex:2]; - NSString *n = [captures objectAtIndex:3]; - - NSString *containerName = nil; - NSString *itemName = nil; - + NSString *capturedName = nil; if ([captures count] >= 6) { - containerName = n; - itemName = [captures objectAtIndex:5]; + capturedName = [captures objectAtIndex:5]; } else { - itemName = n; + capturedName = [captures objectAtIndex:3]; } + if (itemName) + *itemName = capturedName; + + return applecode; +} ++ (NSString *)applecodeToIngrcode:(NSString *)applecode itemName:(NSString *)itemName +{ NSString *ingrcode = nil; + if ([applecode isEqual:@"cl"]) ingrcode = @"class"; else if ([applecode isEqual:@"cat"]) @@ -320,6 +315,42 @@ + (NSString *)hrefToActualFragment:(IGKDocRecordManagedObject *)mo transientObje ingrcode = @"global"; } + return ingrcode; +} ++ (NSString *)hrefToActualFragment:(IGKDocRecordManagedObject *)mo transientObject:(NSManagedObject *)_transientObject displayTypeMask:(IGKHTMLDisplayTypeMask)_displayTypeMask +{ + NSString *href = [mo valueForKey:@"href"]; + + // NSString.html#//apple_ref/occ/instm/NSString/stringByAppendingPathComponent: + // We need to grab + // the type (cl, instm, etc) + // the container (NSString) + // the item (stringByAppendingPathComponent:) + + NSString *regex = @"//apple_ref/(occ|c)/([^/]+)/([^/]+)(/([^/]+))?"; + NSArray *captures = [href captureComponentsMatchedByRegex:regex]; + if ([captures count] < 4) + return nil; + + NSString *applecode = [captures objectAtIndex:2]; + NSString *n = [captures objectAtIndex:3]; + + NSString *containerName = nil; + NSString *itemName = nil; + + + if ([captures count] >= 6) + { + containerName = n; + itemName = [captures objectAtIndex:5]; + } + else + { + itemName = n; + } + + NSString *ingrcode = [[self class] applecodeToIngrcode:applecode itemName:itemName]; + if ([self containsInDocument:mo transientObject:_transientObject displayTypeMask:_displayTypeMask containerName:containerName itemName:itemName ingrcode:ingrcode]) return [NSString stringWithFormat:@"#%@.%@", itemName, ingrcode]; diff --git a/IGKWindowController.m b/IGKWindowController.m index 613bf33..33b3b98 100644 --- a/IGKWindowController.m +++ b/IGKWindowController.m @@ -988,10 +988,20 @@ - (void)reloadRightFilterBarTable:(IGKDocRecordManagedObject *)mo transient:(IGK for (NSManagedObject *taskitem in taskitems) { NSMutableDictionary *taskitemDict = [[NSMutableDictionary alloc] init]; - [taskitemDict setValue:[taskitem valueForKey:@"name"] forKey:@"name"]; [taskitemDict setValue:[IGKHTMLGenerator hrefToActualFragment:taskitem transientObject:transientObject displayTypeMask:acceptableDisplayTypes] forKey:@"href"]; - + + NSString *taskitemHref = [taskitem valueForKey:@"href"]; + + NSString *taskitemName = nil; + NSString *applecode = [IGKHTMLGenerator extractApplecodeFromHref:taskitemHref itemName:&taskitemName]; + NSString *ingrcode = [IGKHTMLGenerator applecodeToIngrcode:applecode itemName:taskitemName]; + NSString *entityName = [IGKDocRecordManagedObject entityNameFromURLComponentExtension:ingrcode]; + CHSymbolButtonImageMask iconmask = [IGKDocRecordManagedObject iconMaskForEntity:entityName isInstanceMethod:[ingrcode isEqual:@"instance-method"]]; + + [taskitemDict setValue:[NSNumber numberWithUnsignedLongLong:iconmask] forKey:@"iconMask"]; + [taskitemDict setValue:taskitemName forKey:@"name"]; + [rightFilterBarTaskGroupedItems addObject:taskitemDict]; } } @@ -1239,6 +1249,44 @@ - (void)tableViewSelectionDidChange:(NSNotification *)aNotification [self rightFilterTableChangedSelection]; } } +- (void)tableView:(NSTableView *)tableView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row +{ + if (tableView == rightFilterBarTable) + { + id currentRow = [rightFilterBarItems objectAtIndex:row]; + + if ([currentRow respondsToSelector:@selector(characterAtIndex:)]) + { + //[cell setAlignment:NSCenterTextAlignment]; + [cell setFont:[NSFont boldSystemFontOfSize:13]];//[NSFont fontWithName:@"Menlo-Bold" size:12]]; + //[(NSCell *)cell setTag:10]; + } + else + { + //[cell setAlignment:NSNaturalTextAlignment]; + [cell setFont:[NSFont fontWithName:@"Menlo" size:12]]; + //[(NSCell *)cell setTag:-2]; + //[cell setTag:-2]; + } + } +} +/* +- (CGFloat)tableView:(NSTableView *)tableView heightOfRow:(NSInteger)row +{ + if (tableView == rightFilterBarTable) + { + id currentRow = [rightFilterBarItems objectAtIndex:row]; + + if ([currentRow respondsToSelector:@selector(characterAtIndex:)]) + { + return 28; + } + } + + return [tableView rowHeight]; +} + */ + - (void)rightFilterTableChangedSelection { NSInteger selind = [rightFilterBarTable selectedRow]; @@ -1260,7 +1308,14 @@ - (void)rightFilterTableChangedSelection NSString *href = [kvobject valueForKey:@"href"]; NSLog(@"[kvobject valueForKey:@\"href\"] = %@", href); - [browserWebView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"window.location.hash = '%@';", href]]; + if ([href isLike:@"#*"]) + { + [browserWebView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"window.location.hash = '%@';", href]]; + } + else + { + [browserWebView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"window.location = '%@';", href]]; + } } }