add ability to copy to the message window, and allow multiple selection

This commit is contained in:
Mitchell Livingston 2007-09-11 00:44:15 +00:00
parent 3e4bf1348f
commit c38b8cb01f
2 changed files with 24 additions and 1 deletions

View File

@ -164,10 +164,33 @@
- (void) tableView: (NSTableView *) tableView sortDescriptorsDidChange: (NSArray *) oldDescriptors
{
[fMessages sortUsingDescriptors: [fMessageTable sortDescriptors]];
[fMessageTable reloadData];
}
- (void) copy: (id) sender
{
NSIndexSet * indexes = [fMessageTable selectedRowIndexes];
NSMutableArray * messageStrings = [NSMutableArray arrayWithCapacity: [indexes count]];
unsigned int i;
for (i = [indexes firstIndex]; i != NSNotFound; i = [indexes indexGreaterThanIndex: i])
[messageStrings addObject: [self stringForMessage: [fMessages objectAtIndex: i]]];
NSPasteboard * pb = [NSPasteboard generalPasteboard];
[pb declareTypes: [NSArray arrayWithObject: NSStringPboardType] owner: self];
[pb setString: [messageStrings componentsJoinedByString: @"\n"] forType: NSStringPboardType];
}
- (BOOL) validateMenuItem: (NSMenuItem *) menuItem
{
SEL action = [menuItem action];
if (action == @selector(copy:))
return [fMessageTable numberOfSelectedRows] > 0;
return YES;
}
- (void) changeLevel: (id) sender
{
[self updateLog: nil];