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

Disable text-sending and navigation key keymaps while in findbar. Fixes bug 996.

parent 059e9076
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -270,6 +270,7 @@ static const float kBackgroundSessionIntervalSec = 1;
- (void)brokenPipe;
 
// PTYTextView
- (BOOL)hasTextSendingKeyMappingForEvent:(NSEvent*)event;
- (BOOL)hasActionableKeyMappingForEvent: (NSEvent *)event;
- (void)keyDown:(NSEvent *)event;
- (BOOL)willHandleEvent: (NSEvent *)theEvent;
Loading
Loading
Loading
Loading
@@ -656,7 +656,7 @@ static NSString* SESSION_ARRANGEMENT_WORKING_DIRECTORY = @"Working Directory";
}
}
 
- (BOOL)hasActionableKeyMappingForEvent:(NSEvent *)event
- (int)_keyBindingActionForEvent:(NSEvent*)event
{
unsigned int modflag;
NSString *unmodkeystr;
Loading
Loading
@@ -676,13 +676,31 @@ static NSString* SESSION_ARRANGEMENT_WORKING_DIRECTORY = @"Working Directory";
*/
 
// Check if we have a custom key mapping for this event
keyBindingAction = [iTermKeyBindingMgr actionForKeyCode:unmodunicode
modifiers:modflag
text:&keyBindingText
keyMappings:[[self addressBookEntry] objectForKey: KEY_KEYBOARD_MAP]];
return keyBindingAction;
}
 
- (BOOL)hasTextSendingKeyMappingForEvent:(NSEvent*)event
{
int keyBindingAction = [self _keyBindingActionForEvent:event];
switch (keyBindingAction) {
case KEY_ACTION_ESCAPE_SEQUENCE:
case KEY_ACTION_HEX_CODE:
case KEY_ACTION_TEXT:
case KEY_ACTION_IGNORE:
case KEY_ACTION_SEND_C_H_BACKSPACE:
case KEY_ACTION_SEND_C_QM_BACKSPACE:
return YES;
}
return NO;
}
 
- (BOOL)hasActionableKeyMappingForEvent:(NSEvent *)event
{
int keyBindingAction = [self _keyBindingActionForEvent:event];
return (keyBindingAction >= 0) && (keyBindingAction != KEY_ACTION_DO_NOT_REMAP_MODIFIERS) && (keyBindingAction != KEY_ACTION_REMAP_LOCALLY);
}
 
Loading
Loading
Loading
Loading
@@ -49,10 +49,33 @@
inFocus = ([[[textField window] firstResponder] isKindOfClass:[NSTextView class]]
&& [[textField window] fieldEditor:NO forObject:nil]!=nil
&& [textField isEqualTo:(id)[(NSTextView *)[[textField window] firstResponder]delegate]]);
return inFocus;
}
 
- (BOOL)_eventUsesNavigationKeys:(NSEvent*)event
{
NSString* unmodkeystr = [event charactersIgnoringModifiers];
if ([unmodkeystr length] == 0) {
return NO;
}
unichar unmodunicode = [unmodkeystr length] > 0 ? [unmodkeystr characterAtIndex:0] : 0;
switch (unmodunicode) {
case NSUpArrowFunctionKey:
case NSDownArrowFunctionKey:
case NSLeftArrowFunctionKey:
case NSRightArrowFunctionKey:
case NSInsertFunctionKey:
case NSDeleteFunctionKey:
case NSDeleteCharFunctionKey:
case NSHomeFunctionKey:
case NSEndFunctionKey:
return YES;
default:
return NO;
}
}
// override to catch key press events very early on
- (void)sendEvent:(NSEvent*)event
{
Loading
Loading
@@ -145,7 +168,18 @@
}
}
 
if ([currentSession hasActionableKeyMappingForEvent:event]) {
BOOL okToRemap = YES;
if ([responder isKindOfClass:[NSTextView class]]) {
// Disable keymaps that send text
if ([currentSession hasTextSendingKeyMappingForEvent:event]) {
okToRemap = NO;
}
if ([self _eventUsesNavigationKeys:event]) {
okToRemap = NO;
}
}
if (okToRemap && [currentSession hasActionableKeyMappingForEvent:event]) {
// Remap key.
[currentSession keyDown:event];
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