1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-21 09:27:59 +02:00

Better key chord matching

This commit is contained in:
Brian Fiete 2021-02-06 07:10:30 -08:00
parent 2e4792d51e
commit 5f5c752f5d

View file

@ -7429,19 +7429,38 @@ namespace IDE
} }
} }
if ((mKeyChordState != null) && (evt.mKeyCode.IsModifier))
{
// Ignore
}
else
{
var keyState = scope KeyState(); var keyState = scope KeyState();
keyState.mKeyCode = evt.mKeyCode; keyState.mKeyCode = evt.mKeyCode;
keyState.mKeyFlags = evt.mKeyFlags; keyState.mKeyFlags = evt.mKeyFlags;
var curKeyMap = mCommands.mKeyMap; var curKeyMap = mCommands.mKeyMap;
bool hadChordState = mKeyChordState != null; bool hadChordState = mKeyChordState != null;
if (mKeyChordState != null) if (mKeyChordState != null)
curKeyMap = mKeyChordState.mCommandMap; curKeyMap = mKeyChordState.mCommandMap;
DeleteAndNullify!(mKeyChordState); var prevKeyChordState = mKeyChordState;
defer delete prevKeyChordState;
mKeyChordState = null;
KeyState matchedKey; KeyState matchedKey;
IDECommandBase commandBase; IDECommandBase commandBase;
if (curKeyMap.mMap.TryGet(keyState, out matchedKey, out commandBase))
bool hadMatch = curKeyMap.mMap.TryGet(keyState, out matchedKey, out commandBase);
if ((!hadMatch) && (prevKeyChordState != null))
{
// If we have a "Ctrl+A, Ctrl+B" style sequence then also try to match that against "Ctrl+A, B"
KeyState rawKeyState = keyState;
rawKeyState.mKeyFlags &= ~prevKeyChordState.mKeyState.mKeyFlags;
hadMatch = curKeyMap.mMap.TryGet(rawKeyState, out matchedKey, out commandBase);
}
if (hadMatch)
{ {
if (var commandMap = commandBase as CommandMap) if (var commandMap = commandBase as CommandMap)
{ {
@ -7497,7 +7516,7 @@ namespace IDE
} }
} }
} }
else if (!evt.mKeyCode.IsModifier) else
{ {
// Not found // Not found
if (hadChordState) if (hadChordState)
@ -7507,6 +7526,7 @@ namespace IDE
return; return;
} }
} }
}
SourceViewPanel sourceViewPanel = null; SourceViewPanel sourceViewPanel = null;
Widget focusWidget = window.mFocusWidget; Widget focusWidget = window.mFocusWidget;