Commit 0f086ab
feat(event): report the kitty protocol's base layout key
The kitty keyboard protocol's "report alternate keys" enhancement sends up to
two extra codepoints with each key: the shifted key and the base layout key -
the key at the same physical position on a standard PC-101 keyboard. The parser
read the shifted one (only when shift was held) and dropped the rest, so
applications had no way to match shortcuts by physical key: under a Cyrillic,
Greek or Hebrew layout every Ctrl+<letter> binding is dead, because the reported
character is the layout's, not the label's.
Parse both alternates positionally (either may be empty, e.g. `CSI 1076::108;5u`)
and expose the base layout key as `KeyEvent::base_layout_code`, alongside the
existing flag-gated `kind`/`state` fields.
The new field takes no part in `PartialEq`/`Hash`: it is metadata about the same
key press, and including it would silently break the ubiquitous
`event == KeyEvent::new(KeyCode::Char('c'), KeyModifiers::CONTROL)` comparison as
soon as the enhancement is enabled. Existing behaviour, including the shifted-key
substitution, is unchanged - no existing test needed updating.
Closes #968.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>1 parent 34636cf commit 0f086ab
3 files changed
Lines changed: 134 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
3 | 10 | | |
4 | 11 | | |
5 | 12 | | |
6 | 13 | | |
7 | 14 | | |
8 | 15 | | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
9 | 20 | | |
10 | 21 | | |
11 | 22 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
933 | 933 | | |
934 | 934 | | |
935 | 935 | | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
936 | 954 | | |
937 | 955 | | |
938 | 956 | | |
| |||
942 | 960 | | |
943 | 961 | | |
944 | 962 | | |
| 963 | + | |
945 | 964 | | |
946 | 965 | | |
947 | 966 | | |
| |||
955 | 974 | | |
956 | 975 | | |
957 | 976 | | |
| 977 | + | |
958 | 978 | | |
959 | 979 | | |
960 | 980 | | |
| |||
969 | 989 | | |
970 | 990 | | |
971 | 991 | | |
| 992 | + | |
972 | 993 | | |
973 | 994 | | |
974 | 995 | | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
975 | 1003 | | |
976 | 1004 | | |
977 | 1005 | | |
| |||
1012 | 1040 | | |
1013 | 1041 | | |
1014 | 1042 | | |
| 1043 | + | |
1015 | 1044 | | |
1016 | 1045 | | |
1017 | 1046 | | |
1018 | 1047 | | |
1019 | 1048 | | |
1020 | 1049 | | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
1021 | 1053 | | |
1022 | 1054 | | |
1023 | 1055 | | |
1024 | 1056 | | |
1025 | 1057 | | |
| 1058 | + | |
1026 | 1059 | | |
1027 | 1060 | | |
1028 | 1061 | | |
1029 | 1062 | | |
1030 | 1063 | | |
1031 | 1064 | | |
| 1065 | + | |
1032 | 1066 | | |
1033 | 1067 | | |
1034 | 1068 | | |
| |||
1041 | 1075 | | |
1042 | 1076 | | |
1043 | 1077 | | |
| 1078 | + | |
| 1079 | + | |
1044 | 1080 | | |
1045 | 1081 | | |
1046 | 1082 | | |
1047 | 1083 | | |
1048 | 1084 | | |
| 1085 | + | |
1049 | 1086 | | |
1050 | 1087 | | |
1051 | 1088 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
590 | 590 | | |
591 | 591 | | |
592 | 592 | | |
593 | | - | |
594 | | - | |
595 | | - | |
596 | | - | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
597 | 603 | | |
598 | | - | |
599 | | - | |
600 | | - | |
601 | | - | |
602 | | - | |
| 604 | + | |
603 | 605 | | |
604 | 606 | | |
605 | 607 | | |
606 | 608 | | |
607 | 609 | | |
608 | | - | |
609 | | - | |
610 | | - | |
611 | | - | |
612 | | - | |
613 | | - | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
614 | 622 | | |
615 | 623 | | |
616 | 624 | | |
617 | 625 | | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
618 | 637 | | |
619 | 638 | | |
620 | 639 | | |
| |||
864 | 883 | | |
865 | 884 | | |
866 | 885 | | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
867 | 889 | | |
868 | 890 | | |
869 | 891 | | |
870 | 892 | | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
871 | 904 | | |
872 | 905 | | |
873 | 906 | | |
| |||
1547 | 1580 | | |
1548 | 1581 | | |
1549 | 1582 | | |
| 1583 | + | |
| 1584 | + | |
| 1585 | + | |
| 1586 | + | |
| 1587 | + | |
| 1588 | + | |
| 1589 | + | |
| 1590 | + | |
| 1591 | + | |
| 1592 | + | |
| 1593 | + | |
| 1594 | + | |
| 1595 | + | |
| 1596 | + | |
| 1597 | + | |
| 1598 | + | |
| 1599 | + | |
| 1600 | + | |
| 1601 | + | |
| 1602 | + | |
| 1603 | + | |
| 1604 | + | |
| 1605 | + | |
| 1606 | + | |
| 1607 | + | |
| 1608 | + | |
| 1609 | + | |
| 1610 | + | |
| 1611 | + | |
| 1612 | + | |
| 1613 | + | |
| 1614 | + | |
| 1615 | + | |
| 1616 | + | |
| 1617 | + | |
| 1618 | + | |
| 1619 | + | |
| 1620 | + | |
1550 | 1621 | | |
1551 | 1622 | | |
1552 | 1623 | | |
| |||
0 commit comments