Previous 199869 Revisions Next

r35108 Wednesday 18th February, 2015 at 15:47:41 UTC by Vasantha Crabb
Allow copying visible portion of debug view to OS clipboard
[src/osd/modules/debugger/osx]debugview.h debugview.m disassemblyview.m memoryview.m

trunk/src/osd/modules/debugger/osx/debugview.h
r243619r243620
4848- (BOOL)cursorVisible;
4949- (debug_view_xy)cursorPosition;
5050
51- (IBAction)copyVisible:(id)sender;
52
5153- (void)windowDidBecomeKey:(NSNotification *)notification;
5254- (void)windowDidResignKey:(NSNotification *)notification;
5355
56- (void)addContextMenuItemsToMenu:(NSMenu *)menu;
57
5458@end
5559
5660
trunk/src/osd/modules/debugger/osx/debugview.m
r243619r243620
224224
225225   [self setFont:[[self class] defaultFont]];
226226
227   NSMenu *contextMenu = [[NSMenu allocWithZone:[NSMenu menuZone]] initWithTitle:@"Context"];
228   [self addContextMenuItemsToMenu:contextMenu];
229   [self setMenu:contextMenu];
230   [contextMenu release];
231
227232   return self;
228233}
229234
r243619r243620
301306}
302307
303308
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
304361- (void)windowDidBecomeKey:(NSNotification *)notification {
305362   NSWindow *win = [notification object];
306363   if ((win == [self window]) && ([win firstResponder] == self) && view->cursor_supported())
r243619r243620
315372}
316373
317374
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
318385- (BOOL)acceptsFirstResponder {
319386   return view->cursor_supported();
320387}
trunk/src/osd/modules/debugger/osx/disassemblyview.m
r243619r243620
1616
1717@implementation MAMEDisassemblyView
1818
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
6519- (id)initWithFrame:(NSRect)f machine:(running_machine &)m {
6620   if (!(self = [super initWithFrame:f type:DVT_DISASSEMBLY machine:m]))
6721      return nil;
68   [self createContextMenu];
6922   return self;
7023}
7124
r243619r243620
10659}
10760
10861
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
109109- (NSString *)selectedSubviewName {
110110   const debug_view_source *source = view->source();
111111   if (source != NULL)
trunk/src/osd/modules/debugger/osx/memoryview.m
r243619r243620
1818@implementation MAMEMemoryView
1919
2020- (id)initWithFrame:(NSRect)f machine:(running_machine &)m {
21   NSMenu   *contextMenu;
22
2321   if (!(self = [super initWithFrame:f type:DVT_MEMORY machine:m]))
2422      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
3123   return self;
3224}
3325
r243619r243620
7163}
7264
7365
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
7474- (NSString *)selectedSubviewName {
7575   debug_view_source const *source = view->source();
7676   if (source != NULL)


Previous 199869 Revisions Next


© 1997-2024 The MAME Team