Skip to content
Snippets Groups Projects
Commit a435c477 authored by George Nachman's avatar George Nachman
Browse files

Adhoc build 1.0.0.20131229_123935

parent 52e92a1d
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -1328,7 +1328,7 @@ static NSString *kTmuxFontChanged = @"kTmuxFontChanged";
// pass the keystroke as input.
- (void)keyDown:(NSEvent *)event
{
BOOL debugKeyDown = [[[NSUserDefaults standardUserDefaults] objectForKey:@"DebugKeyDown"] boolValue];
BOOL debugKeyDown = YES;
unsigned char *send_str = NULL;
unsigned char *dataPtr = NULL;
int dataLength = 0;
Loading
Loading
@@ -1343,7 +1343,7 @@ static NSString *kTmuxFontChanged = @"kTmuxFontChanged";
unichar unicode, unmodunicode;
 
#if DEBUG_METHOD_TRACE || DEBUG_KEYDOWNDUMP
NSLog(@"%s(%d):-[PTYSession keyDown:%@]",
DLog(@"%s(%d):-[PTYSession keyDown:%@]",
__FILE__, __LINE__, event);
#endif
 
Loading
Loading
@@ -1356,13 +1356,13 @@ static NSString *kTmuxFontChanged = @"kTmuxFontChanged";
unicode = [keystr length] > 0 ? [keystr characterAtIndex:0] : 0;
unmodunicode = [unmodkeystr length] > 0 ? [unmodkeystr characterAtIndex:0] : 0;
if (debugKeyDown) {
NSLog(@"PTYSession keyDown modflag=%d keystr=%@ unmodkeystr=%@ unicode=%d unmodunicode=%d", (int)modflag, keystr, unmodkeystr, (int)unicode, (int)unmodunicode);
DLog(@"PTYSession keyDown modflag=%d keystr=%@ unmodkeystr=%@ unicode=%d unmodunicode=%d", (int)modflag, keystr, unmodkeystr, (int)unicode, (int)unmodunicode);
}
gettimeofday(&lastInput, NULL);
 
if ([[[self tab] realParentWindow] inInstantReplay]) {
if (debugKeyDown) {
NSLog(@"PTYSession keyDown in IR");
DLog(@"PTYSession keyDown in IR");
}
// Special key handling in IR mode, and keys never get sent to the live
// session, even though it might be displayed.
Loading
Loading
@@ -1396,7 +1396,7 @@ static NSString *kTmuxFontChanged = @"kTmuxFontChanged";
 
unsigned short keycode = [event keyCode];
if (debugKeyDown) {
NSLog(@"event:%@ (%x+%x)[%@][%@]:%x(%c) <%d>", event,modflag,keycode,keystr,unmodkeystr,unicode,unicode,(modflag & NSNumericPadKeyMask));
DLog(@"event:%@ (%x+%x)[%@][%@]:%x(%c) <%d>", event,modflag,keycode,keystr,unmodkeystr,unicode,unicode,(modflag & NSNumericPadKeyMask));
}
DebugLog([NSString stringWithFormat:@"event:%@ (%x+%x)[%@][%@]:%x(%c) <%d>", event,modflag,keycode,keystr,unmodkeystr,unicode,unicode,(modflag & NSNumericPadKeyMask)]);
 
Loading
Loading
@@ -1408,7 +1408,7 @@ static NSString *kTmuxFontChanged = @"kTmuxFontChanged";
 
if (keyBindingAction >= 0) {
if (debugKeyDown) {
NSLog(@"PTYSession keyDown action=%d", keyBindingAction);
DLog(@"PTYSession keyDown action=%d", keyBindingAction);
}
DebugLog([NSString stringWithFormat:@"keyBindingAction=%d", keyBindingAction]);
// A special action was bound to this key combination.
Loading
Loading
@@ -1591,7 +1591,7 @@ static NSString *kTmuxFontChanged = @"kTmuxFontChanged";
[[[self tab] realParentWindow] splitVertically:YES withBookmarkGuid:keyBindingText];
break;
default:
NSLog(@"Unknown key action %d", keyBindingAction);
DLog(@"Unknown key action %d", keyBindingAction);
break;
}
} else {
Loading
Loading
@@ -1601,7 +1601,7 @@ static NSString *kTmuxFontChanged = @"kTmuxFontChanged";
return;
}
if (debugKeyDown) {
NSLog(@"PTYSession keyDown no keybinding action");
DLog(@"PTYSession keyDown no keybinding action");
}
DebugLog(@"No keybinding action");
if (EXIT) {
Loading
Loading
@@ -1611,7 +1611,7 @@ static NSString *kTmuxFontChanged = @"kTmuxFontChanged";
// No special binding for this key combination.
if (modflag & NSFunctionKeyMask) {
if (debugKeyDown) {
NSLog(@"PTYSession keyDown is a function key");
DLog(@"PTYSession keyDown is a function key");
}
DebugLog(@"Is a function key");
// Handle all "special" keys (arrows, etc.)
Loading
Loading
@@ -1675,7 +1675,7 @@ static NSString *kTmuxFontChanged = @"kTmuxFontChanged";
((modflag & NSRightAlternateKeyMask) == NSRightAlternateKeyMask &&
([self rightOptionKey] != OPT_NORMAL))) {
if (debugKeyDown) {
NSLog(@"PTYSession keyDown opt + key -> modkey");
DLog(@"PTYSession keyDown opt + key -> modkey");
}
DebugLog(@"Option + key -> modified key");
// A key was pressed while holding down option and the option key
Loading
Loading
@@ -1705,7 +1705,7 @@ static NSString *kTmuxFontChanged = @"kTmuxFontChanged";
}
} else {
if (debugKeyDown) {
NSLog(@"PTYSession keyDown regular path");
DLog(@"PTYSession keyDown regular path");
}
DebugLog(@"Regular path for keypress");
// Regular path for inserting a character from a keypress.
Loading
Loading
@@ -1714,13 +1714,13 @@ static NSString *kTmuxFontChanged = @"kTmuxFontChanged";
 
if (max != 1||[keystr characterAtIndex:0] > 0x7f) {
if (debugKeyDown) {
NSLog(@"PTYSession keyDown non-ascii");
DLog(@"PTYSession keyDown non-ascii");
}
DebugLog(@"Non-ascii input");
data = [keystr dataUsingEncoding:[TERMINAL encoding]];
} else {
if (debugKeyDown) {
NSLog(@"PTYSession keyDown ascii");
DLog(@"PTYSession keyDown ascii");
}
DebugLog(@"ASCII input");
data = [keystr dataUsingEncoding:NSUTF8StringEncoding];
Loading
Loading
@@ -1730,7 +1730,7 @@ static NSString *kTmuxFontChanged = @"kTmuxFontChanged";
if (unicode == NSEnterCharacter && unmodunicode == NSEnterCharacter) {
modflag |= NSNumericPadKeyMask;
if (debugKeyDown) {
NSLog(@"PTYSession keyDown enter key");
DLog(@"PTYSession keyDown enter key");
}
DebugLog(@"Enter key");
keystr = @"\015"; // Enter key -> 0x0d
Loading
Loading
@@ -1738,7 +1738,7 @@ static NSString *kTmuxFontChanged = @"kTmuxFontChanged";
// Check if we are in keypad mode
if (modflag & NSNumericPadKeyMask) {
if (debugKeyDown) {
NSLog(@"PTYSession keyDown numeric keyoad");
DLog(@"PTYSession keyDown numeric keyoad");
}
DebugLog(@"Numeric keypad mask");
data = [TERMINAL keypadData:unicode keystr:keystr];
Loading
Loading
@@ -1755,7 +1755,7 @@ static NSString *kTmuxFontChanged = @"kTmuxFontChanged";
// caught by the menu.
DebugLog(@"Cmd + 0-9 or cmd + enter");
if (debugKeyDown) {
NSLog(@"PTYSession keyDown cmd+0-9 or cmd+enter");
DLog(@"PTYSession keyDown cmd+0-9 or cmd+enter");
}
data = nil;
}
Loading
Loading
@@ -1774,7 +1774,7 @@ static NSString *kTmuxFontChanged = @"kTmuxFontChanged";
send_strlen == 1 &&
send_str[0] == '|') {
if (debugKeyDown) {
NSLog(@"PTYSession keyDown c-|");
DLog(@"PTYSession keyDown c-|");
}
// Control-| is sent as Control-backslash
send_str = (unsigned char*)"\034";
Loading
Loading
@@ -1784,7 +1784,7 @@ static NSString *kTmuxFontChanged = @"kTmuxFontChanged";
send_strlen == 1 &&
send_str[0] == '/') {
if (debugKeyDown) {
NSLog(@"PTYSession keyDown c-?");
DLog(@"PTYSession keyDown c-?");
}
// Control-shift-/ is sent as Control-?
send_str = (unsigned char*)"\177";
Loading
Loading
@@ -1793,7 +1793,7 @@ static NSString *kTmuxFontChanged = @"kTmuxFontChanged";
send_strlen == 1 &&
send_str[0] == '/') {
if (debugKeyDown) {
NSLog(@"PTYSession keyDown c-/");
DLog(@"PTYSession keyDown c-/");
}
// Control-/ is sent as Control-/, but needs some help to do so.
send_str = (unsigned char*)"\037"; // control-/
Loading
Loading
@@ -1802,7 +1802,7 @@ static NSString *kTmuxFontChanged = @"kTmuxFontChanged";
send_strlen == 1 &&
send_str[0] == '\031') {
if (debugKeyDown) {
NSLog(@"PTYSession keyDown shift-tab -> esc[Z");
DLog(@"PTYSession keyDown shift-tab -> esc[Z");
}
// Shift-tab is sent as Esc-[Z (or "backtab")
send_str = (unsigned char*)"\033[Z";
Loading
Loading
Loading
Loading
@@ -2376,10 +2376,10 @@ NSMutableArray* screens=0;
isFirstInteraction = NO;
}
 
BOOL debugKeyDown = [[[NSUserDefaults standardUserDefaults] objectForKey:@"DebugKeyDown"] boolValue];
BOOL debugKeyDown = YES;
 
if (debugKeyDown) {
NSLog(@"PTYTextView keyDown BEGIN %@", event);
DLog(@"PTYTextView keyDown BEGIN %@", event);
}
DebugLog(@"PTYTextView keyDown");
id delegate = [self delegate];
Loading
Loading
@@ -2389,7 +2389,7 @@ NSMutableArray* screens=0;
}
if ([[[[[self dataSource] session] tab] realParentWindow] inInstantReplay]) {
if (debugKeyDown) {
NSLog(@"PTYTextView keyDown: in instant replay, send to delegate");
DLog(@"PTYTextView keyDown: in instant replay, send to delegate");
}
// Delegate has special handling for this case.
[delegate keyDown:event];
Loading
Loading
@@ -2401,17 +2401,17 @@ NSMutableArray* screens=0;
 
keyIsARepeat = [event isARepeat];
if (debugKeyDown) {
NSLog(@"PTYTextView keyDown modflag=%d keycode=%d", modflag, (int)keyCode);
NSLog(@"prev=%d", (int)prev);
NSLog(@"hasActionableKeyMappingForEvent=%d", (int)[delegate hasActionableKeyMappingForEvent:event]);
NSLog(@"modFlag & (NSNumericPadKeyMask | NSFUnctionKeyMask)=%d", (modflag & (NSNumericPadKeyMask | NSFunctionKeyMask)));
NSLog(@"charactersIgnoringModififiers length=%d", (int)[[event charactersIgnoringModifiers] length]);
NSLog(@"delegate optionkey=%d, delegate rightOptionKey=%d", (int)[delegate optionKey], (int)[delegate rightOptionKey]);
NSLog(@"modflag & leftAlt == leftAlt && optionKey != NORMAL = %d", (int)((modflag & NSLeftAlternateKeyMask) == NSLeftAlternateKeyMask && [delegate optionKey] != OPT_NORMAL));
NSLog(@"modflag == alt && optionKey != NORMAL = %d", (int)(modflag == NSAlternateKeyMask && [delegate optionKey] != OPT_NORMAL));
NSLog(@"modflag & rightAlt == rightAlt && rightOptionKey != NORMAL = %d", (int)((modflag & NSRightAlternateKeyMask) == NSRightAlternateKeyMask && [delegate rightOptionKey] != OPT_NORMAL));
NSLog(@"isControl=%d", (int)(modflag & NSControlKeyMask));
NSLog(@"keycode is slash=%d, is backslash=%d", (keyCode == 0x2c), (keyCode == 0x2a));
DLog(@"PTYTextView keyDown modflag=%d keycode=%d", modflag, (int)keyCode);
DLog(@"prev=%d", (int)prev);
DLog(@"hasActionableKeyMappingForEvent=%d", (int)[delegate hasActionableKeyMappingForEvent:event]);
DLog(@"modFlag & (NSNumericPadKeyMask | NSFUnctionKeyMask)=%d", (modflag & (NSNumericPadKeyMask | NSFunctionKeyMask)));
DLog(@"charactersIgnoringModififiers length=%d", (int)[[event charactersIgnoringModifiers] length]);
DLog(@"delegate optionkey=%d, delegate rightOptionKey=%d", (int)[delegate optionKey], (int)[delegate rightOptionKey]);
DLog(@"modflag & leftAlt == leftAlt && optionKey != NORMAL = %d", (int)((modflag & NSLeftAlternateKeyMask) == NSLeftAlternateKeyMask && [delegate optionKey] != OPT_NORMAL));
DLog(@"modflag == alt && optionKey != NORMAL = %d", (int)(modflag == NSAlternateKeyMask && [delegate optionKey] != OPT_NORMAL));
DLog(@"modflag & rightAlt == rightAlt && rightOptionKey != NORMAL = %d", (int)((modflag & NSRightAlternateKeyMask) == NSRightAlternateKeyMask && [delegate rightOptionKey] != OPT_NORMAL));
DLog(@"isControl=%d", (int)(modflag & NSControlKeyMask));
DLog(@"keycode is slash=%d, is backslash=%d", (keyCode == 0x2c), (keyCode == 0x2a));
}
 
// Hide the cursor
Loading
Loading
@@ -2428,20 +2428,20 @@ NSMutableArray* screens=0;
((modflag & NSControlKeyMask) && // a few special cases
(keyCode == 0x2c /* slash */ || keyCode == 0x2a /* backslash */)))) {
if (debugKeyDown) {
NSLog(@"PTYTextView keyDown: process in delegate");
DLog(@"PTYTextView keyDown: process in delegate");
}
[delegate keyDown:event];
return;
}
 
if (debugKeyDown) {
NSLog(@"Test for command key");
DLog(@"Test for command key");
}
if (modflag & NSCommandKeyMask) {
// You pressed cmd+something but it's not handled by the delegate. Going further would
// send the unmodified key to the terminal which doesn't make sense.
if (debugKeyDown) {
NSLog(@"PTYTextView keyDown You pressed cmd+something");
DLog(@"PTYTextView keyDown You pressed cmd+something");
}
return;
}
Loading
Loading
@@ -2452,7 +2452,7 @@ NSMutableArray* screens=0;
if (!prev &&
(modflag & (NSControlKeyMask | NSCommandKeyMask | NSAlternateKeyMask)) == NSControlKeyMask) {
if (debugKeyDown) {
NSLog(@"Special ctrl+key handler running");
DLog(@"Special ctrl+key handler running");
}
NSString *unmodkeystr = [event charactersIgnoringModifiers];
if ([unmodkeystr length] != 0) {
Loading
Loading
@@ -2476,7 +2476,7 @@ NSMutableArray* screens=0;
if (cc != 0xffff) {
[self insertText:[NSString stringWithCharacters:&cc length:1]];
if (debugKeyDown) {
NSLog(@"PTYTextView keyDown work around control bug. cc=%d", (int)cc);
DLog(@"PTYTextView keyDown work around control bug. cc=%d", (int)cc);
}
workAroundControlBug = YES;
}
Loading
Loading
@@ -2487,7 +2487,7 @@ NSMutableArray* screens=0;
// Let the IME process key events
IM_INPUT_INSERT = NO;
if (debugKeyDown) {
NSLog(@"PTYTextView keyDown send to IME");
DLog(@"PTYTextView keyDown send to IME");
}
// In issue 2743, it is revealed that in OS 10.9 this sometimes calls -insertText on the
Loading
Loading
@@ -2503,13 +2503,13 @@ NSMutableArray* screens=0;
!IM_INPUT_INSERT &&
![self hasMarkedText]) {
if (debugKeyDown) {
NSLog(@"PTYTextView keyDown IME no, send to delegate");
DLog(@"PTYTextView keyDown IME no, send to delegate");
}
[delegate keyDown:event];
}
}
if (debugKeyDown) {
NSLog(@"PTYTextView keyDown END");
DLog(@"PTYTextView keyDown END");
}
}
 
Loading
Loading
Loading
Loading
@@ -29,6 +29,7 @@
*/
 
#import "iTermApplication.h"
#import "iTermApplicationDelegate.h"
#import "iTermController.h"
#import "PTYWindow.h"
#import "PseudoTerminal.h"
Loading
Loading
@@ -80,6 +81,7 @@
- (void)sendEvent:(NSEvent*)event
{
if ([event type] == NSKeyDown) {
DLog(@"Received event %@", event);
iTermController* cont = [iTermController sharedInstance];
#ifdef FAKE_EVENT_TAP
event = [cont runEventTapHandler:event];
Loading
Loading
@@ -94,12 +96,14 @@
// keys. Only things like cmd-tab will not be remapped in this case. Otherwise,
// the event tap performs the remapping.
event = [iTermKeyBindingMgr remapModifiers:event prefPanel:prefPanel];
DLog(@"Modifiers remapped. %@", event);
}
if (IsSecureEventInputEnabled() &&
[cont eventIsHotkey:event]) {
// User pressed the hotkey while secure input is enabled so the event
// tap won't get it. Do what the event tap would do in this case.
OnHotKeyEvent();
DLog(@"Secure input is enabled, handle hotkey");
return;
}
PreferencePanel* privatePrefPanel = [PreferencePanel sessionsInstance];
Loading
Loading
@@ -110,6 +114,7 @@
 
if (([event modifierFlags] & (NSControlKeyMask | NSCommandKeyMask | NSAlternateKeyMask)) == [prefPanel modifierTagToMask:[prefPanel switchWindowModifier]]) {
// Command-Alt (or selected modifier) + number: Switch to window by number.
DLog(@"Switch to window by number");
int digit = [[event charactersIgnoringModifiers] intValue];
if (!digit) {
digit = [[event characters] intValue];
Loading
Loading
@@ -130,26 +135,31 @@
[prefPanel keySheetIsOpen] &&
[iTermApplication isTextFieldInFocus:[prefPanel shortcutKeyTextField]]) {
// Focus is in the shortcut field in prefspanel. Pass events directly to it.
DLog(@"shortcut keydown");
[prefPanel shortcutKeyDown:event];
return;
} else if ([privatePrefPanel keySheet] == [self keyWindow] &&
[privatePrefPanel keySheetIsOpen] &&
[iTermApplication isTextFieldInFocus:[privatePrefPanel shortcutKeyTextField]]) {
DLog(@"focus in shortcut field");
// Focus is in the shortcut field in sessions prefspanel. Pass events directly to it.
[privatePrefPanel shortcutKeyDown:event];
return;
} else if ([prefPanel window] == [self keyWindow] &&
[iTermApplication isTextFieldInFocus:[prefPanel hotkeyField]]) {
DLog(@"focus in hotkey field");
// Focus is in the hotkey field in prefspanel. Pass events directly to it.
[prefPanel hotkeyKeyDown:event];
return;
} else if ([[self keyWindow] isKindOfClass:[PTYWindow class]]) {
DLog(@"focus in terminal window");
// Focus is in a terminal window.
responder = [[self keyWindow] firstResponder];
bool inTextView = [responder isKindOfClass:[PTYTextView class]];
 
if (inTextView &&
[(PTYTextView *)responder hasMarkedText]) {
DLog(@"Send to IM");
// Let the IM process it
[(PTYTextView *)responder interpretKeyEvents:[NSArray arrayWithObject:event]];
return;
Loading
Loading
@@ -157,6 +167,7 @@
 
const int mask = NSShiftKeyMask | NSControlKeyMask | NSAlternateKeyMask | NSCommandKeyMask;
if (([event modifierFlags] & mask) == [prefPanel modifierTagToMask:[prefPanel switchTabModifier]]) {
DLog(@"Changing tabs");
int digit = [[event charactersIgnoringModifiers] intValue];
if (!digit) {
digit = [[event characters] intValue];
Loading
Loading
@@ -175,23 +186,29 @@
 
BOOL okToRemap = YES;
if ([responder isKindOfClass:[NSTextView class]]) {
DLog(@"Not in a text view");
// Disable keymaps that send text
if ([currentSession hasTextSendingKeyMappingForEvent:event]) {
DLog(@"ok to remap=NO (1)");
okToRemap = NO;
}
if ([self _eventUsesNavigationKeys:event]) {
DLog(@"ok to remap=NO (2)");
okToRemap = NO;
}
}
 
if (okToRemap && [currentSession hasActionableKeyMappingForEvent:event]) {
// Remap key.
DLog(@"ending to session");
[currentSession keyDown:event];
return;
}
} else {
DLog(@"Focus not in terminal window");
// Focus not in terminal window.
if ([PTYSession handleShortcutWithoutTerminal:event]) {
DLog(@"Handle shortcut without terminal");
return;
}
}
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment