mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-25 01:49:25 +00:00
Migrated project to XCTest
This commit is contained in:
@@ -8,12 +8,6 @@
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
extern NSString *const kMPAutotypeSymbolShift;
|
||||
extern NSString *const kMPAutotypeSymbolControl;
|
||||
extern NSString *const kMPAutotypeSymbolAlt;
|
||||
extern NSString *const kMPAutotypeSymbolEnter;
|
||||
extern NSString *const kMPAutptypeCommandEnter;
|
||||
|
||||
@class MPAutotypeContext;
|
||||
|
||||
/**
|
||||
|
||||
@@ -13,79 +13,6 @@
|
||||
|
||||
#import <Carbon/Carbon.h>
|
||||
|
||||
NSString *const kMPAutotypeSymbolShift = @"+";
|
||||
NSString *const kMPAutotypeSymbolControl = @"^";
|
||||
NSString *const kMPAutotypeSymbolAlt = @"%";
|
||||
NSString *const kMPAutotypeSymbolEnter = @"~";
|
||||
NSString *const kMPAutptypeCommandEnter = @"{ENTER}";
|
||||
NSString *const kMPAutotypeCommandTab = @"{TAB}";
|
||||
NSString *const kMPAutotypeCommandUp = @"{UP}";
|
||||
NSString *const kMPAutotypeCommandDown = @"{DOWN}";
|
||||
NSString *const kMPAutotypeCommandLeft = @"{LEFT}";
|
||||
NSString *const kMPAutotypeCommandRight = @"{RIGHT}";
|
||||
NSString *const kMPAutotypeCommandDelete = @"{DELETE}";
|
||||
NSString *const kMPAutotypeCommandHome = @"{HOME}";
|
||||
NSString *const kMPAutotypeCommandEnd = @"{END}";
|
||||
NSString *const kMPAutotypeCommandPageUp = @"{PGUP}";
|
||||
NSString *const kMPAutotypeCommandPageDown = @"{PGDOWN}";
|
||||
NSString *const kMPAutotypeCommandBackspace = @"{BACKSPACE}";
|
||||
NSString *const kMPAutotypeCommandBackspaceShort = @"{BS}";
|
||||
NSString *const kMPAutotypeCommandBackspaceMedium = @"{BKSP}";
|
||||
NSString *const kMPAutotypeCommandBreak = @"{BREAK}";
|
||||
NSString *const kMPAutotypeCommandCapsLock = @"{CAPSLOCK}";
|
||||
NSString *const kMPAutotypeCommandEscape = @"{ESC}";
|
||||
NSString *const kMPAutotypeCommandWindows = @"{WIN}";
|
||||
NSString *const kMPAutotypeCommandLeftWindows = @"{LWIN}";
|
||||
NSString *const kMPAutotypeCommandRightWindows = @"{RWIN}";
|
||||
NSString *const kMPAutotypeCommandApps = @"{APPS}";
|
||||
NSString *const kMPAutotypeCommandHelp = @"{HELP}";
|
||||
NSString *const kMPAutotypeCommandNumlock = @"{NUMLOCK}";
|
||||
NSString *const kMPAutotypeCommandPrintScreen = @"{PRTSC}";
|
||||
NSString *const kMPAutotypeCommandScrollLock = @"{SCROLLLOCK}";
|
||||
NSString *const kMPAutotypeCommandF1 = @"{F1}";
|
||||
/*
|
||||
Tab {TAB}
|
||||
Enter {ENTER} or ~
|
||||
Arrow Up {UP}
|
||||
Arrow Down {DOWN}
|
||||
Arrow Left {LEFT}
|
||||
Arrow Right {RIGHT}
|
||||
Insert {INSERT} or {INS}
|
||||
Delete {DELETE} or {DEL}
|
||||
|
||||
Home {HOME}
|
||||
End {END}
|
||||
Page Up {PGUP}
|
||||
Page Down {PGDN}
|
||||
Backspace {BACKSPACE}, {BS} or {BKSP}
|
||||
Break {BREAK}
|
||||
Caps-Lock {CAPSLOCK}
|
||||
Escape {ESC}
|
||||
Windows Key {WIN} (equ. to {LWIN})
|
||||
Windows Key: left, right {LWIN}, {RWIN}
|
||||
Apps / Menu {APPS}
|
||||
Help {HELP}
|
||||
Numlock {NUMLOCK}
|
||||
Print Screen {PRTSC}
|
||||
Scroll Lock {SCROLLLOCK}
|
||||
F1 - F16 {F1} - {F16}
|
||||
Numeric Keypad + {ADD}
|
||||
Numeric Keypad - {SUBTRACT}
|
||||
Numeric Keypad * {MULTIPLY}
|
||||
Numeric Keypad / {DIVIDE}
|
||||
Numeric Keypad 0 to 9 {NUMPAD0} to {NUMPAD9}
|
||||
Shift +
|
||||
Ctrl ^
|
||||
Alt %
|
||||
+ {+}
|
||||
^ {^}
|
||||
% {%}
|
||||
~ {~}
|
||||
(, ) {(}, {)}
|
||||
[, ] {[}, {]}
|
||||
{, } {{}, {}}
|
||||
*/
|
||||
|
||||
@implementation MPAutotypeCommand
|
||||
|
||||
- (void)sendPressKey:(CGKeyCode)keyCode modifierFlags:(CGEventFlags)flags {
|
||||
|
||||
@@ -7,57 +7,11 @@
|
||||
//
|
||||
|
||||
#import "MPAutotypeParser.h"
|
||||
#import "MPAutotypeCommand.h"
|
||||
|
||||
#import "KPKAutotypeCommands.h"
|
||||
|
||||
@implementation MPAutotypeParser
|
||||
|
||||
/*
|
||||
Tab {TAB}
|
||||
Enter {ENTER} or ~
|
||||
Arrow Up {UP}
|
||||
Arrow Down {DOWN}
|
||||
Arrow Left {LEFT}
|
||||
Arrow Right {RIGHT}
|
||||
Insert {INSERT} or {INS}
|
||||
Delete {DELETE} or {DEL}
|
||||
Home {HOME}
|
||||
End {END}
|
||||
Page Up {PGUP}
|
||||
Page Down {PGDN}
|
||||
Backspace {BACKSPACE}, {BS} or {BKSP}
|
||||
Break {BREAK}
|
||||
Caps-Lock {CAPSLOCK}
|
||||
Escape {ESC}
|
||||
Windows Key {WIN} (equ. to {LWIN})
|
||||
Windows Key: left, right {LWIN}, {RWIN}
|
||||
Apps / Menu {APPS}
|
||||
Help {HELP}
|
||||
Numlock {NUMLOCK}
|
||||
Print Screen {PRTSC}
|
||||
Scroll Lock {SCROLLLOCK}
|
||||
F1 - F16 {F1} - {F16}
|
||||
Numeric Keypad + {ADD}
|
||||
Numeric Keypad - {SUBTRACT}
|
||||
Numeric Keypad * {MULTIPLY}
|
||||
Numeric Keypad / {DIVIDE}
|
||||
Numeric Keypad 0 to 9 {NUMPAD0} to {NUMPAD9}
|
||||
Shift +
|
||||
Ctrl ^
|
||||
Alt %
|
||||
+ {+}
|
||||
^ {^}
|
||||
% {%}
|
||||
~ {~}
|
||||
(, ) {(}, {)}
|
||||
[, ] {[}, {]}
|
||||
{, } {{}, {}}
|
||||
|
||||
special commands:
|
||||
|
||||
{DELAY X} Delays X milliseconds.
|
||||
{CLEARFIELD} Clears the contents of the edit control that currently has the focus (only single-line edit controls).
|
||||
{VKEY X}
|
||||
*/
|
||||
+ (NSArray *)commandsForCommandString:(NSString *)commands {
|
||||
NSUInteger commandIndex = 0;
|
||||
CGEventFlags modiferKeys = 0;
|
||||
@@ -72,13 +26,13 @@
|
||||
NSRange modifierRange = [currentCommands rangeOfCharacterFromSet:modifierKeySet options:NSCaseInsensitiveSearch range:NSMakeRange(0, 1)];
|
||||
if(modifierRange.length != 0 && modifierRange.location == 0) {
|
||||
/* starts with a special key */
|
||||
if([currentCommands hasPrefix:kMPAutotypeSymbolShift]) {
|
||||
if([currentCommands hasPrefix:kMPAutotypeShortShift]) {
|
||||
modiferKeys |= kCGEventFlagMaskAlphaShift;
|
||||
}
|
||||
if([currentCommands hasPrefix:kMPAutotypeSymbolControl]) {
|
||||
if([currentCommands hasPrefix:kMPAutotypeShortControl]) {
|
||||
modiferKeys |= kCGEventFlagMaskControl;
|
||||
}
|
||||
if([currentCommands hasPrefix:kMPAutotypeSymbolAlt]) {
|
||||
if([currentCommands hasPrefix:kMPAutotypeShortAlt]) {
|
||||
modiferKeys = kCGEventFlagMaskAlternate;
|
||||
}
|
||||
/* move the index and continue */
|
||||
@@ -147,7 +101,7 @@
|
||||
+ (NSString *)_normalizeCommands:(NSString *)commandString {
|
||||
/* Cache normalized Commands? */
|
||||
NSMutableString *mutableCommand = [commandString mutableCopy];
|
||||
[mutableCommand replaceOccurrencesOfString:kMPAutotypeSymbolEnter withString:kMPAutptypeCommandEnter options:NSCaseInsensitiveSearch range:NSMakeRange(0, [mutableCommand length])];
|
||||
[mutableCommand replaceOccurrencesOfString:kMPAutotypeShortEnter withString:kMPAutotypeEnter options:NSCaseInsensitiveSearch range:NSMakeRange(0, [mutableCommand length])];
|
||||
[mutableCommand replaceOccurrencesOfString:@"{{}" withString:@"{LCURL}" options:NSCaseInsensitiveSearch range:NSMakeRange(0, [mutableCommand length])];
|
||||
[mutableCommand replaceOccurrencesOfString:@"{}}" withString:@"{RCURL}" options:NSCaseInsensitiveSearch range:NSMakeRange(0, [mutableCommand length])];
|
||||
return nil;
|
||||
|
||||
@@ -4,4 +4,5 @@
|
||||
|
||||
#ifdef __OBJC__
|
||||
#import <Cocoa/Cocoa.h>
|
||||
//#import "KPKAutotypeCommands.h"
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user