From 341fa7b196063999ceab3fa4ebe2d1814e479a47 Mon Sep 17 00:00:00 2001 From: Darren Schroeder <343840+fdncred@users.noreply.github.com> Date: Wed, 12 Jul 2023 10:42:19 -0500 Subject: [PATCH] add kind and state to other key presses (#9669) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Description This PR adds `kind` and `state` to other `keybindings listen` presses like `home` and `end` keys. Before they didn't exist. ``` ❯ keybindings listen Type any key combination to see key details. Press ESC to abort. code: Enter, modifier: NONE, flags: 0b000000, kind: Release, state: NONE code: Home, modifier: NONE, flags: 0b000000, kind: Press, state: NONE code: Home, modifier: NONE, flags: 0b000000, kind: Release, state: NONE code: End, modifier: NONE, flags: 0b000000, kind: Press, state: NONE code: End, modifier: NONE, flags: 0b000000, kind: Release, state: NONE code: End, modifier: CONTROL, flags: 0b000010, kind: Press, state: NONE code: End, modifier: CONTROL, flags: 0b000010, kind: Release, state: NO ``` # User-Facing Changes # Tests + Formatting # After Submitting --- crates/nu-cli/src/commands/keybindings_listen.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/crates/nu-cli/src/commands/keybindings_listen.rs b/crates/nu-cli/src/commands/keybindings_listen.rs index 89c6e2b7b1..234540b99a 100644 --- a/crates/nu-cli/src/commands/keybindings_listen.rs +++ b/crates/nu-cli/src/commands/keybindings_listen.rs @@ -134,11 +134,19 @@ fn print_events_helper(event: Event) -> Result { } _ => { let record = Value::Record { - cols: vec!["code".into(), "modifier".into(), "flags".into()], + cols: vec![ + "code".into(), + "modifier".into(), + "flags".into(), + "kind".into(), + "state".into(), + ], vals: vec![ Value::string(format!("{code:?}"), Span::unknown()), Value::string(format!("{modifiers:?}"), Span::unknown()), Value::string(format!("{modifiers:#08b}"), Span::unknown()), + Value::string(format!("{kind:?}"), Span::unknown()), + Value::string(format!("{state:?}"), Span::unknown()), ], span: Span::unknown(), };