mirror of
https://github.com/holub/mame
synced 2025-07-01 00:09:18 +03:00
Allow copying visible portion of debug view to OS clipboard
This commit is contained in:
parent
c46847b551
commit
9770a7aa9c
@ -48,9 +48,13 @@
|
||||
- (BOOL)cursorVisible;
|
||||
- (debug_view_xy)cursorPosition;
|
||||
|
||||
- (IBAction)copyVisible:(id)sender;
|
||||
|
||||
- (void)windowDidBecomeKey:(NSNotification *)notification;
|
||||
- (void)windowDidResignKey:(NSNotification *)notification;
|
||||
|
||||
- (void)addContextMenuItemsToMenu:(NSMenu *)menu;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
@ -224,6 +224,11 @@ static void debugwin_view_update(debug_view &view, void *osdprivate)
|
||||
|
||||
[self setFont:[[self class] defaultFont]];
|
||||
|
||||
NSMenu *contextMenu = [[NSMenu allocWithZone:[NSMenu menuZone]] initWithTitle:@"Context"];
|
||||
[self addContextMenuItemsToMenu:contextMenu];
|
||||
[self setMenu:contextMenu];
|
||||
[contextMenu release];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@ -301,6 +306,58 @@ static void debugwin_view_update(debug_view &view, void *osdprivate)
|
||||
}
|
||||
|
||||
|
||||
- (IBAction)copyVisible:(id)sender {
|
||||
debug_view_xy const size = view->visible_size();
|
||||
debug_view_char const *data = view->viewdata();
|
||||
if (!data)
|
||||
{
|
||||
NSBeep();
|
||||
return;
|
||||
}
|
||||
|
||||
for (UINT32 row = 0; row < size.y; row++, data += size.x)
|
||||
{
|
||||
int attr = -1;
|
||||
NSUInteger start = [text length], length = 0;
|
||||
for (UINT32 col = 0; col < size.x; col++)
|
||||
{
|
||||
[[text mutableString] appendFormat:@"%c", data[col].byte];
|
||||
if ((start < length) && (attr != (data[col].attrib & ~DCA_SELECTED)))
|
||||
{
|
||||
NSRange const run = NSMakeRange(start, length - start);
|
||||
[text addAttribute:NSForegroundColorAttributeName
|
||||
value:[self foregroundForAttribute:attr]
|
||||
range:run];
|
||||
[text addAttribute:NSBackgroundColorAttributeName
|
||||
value:[self backgroundForAttribute:attr]
|
||||
range:run];
|
||||
start = length;
|
||||
}
|
||||
attr = data[col].attrib & ~DCA_SELECTED;
|
||||
length = [text length];
|
||||
}
|
||||
if (start < length)
|
||||
{
|
||||
NSRange const run = NSMakeRange(start, length - start);
|
||||
[text addAttribute:NSForegroundColorAttributeName
|
||||
value:[self foregroundForAttribute:attr]
|
||||
range:run];
|
||||
[text addAttribute:NSBackgroundColorAttributeName
|
||||
value:[self backgroundForAttribute:attr]
|
||||
range:run];
|
||||
}
|
||||
[[text mutableString] appendString:@"\n"];
|
||||
}
|
||||
|
||||
NSRange const run = NSMakeRange(0, [text length]);
|
||||
[text addAttribute:NSFontAttributeName value:font range:run];
|
||||
NSPasteboard *const board = [NSPasteboard generalPasteboard];
|
||||
[board declareTypes:[NSArray arrayWithObject:NSRTFPboardType] owner:nil];
|
||||
[board setData:[text RTFFromRange:run documentAttributes:nil] forType:NSRTFPboardType];
|
||||
[text deleteCharactersInRange:run];
|
||||
}
|
||||
|
||||
|
||||
- (void)windowDidBecomeKey:(NSNotification *)notification {
|
||||
NSWindow *win = [notification object];
|
||||
if ((win == [self window]) && ([win firstResponder] == self) && view->cursor_supported())
|
||||
@ -315,6 +372,16 @@ static void debugwin_view_update(debug_view &view, void *osdprivate)
|
||||
}
|
||||
|
||||
|
||||
- (void)addContextMenuItemsToMenu:(NSMenu *)menu {
|
||||
NSMenuItem *item;
|
||||
|
||||
item = [menu addItemWithTitle:@"Copy Visible"
|
||||
action:@selector(copyVisible:)
|
||||
keyEquivalent:@""];
|
||||
[item setTarget:self];
|
||||
}
|
||||
|
||||
|
||||
- (BOOL)acceptsFirstResponder {
|
||||
return view->cursor_supported();
|
||||
}
|
||||
|
@ -16,56 +16,9 @@
|
||||
|
||||
@implementation MAMEDisassemblyView
|
||||
|
||||
- (void)createContextMenu {
|
||||
NSMenu *contextMenu = [[NSMenu allocWithZone:[NSMenu menuZone]] initWithTitle:@"Disassembly"];
|
||||
NSMenuItem *item;
|
||||
|
||||
item = [contextMenu addItemWithTitle:@"Toggle Breakpoint"
|
||||
action:@selector(debugToggleBreakpoint:)
|
||||
keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF9FunctionKey]];
|
||||
[item setKeyEquivalentModifierMask:0];
|
||||
|
||||
item = [contextMenu addItemWithTitle:@"Disable Breakpoint"
|
||||
action:@selector(debugToggleBreakpointEnable:)
|
||||
keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF9FunctionKey]];
|
||||
[item setKeyEquivalentModifierMask:NSShiftKeyMask];
|
||||
|
||||
[contextMenu addItem:[NSMenuItem separatorItem]];
|
||||
|
||||
item = [contextMenu addItemWithTitle:@"Run to Cursor"
|
||||
action:@selector(debugRunToCursor:)
|
||||
keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF4FunctionKey]];
|
||||
[item setKeyEquivalentModifierMask:0];
|
||||
|
||||
[contextMenu addItem:[NSMenuItem separatorItem]];
|
||||
|
||||
item = [contextMenu addItemWithTitle:@"Raw Opcodes"
|
||||
action:@selector(showRightColumn:)
|
||||
keyEquivalent:@"r"];
|
||||
[item setTarget:self];
|
||||
[item setTag:DASM_RIGHTCOL_RAW];
|
||||
|
||||
item = [contextMenu addItemWithTitle:@"Encrypted Opcodes"
|
||||
action:@selector(showRightColumn:)
|
||||
keyEquivalent:@"e"];
|
||||
[item setTarget:self];
|
||||
[item setTag:DASM_RIGHTCOL_ENCRYPTED];
|
||||
|
||||
item = [contextMenu addItemWithTitle:@"Comments"
|
||||
action:@selector(showRightColumn:)
|
||||
keyEquivalent:@"n"];
|
||||
[item setTarget:self];
|
||||
[item setTag:DASM_RIGHTCOL_COMMENTS];
|
||||
|
||||
[self setMenu:contextMenu];
|
||||
[contextMenu release];
|
||||
}
|
||||
|
||||
|
||||
- (id)initWithFrame:(NSRect)f machine:(running_machine &)m {
|
||||
if (!(self = [super initWithFrame:f type:DVT_DISASSEMBLY machine:m]))
|
||||
return nil;
|
||||
[self createContextMenu];
|
||||
return self;
|
||||
}
|
||||
|
||||
@ -106,6 +59,53 @@
|
||||
}
|
||||
|
||||
|
||||
- (void)addContextMenuItemsToMenu:(NSMenu *)menu {
|
||||
NSMenuItem *item;
|
||||
|
||||
[super addContextMenuItemsToMenu:menu];
|
||||
|
||||
if ([menu numberOfItems] > 0)
|
||||
[menu addItem:[NSMenuItem separatorItem]];
|
||||
|
||||
item = [menu addItemWithTitle:@"Toggle Breakpoint"
|
||||
action:@selector(debugToggleBreakpoint:)
|
||||
keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF9FunctionKey]];
|
||||
[item setKeyEquivalentModifierMask:0];
|
||||
|
||||
item = [menu addItemWithTitle:@"Disable Breakpoint"
|
||||
action:@selector(debugToggleBreakpointEnable:)
|
||||
keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF9FunctionKey]];
|
||||
[item setKeyEquivalentModifierMask:NSShiftKeyMask];
|
||||
|
||||
[menu addItem:[NSMenuItem separatorItem]];
|
||||
|
||||
item = [menu addItemWithTitle:@"Run to Cursor"
|
||||
action:@selector(debugRunToCursor:)
|
||||
keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF4FunctionKey]];
|
||||
[item setKeyEquivalentModifierMask:0];
|
||||
|
||||
[menu addItem:[NSMenuItem separatorItem]];
|
||||
|
||||
item = [menu addItemWithTitle:@"Raw Opcodes"
|
||||
action:@selector(showRightColumn:)
|
||||
keyEquivalent:@"r"];
|
||||
[item setTarget:self];
|
||||
[item setTag:DASM_RIGHTCOL_RAW];
|
||||
|
||||
item = [menu addItemWithTitle:@"Encrypted Opcodes"
|
||||
action:@selector(showRightColumn:)
|
||||
keyEquivalent:@"e"];
|
||||
[item setTarget:self];
|
||||
[item setTag:DASM_RIGHTCOL_ENCRYPTED];
|
||||
|
||||
item = [menu addItemWithTitle:@"Comments"
|
||||
action:@selector(showRightColumn:)
|
||||
keyEquivalent:@"n"];
|
||||
[item setTarget:self];
|
||||
[item setTag:DASM_RIGHTCOL_COMMENTS];
|
||||
}
|
||||
|
||||
|
||||
- (NSString *)selectedSubviewName {
|
||||
const debug_view_source *source = view->source();
|
||||
if (source != NULL)
|
||||
|
@ -18,16 +18,8 @@
|
||||
@implementation MAMEMemoryView
|
||||
|
||||
- (id)initWithFrame:(NSRect)f machine:(running_machine &)m {
|
||||
NSMenu *contextMenu;
|
||||
|
||||
if (!(self = [super initWithFrame:f type:DVT_MEMORY machine:m]))
|
||||
return nil;
|
||||
|
||||
contextMenu = [[NSMenu allocWithZone:[NSMenu menuZone]] initWithTitle:@"Memory"];
|
||||
[self insertActionItemsInMenu:contextMenu atIndex:0];
|
||||
[self setMenu:contextMenu];
|
||||
[contextMenu release];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@ -71,6 +63,14 @@
|
||||
}
|
||||
|
||||
|
||||
- (void)addContextMenuItemsToMenu:(NSMenu *)menu {
|
||||
[super addContextMenuItemsToMenu:menu];
|
||||
if ([menu numberOfItems] > 0)
|
||||
[menu addItem:[NSMenuItem separatorItem]];
|
||||
[self insertActionItemsInMenu:menu atIndex:[menu numberOfItems]];
|
||||
}
|
||||
|
||||
|
||||
- (NSString *)selectedSubviewName {
|
||||
debug_view_source const *source = view->source();
|
||||
if (source != NULL)
|
||||
|
Loading…
Reference in New Issue
Block a user