diff --git a/runtime/doc/gui_mac.txt b/runtime/doc/gui_mac.txt index f79de5505b..573ce83aaa 100644 --- a/runtime/doc/gui_mac.txt +++ b/runtime/doc/gui_mac.txt @@ -242,8 +242,6 @@ Here is a list of relevant dictionary entries: KEY VALUE ~ MMCellWidthMultiplier width of a normal glyph in em units [float] MMDialogsTrackPwd open/save dialogs track the Vim pwd [bool] -MMFakeEscTimeout timeout for modifier to count as Esc [float] -MMFakeEscOnKeyDown send Esc when modifier is pressed [bool] MMLoginShellArgument login shell parameter [string] MMLoginShellCommand which shell to use to launch Vim [string] MMNoFontSubstitution disable automatic font substitution [bool] @@ -285,30 +283,6 @@ user default MMLoginShellArgument (e.g. to "-l"). Finally, if the "bash" shell is used, then "-l" is automatically added as an argument. To override this behaviour set MMLoginShellArgument to "--". - *macvim-esc* -MacVim can treat a modifier key as Esc in order to avoid having to reach for -the Esc key all the time. The actual modifier key to treat as Esc can be -selected in the preferences (only the left modifier key is affected on -keyboards which have a left and a right modifier key). This is most useful if -Caps Lock has also been remapped to the chosen modifier since it is then -possible to use Caps Lock (which is very easy to reach) to go to normal mode -instead of using Esc (which is somewhat harder to reach). Caps Lock can be -remapped in the "Keyboard & Mouse" System Preference by clicking on the -"Modifier Keys..." button. - -This feature works by swapping the modifier key release event for an Esc key -press event, so the Esc is only sent when the modifier is released. Also, if -the modifier is not released quickly enough no Esc event is sent. This way it -is possible to keep using the modifier key as a modifier (by holding the key -down and pressing another key) as well as using it as Esc (by quickly pressing -the key). It is possible to make MacVim send Esc when the modifier is pressed -(which makes the key feel more responsive) by setting the MMFakeEscOnKeyDown -user default, but then that modifier key can only be used as Esc. The timeout -can also be change by setting the MMFakeEscTimeout user default to the desired -timeout in seconds (e.g. if you want to be able to press the modifier more -slowly but still having it count as Esc, then you could increase the timeout -to 1.0). - ============================================================================== 4. Special colors *macvim-colors* diff --git a/src/MacVim/English.lproj/Preferences.nib/classes.nib b/src/MacVim/English.lproj/Preferences.nib/classes.nib index d163273bc7..fbdbe5193b 100644 --- a/src/MacVim/English.lproj/Preferences.nib/classes.nib +++ b/src/MacVim/English.lproj/Preferences.nib/classes.nib @@ -76,8 +76,6 @@ atsuiButtonClicked id - fakeEscModifierKeyChanged - id loginShellButtonClicked id quickstartButtonClicked diff --git a/src/MacVim/English.lproj/Preferences.nib/info.nib b/src/MacVim/English.lproj/Preferences.nib/info.nib index e5cd30f152..9c4b5d95c6 100644 --- a/src/MacVim/English.lproj/Preferences.nib/info.nib +++ b/src/MacVim/English.lproj/Preferences.nib/info.nib @@ -13,7 +13,7 @@ 115 IBSystem Version - 9F33 + 9E17 targetFramework IBCocoaFramework diff --git a/src/MacVim/English.lproj/Preferences.nib/keyedobjects.nib b/src/MacVim/English.lproj/Preferences.nib/keyedobjects.nib index a21ea9ae9e..d6c412543a 100644 Binary files a/src/MacVim/English.lproj/Preferences.nib/keyedobjects.nib and b/src/MacVim/English.lproj/Preferences.nib/keyedobjects.nib differ diff --git a/src/MacVim/MMAppController.m b/src/MacVim/MMAppController.m index 3d7fa845ef..3bea328aed 100644 --- a/src/MacVim/MMAppController.m +++ b/src/MacVim/MMAppController.m @@ -185,10 +185,6 @@ fsEventCallback(ConstFSEventStreamRef streamRef, [NSNumber numberWithBool:NO], MMVerticalSplitKey, [NSNumber numberWithInt:0], MMPreloadCacheSizeKey, [NSNumber numberWithInt:0], MMLastWindowClosedBehaviorKey, - [NSNumber numberWithInt:MMDisableFakeEsc], - MMFakeEscModifierKey, - [NSNumber numberWithFloat:0.3], MMFakeEscTimeoutKey, - [NSNumber numberWithBool:NO], MMFakeEscOnKeyDownKey, nil]; [[NSUserDefaults standardUserDefaults] registerDefaults:dict]; diff --git a/src/MacVim/MMApplication.h b/src/MacVim/MMApplication.h index 3c1470d3e6..28937e9745 100644 --- a/src/MacVim/MMApplication.h +++ b/src/MacVim/MMApplication.h @@ -12,15 +12,6 @@ @interface MMApplication : NSApplication { - CFAbsoluteTime fakeEscTimeDown; - CFAbsoluteTime fakeEscTimeout; - int fakeEscKeyCode; - unsigned fakeEscModifierMask; - BOOL blockFakeEscEvent; - BOOL blockKeyDown; - BOOL fakeEscOnKeyDown; } -- (IBAction)fakeEscModifierKeyChanged:(id)sender; - @end diff --git a/src/MacVim/MMApplication.m b/src/MacVim/MMApplication.m index 3bea9b836c..10c69d9d62 100644 --- a/src/MacVim/MMApplication.m +++ b/src/MacVim/MMApplication.m @@ -14,7 +14,6 @@ */ #import "MMApplication.h" -#import "Miscellaneous.h" // Ctrl-Tab is broken on pre 10.5, so we add a hack to make it work. #if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4 @@ -27,88 +26,11 @@ @implementation MMApplication -- (void)awakeFromNib -{ - [self fakeEscModifierKeyChanged:nil]; -} - - (void)sendEvent:(NSEvent *)event { NSEventType type = [event type]; unsigned flags = [event modifierFlags]; - // The following hack allows the user to set one modifier key of choice - // (Ctrl, Alt, or Cmd) to generate an Esc key press event. In order for - // the key to still be used as a modifier we only send the "faked" Esc - // event if the modifier was pressed and released without any other keys - // being pressed in between. The user may elect to have the chosen - // modifier sending Esc on key down, since sending it on key up makes it - // appear a bit sluggish. However, this effectively disables the modifier - // key (but only the left key and not the right one, in case there are two - // on the keyboard). - // - // This hack is particularly useful in conjunction with Mac OS X's ability - // to turn Caps-Lock into a modifier key of choice because it enables us to - // turn Caps-Lock into a quasi-Esc key! (This remapping be done inside - // "System Preferences -> Keyboard & Mouse -> Modifier Keys...".) - // - if (fakeEscKeyCode != 0) { - if (NSFlagsChanged == type && [event keyCode] == fakeEscKeyCode) { - BOOL sendEsc = NO; - CFAbsoluteTime timeNow = CFAbsoluteTimeGetCurrent(); - - if ((flags & fakeEscModifierMask) == 0) { - // The chosen modifier was released. If the modifier was - // recently pressed then convert this event to a "fake" Esc key - // press event. - if (!blockFakeEscEvent && !fakeEscOnKeyDown && - timeNow - fakeEscTimeDown < fakeEscTimeout) - sendEsc = YES; - - blockFakeEscEvent = YES; - blockKeyDown = NO; - } else { - // The chosen modifier was pressed. - blockFakeEscEvent = NO; - fakeEscTimeDown = timeNow; - - if (fakeEscOnKeyDown) { - sendEsc = YES; - - // Block key down while the fake Esc modifier key is held, - // otherwise "marked text" may pop up if a key is pressed - // while the fake Esc modifier is held (which looks ugly, - // but is harmless). - blockKeyDown = YES; - } - } - - if (sendEsc) { - NSEvent *e = [NSEvent keyEventWithType:NSKeyDown - location:[event locationInWindow] - modifierFlags:flags & 0x0000ffffU - timestamp:[event timestamp] - windowNumber:[event windowNumber] - context:[event context] - characters:@"\x1b" // Esc - charactersIgnoringModifiers:@"\x1b" - isARepeat:NO - keyCode:53]; - - [self postEvent:e atStart:YES]; - return; - } - } else if (type != NSKeyUp) { - // Another event occurred, so don't send any fake Esc events now - // (else the modifier would not function as a modifier key any - // more). - blockFakeEscEvent = YES; - } - - if (blockKeyDown && type == NSKeyDown) - return; - } - #ifdef MM_CTRL_TAB_HACK NSResponder *firstResponder = [[self keyWindow] firstResponder]; @@ -129,7 +51,7 @@ // key event. if ((NSKeyDown == type || NSKeyUp == type) && (flags & NSHelpKeyMask)) { flags &= ~NSHelpKeyMask; - NSEvent *e = [NSEvent keyEventWithType:[event type] + event = [NSEvent keyEventWithType:[event type] location:[event locationInWindow] modifierFlags:flags timestamp:[event timestamp] @@ -139,9 +61,6 @@ charactersIgnoringModifiers:[event charactersIgnoringModifiers] isARepeat:[event isARepeat] keyCode:[event keyCode]]; - - [self postEvent:e atStart:YES]; - return; } [super sendEvent:event]; @@ -164,28 +83,4 @@ nil]]; } -- (IBAction)fakeEscModifierKeyChanged:(id)sender -{ - NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; - switch ([ud integerForKey:MMFakeEscModifierKey]) { - case MMCtrlFakeEsc: - fakeEscKeyCode = 59; - fakeEscModifierMask = NSControlKeyMask; - break; - case MMAltFakeEsc: - fakeEscKeyCode = 58; - fakeEscModifierMask = NSAlternateKeyMask; - break; - case MMCmdFakeEsc: - fakeEscKeyCode = 55; - fakeEscModifierMask = NSCommandKeyMask; - break; - default: - fakeEscKeyCode = fakeEscModifierMask = 0; - } - - fakeEscTimeout = [ud floatForKey:MMFakeEscTimeoutKey]; - fakeEscOnKeyDown = [ud boolForKey:MMFakeEscOnKeyDownKey]; -} - @end diff --git a/src/MacVim/Miscellaneous.h b/src/MacVim/Miscellaneous.h index ce4a02b55f..23c3ebe206 100644 --- a/src/MacVim/Miscellaneous.h +++ b/src/MacVim/Miscellaneous.h @@ -53,9 +53,6 @@ extern NSString *MMOpenLayoutKey; extern NSString *MMVerticalSplitKey; extern NSString *MMPreloadCacheSizeKey; extern NSString *MMLastWindowClosedBehaviorKey; -extern NSString *MMFakeEscModifierKey; -extern NSString *MMFakeEscTimeoutKey; -extern NSString *MMFakeEscOnKeyDownKey; // Enum for MMUntitledWindowKey @@ -82,14 +79,6 @@ enum { MMTerminateWhenLastWindowClosed = 2, }; -// Enum for MMFakeEscModifierKey -enum { - MMDisableFakeEsc = 0, - MMCtrlFakeEsc = 1, - MMAltFakeEsc = 2, - MMCmdFakeEsc = 3 -}; - diff --git a/src/MacVim/Miscellaneous.m b/src/MacVim/Miscellaneous.m index f36050357a..15259d48d7 100644 --- a/src/MacVim/Miscellaneous.m +++ b/src/MacVim/Miscellaneous.m @@ -44,9 +44,6 @@ NSString *MMOpenLayoutKey = @"MMOpenLayout"; NSString *MMVerticalSplitKey = @"MMVerticalSplit"; NSString *MMPreloadCacheSizeKey = @"MMPreloadCacheSize"; NSString *MMLastWindowClosedBehaviorKey = @"MMLastWindowClosedBehavior"; -NSString *MMFakeEscModifierKey = @"MMFakeEscModifier"; -NSString *MMFakeEscTimeoutKey = @"MMFakeEscTimeout"; -NSString *MMFakeEscOnKeyDownKey = @"MMFakeEscOnKeyDown";