linux: Fix ctrl-0..9
, ctrl-[
, ctrl-^
(#35028)
There were two different underlying reasons for the issues with ctrl-number and ctrl-punctuation: 1. Some keys in the ctrl-0..9 range send codes in the `\1b`..`\1f` range. For example, `ctrl-2` sends keycode for `ctrl-[` (0x1b), but we want to map it to `2`, not to `[`. 2. `ctrl-[` and four other ctrl-punctuation were incorrectly mapped, since the expected conversion is by adding 0x40 Closes #35012 Release Notes: - N/A
This commit is contained in:
parent
3720b6f908
commit
1c0bc89664
1 changed files with 9 additions and 3 deletions
|
@ -845,9 +845,15 @@ impl crate::Keystroke {
|
||||||
{
|
{
|
||||||
if key.is_ascii_graphic() {
|
if key.is_ascii_graphic() {
|
||||||
key_utf8.to_lowercase()
|
key_utf8.to_lowercase()
|
||||||
// map ctrl-a to a
|
// map ctrl-a to `a`
|
||||||
} else if key_utf32 <= 0x1f {
|
// ctrl-0..9 may emit control codes like ctrl-[, but
|
||||||
((key_utf32 as u8 + 0x60) as char).to_string()
|
// we don't want to map them to `[`
|
||||||
|
} else if key_utf32 <= 0x1f
|
||||||
|
&& !name.chars().next().is_some_and(|c| c.is_ascii_digit())
|
||||||
|
{
|
||||||
|
((key_utf32 as u8 + 0x40) as char)
|
||||||
|
.to_ascii_lowercase()
|
||||||
|
.to_string()
|
||||||
} else {
|
} else {
|
||||||
name
|
name
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue