/* PBDebuggerHighlightColor.m created by bbum on Thu 03-Jul-1997 */
#import <AppKit/AppKit.h>
#import <objc/objc-class.h>

#import "PBDebuggerHighlightColor.h"

static NSColor *__debuggerDefaultLineHightlightColor(id self, SEL _cmd)
{
    return [PBDebuggerHighlightColor colorFromRGBString:
        [[NSUserDefaults standardUserDefaults] objectForKey: @"PBDebugHighlightColor"]];
}

@implementation PBDebuggerHighlightColor
+ (NSColor *) colorFromRGBString: (NSString *) aString
{
    NSScanner *floatScanner = [NSScanner scannerWithString: aString];
    float red, green, blue;

    if (aString == nil)
        return [NSColor yellowColor];

    [floatScanner scanFloat: &red];
    [floatScanner scanFloat: &green];
    [floatScanner scanFloat: &blue];

    return [NSColor colorWithCalibratedRed: red green: green blue: blue alpha: 1.0];
}

+ (void) load 
// this is a loadable bundle-- the runtime will be happy enough that we can do unhappy things
{
    Class launcherClass = NSClassFromString(@"Launcher");
    Method defaultHighlightColorMethod;

    defaultHighlightColorMethod = class_getInstanceMethod(launcherClass, @selector(debuggerDefaultLineHightlightColor));
    defaultHighlightColorMethod->method_imp = (IMP) __debuggerDefaultLineHightlightColor;

    NSLog(@"PSDebuggingHighlightColor Bundle installed. Caveat Emptor.");
}
@end
