diff options
Diffstat (limited to 'src/osd/modules/debugger/osx/debugview.mm')
-rw-r--r-- | src/osd/modules/debugger/osx/debugview.mm | 94 |
1 files changed, 58 insertions, 36 deletions
diff --git a/src/osd/modules/debugger/osx/debugview.mm b/src/osd/modules/debugger/osx/debugview.mm index f3e4c6b8b64..504eaab8fe3 100644 --- a/src/osd/modules/debugger/osx/debugview.mm +++ b/src/osd/modules/debugger/osx/debugview.mm @@ -10,13 +10,14 @@ #include "emu.h" #include "debugger.h" +#include "debug/debugcon.h" #include "debug/debugcpu.h" #include "modules/lib/osdobj_common.h" #include "util/xmlfile.h" -#include <string.h> +#include <cstring> static NSColor *DefaultForeground; @@ -50,6 +51,26 @@ static void debugwin_view_update(debug_view &view, void *osdprivate) @implementation MAMEDebugView + (void)initialize { + // 10.15 and better get full adaptive Dark Mode support +#if defined(MAC_OS_X_VERSION_10_15) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15 + DefaultForeground = [[NSColor textColor] retain]; + ChangedForeground = [[NSColor systemRedColor] retain]; + CommentForeground = [[NSColor systemGreenColor] retain]; + // DCA_INVALID and DCA_DISABLED currently are not set by the core, so these 4 are unused + InvalidForeground = [[NSColor colorWithCalibratedRed:0.0 green:0.0 blue:1.0 alpha:1.0] retain]; + DisabledChangedForeground = [[NSColor colorWithCalibratedRed:0.5 green:0.125 blue:0.125 alpha:1.0] retain]; + DisabledInvalidForeground = [[NSColor colorWithCalibratedRed:0.0 green:0.0 blue:0.5 alpha:1.0] retain]; + DisabledCommentForeground = [[NSColor colorWithCalibratedRed:0.0 green:0.25 blue:0.0 alpha:1.0] retain]; + + DefaultBackground = [[NSColor textBackgroundColor] retain]; + VisitedBackground = [[NSColor systemTealColor] retain]; + AncillaryBackground = [[NSColor unemphasizedSelectedContentBackgroundColor] retain]; + SelectedBackground = [[NSColor selectedContentBackgroundColor] retain]; + CurrentBackground = [[NSColor selectedControlColor] retain]; + SelectedCurrentBackground = [[NSColor unemphasizedSelectedContentBackgroundColor] retain]; + InactiveSelectedBackground = [[NSColor unemphasizedSelectedContentBackgroundColor] retain]; + InactiveSelectedCurrentBackground = [[NSColor systemGrayColor] retain]; +#else DefaultForeground = [[NSColor colorWithCalibratedWhite:0.0 alpha:1.0] retain]; ChangedForeground = [[NSColor colorWithCalibratedRed:0.875 green:0.0 blue:0.0 alpha:1.0] retain]; InvalidForeground = [[NSColor colorWithCalibratedRed:0.0 green:0.0 blue:1.0 alpha:1.0] retain]; @@ -66,6 +87,7 @@ static void debugwin_view_update(debug_view &view, void *osdprivate) SelectedCurrentBackground = [[NSColor colorWithCalibratedRed:0.875 green:0.625 blue:0.875 alpha:1.0] retain]; InactiveSelectedBackground = [[NSColor colorWithCalibratedWhite:0.875 alpha:1.0] retain]; InactiveSelectedCurrentBackground = [[NSColor colorWithCalibratedRed:0.875 green:0.5 blue:0.625 alpha:1.0] retain]; +#endif NonWhiteCharacters = [[[NSCharacterSet whitespaceAndNewlineCharacterSet] invertedSet] retain]; } @@ -255,7 +277,7 @@ static void debugwin_view_update(debug_view &view, void *osdprivate) [self setFont:[[self class] defaultFontForMachine:m]]; - NSMenu *contextMenu = [[NSMenu allocWithZone:[NSMenu menuZone]] initWithTitle:@"Context"]; + NSMenu *contextMenu = [[NSMenu alloc] initWithTitle:@"Context"]; [self addContextMenuItemsToMenu:contextMenu]; [self setMenu:contextMenu]; [contextMenu release]; @@ -410,15 +432,15 @@ static void debugwin_view_update(debug_view &view, void *osdprivate) 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:[NSDictionary dictionary]] forType:NSRTFPboardType]; + [board declareTypes:[NSArray arrayWithObject:NSPasteboardTypeRTF] owner:nil]; + [board setData:[text RTFFromRange:run documentAttributes:[NSDictionary dictionary]] forType:NSPasteboardTypeRTF]; [text deleteCharactersInRange:run]; } - (IBAction)paste:(id)sender { NSPasteboard *const board = [NSPasteboard generalPasteboard]; - NSString *const avail = [board availableTypeFromArray:[NSArray arrayWithObject:NSStringPboardType]]; + NSString *const avail = [board availableTypeFromArray:[NSArray arrayWithObject:NSPasteboardTypeString]]; if (avail == nil) { NSBeep(); @@ -492,22 +514,22 @@ static void debugwin_view_update(debug_view &view, void *osdprivate) - (void)saveConfigurationToNode:(util::xml::data_node *)node { if (view->cursor_supported()) { - util::xml::data_node *const selection = node->add_child("selection", nullptr); + util::xml::data_node *const selection = node->add_child(osd::debugger::NODE_WINDOW_SELECTION, nullptr); if (selection) { debug_view_xy const pos = view->cursor_position(); - selection->set_attribute_int("visible", view->cursor_visible() ? 1 : 0); - selection->set_attribute_int("start_x", pos.x); - selection->set_attribute_int("start_y", pos.y); + selection->set_attribute_int(osd::debugger::ATTR_SELECTION_CURSOR_VISIBLE, view->cursor_visible() ? 1 : 0); + selection->set_attribute_int(osd::debugger::ATTR_SELECTION_CURSOR_X, pos.x); + selection->set_attribute_int(osd::debugger::ATTR_SELECTION_CURSOR_Y, pos.y); } } - util::xml::data_node *const scroll = node->add_child("scroll", nullptr); + util::xml::data_node *const scroll = node->add_child(osd::debugger::NODE_WINDOW_SCROLL, nullptr); if (scroll) { NSRect const visible = [self visibleRect]; - scroll->set_attribute_float("position_x", visible.origin.x); - scroll->set_attribute_float("position_y", visible.origin.y); + scroll->set_attribute_float(osd::debugger::ATTR_SCROLL_ORIGIN_X, visible.origin.x); + scroll->set_attribute_float(osd::debugger::ATTR_SCROLL_ORIGIN_Y, visible.origin.y); } } @@ -515,23 +537,23 @@ static void debugwin_view_update(debug_view &view, void *osdprivate) - (void)restoreConfigurationFromNode:(util::xml::data_node const *)node { if (view->cursor_supported()) { - util::xml::data_node const *const selection = node->get_child("selection"); + util::xml::data_node const *const selection = node->get_child(osd::debugger::NODE_WINDOW_SELECTION); if (selection) { debug_view_xy pos = view->cursor_position(); - view->set_cursor_visible(0 != selection->get_attribute_int("visible", view->cursor_visible() ? 1 : 0)); - pos.x = selection->get_attribute_int("start_x", pos.x); - pos.y = selection->get_attribute_int("start_y", pos.y); + view->set_cursor_visible(0 != selection->get_attribute_int(osd::debugger::ATTR_SELECTION_CURSOR_VISIBLE, view->cursor_visible() ? 1 : 0)); + pos.x = selection->get_attribute_int(osd::debugger::ATTR_SELECTION_CURSOR_X, pos.x); + pos.y = selection->get_attribute_int(osd::debugger::ATTR_SELECTION_CURSOR_Y, pos.y); view->set_cursor_position(pos); } } - util::xml::data_node const *const scroll = node->get_child("scroll"); + util::xml::data_node const *const scroll = node->get_child(osd::debugger::NODE_WINDOW_SCROLL); if (scroll) { NSRect visible = [self visibleRect]; - visible.origin.x = scroll->get_attribute_float("position_x", visible.origin.x); - visible.origin.y = scroll->get_attribute_float("position_y", visible.origin.y); + visible.origin.x = scroll->get_attribute_float(osd::debugger::ATTR_SCROLL_ORIGIN_X, visible.origin.x); + visible.origin.y = scroll->get_attribute_float(osd::debugger::ATTR_SCROLL_ORIGIN_Y, visible.origin.y); [self scrollRectToVisible:visible]; } } @@ -674,7 +696,7 @@ static void debugwin_view_update(debug_view &view, void *osdprivate) NSUInteger start = 0, length = 0; for (uint32_t col = origin.x; col < origin.x + size.x; col++) { - [[text mutableString] appendFormat:@"%c", data[col - origin.x].byte]; + [[text mutableString] appendFormat:@"%C", unichar(data[col - origin.x].byte)]; if ((start < length) && (attr != data[col - origin.x].attrib)) { NSRange const run = NSMakeRange(start, length - start); @@ -742,8 +764,8 @@ static void debugwin_view_update(debug_view &view, void *osdprivate) - (void)mouseDown:(NSEvent *)event { NSPoint const location = [self convertPoint:[event locationInWindow] fromView:nil]; NSUInteger const modifiers = [event modifierFlags]; - view->process_click(((modifiers & NSCommandKeyMask) && [[self window] isMainWindow]) ? DCK_RIGHT_CLICK - : (modifiers & NSAlternateKeyMask) ? DCK_MIDDLE_CLICK + view->process_click(((modifiers & NSEventModifierFlagCommand) && [[self window] isMainWindow]) ? DCK_RIGHT_CLICK + : (modifiers & NSEventModifierFlagOption) ? DCK_MIDDLE_CLICK : DCK_LEFT_CLICK, [self convertLocation:location]); } @@ -754,8 +776,8 @@ static void debugwin_view_update(debug_view &view, void *osdprivate) NSPoint const location = [self convertPoint:[event locationInWindow] fromView:nil]; NSUInteger const modifiers = [event modifierFlags]; if (view->cursor_supported() - && !(modifiers & NSAlternateKeyMask) - && (!(modifiers & NSCommandKeyMask) || ![[self window] isMainWindow])) + && !(modifiers & NSEventModifierFlagOption) + && (!(modifiers & NSEventModifierFlagCommand) || ![[self window] isMainWindow])) { view->set_cursor_position([self convertLocation:location]); view->set_cursor_visible(true); @@ -782,34 +804,34 @@ static void debugwin_view_update(debug_view &view, void *osdprivate) if ([str length] == 1) { - if (modifiers & NSNumericPadKeyMask) + if (modifiers & NSEventModifierFlagNumericPad) { switch ([str characterAtIndex:0]) { case NSUpArrowFunctionKey: - if (modifiers & NSCommandKeyMask) + if (modifiers & NSEventModifierFlagCommand) view->process_char(DCH_CTRLHOME); else view->process_char(DCH_UP); return; case NSDownArrowFunctionKey: - if (modifiers & NSCommandKeyMask) + if (modifiers & NSEventModifierFlagCommand) view->process_char(DCH_CTRLEND); else view->process_char(DCH_DOWN); return; case NSLeftArrowFunctionKey: - if (modifiers & NSCommandKeyMask) + if (modifiers & NSEventModifierFlagCommand) [self typeCharacterAndScrollToCursor:DCH_HOME]; - else if (modifiers & NSAlternateKeyMask) + else if (modifiers & NSEventModifierFlagOption) [self typeCharacterAndScrollToCursor:DCH_CTRLLEFT]; else [self typeCharacterAndScrollToCursor:DCH_LEFT]; return; case NSRightArrowFunctionKey: - if (modifiers & NSCommandKeyMask) + if (modifiers & NSEventModifierFlagCommand) [self typeCharacterAndScrollToCursor:DCH_END]; - else if (modifiers & NSAlternateKeyMask) + else if (modifiers & NSEventModifierFlagOption) [self typeCharacterAndScrollToCursor:DCH_CTRLRIGHT]; else [self typeCharacterAndScrollToCursor:DCH_RIGHT]; @@ -819,18 +841,18 @@ static void debugwin_view_update(debug_view &view, void *osdprivate) return; } } - else if (modifiers & NSFunctionKeyMask) + else if (modifiers & NSEventModifierFlagFunction) { switch ([str characterAtIndex:0]) { case NSPageUpFunctionKey: - if (modifiers & NSAlternateKeyMask) + if (modifiers & NSEventModifierFlagOption) { view->process_char(DCH_PUP); return; } case NSPageDownFunctionKey: - if (modifiers & NSAlternateKeyMask) + if (modifiers & NSEventModifierFlagOption) { view->process_char(DCH_PDOWN); return; @@ -871,7 +893,7 @@ static void debugwin_view_update(debug_view &view, void *osdprivate) - (void)insertNewline:(id)sender { - machine->debugger().cpu().get_visible_cpu()->debug()->single_step(); + machine->debugger().console().get_visible_cpu()->debug()->single_step(); } @@ -899,7 +921,7 @@ static void debugwin_view_update(debug_view &view, void *osdprivate) if (action == @selector(paste:)) { NSPasteboard *const board = [NSPasteboard generalPasteboard]; - return [board availableTypeFromArray:[NSArray arrayWithObject:NSStringPboardType]] != nil; + return [board availableTypeFromArray:[NSArray arrayWithObject:NSPasteboardTypeString]] != nil; } else { |