Revert "Modifier key sends Esc" related commits

This reverts the following three commits:
  3ae360ddb38dd49e9392aad7a70f0f31a30849ee
  007bb96eb3ec035169510caa4e206ab901e4b6d0
  b6c06f31be1e8124ed12cc2ff5361752df1e4634
This commit is contained in:
Bjorn Winckler
2008-10-25 16:34:16 +02:00
parent 2cccddd458
commit 331a21d0bd
9 changed files with 2 additions and 162 deletions
-26
View File
@@ -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*
-2
View File
@@ -76,8 +76,6 @@
<dict>
<key>atsuiButtonClicked</key>
<string>id</string>
<key>fakeEscModifierKeyChanged</key>
<string>id</string>
<key>loginShellButtonClicked</key>
<string>id</string>
<key>quickstartButtonClicked</key>
+1 -1
View File
@@ -13,7 +13,7 @@
<integer>115</integer>
</array>
<key>IBSystem Version</key>
<string>9F33</string>
<string>9E17</string>
<key>targetFramework</key>
<string>IBCocoaFramework</string>
</dict>
Binary file not shown.
-4
View File
@@ -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];
-9
View File
@@ -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
+1 -106
View File
@@ -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
-11
View File
@@ -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
};
-3
View File
@@ -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";