trunk/src/osd/modules/debugger/osx/debugview.m
| r243619 | r243620 | |
| 224 | 224 | |
| 225 | 225 | [self setFont:[[self class] defaultFont]]; |
| 226 | 226 | |
| 227 | NSMenu *contextMenu = [[NSMenu allocWithZone:[NSMenu menuZone]] initWithTitle:@"Context"]; |
| 228 | [self addContextMenuItemsToMenu:contextMenu]; |
| 229 | [self setMenu:contextMenu]; |
| 230 | [contextMenu release]; |
| 231 | |
| 227 | 232 | return self; |
| 228 | 233 | } |
| 229 | 234 | |
| r243619 | r243620 | |
| 301 | 306 | } |
| 302 | 307 | |
| 303 | 308 | |
| 309 | - (IBAction)copyVisible:(id)sender { |
| 310 | debug_view_xy const size = view->visible_size(); |
| 311 | debug_view_char const *data = view->viewdata(); |
| 312 | if (!data) |
| 313 | { |
| 314 | NSBeep(); |
| 315 | return; |
| 316 | } |
| 317 | |
| 318 | for (UINT32 row = 0; row < size.y; row++, data += size.x) |
| 319 | { |
| 320 | int attr = -1; |
| 321 | NSUInteger start = [text length], length = 0; |
| 322 | for (UINT32 col = 0; col < size.x; col++) |
| 323 | { |
| 324 | [[text mutableString] appendFormat:@"%c", data[col].byte]; |
| 325 | if ((start < length) && (attr != (data[col].attrib & ~DCA_SELECTED))) |
| 326 | { |
| 327 | NSRange const run = NSMakeRange(start, length - start); |
| 328 | [text addAttribute:NSForegroundColorAttributeName |
| 329 | value:[self foregroundForAttribute:attr] |
| 330 | range:run]; |
| 331 | [text addAttribute:NSBackgroundColorAttributeName |
| 332 | value:[self backgroundForAttribute:attr] |
| 333 | range:run]; |
| 334 | start = length; |
| 335 | } |
| 336 | attr = data[col].attrib & ~DCA_SELECTED; |
| 337 | length = [text length]; |
| 338 | } |
| 339 | if (start < length) |
| 340 | { |
| 341 | NSRange const run = NSMakeRange(start, length - start); |
| 342 | [text addAttribute:NSForegroundColorAttributeName |
| 343 | value:[self foregroundForAttribute:attr] |
| 344 | range:run]; |
| 345 | [text addAttribute:NSBackgroundColorAttributeName |
| 346 | value:[self backgroundForAttribute:attr] |
| 347 | range:run]; |
| 348 | } |
| 349 | [[text mutableString] appendString:@"\n"]; |
| 350 | } |
| 351 | |
| 352 | NSRange const run = NSMakeRange(0, [text length]); |
| 353 | [text addAttribute:NSFontAttributeName value:font range:run]; |
| 354 | NSPasteboard *const board = [NSPasteboard generalPasteboard]; |
| 355 | [board declareTypes:[NSArray arrayWithObject:NSRTFPboardType] owner:nil]; |
| 356 | [board setData:[text RTFFromRange:run documentAttributes:nil] forType:NSRTFPboardType]; |
| 357 | [text deleteCharactersInRange:run]; |
| 358 | } |
| 359 | |
| 360 | |
| 304 | 361 | - (void)windowDidBecomeKey:(NSNotification *)notification { |
| 305 | 362 | NSWindow *win = [notification object]; |
| 306 | 363 | if ((win == [self window]) && ([win firstResponder] == self) && view->cursor_supported()) |
| r243619 | r243620 | |
| 315 | 372 | } |
| 316 | 373 | |
| 317 | 374 | |
| 375 | - (void)addContextMenuItemsToMenu:(NSMenu *)menu { |
| 376 | NSMenuItem *item; |
| 377 | |
| 378 | item = [menu addItemWithTitle:@"Copy Visible" |
| 379 | action:@selector(copyVisible:) |
| 380 | keyEquivalent:@""]; |
| 381 | [item setTarget:self]; |
| 382 | } |
| 383 | |
| 384 | |
| 318 | 385 | - (BOOL)acceptsFirstResponder { |
| 319 | 386 | return view->cursor_supported(); |
| 320 | 387 | } |
trunk/src/osd/modules/debugger/osx/disassemblyview.m
| r243619 | r243620 | |
| 16 | 16 | |
| 17 | 17 | @implementation MAMEDisassemblyView |
| 18 | 18 | |
| 19 | | - (void)createContextMenu { |
| 20 | | NSMenu *contextMenu = [[NSMenu allocWithZone:[NSMenu menuZone]] initWithTitle:@"Disassembly"]; |
| 21 | | NSMenuItem *item; |
| 22 | | |
| 23 | | item = [contextMenu addItemWithTitle:@"Toggle Breakpoint" |
| 24 | | action:@selector(debugToggleBreakpoint:) |
| 25 | | keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF9FunctionKey]]; |
| 26 | | [item setKeyEquivalentModifierMask:0]; |
| 27 | | |
| 28 | | item = [contextMenu addItemWithTitle:@"Disable Breakpoint" |
| 29 | | action:@selector(debugToggleBreakpointEnable:) |
| 30 | | keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF9FunctionKey]]; |
| 31 | | [item setKeyEquivalentModifierMask:NSShiftKeyMask]; |
| 32 | | |
| 33 | | [contextMenu addItem:[NSMenuItem separatorItem]]; |
| 34 | | |
| 35 | | item = [contextMenu addItemWithTitle:@"Run to Cursor" |
| 36 | | action:@selector(debugRunToCursor:) |
| 37 | | keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF4FunctionKey]]; |
| 38 | | [item setKeyEquivalentModifierMask:0]; |
| 39 | | |
| 40 | | [contextMenu addItem:[NSMenuItem separatorItem]]; |
| 41 | | |
| 42 | | item = [contextMenu addItemWithTitle:@"Raw Opcodes" |
| 43 | | action:@selector(showRightColumn:) |
| 44 | | keyEquivalent:@"r"]; |
| 45 | | [item setTarget:self]; |
| 46 | | [item setTag:DASM_RIGHTCOL_RAW]; |
| 47 | | |
| 48 | | item = [contextMenu addItemWithTitle:@"Encrypted Opcodes" |
| 49 | | action:@selector(showRightColumn:) |
| 50 | | keyEquivalent:@"e"]; |
| 51 | | [item setTarget:self]; |
| 52 | | [item setTag:DASM_RIGHTCOL_ENCRYPTED]; |
| 53 | | |
| 54 | | item = [contextMenu addItemWithTitle:@"Comments" |
| 55 | | action:@selector(showRightColumn:) |
| 56 | | keyEquivalent:@"n"]; |
| 57 | | [item setTarget:self]; |
| 58 | | [item setTag:DASM_RIGHTCOL_COMMENTS]; |
| 59 | | |
| 60 | | [self setMenu:contextMenu]; |
| 61 | | [contextMenu release]; |
| 62 | | } |
| 63 | | |
| 64 | | |
| 65 | 19 | - (id)initWithFrame:(NSRect)f machine:(running_machine &)m { |
| 66 | 20 | if (!(self = [super initWithFrame:f type:DVT_DISASSEMBLY machine:m])) |
| 67 | 21 | return nil; |
| 68 | | [self createContextMenu]; |
| 69 | 22 | return self; |
| 70 | 23 | } |
| 71 | 24 | |
| r243619 | r243620 | |
| 106 | 59 | } |
| 107 | 60 | |
| 108 | 61 | |
| 62 | - (void)addContextMenuItemsToMenu:(NSMenu *)menu { |
| 63 | NSMenuItem *item; |
| 64 | |
| 65 | [super addContextMenuItemsToMenu:menu]; |
| 66 | |
| 67 | if ([menu numberOfItems] > 0) |
| 68 | [menu addItem:[NSMenuItem separatorItem]]; |
| 69 | |
| 70 | item = [menu addItemWithTitle:@"Toggle Breakpoint" |
| 71 | action:@selector(debugToggleBreakpoint:) |
| 72 | keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF9FunctionKey]]; |
| 73 | [item setKeyEquivalentModifierMask:0]; |
| 74 | |
| 75 | item = [menu addItemWithTitle:@"Disable Breakpoint" |
| 76 | action:@selector(debugToggleBreakpointEnable:) |
| 77 | keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF9FunctionKey]]; |
| 78 | [item setKeyEquivalentModifierMask:NSShiftKeyMask]; |
| 79 | |
| 80 | [menu addItem:[NSMenuItem separatorItem]]; |
| 81 | |
| 82 | item = [menu addItemWithTitle:@"Run to Cursor" |
| 83 | action:@selector(debugRunToCursor:) |
| 84 | keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF4FunctionKey]]; |
| 85 | [item setKeyEquivalentModifierMask:0]; |
| 86 | |
| 87 | [menu addItem:[NSMenuItem separatorItem]]; |
| 88 | |
| 89 | item = [menu addItemWithTitle:@"Raw Opcodes" |
| 90 | action:@selector(showRightColumn:) |
| 91 | keyEquivalent:@"r"]; |
| 92 | [item setTarget:self]; |
| 93 | [item setTag:DASM_RIGHTCOL_RAW]; |
| 94 | |
| 95 | item = [menu addItemWithTitle:@"Encrypted Opcodes" |
| 96 | action:@selector(showRightColumn:) |
| 97 | keyEquivalent:@"e"]; |
| 98 | [item setTarget:self]; |
| 99 | [item setTag:DASM_RIGHTCOL_ENCRYPTED]; |
| 100 | |
| 101 | item = [menu addItemWithTitle:@"Comments" |
| 102 | action:@selector(showRightColumn:) |
| 103 | keyEquivalent:@"n"]; |
| 104 | [item setTarget:self]; |
| 105 | [item setTag:DASM_RIGHTCOL_COMMENTS]; |
| 106 | } |
| 107 | |
| 108 | |
| 109 | 109 | - (NSString *)selectedSubviewName { |
| 110 | 110 | const debug_view_source *source = view->source(); |
| 111 | 111 | if (source != NULL) |
trunk/src/osd/modules/debugger/osx/memoryview.m
| r243619 | r243620 | |
| 18 | 18 | @implementation MAMEMemoryView |
| 19 | 19 | |
| 20 | 20 | - (id)initWithFrame:(NSRect)f machine:(running_machine &)m { |
| 21 | | NSMenu *contextMenu; |
| 22 | | |
| 23 | 21 | if (!(self = [super initWithFrame:f type:DVT_MEMORY machine:m])) |
| 24 | 22 | return nil; |
| 25 | | |
| 26 | | contextMenu = [[NSMenu allocWithZone:[NSMenu menuZone]] initWithTitle:@"Memory"]; |
| 27 | | [self insertActionItemsInMenu:contextMenu atIndex:0]; |
| 28 | | [self setMenu:contextMenu]; |
| 29 | | [contextMenu release]; |
| 30 | | |
| 31 | 23 | return self; |
| 32 | 24 | } |
| 33 | 25 | |
| r243619 | r243620 | |
| 71 | 63 | } |
| 72 | 64 | |
| 73 | 65 | |
| 66 | - (void)addContextMenuItemsToMenu:(NSMenu *)menu { |
| 67 | [super addContextMenuItemsToMenu:menu]; |
| 68 | if ([menu numberOfItems] > 0) |
| 69 | [menu addItem:[NSMenuItem separatorItem]]; |
| 70 | [self insertActionItemsInMenu:menu atIndex:[menu numberOfItems]]; |
| 71 | } |
| 72 | |
| 73 | |
| 74 | 74 | - (NSString *)selectedSubviewName { |
| 75 | 75 | debug_view_source const *source = view->source(); |
| 76 | 76 | if (source != NULL) |