From 88392d1a6963cca5009b9b0c20b054ad9e911b6c Mon Sep 17 00:00:00 2001 From: Tomáš Znamenáček Date: Tue, 5 Aug 2014 15:16:59 +0200 Subject: Introduced a separate header file for keycode definitions. --- Framework/MASKeyCodes.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Framework/MASKeyCodes.h (limited to 'Framework/MASKeyCodes.h') diff --git a/Framework/MASKeyCodes.h b/Framework/MASKeyCodes.h new file mode 100644 index 0000000..69b2a97 --- /dev/null +++ b/Framework/MASKeyCodes.h @@ -0,0 +1,23 @@ +#import + +// These glyphs are missed in Carbon.h +enum { + kMASShortcutGlyphEject = 0x23CF, + kMASShortcutGlyphClear = 0x2715, + kMASShortcutGlyphDeleteLeft = 0x232B, + kMASShortcutGlyphDeleteRight = 0x2326, + kMASShortcutGlyphLeftArrow = 0x2190, + kMASShortcutGlyphRightArrow = 0x2192, + kMASShortcutGlyphUpArrow = 0x2191, + kMASShortcutGlyphDownArrow = 0x2193, + kMASShortcutGlyphEscape = 0x238B, + kMASShortcutGlyphHelp = 0x003F, + kMASShortcutGlyphPageDown = 0x21DF, + kMASShortcutGlyphPageUp = 0x21DE, + kMASShortcutGlyphTabRight = 0x21E5, + kMASShortcutGlyphReturn = 0x2305, + kMASShortcutGlyphReturnR2L = 0x21A9, + kMASShortcutGlyphPadClear = 0x2327, + kMASShortcutGlyphNorthwestArrow = 0x2196, + kMASShortcutGlyphSoutheastArrow = 0x2198, +} MASShortcutGlyph; -- cgit v1.2.3 From 1c801726d35e56d3bbf4a33279213bc60935c244 Mon Sep 17 00:00:00 2001 From: Tomáš Znamenáček Date: Tue, 5 Aug 2014 15:34:46 +0200 Subject: Converted keycode macros to plain functions. Plain functions are less prone to bugs, the compiler understands them better and can offer better error messages, and plain functions can be refactored more easily. --- Framework/MASKeyCodes.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'Framework/MASKeyCodes.h') diff --git a/Framework/MASKeyCodes.h b/Framework/MASKeyCodes.h index 69b2a97..9fb5b02 100644 --- a/Framework/MASKeyCodes.h +++ b/Framework/MASKeyCodes.h @@ -21,3 +21,22 @@ enum { kMASShortcutGlyphNorthwestArrow = 0x2196, kMASShortcutGlyphSoutheastArrow = 0x2198, } MASShortcutGlyph; + +NS_INLINE NSString* NSStringFromMASKeyCode(unsigned short ch) +{ + return [NSString stringWithFormat:@"%C", ch]; +} + +NS_INLINE NSUInteger MASPickCocoaModifiers(NSUInteger flags) +{ + return (flags & (NSControlKeyMask | NSShiftKeyMask | NSAlternateKeyMask | NSCommandKeyMask)); +} + +NS_INLINE UInt32 MASCarbonModifiersFromCocoaModifiers(NSUInteger cocoaFlags) +{ + return + (cocoaFlags & NSCommandKeyMask ? cmdKey : 0) + | (cocoaFlags & NSAlternateKeyMask ? optionKey : 0) + | (cocoaFlags & NSControlKeyMask ? controlKey : 0) + | (cocoaFlags & NSShiftKeyMask ? shiftKey : 0); +} -- cgit v1.2.3 From 6128e529ea5c0d09de65dcbbc00a299f6b871735 Mon Sep 17 00:00:00 2001 From: Tomáš Znamenáček Date: Thu, 7 Aug 2014 14:04:32 +0200 Subject: Whitespace fixes. --- Framework/MASKeyCodes.h | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'Framework/MASKeyCodes.h') diff --git a/Framework/MASKeyCodes.h b/Framework/MASKeyCodes.h index 9fb5b02..8c1ce06 100644 --- a/Framework/MASKeyCodes.h +++ b/Framework/MASKeyCodes.h @@ -4,22 +4,22 @@ enum { kMASShortcutGlyphEject = 0x23CF, kMASShortcutGlyphClear = 0x2715, - kMASShortcutGlyphDeleteLeft = 0x232B, - kMASShortcutGlyphDeleteRight = 0x2326, + kMASShortcutGlyphDeleteLeft = 0x232B, + kMASShortcutGlyphDeleteRight = 0x2326, kMASShortcutGlyphLeftArrow = 0x2190, - kMASShortcutGlyphRightArrow = 0x2192, - kMASShortcutGlyphUpArrow = 0x2191, - kMASShortcutGlyphDownArrow = 0x2193, - kMASShortcutGlyphEscape = 0x238B, - kMASShortcutGlyphHelp = 0x003F, + kMASShortcutGlyphRightArrow = 0x2192, + kMASShortcutGlyphUpArrow = 0x2191, + kMASShortcutGlyphDownArrow = 0x2193, + kMASShortcutGlyphEscape = 0x238B, + kMASShortcutGlyphHelp = 0x003F, kMASShortcutGlyphPageDown = 0x21DF, - kMASShortcutGlyphPageUp = 0x21DE, - kMASShortcutGlyphTabRight = 0x21E5, - kMASShortcutGlyphReturn = 0x2305, - kMASShortcutGlyphReturnR2L = 0x21A9, - kMASShortcutGlyphPadClear = 0x2327, - kMASShortcutGlyphNorthwestArrow = 0x2196, - kMASShortcutGlyphSoutheastArrow = 0x2198, + kMASShortcutGlyphPageUp = 0x21DE, + kMASShortcutGlyphTabRight = 0x21E5, + kMASShortcutGlyphReturn = 0x2305, + kMASShortcutGlyphReturnR2L = 0x21A9, + kMASShortcutGlyphPadClear = 0x2327, + kMASShortcutGlyphNorthwestArrow = 0x2196, + kMASShortcutGlyphSoutheastArrow = 0x2198, } MASShortcutGlyph; NS_INLINE NSString* NSStringFromMASKeyCode(unsigned short ch) -- cgit v1.2.3