From f25fd1d6f5b2f5430d4b3f7ebb0f72a077c40ff5 Mon Sep 17 00:00:00 2001 From: Manuel Wettstein Date: Fri, 16 May 2025 15:19:27 +0200 Subject: [PATCH 1/4] Added support for `ctrl_h` and `ctrl_i` in keymap config Before this commit, having `ctrl_h` or `ctrl_i` in the keymap configuration would define a mapping for `Key::Ctrl('h')` or `Key::Ctrl('i')`, respectively. These two mappings would never trigger, however, since the corresponding key strokes are represented as `Key::Backspace` and `Key::Tab`. After the commit, `ctrl_h` and `ctrl_i` effectively serve as synonyms of `backspace` and `tab`. For consistency, also added support for `ctrl_[` as a synonym of `esc`. --- crates/libtiny_tui/src/key_map.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/libtiny_tui/src/key_map.rs b/crates/libtiny_tui/src/key_map.rs index 02ba4bcb..b232e026 100644 --- a/crates/libtiny_tui/src/key_map.rs +++ b/crates/libtiny_tui/src/key_map.rs @@ -212,7 +212,12 @@ impl<'de> Deserialize<'de> for MappedKey { } else if let Some(f_key) = parse_f_key(k2) { Key::CtrlF(f_key) } else { - Key::Ctrl(single_key(k2)?) + match single_key(k2)? { + 'h' => Key::Backspace, + 'i' => Key::Tab, + '[' => Key::Esc, + other => Key::Ctrl(other), + } } } "shift" => { From 775f8154ef576b50a55f0fdd0e31ed3bb955d210 Mon Sep 17 00:00:00 2001 From: Manuel Wettstein Date: Tue, 20 May 2025 16:03:59 +0200 Subject: [PATCH 2/4] Add explanation for special treatment of `ctrl_i` and `ctrl_[` --- crates/libtiny_tui/src/key_map.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/libtiny_tui/src/key_map.rs b/crates/libtiny_tui/src/key_map.rs index b232e026..4a3cf347 100644 --- a/crates/libtiny_tui/src/key_map.rs +++ b/crates/libtiny_tui/src/key_map.rs @@ -213,7 +213,13 @@ impl<'de> Deserialize<'de> for MappedKey { Key::CtrlF(f_key) } else { match single_key(k2)? { - 'h' => Key::Backspace, + // NOTE: The following special mappings are needed + // because, e.g., `Key::Ctrl('i')` is never generated + // by `term_input` since `ctrl_i` and `tab` send + // identical bytes and hence cannot be distinguished + // in a terminal app. Having the special mapping here + // allows the user to define a working key binding for + // `ctrl_i`, which would otherwise be ignored. 'i' => Key::Tab, '[' => Key::Esc, other => Key::Ctrl(other), From 3bf583177aa21f4d0294e740823d8faa224294df Mon Sep 17 00:00:00 2001 From: Manuel Wettstein Date: Tue, 20 May 2025 16:05:05 +0200 Subject: [PATCH 3/4] Update CHANGELOG (#444, #445) --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 03749bba..42941e60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ color code. (#434) - Refactor an internal macro to make tiny builds deterministic, allowing reproducible builds. (#437) +- Key bindings for `ctrl_i` and `ctrl_[` in the config file are no longer + ignored and are now synonymous with `tab` and `esc`. (#444) +- The keystrokes `ctrl_h` and `backspace` can now be distinguished, which + allows the user to define separate key bindings in the config tile. (#445) # 2024/01/01: 0.12.0 From af5ff2eaaf3c90184f823539abd5d2ef299049c4 Mon Sep 17 00:00:00 2001 From: Manuel Wettstein Date: Tue, 20 May 2025 16:38:51 +0200 Subject: [PATCH 4/4] Moved recent changes to new Unreleased section in CHANGELOG --- CHANGELOG.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 42941e60..c0440753 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# Unreleased + +- Key bindings for `ctrl_i` and `ctrl_[` in the config file are no longer + ignored and are now synonymous with `tab` and `esc`. (#444) +- The keystrokes `ctrl_h` and `backspace` can now be distinguished, which + allows the user to define separate key bindings in the config file. (#445) + # 2025/01/01: 0.13.0 - Improve nick matching to avoid highlighting message incorrectly. (#430) @@ -5,10 +12,6 @@ color code. (#434) - Refactor an internal macro to make tiny builds deterministic, allowing reproducible builds. (#437) -- Key bindings for `ctrl_i` and `ctrl_[` in the config file are no longer - ignored and are now synonymous with `tab` and `esc`. (#444) -- The keystrokes `ctrl_h` and `backspace` can now be distinguished, which - allows the user to define separate key bindings in the config tile. (#445) # 2024/01/01: 0.12.0