#import "MyMenuCell.h"

@implementation  MyMenuCell

fixItem(p) char *p; {
    int nl=1;
    char *l = p;
    squishblank(p);
    while (*p){
        if (*p==':' && nl && p[1])
            p[1]='\t', nl=0;
        else
        if (*p=='\n') nl=1;
        p++;
    }
}

- click:sender {
    char buf[80000], *p = buf;
    if (getItem(buf,n)){
        if (strncmp(p,"\n(Record",8)==0) p = index(p,')')+1;
        fixItem(p);
        setText(p);
    }
    return self;
}

- setStringValueNoCopy:(char *)s {
    [super setStringValue:s];
    [self setLeaf:YES];
    [self setAction:@selector(click:)];
    [self setTarget:self];
    return self;
}

#import <appkit/Font.h>
#import <appkit/FontManager.h>
static id f = (id)0;

- setContents:(int)N {
    extern char *nthItem();
    extern int nthItemIndex();
    
    if (!f) f = [Font newFont:"Courier" size:12.];
    [self setFont:f];
    [super setStringValueNoCopy:s=nthItem(N)];
    n = nthItemIndex(N);
    return self;
}

- setStringValue: (char *)s {
    return [self setStringValueNoCopy:s];
}

- (char *)stringValue {
    return s;
}

@end	