WIP fix TryRemapPacketKey to correctly apply Alt/Ctrl mask

This commit is contained in:
tznind
2022-09-21 13:13:46 +01:00
parent 98441c580e
commit ecfd9c1132
2 changed files with 60 additions and 12 deletions

View File

@@ -1761,9 +1761,37 @@ namespace Terminal.Gui {
// do not have a explicit mapping and char is nonzero so
// we can just treat the `Key` as a regular unicode entry
result = (Key)c;
result = ApplyModifiers ((Key)c,original.Modifiers);
return true;
}
/// <summary>
/// Applies
/// </summary>
/// <param name="c"></param>
/// <param name="modifiers"></param>
/// <returns></returns>
private static Key ApplyModifiers (Key c, ConsoleModifiers modifiers)
{
if(modifiers.HasFlag(ConsoleModifiers.Control)) {
c |= Key.CtrlMask;
}
if (modifiers.HasFlag (ConsoleModifiers.Alt)) {
c |= Key.AltMask;
}
/* TODO: Why not this too? I'm a bit confused
ALSO this method looks a lot like `Key MapKeyModifiers (ConsoleKeyInfo keyInfo, Key key)`
Maybe we should be using that instead?
if (modifiers.HasFlag (ConsoleModifiers.Shift)) {
c |= Key.ShiftMask;
}
*/
return c;
}
#endregion
}