mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-20 14:29:31 +00:00
Some reshuffling of the Autotype Code.
Added preferences key for Ctrl/Command swapping, since this might be a problem in multi platform use cases
This commit is contained in:
Submodule KeePassKit updated: 6992db3611...2b5a795a43
@@ -70,12 +70,80 @@
|
||||
|
||||
+ (NSArray *)commandsForCommandString:(NSString *)commands {
|
||||
NSUInteger commandIndex = 0;
|
||||
CGEventFlags modiferKeys = 0;
|
||||
while(commandIndex <= [commands length]) {
|
||||
NSString *nextCommand = [commands nextCommandFromIndex:0];
|
||||
/* itearte over all comamnds */
|
||||
/* determine singel commands, paste, etc */
|
||||
/* create command with appropriate initalizers */
|
||||
/* return array with ordered commands */
|
||||
/* Modifier Keys
|
||||
Shift +
|
||||
Ctrl ^
|
||||
Alt %
|
||||
Enter ~ // No modifier!
|
||||
*/
|
||||
NSString *currentCommans = [commands substringFromIndex:commandIndex];
|
||||
NSCharacterSet *modifierKeySet = [NSCharacterSet characterSetWithCharactersInString:@"+^%"];
|
||||
NSRange modifierRange = [currentCommans rangeOfCharacterFromSet:modifierKeySet options:NSCaseInsensitiveSearch range:NSMakeRange(0, 1)];
|
||||
if(modifierRange.length != 0 && modifierRange.location == 0) {
|
||||
/* starts with a special key */
|
||||
if([currentCommans hasPrefix:@"+"]) {
|
||||
modiferKeys |= kCGEventFlagMaskAlphaShift;
|
||||
}
|
||||
if([currentCommans hasPrefix:@"^"]) {
|
||||
modiferKeys |= kCGEventFlagMaskControl;
|
||||
}
|
||||
if([currentCommans hasPrefix:@"%"]) {
|
||||
modiferKeys = kCGEventFlagMaskAlternate;
|
||||
}
|
||||
/* move the index and continue */
|
||||
commandIndex++;
|
||||
continue;
|
||||
}
|
||||
if([currentCommans hasPrefix:@"{"]) {
|
||||
NSRange closeBracket = [currentCommans rangeOfString:@"}"];
|
||||
if(closeBracket.length == 0) {
|
||||
NSLog(@"Syntax error in Autotype Sequence %@ at index: %ld", commands, commandIndex);
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
/* Search on to another bracket or a special key */
|
||||
|
||||
/* Command Keys
|
||||
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}
|
||||
+ {+}
|
||||
^ {^}
|
||||
% {%}
|
||||
~ {~}
|
||||
(, ) {(}, {)}
|
||||
[, ] {[}, {]}
|
||||
{, } {{}, {}}
|
||||
|
||||
*/
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
@@ -192,6 +260,8 @@
|
||||
return (CGKeyCode)virtualKeyCode;
|
||||
}
|
||||
|
||||
|
||||
|
||||
- (void)execute {}
|
||||
|
||||
@end
|
||||
|
||||
@@ -46,6 +46,9 @@ APPKIT_EXTERN NSString *const kMPSettingsKeyLastKeyURL;
|
||||
APPKIT_EXTERN NSString *const kMPSettingsKeyRememberLastKey;
|
||||
*/
|
||||
|
||||
/* Autotype */
|
||||
APPKIT_EXTERN NSString *const kMPSettingsKeySendCommandForControlKey;
|
||||
|
||||
typedef NS_ENUM(NSUInteger, MPPasswordEncoding) {
|
||||
MPPasswordEncodingUTF8,
|
||||
MPPasswordEncodingASCII,
|
||||
|
||||
@@ -30,6 +30,8 @@ NSString *const kMPSettingsKeyLastDatabasePath = @"LastDatabasePath";
|
||||
NSString *const kMPSettingsKeyRememeberdKeysForDatabases = @"RememeberdKeysForDatabases";
|
||||
NSString *const kMPSettingsKeyRememberKeyFilesForDatabases = @"RememberKeyFilesForDatabases";
|
||||
|
||||
NSString *const kMPSettingsKeySendCommandForControlKey = @"SendCommandKeyForControlKey";
|
||||
|
||||
@implementation MPSettingsHelper
|
||||
|
||||
+ (void)setupDefaults {
|
||||
@@ -58,7 +60,8 @@ NSString *const kMPSettingsKeyRememberKeyFilesForDatabases = @"RememberKeyFilesF
|
||||
kMPSettingsKeyLegacyHideTitle: @NO,
|
||||
kMPSettingsKeyLegacyHideURL: @NO,
|
||||
kMPSettingsKeyLegacyHideUsername: @NO,
|
||||
kMPSettingsKeyRememberKeyFilesForDatabases: @NO
|
||||
kMPSettingsKeyRememberKeyFilesForDatabases: @NO,
|
||||
kMPSettingsKeySendCommandForControlKey: @YES
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user