diff --git a/Cargo.lock b/Cargo.lock index 1988641c..f3292317 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5306,6 +5306,7 @@ dependencies = [ "async-channel", "async-std", "backtrace", + "bitflags 2.5.0", "clap", "clap_complete", "colored", diff --git a/default-plugins/fixture-plugin-for-tests/src/main.rs b/default-plugins/fixture-plugin-for-tests/src/main.rs index e9555dac..f504eec8 100644 --- a/default-plugins/fixture-plugin-for-tests/src/main.rs +++ b/default-plugins/fixture-plugin-for-tests/src/main.rs @@ -72,11 +72,11 @@ impl ZellijPlugin for State { fn update(&mut self, event: Event) -> bool { match &event { - Event::Key(key) => match key { - Key::Char('a') => { + Event::Key(key) => match key.bare_key { + BareKey::Char('a') if key.has_no_modifiers() => { switch_to_input_mode(&InputMode::Tab); }, - Key::Char('b') => { + BareKey::Char('b') if key.has_no_modifiers() => { new_tabs_with_layout( "layout { tab { @@ -90,85 +90,87 @@ impl ZellijPlugin for State { }", ); }, - Key::Char('c') => new_tab(), - Key::Char('d') => go_to_next_tab(), - Key::Char('e') => go_to_previous_tab(), - Key::Char('f') => { + BareKey::Char('c') if key.has_no_modifiers() => new_tab(), + BareKey::Char('d') if key.has_no_modifiers() => go_to_next_tab(), + BareKey::Char('e') if key.has_no_modifiers() => go_to_previous_tab(), + BareKey::Char('f') if key.has_no_modifiers() => { let resize = Resize::Increase; resize_focused_pane(resize) }, - Key::Char('g') => { + BareKey::Char('g') if key.has_no_modifiers() => { let resize = Resize::Increase; let direction = Direction::Left; resize_focused_pane_with_direction(resize, direction); }, - Key::Char('h') => focus_next_pane(), - Key::Char('i') => focus_previous_pane(), - Key::Char('j') => { + BareKey::Char('h') if key.has_no_modifiers() => focus_next_pane(), + BareKey::Char('i') if key.has_no_modifiers() => focus_previous_pane(), + BareKey::Char('j') if key.has_no_modifiers() => { let direction = Direction::Left; move_focus(direction) }, - Key::Char('k') => { + BareKey::Char('k') if key.has_no_modifiers() => { let direction = Direction::Left; move_focus_or_tab(direction) }, - Key::Char('l') => detach(), - Key::Char('m') => edit_scrollback(), - Key::Char('n') => { + BareKey::Char('l') if key.has_no_modifiers() => detach(), + BareKey::Char('m') if key.has_no_modifiers() => edit_scrollback(), + BareKey::Char('n') if key.has_no_modifiers() => { let bytes = vec![102, 111, 111]; write(bytes) }, - Key::Char('o') => { + BareKey::Char('o') if key.has_no_modifiers() => { let chars = "foo"; write_chars(chars); }, - Key::Char('p') => toggle_tab(), - Key::Char('q') => move_pane(), - Key::Char('r') => { + BareKey::Char('p') if key.has_no_modifiers() => toggle_tab(), + BareKey::Char('q') if key.has_no_modifiers() => move_pane(), + BareKey::Char('r') if key.has_no_modifiers() => { let direction = Direction::Left; move_pane_with_direction(direction) }, - Key::Char('s') => clear_screen(), - Key::Char('t') => scroll_up(), - Key::Char('u') => scroll_down(), - Key::Char('v') => scroll_to_top(), - Key::Char('w') => scroll_to_bottom(), - Key::Char('x') => page_scroll_up(), - Key::Char('y') => page_scroll_down(), - Key::Char('z') => toggle_focus_fullscreen(), - Key::Char('1') => toggle_pane_frames(), - Key::Char('2') => toggle_pane_embed_or_eject(), - Key::Char('3') => undo_rename_pane(), - Key::Char('4') => close_focus(), - Key::Char('5') => toggle_active_tab_sync(), - Key::Char('6') => close_focused_tab(), - Key::Char('7') => undo_rename_tab(), - Key::Char('8') => quit_zellij(), - Key::Ctrl('a') => previous_swap_layout(), - Key::Ctrl('b') => next_swap_layout(), - Key::Ctrl('c') => { + BareKey::Char('s') if key.has_no_modifiers() => clear_screen(), + BareKey::Char('t') if key.has_no_modifiers() => scroll_up(), + BareKey::Char('u') if key.has_no_modifiers() => scroll_down(), + BareKey::Char('v') if key.has_no_modifiers() => scroll_to_top(), + BareKey::Char('w') if key.has_no_modifiers() => scroll_to_bottom(), + BareKey::Char('x') if key.has_no_modifiers() => page_scroll_up(), + BareKey::Char('y') if key.has_no_modifiers() => page_scroll_down(), + BareKey::Char('z') if key.has_no_modifiers() => toggle_focus_fullscreen(), + BareKey::Char('1') if key.has_no_modifiers() => toggle_pane_frames(), + BareKey::Char('2') if key.has_no_modifiers() => toggle_pane_embed_or_eject(), + BareKey::Char('3') if key.has_no_modifiers() => undo_rename_pane(), + BareKey::Char('4') if key.has_no_modifiers() => close_focus(), + BareKey::Char('5') if key.has_no_modifiers() => toggle_active_tab_sync(), + BareKey::Char('6') if key.has_no_modifiers() => close_focused_tab(), + BareKey::Char('7') if key.has_no_modifiers() => undo_rename_tab(), + BareKey::Char('8') if key.has_no_modifiers() => quit_zellij(), + BareKey::Char('a') if key.has_modifiers(&[KeyModifier::Ctrl]) => { + previous_swap_layout() + }, + BareKey::Char('b') if key.has_modifiers(&[KeyModifier::Ctrl]) => next_swap_layout(), + BareKey::Char('c') if key.has_modifiers(&[KeyModifier::Ctrl]) => { let tab_name = "my tab name"; go_to_tab_name(tab_name) }, - Key::Ctrl('d') => { + BareKey::Char('d') if key.has_modifiers(&[KeyModifier::Ctrl]) => { let tab_name = "my tab name"; focus_or_create_tab(tab_name) }, - Key::Ctrl('e') => { + BareKey::Char('e') if key.has_modifiers(&[KeyModifier::Ctrl]) => { let tab_index = 2; go_to_tab(tab_index) }, - Key::Ctrl('f') => { + BareKey::Char('f') if key.has_modifiers(&[KeyModifier::Ctrl]) => { let plugin_url = "file:/path/to/my/plugin.wasm"; start_or_reload_plugin(plugin_url) }, - Key::Ctrl('g') => { + BareKey::Char('g') if key.has_modifiers(&[KeyModifier::Ctrl]) => { open_file(FileToOpen { path: std::path::PathBuf::from("/path/to/my/file.rs"), ..Default::default() }); }, - Key::Ctrl('h') => { + BareKey::Char('h') if key.has_modifiers(&[KeyModifier::Ctrl]) => { open_file_floating( FileToOpen { path: std::path::PathBuf::from("/path/to/my/file.rs"), @@ -177,14 +179,14 @@ impl ZellijPlugin for State { None, ); }, - Key::Ctrl('i') => { + BareKey::Char('i') if key.has_modifiers(&[KeyModifier::Ctrl]) => { open_file(FileToOpen { path: std::path::PathBuf::from("/path/to/my/file.rs"), line_number: Some(42), ..Default::default() }); }, - Key::Ctrl('j') => { + BareKey::Char('j') if key.has_modifiers(&[KeyModifier::Ctrl]) => { open_file_floating( FileToOpen { path: std::path::PathBuf::from("/path/to/my/file.rs"), @@ -194,23 +196,23 @@ impl ZellijPlugin for State { None, ); }, - Key::Ctrl('k') => { + BareKey::Char('k') if key.has_modifiers(&[KeyModifier::Ctrl]) => { open_terminal(std::path::PathBuf::from("/path/to/my/file.rs").as_path()); }, - Key::Ctrl('l') => { + BareKey::Char('l') if key.has_modifiers(&[KeyModifier::Ctrl]) => { open_terminal_floating( std::path::PathBuf::from("/path/to/my/file.rs").as_path(), None, ); }, - Key::Ctrl('m') => { + BareKey::Char('m') if key.has_modifiers(&[KeyModifier::Ctrl]) => { open_command_pane(CommandToRun { path: std::path::PathBuf::from("/path/to/my/file.rs"), args: vec!["arg1".to_owned(), "arg2".to_owned()], ..Default::default() }); }, - Key::Ctrl('n') => { + BareKey::Char('n') if key.has_modifiers(&[KeyModifier::Ctrl]) => { open_command_pane_floating( CommandToRun { path: std::path::PathBuf::from("/path/to/my/file.rs"), @@ -220,51 +222,51 @@ impl ZellijPlugin for State { None, ); }, - Key::Ctrl('o') => { + BareKey::Char('o') if key.has_modifiers(&[KeyModifier::Ctrl]) => { switch_tab_to(1); }, - Key::Ctrl('p') => { + BareKey::Char('p') if key.has_modifiers(&[KeyModifier::Ctrl]) => { hide_self(); }, - Key::Ctrl('q') => { + BareKey::Char('q') if key.has_modifiers(&[KeyModifier::Ctrl]) => { let should_float_if_hidden = false; show_self(should_float_if_hidden); }, - Key::Ctrl('r') => { + BareKey::Char('r') if key.has_modifiers(&[KeyModifier::Ctrl]) => { close_terminal_pane(1); }, - Key::Ctrl('s') => { + BareKey::Char('s') if key.has_modifiers(&[KeyModifier::Ctrl]) => { close_plugin_pane(1); }, - Key::Ctrl('t') => { + BareKey::Char('t') if key.has_modifiers(&[KeyModifier::Ctrl]) => { let should_float_if_hidden = false; focus_terminal_pane(1, should_float_if_hidden); }, - Key::Ctrl('u') => { + BareKey::Char('u') if key.has_modifiers(&[KeyModifier::Ctrl]) => { let should_float_if_hidden = false; focus_plugin_pane(1, should_float_if_hidden); }, - Key::Ctrl('v') => { + BareKey::Char('v') if key.has_modifiers(&[KeyModifier::Ctrl]) => { rename_terminal_pane(1, "new terminal_pane_name"); }, - Key::Ctrl('w') => { + BareKey::Char('w') if key.has_modifiers(&[KeyModifier::Ctrl]) => { rename_plugin_pane(1, "new plugin_pane_name"); }, - Key::Ctrl('x') => { + BareKey::Char('x') if key.has_modifiers(&[KeyModifier::Ctrl]) => { rename_tab(1, "new tab name"); }, - Key::Ctrl('z') => { + BareKey::Char('z') if key.has_modifiers(&[KeyModifier::Ctrl]) => { go_to_tab_name(&format!("{:?}", self.configuration)); }, - Key::Ctrl('1') => { + BareKey::Char('1') if key.has_modifiers(&[KeyModifier::Ctrl]) => { request_permission(&[PermissionType::ReadApplicationState]); }, - Key::Ctrl('2') => { + BareKey::Char('2') if key.has_modifiers(&[KeyModifier::Ctrl]) => { let mut context = BTreeMap::new(); context.insert("user_key_1".to_owned(), "user_value_1".to_owned()); run_command(&["ls", "-l"], context); }, - Key::Ctrl('3') => { + BareKey::Char('3') if key.has_modifiers(&[KeyModifier::Ctrl]) => { let mut context = BTreeMap::new(); context.insert("user_key_2".to_owned(), "user_value_2".to_owned()); let mut env_vars = BTreeMap::new(); @@ -276,7 +278,7 @@ impl ZellijPlugin for State { context, ); }, - Key::Ctrl('4') => { + BareKey::Char('4') if key.has_modifiers(&[KeyModifier::Ctrl]) => { let mut headers = BTreeMap::new(); let mut context = BTreeMap::new(); let body = vec![1, 2, 3]; @@ -292,22 +294,24 @@ impl ZellijPlugin for State { context, ); }, - Key::Ctrl('5') => { + BareKey::Char('5') if key.has_modifiers(&[KeyModifier::Ctrl]) => { switch_session(Some("my_new_session")); }, - Key::Ctrl('6') => disconnect_other_clients(), - Key::Ctrl('7') => { + BareKey::Char('6') if key.has_modifiers(&[KeyModifier::Ctrl]) => { + disconnect_other_clients() + }, + BareKey::Char('7') if key.has_modifiers(&[KeyModifier::Ctrl]) => { switch_session_with_layout( Some("my_other_new_session"), LayoutInfo::BuiltIn("compact".to_owned()), None, ); }, - Key::Ctrl('8') => { + BareKey::Char('8') if key.has_modifiers(&[KeyModifier::Ctrl]) => { let mut file = std::fs::File::create("/host/hi-from-plugin.txt").unwrap(); file.write_all(b"Hi there!").unwrap(); }, - Key::Ctrl('9') => { + BareKey::Char('9') if key.has_modifiers(&[KeyModifier::Ctrl]) => { switch_session_with_layout( Some("my_other_new_session_with_cwd"), LayoutInfo::BuiltIn("compact".to_owned()), diff --git a/default-plugins/session-manager/src/main.rs b/default-plugins/session-manager/src/main.rs index 9f37a34a..05a33286 100644 --- a/default-plugins/session-manager/src/main.rs +++ b/default-plugins/session-manager/src/main.rs @@ -175,7 +175,7 @@ impl State { fn reset_selected_index(&mut self) { self.sessions.reset_selected_index(); } - fn handle_key(&mut self, key: Key) -> bool { + fn handle_key(&mut self, key: KeyWithModifier) -> bool { if self.error.is_some() { self.error = None; return true; @@ -186,197 +186,246 @@ impl State { ActiveScreen::ResurrectSession => self.handle_resurrect_session_key(key), } } - fn handle_new_session_key(&mut self, key: Key) -> bool { + fn handle_new_session_key(&mut self, key: KeyWithModifier) -> bool { let mut should_render = false; - if let Key::Down = key { - self.new_session_info.handle_key(key); - should_render = true; - } else if let Key::Up = key { - self.new_session_info.handle_key(key); - should_render = true; - } else if let Key::Char(character) = key { - if character == '\n' { - self.handle_selection(); - } else { + match key.bare_key { + BareKey::Down if key.has_no_modifiers() => { self.new_session_info.handle_key(key); - } - should_render = true; - } else if let Key::Backspace = key { - self.new_session_info.handle_key(key); - should_render = true; - } else if let Key::Ctrl('w') = key { - self.active_screen = ActiveScreen::NewSession; - should_render = true; - } else if let Key::BackTab = key { - self.toggle_active_screen(); - should_render = true; - } else if let Key::Ctrl('f') = key { - let request_id = Uuid::new_v4(); - let mut config = BTreeMap::new(); - let mut args = BTreeMap::new(); - self.request_ids.push(request_id.to_string()); - // we insert this into the config so that a new plugin will be opened (the plugin's - // uniqueness is determined by its name/url as well as its config) - config.insert("request_id".to_owned(), request_id.to_string()); - // we also insert this into the args so that the plugin will have an easier access to - // it - args.insert("request_id".to_owned(), request_id.to_string()); - pipe_message_to_plugin( - MessageToPlugin::new("filepicker") - .with_plugin_url("filepicker") - .with_plugin_config(config) - .new_plugin_instance_should_have_pane_title( - "Select folder for the new session...", - ) - .with_args(args), - ); - should_render = true; - } else if let Key::Ctrl('c') = key { - self.new_session_info.new_session_folder = None; - should_render = true; - } else if let Key::Esc = key { - self.new_session_info.handle_key(key); - should_render = true; + should_render = true; + }, + BareKey::Up if key.has_no_modifiers() => { + self.new_session_info.handle_key(key); + should_render = true; + }, + BareKey::Char(character) if key.has_no_modifiers() => { + if character == '\n' { + self.handle_selection(); + } else { + self.new_session_info.handle_key(key); + } + should_render = true; + }, + BareKey::Backspace if key.has_no_modifiers() => { + self.new_session_info.handle_key(key); + should_render = true; + }, + BareKey::Char('w') if key.has_modifiers(&[KeyModifier::Ctrl]) => { + self.active_screen = ActiveScreen::NewSession; + should_render = true; + }, + BareKey::Tab if key.has_no_modifiers() => { + self.toggle_active_screen(); + should_render = true; + }, + BareKey::Char('f') if key.has_modifiers(&[KeyModifier::Ctrl]) => { + let request_id = Uuid::new_v4(); + let mut config = BTreeMap::new(); + let mut args = BTreeMap::new(); + self.request_ids.push(request_id.to_string()); + // we insert this into the config so that a new plugin will be opened (the plugin's + // uniqueness is determined by its name/url as well as its config) + config.insert("request_id".to_owned(), request_id.to_string()); + // we also insert this into the args so that the plugin will have an easier access to + // it + args.insert("request_id".to_owned(), request_id.to_string()); + pipe_message_to_plugin( + MessageToPlugin::new("filepicker") + .with_plugin_url("filepicker") + .with_plugin_config(config) + .new_plugin_instance_should_have_pane_title( + "Select folder for the new session...", + ) + .with_args(args), + ); + should_render = true; + }, + BareKey::Char('c') if key.has_modifiers(&[KeyModifier::Ctrl]) => { + self.new_session_info.new_session_folder = None; + should_render = true; + }, + BareKey::Esc if key.has_no_modifiers() => { + self.new_session_info.handle_key(key); + should_render = true; + }, + _ => {}, } should_render } - fn handle_attach_to_session(&mut self, key: Key) -> bool { + fn handle_attach_to_session(&mut self, key: KeyWithModifier) -> bool { let mut should_render = false; if self.show_kill_all_sessions_warning { - if let Key::Char('y') = key { - let all_other_sessions = self.sessions.all_other_sessions(); - kill_sessions(&all_other_sessions); - self.reset_selected_index(); - self.search_term.clear(); - self.sessions - .update_search_term(&self.search_term, &self.colors); - self.show_kill_all_sessions_warning = false - } else if let Key::Char('n') | Key::Esc | Key::Ctrl('c') = key { - self.show_kill_all_sessions_warning = false + match key.bare_key { + BareKey::Char('y') if key.has_no_modifiers() => { + let all_other_sessions = self.sessions.all_other_sessions(); + kill_sessions(&all_other_sessions); + self.reset_selected_index(); + self.search_term.clear(); + self.sessions + .update_search_term(&self.search_term, &self.colors); + self.show_kill_all_sessions_warning = false; + should_render = true; + }, + BareKey::Char('n') | BareKey::Esc if key.has_no_modifiers() => { + self.show_kill_all_sessions_warning = false; + should_render = true; + }, + BareKey::Char('c') if key.has_modifiers(&[KeyModifier::Ctrl]) => { + self.show_kill_all_sessions_warning = false; + should_render = true; + }, + _ => {}, } - should_render = true; - } else if let Key::Right = key { - self.sessions.result_expand(); - should_render = true; - } else if let Key::Left = key { - self.sessions.result_shrink(); - should_render = true; - } else if let Key::Down = key { - self.sessions.move_selection_down(); - should_render = true; - } else if let Key::Up = key { - self.sessions.move_selection_up(); - should_render = true; - } else if let Key::Char(character) = key { - if character == '\n' { - self.handle_selection(); - } else if let Some(new_session_name) = self.renaming_session_name.as_mut() { - new_session_name.push(character); - } else { - self.search_term.push(character); - self.sessions - .update_search_term(&self.search_term, &self.colors); - } - should_render = true; - } else if let Key::Backspace = key { - if let Some(new_session_name) = self.renaming_session_name.as_mut() { - if new_session_name.is_empty() { - self.renaming_session_name = None; - } else { - new_session_name.pop(); - } - } else { - self.search_term.pop(); - self.sessions - .update_search_term(&self.search_term, &self.colors); - } - should_render = true; - } else if let Key::Ctrl('w') = key { - self.active_screen = ActiveScreen::NewSession; - should_render = true; - } else if let Key::Ctrl('r') = key { - self.renaming_session_name = Some(String::new()); - should_render = true; - } else if let Key::Delete = key { - if let Some(selected_session_name) = self.sessions.get_selected_session_name() { - kill_sessions(&[selected_session_name]); - self.reset_selected_index(); - self.search_term.clear(); - self.sessions - .update_search_term(&self.search_term, &self.colors); - } else { - self.show_error("Must select session before killing it."); - } - should_render = true; - } else if let Key::Ctrl('d') = key { - let all_other_sessions = self.sessions.all_other_sessions(); - if all_other_sessions.is_empty() { - self.show_error("No other sessions to kill. Quit to kill the current one."); - } else { - self.show_kill_all_sessions_warning = true; - } - should_render = true; - } else if let Key::Ctrl('x') = key { - disconnect_other_clients(); - } else if let Key::Ctrl('c') = key { - if !self.search_term.is_empty() { - self.search_term.clear(); - self.sessions - .update_search_term(&self.search_term, &self.colors); - self.reset_selected_index(); - } else if !self.is_welcome_screen { - self.reset_selected_index(); - hide_self(); - } - should_render = true; - } else if let Key::BackTab = key { - self.toggle_active_screen(); - should_render = true; - } else if let Key::Esc = key { - if self.renaming_session_name.is_some() { - self.renaming_session_name = None; - should_render = true; - } else if !self.is_welcome_screen { - hide_self(); + } else { + match key.bare_key { + BareKey::Right if key.has_no_modifiers() => { + self.sessions.result_expand(); + should_render = true; + }, + BareKey::Left if key.has_no_modifiers() => { + self.sessions.result_shrink(); + should_render = true; + }, + BareKey::Down if key.has_no_modifiers() => { + self.sessions.move_selection_down(); + should_render = true; + }, + BareKey::Up if key.has_no_modifiers() => { + self.sessions.move_selection_up(); + should_render = true; + }, + BareKey::Char(character) if key.has_no_modifiers() => { + if character == '\n' { + self.handle_selection(); + } else if let Some(new_session_name) = self.renaming_session_name.as_mut() { + new_session_name.push(character); + } else { + self.search_term.push(character); + self.sessions + .update_search_term(&self.search_term, &self.colors); + } + should_render = true; + }, + BareKey::Backspace if key.has_no_modifiers() => { + if let Some(new_session_name) = self.renaming_session_name.as_mut() { + if new_session_name.is_empty() { + self.renaming_session_name = None; + } else { + new_session_name.pop(); + } + } else { + self.search_term.pop(); + self.sessions + .update_search_term(&self.search_term, &self.colors); + } + should_render = true; + }, + BareKey::Char('w') if key.has_modifiers(&[KeyModifier::Ctrl]) => { + self.active_screen = ActiveScreen::NewSession; + should_render = true; + }, + BareKey::Char('r') if key.has_modifiers(&[KeyModifier::Ctrl]) => { + self.renaming_session_name = Some(String::new()); + should_render = true; + }, + BareKey::Delete if key.has_no_modifiers() => { + if let Some(selected_session_name) = self.sessions.get_selected_session_name() { + kill_sessions(&[selected_session_name]); + self.reset_selected_index(); + self.search_term.clear(); + self.sessions + .update_search_term(&self.search_term, &self.colors); + } else { + self.show_error("Must select session before killing it."); + } + should_render = true; + }, + BareKey::Char('d') if key.has_modifiers(&[KeyModifier::Ctrl]) => { + let all_other_sessions = self.sessions.all_other_sessions(); + if all_other_sessions.is_empty() { + self.show_error("No other sessions to kill. Quit to kill the current one."); + } else { + self.show_kill_all_sessions_warning = true; + } + should_render = true; + }, + BareKey::Char('x') if key.has_modifiers(&[KeyModifier::Ctrl]) => { + disconnect_other_clients() + }, + BareKey::Char('c') if key.has_modifiers(&[KeyModifier::Ctrl]) => { + if !self.search_term.is_empty() { + self.search_term.clear(); + self.sessions + .update_search_term(&self.search_term, &self.colors); + self.reset_selected_index(); + } else if !self.is_welcome_screen { + self.reset_selected_index(); + hide_self(); + } + should_render = true; + }, + BareKey::Tab if key.has_no_modifiers() => { + self.toggle_active_screen(); + should_render = true; + }, + BareKey::Esc if key.has_no_modifiers() => { + if self.renaming_session_name.is_some() { + self.renaming_session_name = None; + should_render = true; + } else if !self.is_welcome_screen { + hide_self(); + } + }, + _ => {}, } } should_render } - fn handle_resurrect_session_key(&mut self, key: Key) -> bool { + fn handle_resurrect_session_key(&mut self, key: KeyWithModifier) -> bool { let mut should_render = false; - if let Key::Down = key { - self.resurrectable_sessions.move_selection_down(); - should_render = true; - } else if let Key::Up = key { - self.resurrectable_sessions.move_selection_up(); - should_render = true; - } else if let Key::Char(character) = key { - if character == '\n' { - self.handle_selection(); - } else { - self.resurrectable_sessions.handle_character(character); - } - should_render = true; - } else if let Key::Backspace = key { - self.resurrectable_sessions.handle_backspace(); - should_render = true; - } else if let Key::Ctrl('w') = key { - self.active_screen = ActiveScreen::NewSession; - should_render = true; - } else if let Key::BackTab = key { - self.toggle_active_screen(); - should_render = true; - } else if let Key::Delete = key { - self.resurrectable_sessions.delete_selected_session(); - should_render = true; - } else if let Key::Ctrl('d') = key { - self.resurrectable_sessions - .show_delete_all_sessions_warning(); - should_render = true; - } else if let Key::Esc = key { - if !self.is_welcome_screen { - hide_self(); - } + match key.bare_key { + BareKey::Down if key.has_no_modifiers() => { + self.resurrectable_sessions.move_selection_down(); + should_render = true; + }, + BareKey::Up if key.has_no_modifiers() => { + self.resurrectable_sessions.move_selection_up(); + should_render = true; + }, + BareKey::Char(character) if key.has_no_modifiers() => { + if character == '\n' { + self.handle_selection(); + } else { + self.resurrectable_sessions.handle_character(character); + } + should_render = true; + }, + BareKey::Backspace if key.has_no_modifiers() => { + self.resurrectable_sessions.handle_backspace(); + should_render = true; + }, + BareKey::Char('w') if key.has_modifiers(&[KeyModifier::Ctrl]) => { + self.active_screen = ActiveScreen::NewSession; + should_render = true; + }, + BareKey::Tab if key.has_no_modifiers() => { + self.toggle_active_screen(); + should_render = true; + }, + BareKey::Delete if key.has_no_modifiers() => { + self.resurrectable_sessions.delete_selected_session(); + should_render = true; + }, + BareKey::Char('d') if key.has_modifiers(&[KeyModifier::Ctrl]) => { + self.resurrectable_sessions + .show_delete_all_sessions_warning(); + should_render = true; + }, + BareKey::Esc if key.has_no_modifiers() => { + if !self.is_welcome_screen { + hide_self(); + } + }, + _ => {}, } should_render } diff --git a/default-plugins/session-manager/src/new_session_info.rs b/default-plugins/session-manager/src/new_session_info.rs index 3527b7dc..a6ff7901 100644 --- a/default-plugins/session-manager/src/new_session_info.rs +++ b/default-plugins/session-manager/src/new_session_info.rs @@ -70,21 +70,24 @@ impl NewSessionInfo { }, } } - pub fn handle_key(&mut self, key: Key) { - match key { - Key::Backspace => { + pub fn handle_key(&mut self, key: KeyWithModifier) { + match key.bare_key { + BareKey::Backspace if key.has_no_modifiers() => { self.handle_backspace(); }, - Key::Ctrl('c') | Key::Esc => { + BareKey::Char('c') if key.has_modifiers(&[KeyModifier::Ctrl]) => { self.handle_break(); }, - Key::Char(character) => { + BareKey::Esc if key.has_no_modifiers() => { + self.handle_break(); + }, + BareKey::Char(character) if key.has_no_modifiers() => { self.add_char(character); }, - Key::Up => { + BareKey::Up if key.has_no_modifiers() => { self.move_selection_up(); }, - Key::Down => { + BareKey::Down if key.has_no_modifiers() => { self.move_selection_down(); }, _ => {}, diff --git a/default-plugins/status-bar/src/first_line.rs b/default-plugins/status-bar/src/first_line.rs index 4ac09064..1fffd755 100644 --- a/default-plugins/status-bar/src/first_line.rs +++ b/default-plugins/status-bar/src/first_line.rs @@ -4,14 +4,14 @@ use zellij_tile::prelude::*; use crate::color_elements; use crate::{ - action_key, action_key_group, get_common_modifier, style_key_with_modifier, TO_NORMAL, + action_key, action_key_group, get_common_modifiers, style_key_with_modifier, TO_NORMAL, }; use crate::{ColoredElements, LinePart}; struct KeyShortcut { mode: KeyMode, action: KeyAction, - key: Option, + key: Option, } #[derive(PartialEq)] @@ -35,7 +35,7 @@ enum KeyMode { } impl KeyShortcut { - pub fn new(mode: KeyMode, action: KeyAction, key: Option) -> Self { + pub fn new(mode: KeyMode, action: KeyAction, key: Option) -> Self { KeyShortcut { mode, action, key } } @@ -52,25 +52,36 @@ impl KeyShortcut { KeyAction::Tmux => String::from("TMUX"), } } - pub fn letter_shortcut(&self, with_prefix: bool) -> String { - let key = match self.key { - Some(k) => k, + pub fn with_shortened_modifiers(&self, common_modifiers: &Vec) -> String { + let key = match &self.key { + Some(k) => k.strip_common_modifiers(common_modifiers), None => return String::from("?"), }; - if with_prefix { + let shortened_modifiers = key + .key_modifiers + .iter() + .map(|m| match m { + KeyModifier::Ctrl => "^C", + KeyModifier::Alt => "^A", + KeyModifier::Super => "^Su", + KeyModifier::Shift => "^Sh", + _ => "", + }) + .collect::>() + .join("-"); + if shortened_modifiers.is_empty() { format!("{}", key) } else { - match key { - Key::F(c) => format!("{}", c), - Key::CtrlF(n) => format!("F{}", n), - Key::AltF(n) => format!("F{}", n), - Key::Ctrl(c) => format!("{}", c), - Key::Char(_) => format!("{}", key), - Key::Alt(c) => format!("{}", c), - _ => String::from("??"), - } + format!("{} {}", shortened_modifiers, key.bare_key) } } + pub fn letter_shortcut(&self, common_modifiers: &Vec) -> String { + let key = match &self.key { + Some(k) => k.strip_common_modifiers(common_modifiers), + None => return String::from("?"), + }; + format!("{}", key) + } } /// Generate long mode shortcut tile. @@ -96,14 +107,15 @@ fn long_mode_shortcut( key: &KeyShortcut, palette: ColoredElements, separator: &str, - shared_super: bool, + common_modifiers: &Vec, first_tile: bool, ) -> LinePart { let key_hint = key.full_text(); + let has_common_modifiers = !common_modifiers.is_empty(); let key_binding = match (&key.mode, &key.key) { (KeyMode::Disabled, None) => "".to_string(), (_, None) => return LinePart::default(), - (_, Some(_)) => key.letter_shortcut(!shared_super), + (_, Some(_)) => key.letter_shortcut(common_modifiers), }; let colors = match key.mode { @@ -112,7 +124,59 @@ fn long_mode_shortcut( KeyMode::Selected => palette.selected, KeyMode::Disabled => palette.disabled, }; - let start_separator = if !shared_super && first_tile { + let start_separator = if !has_common_modifiers && first_tile { + "" + } else { + separator + }; + let prefix_separator = colors.prefix_separator.paint(start_separator); + let char_left_separator = colors.char_left_separator.paint(" <".to_string()); + let char_shortcut = colors.char_shortcut.paint(key_binding.to_string()); + let char_right_separator = colors.char_right_separator.paint("> ".to_string()); + let styled_text = colors.styled_text.paint(format!("{} ", key_hint)); + let suffix_separator = colors.suffix_separator.paint(separator); + LinePart { + part: ANSIStrings(&[ + prefix_separator, + char_left_separator, + char_shortcut, + char_right_separator, + styled_text, + suffix_separator, + ]) + .to_string(), + len: start_separator.chars().count() // Separator + + 2 // " <" + + key_binding.chars().count() // Key binding + + 2 // "> " + + key_hint.chars().count() // Key hint (mode) + + 1 // " " + + separator.chars().count(), // Separator + } +} + +fn shortened_modifier_shortcut( + key: &KeyShortcut, + palette: ColoredElements, + separator: &str, + common_modifiers: &Vec, + first_tile: bool, +) -> LinePart { + let key_hint = key.full_text(); + let has_common_modifiers = !common_modifiers.is_empty(); + let key_binding = match (&key.mode, &key.key) { + (KeyMode::Disabled, None) => "".to_string(), + (_, None) => return LinePart::default(), + (_, Some(_)) => key.with_shortened_modifiers(common_modifiers), + }; + + let colors = match key.mode { + KeyMode::Unselected => palette.unselected, + KeyMode::UnselectedAlternate => palette.unselected_alternate, + KeyMode::Selected => palette.selected, + KeyMode::Disabled => palette.disabled, + }; + let start_separator = if !has_common_modifiers && first_tile { "" } else { separator @@ -165,13 +229,14 @@ fn short_mode_shortcut( key: &KeyShortcut, palette: ColoredElements, separator: &str, - shared_super: bool, + common_modifiers: &Vec, first_tile: bool, ) -> LinePart { + let has_common_modifiers = !common_modifiers.is_empty(); let key_binding = match (&key.mode, &key.key) { (KeyMode::Disabled, None) => "".to_string(), (_, None) => return LinePart::default(), - (_, Some(_)) => key.letter_shortcut(!shared_super), + (_, Some(_)) => key.letter_shortcut(common_modifiers), }; let colors = match key.mode { @@ -180,7 +245,7 @@ fn short_mode_shortcut( KeyMode::Selected => palette.selected, KeyMode::Disabled => palette.disabled, }; - let start_separator = if !shared_super && first_tile { + let start_separator = if !has_common_modifiers && first_tile { "" } else { separator @@ -206,11 +271,23 @@ fn key_indicators( mode_info: &ModeInfo, ) -> LinePart { // Print full-width hints - let mut line_part = superkey(palette, separator, mode_info); - let shared_super = line_part.len > 0; - for ctrl_key in keys { + let (shared_modifiers, mut line_part) = superkey(palette, separator, mode_info); + for key in keys { let line_empty = line_part.len == 0; - let key = long_mode_shortcut(ctrl_key, palette, separator, shared_super, line_empty); + let key = long_mode_shortcut(key, palette, separator, &shared_modifiers, line_empty); + line_part.part = format!("{}{}", line_part.part, key.part); + line_part.len += key.len; + } + if line_part.len < max_len { + return line_part; + } + + // Full-width doesn't fit, try shortened modifiers (eg. "^C" instead of "Ctrl") + line_part = superkey(palette, separator, mode_info).1; + for key in keys { + let line_empty = line_part.len == 0; + let key = + shortened_modifier_shortcut(key, palette, separator, &shared_modifiers, line_empty); line_part.part = format!("{}{}", line_part.part, key.part); line_part.len += key.len; } @@ -219,11 +296,10 @@ fn key_indicators( } // Full-width doesn't fit, try shortened hints (just keybindings, no meanings/actions) - line_part = superkey(palette, separator, mode_info); - let shared_super = line_part.len > 0; - for ctrl_key in keys { + line_part = superkey(palette, separator, mode_info).1; + for key in keys { let line_empty = line_part.len == 0; - let key = short_mode_shortcut(ctrl_key, palette, separator, shared_super, line_empty); + let key = short_mode_shortcut(key, palette, separator, &shared_modifiers, line_empty); line_part.part = format!("{}{}", line_part.part, key.part); line_part.len += key.len; } @@ -345,7 +421,7 @@ fn swap_layout_status( /// to get back to normal mode from any input mode, but they aren't of interest when searching /// for the super key. If for any input mode the user has bound only these keys to switching back /// to `InputMode::Normal`, a '?' will be displayed as keybinding instead. -pub fn mode_switch_keys(mode_info: &ModeInfo) -> Vec { +pub fn mode_switch_keys(mode_info: &ModeInfo) -> Vec { mode_info .get_mode_keybinds() .iter() @@ -355,7 +431,19 @@ pub fn mode_switch_keys(mode_info: &ModeInfo) -> Vec { Some(vac) => { // We ignore certain "default" keybindings that switch back to normal InputMode. // These include: ' ', '\n', 'Esc' - if matches!(key, Key::Char(' ') | Key::Char('\n') | Key::Esc) { + if matches!( + key, + KeyWithModifier { + bare_key: BareKey::Char(' '), + .. + } | KeyWithModifier { + bare_key: BareKey::Enter, + .. + } | KeyWithModifier { + bare_key: BareKey::Esc, + .. + } + ) { return None; } if let actions::Action::SwitchToMode(mode) = vac { @@ -368,12 +456,12 @@ pub fn mode_switch_keys(mode_info: &ModeInfo) -> Vec { | InputMode::Resize | InputMode::Move | InputMode::Scroll - | InputMode::Session => Some(*key), + | InputMode::Session => Some(key.clone()), _ => None, }; } if let actions::Action::Quit = vac { - return Some(*key); + return Some(key.clone()); } // Not a `SwitchToMode` or `Quit` action, ignore None @@ -382,36 +470,69 @@ pub fn mode_switch_keys(mode_info: &ModeInfo) -> Vec { .collect() } -pub fn superkey(palette: ColoredElements, separator: &str, mode_info: &ModeInfo) -> LinePart { +pub fn superkey( + palette: ColoredElements, + separator: &str, + mode_info: &ModeInfo, +) -> (Vec, LinePart) { // Find a common modifier if any - let prefix_text = match get_common_modifier(mode_switch_keys(mode_info).iter().collect()) { - Some(text) => { - if mode_info.capabilities.arrow_fonts { - // Add extra space in simplified ui - format!(" {} + ", text) - } else { - format!(" {} +", text) - } - }, - _ => return LinePart::default(), + let common_modifiers = get_common_modifiers(mode_switch_keys(mode_info).iter().collect()); + if common_modifiers.is_empty() { + return (common_modifiers, LinePart::default()); + } + + let prefix_text = if mode_info.capabilities.arrow_fonts { + // Add extra space in simplified ui + format!( + " {} + ", + common_modifiers + .iter() + .map(|m| m.to_string()) + .collect::>() + .join("-") + ) + } else { + format!( + " {} +", + common_modifiers + .iter() + .map(|m| m.to_string()) + .collect::>() + .join("-") + ) }; let prefix = palette.superkey_prefix.paint(&prefix_text); let suffix_separator = palette.superkey_suffix_separator.paint(separator); - LinePart { - part: ANSIStrings(&[prefix, suffix_separator]).to_string(), - len: prefix_text.chars().count() + separator.chars().count(), - } + ( + common_modifiers, + LinePart { + part: ANSIStrings(&[prefix, suffix_separator]).to_string(), + len: prefix_text.chars().count() + separator.chars().count(), + }, + ) } -pub fn to_char(kv: Vec) -> Option { +pub fn to_char(kv: Vec) -> Option { let key = kv .iter() .filter(|key| { // These are general "keybindings" to get back to normal, they aren't interesting here. - !matches!(key, Key::Char('\n') | Key::Char(' ') | Key::Esc) + !matches!( + key, + KeyWithModifier { + bare_key: BareKey::Enter, + .. + } | KeyWithModifier { + bare_key: BareKey::Char(' '), + .. + } | KeyWithModifier { + bare_key: BareKey::Esc, + .. + } + ) }) - .collect::>() + .collect::>() .into_iter() .next(); // Maybe the user bound one of the ignored keys? @@ -593,10 +714,14 @@ mod tests { #[test] fn long_mode_shortcut_selected_with_binding() { - let key = KeyShortcut::new(KeyMode::Selected, KeyAction::Session, Some(Key::Char('0'))); + let key = KeyShortcut::new( + KeyMode::Selected, + KeyAction::Session, + Some(KeyWithModifier::new(BareKey::Char('0'))), + ); let color = colored_elements(); - let ret = long_mode_shortcut(&key, color, "+", false, false); + let ret = long_mode_shortcut(&key, color, "+", &vec![], false); let ret = unstyle(ret); assert_eq!(ret, "+ <0> SESSION +".to_string()); @@ -608,11 +733,11 @@ mod tests { let key = KeyShortcut::new( KeyMode::Unselected, KeyAction::Session, - Some(Key::Char('0')), + Some(KeyWithModifier::new(BareKey::Char('0'))), ); let color = colored_elements(); - let ret = long_mode_shortcut(&key, color, "+", false, false); + let ret = long_mode_shortcut(&key, color, "+", &vec![], false); let ret = unstyle(ret); assert_eq!(ret, "+ <0> SESSION +".to_string()); @@ -624,11 +749,11 @@ mod tests { let key = KeyShortcut::new( KeyMode::UnselectedAlternate, KeyAction::Session, - Some(Key::Char('0')), + Some(KeyWithModifier::new(BareKey::Char('0'))), ); let color = colored_elements(); - let ret = long_mode_shortcut(&key, color, "+", false, false); + let ret = long_mode_shortcut(&key, color, "+", &vec![], false); let ret = unstyle(ret); assert_eq!(ret, "+ <0> SESSION +".to_string()); @@ -640,7 +765,7 @@ mod tests { let key = KeyShortcut::new(KeyMode::Selected, KeyAction::Session, None); let color = colored_elements(); - let ret = long_mode_shortcut(&key, color, "+", false, false); + let ret = long_mode_shortcut(&key, color, "+", &vec![], false); let ret = unstyle(ret); assert_eq!(ret, "".to_string()); @@ -649,10 +774,14 @@ mod tests { #[test] // First tile doesn't print a starting separator fn long_mode_shortcut_selected_with_binding_first_tile() { - let key = KeyShortcut::new(KeyMode::Selected, KeyAction::Session, Some(Key::Char('0'))); + let key = KeyShortcut::new( + KeyMode::Selected, + KeyAction::Session, + Some(KeyWithModifier::new(BareKey::Char('0'))), + ); let color = colored_elements(); - let ret = long_mode_shortcut(&key, color, "+", false, true); + let ret = long_mode_shortcut(&key, color, "+", &vec![], true); let ret = unstyle(ret); assert_eq!(ret, " <0> SESSION +".to_string()); @@ -661,10 +790,14 @@ mod tests { #[test] // Modifier is the superkey, mustn't appear in angled brackets fn long_mode_shortcut_selected_with_ctrl_binding_shared_superkey() { - let key = KeyShortcut::new(KeyMode::Selected, KeyAction::Session, Some(Key::Ctrl('0'))); + let key = KeyShortcut::new( + KeyMode::Selected, + KeyAction::Session, + Some(KeyWithModifier::new(BareKey::Char('0')).with_ctrl_modifier()), + ); let color = colored_elements(); - let ret = long_mode_shortcut(&key, color, "+", true, false); + let ret = long_mode_shortcut(&key, color, "+", &vec![KeyModifier::Ctrl], false); let ret = unstyle(ret); assert_eq!(ret, "+ <0> SESSION +".to_string()); @@ -673,22 +806,30 @@ mod tests { #[test] // Modifier must be in the angled brackets fn long_mode_shortcut_selected_with_ctrl_binding_no_shared_superkey() { - let key = KeyShortcut::new(KeyMode::Selected, KeyAction::Session, Some(Key::Ctrl('0'))); + let key = KeyShortcut::new( + KeyMode::Selected, + KeyAction::Session, + Some(KeyWithModifier::new(BareKey::Char('0')).with_ctrl_modifier()), + ); let color = colored_elements(); - let ret = long_mode_shortcut(&key, color, "+", false, false); + let ret = long_mode_shortcut(&key, color, "+", &vec![], false); let ret = unstyle(ret); - assert_eq!(ret, "+ SESSION +".to_string()); + assert_eq!(ret, "+ SESSION +".to_string()); } #[test] // Must be displayed as usual, but it is styled to be greyed out which we don't test here fn long_mode_shortcut_disabled_with_binding() { - let key = KeyShortcut::new(KeyMode::Disabled, KeyAction::Session, Some(Key::Char('0'))); + let key = KeyShortcut::new( + KeyMode::Disabled, + KeyAction::Session, + Some(KeyWithModifier::new(BareKey::Char('0'))), + ); let color = colored_elements(); - let ret = long_mode_shortcut(&key, color, "+", false, false); + let ret = long_mode_shortcut(&key, color, "+", &vec![], false); let ret = unstyle(ret); assert_eq!(ret, "+ <0> SESSION +".to_string()); @@ -700,7 +841,7 @@ mod tests { let key = KeyShortcut::new(KeyMode::Disabled, KeyAction::Session, None); let color = colored_elements(); - let ret = long_mode_shortcut(&key, color, "+", false, false); + let ret = long_mode_shortcut(&key, color, "+", &vec![], false); let ret = unstyle(ret); assert_eq!(ret, "+ <> SESSION +".to_string()); @@ -711,10 +852,14 @@ mod tests { // Note that when "shared_super" is true, the tile **cannot** be the first on the line, so we // ignore **first** here. fn long_mode_shortcut_selected_with_ctrl_binding_and_shared_super_and_first_tile() { - let key = KeyShortcut::new(KeyMode::Selected, KeyAction::Session, Some(Key::Ctrl('0'))); + let key = KeyShortcut::new( + KeyMode::Selected, + KeyAction::Session, + Some(KeyWithModifier::new(BareKey::Char('0')).with_ctrl_modifier()), + ); let color = colored_elements(); - let ret = long_mode_shortcut(&key, color, "+", true, true); + let ret = long_mode_shortcut(&key, color, "+", &vec![KeyModifier::Ctrl], true); let ret = unstyle(ret); assert_eq!(ret, "+ <0> SESSION +".to_string()); @@ -722,10 +867,14 @@ mod tests { #[test] fn short_mode_shortcut_selected_with_binding() { - let key = KeyShortcut::new(KeyMode::Selected, KeyAction::Session, Some(Key::Char('0'))); + let key = KeyShortcut::new( + KeyMode::Selected, + KeyAction::Session, + Some(KeyWithModifier::new(BareKey::Char('0'))), + ); let color = colored_elements(); - let ret = short_mode_shortcut(&key, color, "+", false, false); + let ret = short_mode_shortcut(&key, color, "+", &vec![], false); let ret = unstyle(ret); assert_eq!(ret, "+ 0 +".to_string()); @@ -733,21 +882,29 @@ mod tests { #[test] fn short_mode_shortcut_selected_with_ctrl_binding_no_shared_super() { - let key = KeyShortcut::new(KeyMode::Selected, KeyAction::Session, Some(Key::Ctrl('0'))); + let key = KeyShortcut::new( + KeyMode::Selected, + KeyAction::Session, + Some(KeyWithModifier::new(BareKey::Char('0')).with_ctrl_modifier()), + ); let color = colored_elements(); - let ret = short_mode_shortcut(&key, color, "+", false, false); + let ret = short_mode_shortcut(&key, color, "+", &vec![], false); let ret = unstyle(ret); - assert_eq!(ret, "+ Ctrl+0 +".to_string()); + assert_eq!(ret, "+ Ctrl 0 +".to_string()); } #[test] fn short_mode_shortcut_selected_with_ctrl_binding_shared_super() { - let key = KeyShortcut::new(KeyMode::Selected, KeyAction::Session, Some(Key::Ctrl('0'))); + let key = KeyShortcut::new( + KeyMode::Selected, + KeyAction::Session, + Some(KeyWithModifier::new(BareKey::Char('0')).with_ctrl_modifier()), + ); let color = colored_elements(); - let ret = short_mode_shortcut(&key, color, "+", true, false); + let ret = short_mode_shortcut(&key, color, "+", &vec![KeyModifier::Ctrl], false); let ret = unstyle(ret); assert_eq!(ret, "+ 0 +".to_string()); @@ -755,10 +912,14 @@ mod tests { #[test] fn short_mode_shortcut_selected_with_binding_first_tile() { - let key = KeyShortcut::new(KeyMode::Selected, KeyAction::Session, Some(Key::Char('0'))); + let key = KeyShortcut::new( + KeyMode::Selected, + KeyAction::Session, + Some(KeyWithModifier::new(BareKey::Char('0'))), + ); let color = colored_elements(); - let ret = short_mode_shortcut(&key, color, "+", false, true); + let ret = short_mode_shortcut(&key, color, "+", &vec![], true); let ret = unstyle(ret); assert_eq!(ret, " 0 +".to_string()); @@ -769,11 +930,11 @@ mod tests { let key = KeyShortcut::new( KeyMode::Unselected, KeyAction::Session, - Some(Key::Char('0')), + Some(KeyWithModifier::new(BareKey::Char('0'))), ); let color = colored_elements(); - let ret = short_mode_shortcut(&key, color, "+", false, false); + let ret = short_mode_shortcut(&key, color, "+", &vec![], false); let ret = unstyle(ret); assert_eq!(ret, "+ 0 +".to_string()); @@ -784,11 +945,11 @@ mod tests { let key = KeyShortcut::new( KeyMode::UnselectedAlternate, KeyAction::Session, - Some(Key::Char('0')), + Some(KeyWithModifier::new(BareKey::Char('0'))), ); let color = colored_elements(); - let ret = short_mode_shortcut(&key, color, "+", false, false); + let ret = short_mode_shortcut(&key, color, "+", &vec![], false); let ret = unstyle(ret); assert_eq!(ret, "+ 0 +".to_string()); @@ -796,10 +957,14 @@ mod tests { #[test] fn short_mode_shortcut_disabled_with_binding() { - let key = KeyShortcut::new(KeyMode::Selected, KeyAction::Session, Some(Key::Char('0'))); + let key = KeyShortcut::new( + KeyMode::Selected, + KeyAction::Session, + Some(KeyWithModifier::new(BareKey::Char('0'))), + ); let color = colored_elements(); - let ret = short_mode_shortcut(&key, color, "+", false, false); + let ret = short_mode_shortcut(&key, color, "+", &vec![], false); let ret = unstyle(ret); assert_eq!(ret, "+ 0 +".to_string()); @@ -810,7 +975,7 @@ mod tests { let key = KeyShortcut::new(KeyMode::Selected, KeyAction::Session, None); let color = colored_elements(); - let ret = short_mode_shortcut(&key, color, "+", false, false); + let ret = short_mode_shortcut(&key, color, "+", &vec![], false); let ret = unstyle(ret); assert_eq!(ret, "".to_string()); @@ -821,7 +986,7 @@ mod tests { let key = KeyShortcut::new(KeyMode::Unselected, KeyAction::Session, None); let color = colored_elements(); - let ret = short_mode_shortcut(&key, color, "+", false, false); + let ret = short_mode_shortcut(&key, color, "+", &vec![], false); let ret = unstyle(ret); assert_eq!(ret, "".to_string()); @@ -832,7 +997,7 @@ mod tests { let key = KeyShortcut::new(KeyMode::UnselectedAlternate, KeyAction::Session, None); let color = colored_elements(); - let ret = short_mode_shortcut(&key, color, "+", false, false); + let ret = short_mode_shortcut(&key, color, "+", &vec![], false); let ret = unstyle(ret); assert_eq!(ret, "".to_string()); @@ -843,7 +1008,7 @@ mod tests { let key = KeyShortcut::new(KeyMode::Selected, KeyAction::Session, None); let color = colored_elements(); - let ret = short_mode_shortcut(&key, color, "+", false, false); + let ret = short_mode_shortcut(&key, color, "+", &vec![], false); let ret = unstyle(ret); assert_eq!(ret, "".to_string()); @@ -857,9 +1022,9 @@ mod tests { mode: InputMode::Normal, keybinds : vec![ (InputMode::Normal, vec![ - (Key::Ctrl('a'), vec![Action::SwitchToMode(InputMode::Pane)]), - (Key::Ctrl('b'), vec![Action::SwitchToMode(InputMode::Resize)]), - (Key::Ctrl('c'), vec![Action::SwitchToMode(InputMode::Move)]), + (KeyWithModifier::new(BareKey::Char('a')).with_ctrl_modifier(), vec![Action::SwitchToMode(InputMode::Pane)]), + (KeyWithModifier::new(BareKey::Char('b')).with_ctrl_modifier(), vec![Action::SwitchToMode(InputMode::Resize)]), + (KeyWithModifier::new(BareKey::Char('c')).with_ctrl_modifier(), vec![Action::SwitchToMode(InputMode::Move)]), ]), ], ..ModeInfo::default() @@ -881,9 +1046,9 @@ mod tests { mode: InputMode::Normal, keybinds : vec![ (InputMode::Normal, vec![ - (Key::Ctrl('a'), vec![Action::SwitchToMode(InputMode::Pane)]), - (Key::Ctrl('b'), vec![Action::SwitchToMode(InputMode::Resize)]), - (Key::Char('c'), vec![Action::SwitchToMode(InputMode::Move)]), + (KeyWithModifier::new(BareKey::Char('a')).with_ctrl_modifier(), vec![Action::SwitchToMode(InputMode::Pane)]), + (KeyWithModifier::new(BareKey::Char('b')).with_ctrl_modifier(), vec![Action::SwitchToMode(InputMode::Resize)]), + (KeyWithModifier::new(BareKey::Char('c')), vec![Action::SwitchToMode(InputMode::Move)]), ]), ], ..ModeInfo::default() @@ -894,7 +1059,7 @@ mod tests { assert_eq!( ret, - " PANE >> RESIZE >> MOVE >".to_string() + " PANE >> RESIZE >> MOVE >".to_string() ); } @@ -905,11 +1070,11 @@ mod tests { mode: InputMode::Normal, keybinds : vec![ (InputMode::Normal, vec![ - (Key::Ctrl('a'), vec![Action::SwitchToMode(InputMode::Locked)]), - (Key::Backspace, vec![Action::SwitchToMode(InputMode::Pane)]), - (Key::Char('\n'), vec![Action::SwitchToMode(InputMode::Tab)]), - (Key::Char('\t'), vec![Action::SwitchToMode(InputMode::Resize)]), - (Key::Left, vec![Action::SwitchToMode(InputMode::Move)]), + (KeyWithModifier::new(BareKey::Char('a')).with_ctrl_modifier(), vec![Action::SwitchToMode(InputMode::Locked)]), + (KeyWithModifier::new(BareKey::Backspace), vec![Action::SwitchToMode(InputMode::Pane)]), + (KeyWithModifier::new(BareKey::Enter), vec![Action::SwitchToMode(InputMode::Tab)]), + (KeyWithModifier::new(BareKey::Tab), vec![Action::SwitchToMode(InputMode::Resize)]), + (KeyWithModifier::new(BareKey::Left), vec![Action::SwitchToMode(InputMode::Move)]), ]), ], ..ModeInfo::default() @@ -920,7 +1085,7 @@ mod tests { assert_eq!( ret, - " LOCK >> PANE >> TAB >> RESIZE >> <←> MOVE >" + " LOCK >> PANE >> TAB >> RESIZE >> <←> MOVE >" .to_string() ); } @@ -932,11 +1097,11 @@ mod tests { mode: InputMode::Normal, keybinds : vec![ (InputMode::Normal, vec![ - (Key::Ctrl('a'), vec![Action::SwitchToMode(InputMode::Locked)]), - (Key::Ctrl('b'), vec![Action::SwitchToMode(InputMode::Pane)]), - (Key::Ctrl('c'), vec![Action::SwitchToMode(InputMode::Tab)]), - (Key::Ctrl('d'), vec![Action::SwitchToMode(InputMode::Resize)]), - (Key::Ctrl('e'), vec![Action::SwitchToMode(InputMode::Move)]), + (KeyWithModifier::new(BareKey::Char('a')).with_ctrl_modifier(), vec![Action::SwitchToMode(InputMode::Locked)]), + (KeyWithModifier::new(BareKey::Char('b')).with_ctrl_modifier(), vec![Action::SwitchToMode(InputMode::Pane)]), + (KeyWithModifier::new(BareKey::Char('c')).with_ctrl_modifier(), vec![Action::SwitchToMode(InputMode::Tab)]), + (KeyWithModifier::new(BareKey::Char('d')).with_ctrl_modifier(), vec![Action::SwitchToMode(InputMode::Resize)]), + (KeyWithModifier::new(BareKey::Char('e')).with_ctrl_modifier(), vec![Action::SwitchToMode(InputMode::Move)]), ]), ], ..ModeInfo::default() @@ -955,9 +1120,9 @@ mod tests { mode: InputMode::Normal, keybinds : vec![ (InputMode::Normal, vec![ - (Key::Ctrl('a'), vec![Action::SwitchToMode(InputMode::Pane)]), - (Key::Ctrl('b'), vec![Action::SwitchToMode(InputMode::Resize)]), - (Key::Ctrl('c'), vec![Action::SwitchToMode(InputMode::Move)]), + (KeyWithModifier::new(BareKey::Char('a')).with_ctrl_modifier(), vec![Action::SwitchToMode(InputMode::Pane)]), + (KeyWithModifier::new(BareKey::Char('b')).with_ctrl_modifier(), vec![Action::SwitchToMode(InputMode::Resize)]), + (KeyWithModifier::new(BareKey::Char('c')).with_ctrl_modifier(), vec![Action::SwitchToMode(InputMode::Move)]), ]), ], ..ModeInfo::default() diff --git a/default-plugins/status-bar/src/main.rs b/default-plugins/status-bar/src/main.rs index 1d85c7f6..6fed529f 100644 --- a/default-plugins/status-bar/src/main.rs +++ b/default-plugins/status-bar/src/main.rs @@ -324,30 +324,18 @@ impl State { } } -/// Get a common modifier key from a key vector. -/// -/// Iterates over all keys and returns any found common modifier key. Possible modifiers that will -/// be detected are "Ctrl" and "Alt". -pub fn get_common_modifier(keyvec: Vec<&Key>) -> Option { - let mut modifier = ""; - let mut new_modifier; - for key in keyvec.iter() { - match key { - Key::Ctrl(_) | Key::CtrlF(_) => new_modifier = "Ctrl", - Key::Alt(_) | Key::AltF(_) => new_modifier = "Alt", - _ => return None, - } - if modifier.is_empty() { - modifier = new_modifier; - } else if modifier != new_modifier { - // Prefix changed! - return None; - } +pub fn get_common_modifiers(mut keyvec: Vec<&KeyWithModifier>) -> Vec { + if keyvec.is_empty() { + return vec![]; } - match modifier.is_empty() { - true => None, - false => Some(modifier.to_string()), + let mut common_modifiers = keyvec.pop().unwrap().key_modifiers.clone(); + for key in keyvec { + common_modifiers = common_modifiers + .intersection(&key.key_modifiers) + .cloned() + .collect(); } + common_modifiers.into_iter().collect() } /// Get key from action pattern(s). @@ -356,7 +344,10 @@ pub fn get_common_modifier(keyvec: Vec<&Key>) -> Option { /// all keybindings for the current mode and one or more `p` patterns which match a sequence of /// actions to search for. If within the keymap a sequence of actions matching `p` is found, all /// keys that trigger the action pattern are returned as vector of `Vec`. -pub fn action_key(keymap: &[(Key, Vec)], action: &[Action]) -> Vec { +pub fn action_key( + keymap: &[(KeyWithModifier, Vec)], + action: &[Action], +) -> Vec { keymap .iter() .filter_map(|(key, acvec)| { @@ -367,18 +358,21 @@ pub fn action_key(keymap: &[(Key, Vec)], action: &[Action]) -> Vec .count(); if matching == acvec.len() && matching == action.len() { - Some(*key) + Some(key.clone()) } else { None } }) - .collect::>() + .collect::>() } /// Get multiple keys for multiple actions. /// /// An extension of [`action_key`] that iterates over all action tuples and collects the results. -pub fn action_key_group(keymap: &[(Key, Vec)], actions: &[&[Action]]) -> Vec { +pub fn action_key_group( + keymap: &[(KeyWithModifier, Vec)], + actions: &[&[Action]], +) -> Vec { let mut ret = vec![]; for action in actions { ret.extend(action_key(keymap, action)); @@ -406,11 +400,10 @@ pub fn action_key_group(keymap: &[(Key, Vec)], actions: &[&[Action]]) -> /// The returned Vector of [`ANSIString`] is suitable for transformation into an [`ANSIStrings`] /// type. pub fn style_key_with_modifier( - keyvec: &[Key], + keyvec: &[KeyWithModifier], palette: &Palette, background: Option, ) -> Vec> { - // Nothing to do, quit... if keyvec.is_empty() { return vec![]; } @@ -423,12 +416,18 @@ pub fn style_key_with_modifier( let orange_color = palette_match!(palette.orange); let mut ret = vec![]; - // Prints modifier key - let modifier_str = match get_common_modifier(keyvec.iter().collect()) { - Some(modifier) => modifier, - None => "".to_string(), - }; - let no_modifier = modifier_str.is_empty(); + let common_modifiers = get_common_modifiers(keyvec.iter().collect()); + + // let modifier_str = match get_common_modifier(keyvec.iter().collect()) { + // Some(modifier) => modifier, + // None => "".to_string(), + // }; + let no_common_modifier = common_modifiers.is_empty(); + let modifier_str = common_modifiers + .iter() + .map(|m| m.to_string()) + .collect::>() + .join("-"); let painted_modifier = if modifier_str.is_empty() { Style::new().paint("") } else { @@ -446,7 +445,7 @@ pub fn style_key_with_modifier( ret.push(painted_modifier); // Prints key group start - let group_start_str = if no_modifier { "<" } else { " + <" }; + let group_start_str = if no_common_modifier { "<" } else { " + <" }; if let Some(background) = background { let background = palette_match!(background); ret.push( @@ -463,15 +462,20 @@ pub fn style_key_with_modifier( let key = keyvec .iter() .map(|key| { - if no_modifier { + if no_common_modifier { format!("{}", key) } else { - match key { - Key::Ctrl(c) => format!("{}", Key::Char(*c)), - Key::CtrlF(n) => format!("{}", Key::F(*n)), - Key::Alt(c) => format!("{}", c), - Key::AltF(n) => format!("{}", Key::F(*n)), - _ => format!("{}", key), + let key_modifier_for_key = key + .key_modifiers + .iter() + .filter(|m| !common_modifiers.contains(m)) + .map(|m| m.to_string()) + .collect::>() + .join(" "); + if key_modifier_for_key.is_empty() { + format!("{}", key.bare_key) + } else { + format!("{} {}", key_modifier_for_key, key.bare_key) } } }) @@ -538,20 +542,24 @@ pub mod tests { use super::*; use ansi_term::unstyle; use ansi_term::ANSIStrings; - use zellij_tile::prelude::CharOrArrow; - use zellij_tile::prelude::Direction; - fn big_keymap() -> Vec<(Key, Vec)> { + fn big_keymap() -> Vec<(KeyWithModifier, Vec)> { vec![ - (Key::Char('a'), vec![Action::Quit]), - (Key::Ctrl('b'), vec![Action::ScrollUp]), - (Key::Ctrl('d'), vec![Action::ScrollDown]), + (KeyWithModifier::new(BareKey::Char('a')), vec![Action::Quit]), ( - Key::Alt(CharOrArrow::Char('c')), + KeyWithModifier::new(BareKey::Char('b')).with_ctrl_modifier(), + vec![Action::ScrollUp], + ), + ( + KeyWithModifier::new(BareKey::Char('d')).with_ctrl_modifier(), + vec![Action::ScrollDown], + ), + ( + KeyWithModifier::new(BareKey::Char('c')).with_alt_modifier(), vec![Action::ScrollDown, Action::SwitchToMode(InputMode::Normal)], ), ( - Key::Char('1'), + KeyWithModifier::new(BareKey::Char('1')), vec![TO_NORMAL, Action::SwitchToMode(InputMode::Locked)], ), ] @@ -559,94 +567,65 @@ pub mod tests { #[test] fn common_modifier_with_ctrl_keys() { - let keyvec = vec![Key::Ctrl('a'), Key::Ctrl('b'), Key::Ctrl('c')]; - let ret = get_common_modifier(keyvec.iter().collect()); - assert_eq!(ret, Some("Ctrl".to_string())); + let keyvec = vec![ + KeyWithModifier::new(BareKey::Char('a')).with_ctrl_modifier(), + KeyWithModifier::new(BareKey::Char('b')).with_ctrl_modifier(), + KeyWithModifier::new(BareKey::Char('c')).with_ctrl_modifier(), + ]; + let ret = get_common_modifiers(keyvec.iter().collect()); + assert_eq!(ret, vec![KeyModifier::Ctrl]); } #[test] fn common_modifier_with_alt_keys_chars() { let keyvec = vec![ - Key::Alt(CharOrArrow::Char('1')), - Key::Alt(CharOrArrow::Char('t')), - Key::Alt(CharOrArrow::Char('z')), + KeyWithModifier::new(BareKey::Char('1')).with_alt_modifier(), + KeyWithModifier::new(BareKey::Char('t')).with_alt_modifier(), + KeyWithModifier::new(BareKey::Char('z')).with_alt_modifier(), ]; - let ret = get_common_modifier(keyvec.iter().collect()); - assert_eq!(ret, Some("Alt".to_string())); - } - - #[test] - fn common_modifier_with_alt_keys_arrows() { - let keyvec = vec![ - Key::Alt(CharOrArrow::Direction(Direction::Left)), - Key::Alt(CharOrArrow::Direction(Direction::Right)), - ]; - let ret = get_common_modifier(keyvec.iter().collect()); - assert_eq!(ret, Some("Alt".to_string())); - } - - #[test] - fn common_modifier_with_alt_keys_arrows_and_chars() { - let keyvec = vec![ - Key::Alt(CharOrArrow::Direction(Direction::Left)), - Key::Alt(CharOrArrow::Direction(Direction::Right)), - Key::Alt(CharOrArrow::Char('t')), - Key::Alt(CharOrArrow::Char('z')), - ]; - let ret = get_common_modifier(keyvec.iter().collect()); - assert_eq!(ret, Some("Alt".to_string())); + let ret = get_common_modifiers(keyvec.iter().collect()); + assert_eq!(ret, vec![KeyModifier::Alt]); } #[test] fn common_modifier_with_mixed_alt_ctrl_keys() { let keyvec = vec![ - Key::Alt(CharOrArrow::Direction(Direction::Left)), - Key::Alt(CharOrArrow::Char('z')), - Key::Ctrl('a'), - Key::Ctrl('1'), + KeyWithModifier::new(BareKey::Char('1')).with_ctrl_modifier(), + KeyWithModifier::new(BareKey::Char('t')).with_alt_modifier(), + KeyWithModifier::new(BareKey::Char('z')).with_alt_modifier(), ]; - let ret = get_common_modifier(keyvec.iter().collect()); - assert_eq!(ret, None); + let ret = get_common_modifiers(keyvec.iter().collect()); + assert_eq!(ret, vec![]); // no common modifiers } #[test] fn common_modifier_with_any_keys() { - let keyvec = vec![Key::Backspace, Key::Char('f'), Key::Down]; - let ret = get_common_modifier(keyvec.iter().collect()); - assert_eq!(ret, None); - } - - #[test] - fn common_modifier_with_ctrl_and_normal_keys() { - let keyvec = vec![Key::Ctrl('a'), Key::Char('f'), Key::Down]; - let ret = get_common_modifier(keyvec.iter().collect()); - assert_eq!(ret, None); - } - - #[test] - fn common_modifier_with_alt_and_normal_keys() { - let keyvec = vec![Key::Alt(CharOrArrow::Char('a')), Key::Char('f'), Key::Down]; - let ret = get_common_modifier(keyvec.iter().collect()); - assert_eq!(ret, None); + let keyvec = vec![ + KeyWithModifier::new(BareKey::Char('1')), + KeyWithModifier::new(BareKey::Char('t')).with_alt_modifier(), + KeyWithModifier::new(BareKey::Char('z')).with_alt_modifier(), + ]; + let ret = get_common_modifiers(keyvec.iter().collect()); + assert_eq!(ret, vec![]); // no common modifiers } #[test] fn action_key_simple_pattern_match_exact() { - let keymap = &[(Key::Char('f'), vec![Action::Quit])]; + let keymap = &[(KeyWithModifier::new(BareKey::Char('f')), vec![Action::Quit])]; let ret = action_key(keymap, &[Action::Quit]); - assert_eq!(ret, vec![Key::Char('f')]); + assert_eq!(ret, vec![KeyWithModifier::new(BareKey::Char('f'))]); } #[test] fn action_key_simple_pattern_match_pattern_too_long() { - let keymap = &[(Key::Char('f'), vec![Action::Quit])]; + let keymap = &[(KeyWithModifier::new(BareKey::Char('f')), vec![Action::Quit])]; let ret = action_key(keymap, &[Action::Quit, Action::ScrollUp]); assert_eq!(ret, Vec::new()); } #[test] fn action_key_simple_pattern_match_pattern_empty() { - let keymap = &[(Key::Char('f'), vec![Action::Quit])]; + let keymap = &[(KeyWithModifier::new(BareKey::Char('f')), vec![Action::Quit])]; let ret = action_key(keymap, &[]); assert_eq!(ret, Vec::new()); } @@ -655,7 +634,10 @@ pub mod tests { fn action_key_long_pattern_match_exact() { let keymap = big_keymap(); let ret = action_key(&keymap, &[Action::ScrollDown, TO_NORMAL]); - assert_eq!(ret, vec![Key::Alt(CharOrArrow::Char('c'))]); + assert_eq!( + ret, + vec![KeyWithModifier::new(BareKey::Char('c')).with_alt_modifier()] + ); } #[test] @@ -669,7 +651,7 @@ pub mod tests { fn action_key_group_single_pattern() { let keymap = big_keymap(); let ret = action_key_group(&keymap, &[&[Action::Quit]]); - assert_eq!(ret, vec![Key::Char('a')]); + assert_eq!(ret, vec![KeyWithModifier::new(BareKey::Char('a'))]); } #[test] @@ -677,7 +659,13 @@ pub mod tests { let keymap = big_keymap(); let ret = action_key_group(&keymap, &[&[Action::ScrollDown], &[Action::ScrollUp]]); // Mind the order! - assert_eq!(ret, vec![Key::Ctrl('d'), Key::Ctrl('b')]); + assert_eq!( + ret, + vec![ + KeyWithModifier::new(BareKey::Char('d')).with_ctrl_modifier(), + KeyWithModifier::new(BareKey::Char('b')).with_ctrl_modifier() + ] + ); } fn get_palette() -> Palette { @@ -686,7 +674,11 @@ pub mod tests { #[test] fn style_key_with_modifier_only_chars() { - let keyvec = vec![Key::Char('a'), Key::Char('b'), Key::Char('c')]; + let keyvec = vec![ + KeyWithModifier::new(BareKey::Char('a')), + KeyWithModifier::new(BareKey::Char('b')), + KeyWithModifier::new(BareKey::Char('c')), + ]; let palette = get_palette(); let ret = style_key_with_modifier(&keyvec, &palette, None); @@ -698,10 +690,10 @@ pub mod tests { #[test] fn style_key_with_modifier_special_group_hjkl() { let keyvec = vec![ - Key::Char('h'), - Key::Char('j'), - Key::Char('k'), - Key::Char('l'), + KeyWithModifier::new(BareKey::Char('h')), + KeyWithModifier::new(BareKey::Char('j')), + KeyWithModifier::new(BareKey::Char('k')), + KeyWithModifier::new(BareKey::Char('l')), ]; let palette = get_palette(); @@ -711,30 +703,13 @@ pub mod tests { assert_eq!(ret, "".to_string()) } - #[test] - fn style_key_with_modifier_special_group_hjkl_broken() { - // Sorted the wrong way - let keyvec = vec![ - Key::Char('h'), - Key::Char('k'), - Key::Char('j'), - Key::Char('l'), - ]; - let palette = get_palette(); - - let ret = style_key_with_modifier(&keyvec, &palette, None); - let ret = unstyle(&ANSIStrings(&ret)); - - assert_eq!(ret, "".to_string()) - } - #[test] fn style_key_with_modifier_special_group_all_arrows() { let keyvec = vec![ - Key::Char('←'), - Key::Char('↓'), - Key::Char('↑'), - Key::Char('→'), + KeyWithModifier::new(BareKey::Left), + KeyWithModifier::new(BareKey::Down), + KeyWithModifier::new(BareKey::Up), + KeyWithModifier::new(BareKey::Right), ]; let palette = get_palette(); @@ -746,7 +721,10 @@ pub mod tests { #[test] fn style_key_with_modifier_special_group_left_right_arrows() { - let keyvec = vec![Key::Char('←'), Key::Char('→')]; + let keyvec = vec![ + KeyWithModifier::new(BareKey::Left), + KeyWithModifier::new(BareKey::Right), + ]; let palette = get_palette(); let ret = style_key_with_modifier(&keyvec, &palette, None); @@ -757,7 +735,10 @@ pub mod tests { #[test] fn style_key_with_modifier_special_group_down_up_arrows() { - let keyvec = vec![Key::Char('↓'), Key::Char('↑')]; + let keyvec = vec![ + KeyWithModifier::new(BareKey::Down), + KeyWithModifier::new(BareKey::Up), + ]; let palette = get_palette(); let ret = style_key_with_modifier(&keyvec, &palette, None); @@ -769,10 +750,10 @@ pub mod tests { #[test] fn style_key_with_modifier_common_ctrl_modifier_chars() { let keyvec = vec![ - Key::Ctrl('a'), - Key::Ctrl('b'), - Key::Ctrl('c'), - Key::Ctrl('d'), + KeyWithModifier::new(BareKey::Char('a')).with_ctrl_modifier(), + KeyWithModifier::new(BareKey::Char('b')).with_ctrl_modifier(), + KeyWithModifier::new(BareKey::Char('c')).with_ctrl_modifier(), + KeyWithModifier::new(BareKey::Char('d')).with_ctrl_modifier(), ]; let palette = get_palette(); @@ -785,10 +766,10 @@ pub mod tests { #[test] fn style_key_with_modifier_common_alt_modifier_chars() { let keyvec = vec![ - Key::Alt(CharOrArrow::Char('a')), - Key::Alt(CharOrArrow::Char('b')), - Key::Alt(CharOrArrow::Char('c')), - Key::Alt(CharOrArrow::Char('d')), + KeyWithModifier::new(BareKey::Char('a')).with_alt_modifier(), + KeyWithModifier::new(BareKey::Char('b')).with_alt_modifier(), + KeyWithModifier::new(BareKey::Char('c')).with_alt_modifier(), + KeyWithModifier::new(BareKey::Char('d')).with_alt_modifier(), ]; let palette = get_palette(); @@ -801,10 +782,10 @@ pub mod tests { #[test] fn style_key_with_modifier_common_alt_modifier_with_special_group_all_arrows() { let keyvec = vec![ - Key::Alt(CharOrArrow::Direction(Direction::Left)), - Key::Alt(CharOrArrow::Direction(Direction::Down)), - Key::Alt(CharOrArrow::Direction(Direction::Up)), - Key::Alt(CharOrArrow::Direction(Direction::Right)), + KeyWithModifier::new(BareKey::Left).with_alt_modifier(), + KeyWithModifier::new(BareKey::Down).with_alt_modifier(), + KeyWithModifier::new(BareKey::Up).with_alt_modifier(), + KeyWithModifier::new(BareKey::Right).with_alt_modifier(), ]; let palette = get_palette(); @@ -817,32 +798,32 @@ pub mod tests { #[test] fn style_key_with_modifier_ctrl_alt_char_mixed() { let keyvec = vec![ - Key::Alt(CharOrArrow::Char('a')), - Key::Ctrl('b'), - Key::Char('c'), + KeyWithModifier::new(BareKey::Char('a')).with_alt_modifier(), + KeyWithModifier::new(BareKey::Char('b')).with_ctrl_modifier(), + KeyWithModifier::new(BareKey::Char('c')), ]; let palette = get_palette(); let ret = style_key_with_modifier(&keyvec, &palette, None); let ret = unstyle(&ANSIStrings(&ret)); - assert_eq!(ret, "".to_string()) + assert_eq!(ret, "".to_string()) } #[test] fn style_key_with_modifier_unprintables() { let keyvec = vec![ - Key::Backspace, - Key::Char('\n'), - Key::Char(' '), - Key::Char('\t'), - Key::PageDown, - Key::Delete, - Key::Home, - Key::End, - Key::Insert, - Key::BackTab, - Key::Esc, + KeyWithModifier::new(BareKey::Backspace), + KeyWithModifier::new(BareKey::Enter), + KeyWithModifier::new(BareKey::Char(' ')), + KeyWithModifier::new(BareKey::Tab), + KeyWithModifier::new(BareKey::PageDown), + KeyWithModifier::new(BareKey::Delete), + KeyWithModifier::new(BareKey::Home), + KeyWithModifier::new(BareKey::End), + KeyWithModifier::new(BareKey::Insert), + KeyWithModifier::new(BareKey::Tab), + KeyWithModifier::new(BareKey::Esc), ]; let palette = get_palette(); @@ -857,7 +838,11 @@ pub mod tests { #[test] fn style_key_with_modifier_unprintables_with_common_ctrl_modifier() { - let keyvec = vec![Key::Ctrl('\n'), Key::Ctrl(' '), Key::Ctrl('\t')]; + let keyvec = vec![ + KeyWithModifier::new(BareKey::Enter).with_ctrl_modifier(), + KeyWithModifier::new(BareKey::Char(' ')).with_ctrl_modifier(), + KeyWithModifier::new(BareKey::Tab).with_ctrl_modifier(), + ]; let palette = get_palette(); let ret = style_key_with_modifier(&keyvec, &palette, None); @@ -869,9 +854,9 @@ pub mod tests { #[test] fn style_key_with_modifier_unprintables_with_common_alt_modifier() { let keyvec = vec![ - Key::Alt(CharOrArrow::Char('\n')), - Key::Alt(CharOrArrow::Char(' ')), - Key::Alt(CharOrArrow::Char('\t')), + KeyWithModifier::new(BareKey::Enter).with_alt_modifier(), + KeyWithModifier::new(BareKey::Char(' ')).with_alt_modifier(), + KeyWithModifier::new(BareKey::Tab).with_alt_modifier(), ]; let palette = get_palette(); diff --git a/default-plugins/status-bar/src/second_line.rs b/default-plugins/status-bar/src/second_line.rs index 53fbc6ec..63730aa4 100644 --- a/default-plugins/status-bar/src/second_line.rs +++ b/default-plugins/status-bar/src/second_line.rs @@ -15,7 +15,7 @@ use crate::{ fn full_length_shortcut( is_first_shortcut: bool, - key: Vec, + key: Vec, action: &str, palette: Palette, ) -> LinePart { @@ -59,7 +59,12 @@ fn locked_interface_indication(palette: Palette) -> LinePart { } } -fn add_shortcut(help: &ModeInfo, linepart: &LinePart, text: &str, keys: Vec) -> LinePart { +fn add_shortcut( + help: &ModeInfo, + linepart: &LinePart, + text: &str, + keys: Vec, +) -> LinePart { let shortcut = if linepart.len == 0 { full_length_shortcut(true, keys, text, help.style.colors) } else { @@ -106,7 +111,7 @@ fn full_shortcut_list_nonstandard_mode(help: &ModeInfo) -> LinePart { // three times the length and all the keybinding vectors we generate become virtually unreadable // for humans. #[rustfmt::skip] -fn get_keys_and_hints(mi: &ModeInfo) -> Vec<(String, String, Vec)> { +fn get_keys_and_hints(mi: &ModeInfo) -> Vec<(String, String, Vec)> { use Action as A; use InputMode as IM; use Direction as Dir; @@ -119,8 +124,8 @@ fn get_keys_and_hints(mi: &ModeInfo) -> Vec<(String, String, Vec)> { // Find a keybinding to get back to "Normal" input mode. In this case we prefer '\n' over other // choices. Do it here before we dedupe the keymap below! let to_normal_keys = action_key(&old_keymap, &[TO_NORMAL]); - let to_normal_key = if to_normal_keys.contains(&Key::Char('\n')) { - vec![Key::Char('\n')] + let to_normal_key = if to_normal_keys.contains(&KeyWithModifier::new(BareKey::Enter)) { + vec![KeyWithModifier::new(BareKey::Enter)] } else { // Yield `vec![key]` if `to_normal_keys` has at least one key, or an empty vec otherwise. to_normal_keys.into_iter().take(1).collect() @@ -164,11 +169,11 @@ fn get_keys_and_hints(mi: &ModeInfo) -> Vec<(String, String, Vec)> { // RightArrow. // FIXME: So for lack of a better idea we just check this case manually here. let old_keymap = mi.get_mode_keybinds(); - let focus_keys_full: Vec = action_key_group(&old_keymap, + let focus_keys_full: Vec = action_key_group(&old_keymap, &[&[A::GoToPreviousTab], &[A::GoToNextTab]]); - let focus_keys = if focus_keys_full.contains(&Key::Left) - && focus_keys_full.contains(&Key::Right) { - vec![Key::Left, Key::Right] + let focus_keys = if focus_keys_full.contains(&KeyWithModifier::new(BareKey::Left)) + && focus_keys_full.contains(&KeyWithModifier::new(BareKey::Right)) { + vec![KeyWithModifier::new(BareKey::Left), KeyWithModifier::new(BareKey::Right)] } else { action_key_group(&km, &[&[A::GoToPreviousTab], &[A::GoToNextTab]]) }; @@ -429,7 +434,7 @@ pub fn floating_panes_are_visible(mode_info: &ModeInfo) -> LinePart { "{}", action_key(km, &[Action::SwitchToMode(InputMode::Pane)]) .first() - .unwrap_or(&Key::Char('?')) + .unwrap_or(&KeyWithModifier::new(BareKey::Char('?'))) ); let plus = ", "; let p_left_separator = "<"; @@ -440,7 +445,7 @@ pub fn floating_panes_are_visible(mode_info: &ModeInfo) -> LinePart { &[Action::ToggleFloatingPanes, TO_NORMAL] ) .first() - .unwrap_or(&Key::Char('?')) + .unwrap_or(&KeyWithModifier::new(BareKey::Char('?'))) ); let p_right_separator = "> "; let to_hide = "to hide."; @@ -560,7 +565,7 @@ mod tests { #[test] fn full_length_shortcut_with_key() { - let keyvec = vec![Key::Char('a')]; + let keyvec = vec![KeyWithModifier::new(BareKey::Char('a'))]; let palette = get_palette(); let ret = full_length_shortcut(false, keyvec, "Foobar", palette); @@ -571,7 +576,7 @@ mod tests { #[test] fn full_length_shortcut_with_key_first_element() { - let keyvec = vec![Key::Char('a')]; + let keyvec = vec![KeyWithModifier::new(BareKey::Char('a'))]; let palette = get_palette(); let ret = full_length_shortcut(true, keyvec, "Foobar", palette); @@ -594,7 +599,7 @@ mod tests { #[test] fn full_length_shortcut_with_key_unprintable_1() { - let keyvec = vec![Key::Char('\n')]; + let keyvec = vec![KeyWithModifier::new(BareKey::Enter)]; let palette = get_palette(); let ret = full_length_shortcut(false, keyvec, "Foobar", palette); @@ -605,7 +610,7 @@ mod tests { #[test] fn full_length_shortcut_with_key_unprintable_2() { - let keyvec = vec![Key::Backspace]; + let keyvec = vec![KeyWithModifier::new(BareKey::Backspace)]; let palette = get_palette(); let ret = full_length_shortcut(false, keyvec, "Foobar", palette); @@ -616,7 +621,7 @@ mod tests { #[test] fn full_length_shortcut_with_ctrl_key() { - let keyvec = vec![Key::Ctrl('a')]; + let keyvec = vec![KeyWithModifier::new(BareKey::Char('a')).with_ctrl_modifier()]; let palette = get_palette(); let ret = full_length_shortcut(false, keyvec, "Foobar", palette); @@ -627,7 +632,7 @@ mod tests { #[test] fn full_length_shortcut_with_alt_key() { - let keyvec = vec![Key::Alt(CharOrArrow::Char('a'))]; + let keyvec = vec![KeyWithModifier::new(BareKey::Char('a')).with_alt_modifier()]; let palette = get_palette(); let ret = full_length_shortcut(false, keyvec, "Foobar", palette); @@ -638,7 +643,11 @@ mod tests { #[test] fn full_length_shortcut_with_homogenous_key_group() { - let keyvec = vec![Key::Char('a'), Key::Char('b'), Key::Char('c')]; + let keyvec = vec![ + KeyWithModifier::new(BareKey::Char('a')), + KeyWithModifier::new(BareKey::Char('b')), + KeyWithModifier::new(BareKey::Char('c')), + ]; let palette = get_palette(); let ret = full_length_shortcut(false, keyvec, "Foobar", palette); @@ -649,18 +658,26 @@ mod tests { #[test] fn full_length_shortcut_with_heterogenous_key_group() { - let keyvec = vec![Key::Char('a'), Key::Ctrl('b'), Key::Char('\n')]; + let keyvec = vec![ + KeyWithModifier::new(BareKey::Char('a')), + KeyWithModifier::new(BareKey::Char('b')).with_ctrl_modifier(), + KeyWithModifier::new(BareKey::Enter), + ]; let palette = get_palette(); let ret = full_length_shortcut(false, keyvec, "Foobar", palette); let ret = unstyle(ret); - assert_eq!(ret, " / Foobar"); + assert_eq!(ret, " / Foobar"); } #[test] fn full_length_shortcut_with_key_group_shared_ctrl_modifier() { - let keyvec = vec![Key::Ctrl('a'), Key::Ctrl('b'), Key::Ctrl('c')]; + let keyvec = vec![ + KeyWithModifier::new(BareKey::Char('a')).with_ctrl_modifier(), + KeyWithModifier::new(BareKey::Char('b')).with_ctrl_modifier(), + KeyWithModifier::new(BareKey::Char('c')).with_ctrl_modifier(), + ]; let palette = get_palette(); let ret = full_length_shortcut(false, keyvec, "Foobar", palette); @@ -678,14 +695,32 @@ mod tests { keybinds: vec![( InputMode::Pane, vec![ - (Key::Left, vec![Action::MoveFocus(Direction::Left)]), - (Key::Down, vec![Action::MoveFocus(Direction::Down)]), - (Key::Up, vec![Action::MoveFocus(Direction::Up)]), - (Key::Right, vec![Action::MoveFocus(Direction::Right)]), - (Key::Char('n'), vec![Action::NewPane(None, None), TO_NORMAL]), - (Key::Char('x'), vec![Action::CloseFocus, TO_NORMAL]), ( - Key::Char('f'), + KeyWithModifier::new(BareKey::Left), + vec![Action::MoveFocus(Direction::Left)], + ), + ( + KeyWithModifier::new(BareKey::Down), + vec![Action::MoveFocus(Direction::Down)], + ), + ( + KeyWithModifier::new(BareKey::Up), + vec![Action::MoveFocus(Direction::Up)], + ), + ( + KeyWithModifier::new(BareKey::Right), + vec![Action::MoveFocus(Direction::Right)], + ), + ( + KeyWithModifier::new(BareKey::Char('n')), + vec![Action::NewPane(None, None), TO_NORMAL], + ), + ( + KeyWithModifier::new(BareKey::Char('x')), + vec![Action::CloseFocus, TO_NORMAL], + ), + ( + KeyWithModifier::new(BareKey::Char('f')), vec![Action::ToggleFocusFullscreen, TO_NORMAL], ), ], @@ -710,14 +745,32 @@ mod tests { keybinds: vec![( InputMode::Pane, vec![ - (Key::Left, vec![Action::MoveFocus(Direction::Left)]), - (Key::Down, vec![Action::MoveFocus(Direction::Down)]), - (Key::Up, vec![Action::MoveFocus(Direction::Up)]), - (Key::Right, vec![Action::MoveFocus(Direction::Right)]), - (Key::Char('n'), vec![Action::NewPane(None, None), TO_NORMAL]), - (Key::Char('x'), vec![Action::CloseFocus, TO_NORMAL]), ( - Key::Char('f'), + KeyWithModifier::new(BareKey::Left), + vec![Action::MoveFocus(Direction::Left)], + ), + ( + KeyWithModifier::new(BareKey::Down), + vec![Action::MoveFocus(Direction::Down)], + ), + ( + KeyWithModifier::new(BareKey::Up), + vec![Action::MoveFocus(Direction::Up)], + ), + ( + KeyWithModifier::new(BareKey::Right), + vec![Action::MoveFocus(Direction::Right)], + ), + ( + KeyWithModifier::new(BareKey::Char('n')), + vec![Action::NewPane(None, None), TO_NORMAL], + ), + ( + KeyWithModifier::new(BareKey::Char('x')), + vec![Action::CloseFocus, TO_NORMAL], + ), + ( + KeyWithModifier::new(BareKey::Char('f')), vec![Action::ToggleFocusFullscreen, TO_NORMAL], ), ], @@ -738,13 +791,34 @@ mod tests { keybinds: vec![( InputMode::Pane, vec![ - (Key::Ctrl('a'), vec![Action::MoveFocus(Direction::Left)]), - (Key::Ctrl('\n'), vec![Action::MoveFocus(Direction::Down)]), - (Key::Ctrl('1'), vec![Action::MoveFocus(Direction::Up)]), - (Key::Ctrl(' '), vec![Action::MoveFocus(Direction::Right)]), - (Key::Backspace, vec![Action::NewPane(None, None), TO_NORMAL]), - (Key::Esc, vec![Action::CloseFocus, TO_NORMAL]), - (Key::End, vec![Action::ToggleFocusFullscreen, TO_NORMAL]), + ( + KeyWithModifier::new(BareKey::Char('a')).with_ctrl_modifier(), + vec![Action::MoveFocus(Direction::Left)], + ), + ( + KeyWithModifier::new(BareKey::Enter).with_ctrl_modifier(), + vec![Action::MoveFocus(Direction::Down)], + ), + ( + KeyWithModifier::new(BareKey::Char('1')).with_ctrl_modifier(), + vec![Action::MoveFocus(Direction::Up)], + ), + ( + KeyWithModifier::new(BareKey::Char(' ')).with_ctrl_modifier(), + vec![Action::MoveFocus(Direction::Right)], + ), + ( + KeyWithModifier::new(BareKey::Backspace), + vec![Action::NewPane(None, None), TO_NORMAL], + ), + ( + KeyWithModifier::new(BareKey::Esc), + vec![Action::CloseFocus, TO_NORMAL], + ), + ( + KeyWithModifier::new(BareKey::End), + vec![Action::ToggleFocusFullscreen, TO_NORMAL], + ), ], )], ..ModeInfo::default() diff --git a/default-plugins/status-bar/src/tip/data/quicknav.rs b/default-plugins/status-bar/src/tip/data/quicknav.rs index 318fe702..9d66754e 100644 --- a/default-plugins/status-bar/src/tip/data/quicknav.rs +++ b/default-plugins/status-bar/src/tip/data/quicknav.rs @@ -76,10 +76,10 @@ fn add_keybinds(help: &ModeInfo) -> Keygroups { &[Action::Resize(Resize::Decrease, None)], ], ); - if resize_keys.contains(&Key::Alt(CharOrArrow::Char('='))) - && resize_keys.contains(&Key::Alt(CharOrArrow::Char('+'))) + if resize_keys.contains(&KeyWithModifier::new(BareKey::Char('=')).with_alt_modifier()) + && resize_keys.contains(&KeyWithModifier::new(BareKey::Char('+')).with_alt_modifier()) { - resize_keys.retain(|k| k != &Key::Alt(CharOrArrow::Char('='))); + resize_keys.retain(|k| k != &KeyWithModifier::new(BareKey::Char('=')).with_alt_modifier()) } let resize = if resize_keys.is_empty() { vec![Style::new().bold().paint("UNBOUND")] diff --git a/default-plugins/strider/src/main.rs b/default-plugins/strider/src/main.rs index ce9a5273..b1c2308b 100644 --- a/default-plugins/strider/src/main.rs +++ b/default-plugins/strider/src/main.rs @@ -63,42 +63,47 @@ impl ZellijPlugin for State { self.update_files(paths); should_render = true; }, - Event::Key(key) => match key { - Key::Char(character) if character != '\n' => { + Event::Key(key) => match key.bare_key { + BareKey::Char(character) if key.has_no_modifiers() => { self.update_search_term(character); should_render = true; }, - Key::Backspace => { + BareKey::Backspace if key.has_no_modifiers() => { self.handle_backspace(); should_render = true; }, - Key::Esc | Key::Ctrl('c') => { + BareKey::Esc if key.has_no_modifiers() => { self.clear_search_term_or_descend(); should_render = true; }, - Key::Up => { + BareKey::Char('c') if key.has_modifiers(&[KeyModifier::Ctrl]) => { + self.clear_search_term_or_descend(); + }, + BareKey::Up if key.has_no_modifiers() => { self.move_selection_up(); should_render = true; }, - Key::Down => { + BareKey::Down if key.has_no_modifiers() => { self.move_selection_down(); should_render = true; }, - Key::Char('\n') if self.handling_filepick_request_from.is_some() => { + BareKey::Enter + if key.has_no_modifiers() && self.handling_filepick_request_from.is_some() => + { self.send_filepick_response(); }, - Key::Char('\n') => { + BareKey::Enter if key.has_no_modifiers() => { self.open_selected_path(); }, - Key::Right | Key::BackTab => { + BareKey::Right | BareKey::Tab if key.has_no_modifiers() => { self.traverse_dir(); should_render = true; }, - Key::Left => { + BareKey::Left if key.has_no_modifiers() => { self.descend_to_previous_path(); should_render = true; }, - Key::Ctrl('e') => { + BareKey::Char('e') if key.has_modifiers(&[KeyModifier::Ctrl]) => { should_render = true; self.toggle_hidden_files(); refresh_directory(&self.file_list_view.path); diff --git a/src/tests/e2e/cases.rs b/src/tests/e2e/cases.rs index f2dd0933..6b1c12c6 100644 --- a/src/tests/e2e/cases.rs +++ b/src/tests/e2e/cases.rs @@ -2226,6 +2226,7 @@ pub fn send_command_through_the_cli() { // cursor does not appear in // suspend_start panes { + std::thread::sleep(std::time::Duration::from_millis(100)); remote_terminal.send_key(&SPACE); // run script - here we use SPACE // instead of the default ENTER because // sending ENTER over SSH can be a little @@ -2243,6 +2244,7 @@ pub fn send_command_through_the_cli() { if remote_terminal.snapshot_contains("") && remote_terminal.cursor_position_is(76, 3) { + std::thread::sleep(std::time::Duration::from_millis(100)); remote_terminal.send_key(&SPACE); // re-run script - here we use SPACE // instead of the default ENTER because // sending ENTER over SSH can be a little diff --git a/src/tests/e2e/remote_runner.rs b/src/tests/e2e/remote_runner.rs index 2f93d5b6..ab2c4a9e 100644 --- a/src/tests/e2e/remote_runner.rs +++ b/src/tests/e2e/remote_runner.rs @@ -237,6 +237,7 @@ fn read_from_channel( let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut terminal_output = TerminalPane::new( 0, pane_geom, @@ -253,6 +254,7 @@ fn read_from_channel( debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); // 0 is the pane index loop { if !should_keep_running.load(Ordering::SeqCst) { diff --git a/src/tests/e2e/snapshots/zellij__tests__e2e__cases__quit_and_resurrect_session.snap b/src/tests/e2e/snapshots/zellij__tests__e2e__cases__quit_and_resurrect_session.snap index fd55ac42..5308c782 100644 --- a/src/tests/e2e/snapshots/zellij__tests__e2e__cases__quit_and_resurrect_session.snap +++ b/src/tests/e2e/snapshots/zellij__tests__e2e__cases__quit_and_resurrect_session.snap @@ -1,6 +1,6 @@ --- source: src/tests/e2e/cases.rs -assertion_line: 1048 +assertion_line: 1171 expression: last_snapshot --- Zellij (e2e-test)  Tab #1  Tab #2  Tab #3  Tab #4  @@ -26,4 +26,4 @@ expression: last_snapshot │ ││ │ └──────────────────────────────────────────────────────────┘└──────────────────────────────────────────────────────────┘ Ctrl + LOCK 

PANE  TAB  RESIZE  MOVE  SEARCH  SESSION  QUIT  - (FLOATING PANES VISIBLE): Press Ctrl+p, to hide. + (FLOATING PANES VISIBLE): Press Ctrl p, to hide. diff --git a/src/tests/e2e/snapshots/zellij__tests__e2e__cases__quit_and_resurrect_session_with_viewport_serialization.snap b/src/tests/e2e/snapshots/zellij__tests__e2e__cases__quit_and_resurrect_session_with_viewport_serialization.snap index f3677360..8c0477f8 100644 --- a/src/tests/e2e/snapshots/zellij__tests__e2e__cases__quit_and_resurrect_session_with_viewport_serialization.snap +++ b/src/tests/e2e/snapshots/zellij__tests__e2e__cases__quit_and_resurrect_session_with_viewport_serialization.snap @@ -1,6 +1,6 @@ --- source: src/tests/e2e/cases.rs -assertion_line: 1109 +assertion_line: 1232 expression: last_snapshot --- Zellij (e2e-test)  Tab #1  Tab #2  Tab #3  Tab #4  @@ -26,4 +26,4 @@ expression: last_snapshot │ ││ │ └──────────────────────────────────────────────────────────┘└──────────────────────────────────────────────────────────┘ Ctrl + LOCK 

PANE  TAB  RESIZE  MOVE  SEARCH  SESSION  QUIT  - (FLOATING PANES VISIBLE): Press Ctrl+p, to hide. + (FLOATING PANES VISIBLE): Press Ctrl p, to hide. diff --git a/src/tests/e2e/snapshots/zellij__tests__e2e__cases__status_bar_loads_custom_keybindings.snap b/src/tests/e2e/snapshots/zellij__tests__e2e__cases__status_bar_loads_custom_keybindings.snap index 974a63bd..a0fe5fbd 100644 --- a/src/tests/e2e/snapshots/zellij__tests__e2e__cases__status_bar_loads_custom_keybindings.snap +++ b/src/tests/e2e/snapshots/zellij__tests__e2e__cases__status_bar_loads_custom_keybindings.snap @@ -1,6 +1,6 @@ --- source: src/tests/e2e/cases.rs -assertion_line: 1011 +assertion_line: 1266 expression: last_snapshot --- Zellij (e2e-test)  Tab #1  @@ -25,5 +25,5 @@ expression: last_snapshot │ │ │ │ └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ - LOCK  PANE  TAB  RESIZE  MOVE  SEARCH  SESSION  QUIT  + LOCK  PANE  TAB  RESIZE  MOVE  SEARCH  SESSION  QUIT  Tip: UNBOUND => open new pane. UNBOUND => navigate between panes. UNBOUND => increase/decrease pane size. diff --git a/src/tests/e2e/snapshots/zellij__tests__e2e__cases__toggle_floating_panes.snap b/src/tests/e2e/snapshots/zellij__tests__e2e__cases__toggle_floating_panes.snap index e76aa32a..3007e299 100644 --- a/src/tests/e2e/snapshots/zellij__tests__e2e__cases__toggle_floating_panes.snap +++ b/src/tests/e2e/snapshots/zellij__tests__e2e__cases__toggle_floating_panes.snap @@ -1,6 +1,6 @@ --- source: src/tests/e2e/cases.rs -assertion_line: 1724 +assertion_line: 1984 expression: last_snapshot --- Zellij (e2e-test)  Tab #1  @@ -26,4 +26,4 @@ expression: last_snapshot │ │ └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ Ctrl + LOCK 

PANE  TAB  RESIZE  MOVE  SEARCH  SESSION  QUIT  - (FLOATING PANES VISIBLE): Press Ctrl+p, to hide. + (FLOATING PANES VISIBLE): Press Ctrl p, to hide. diff --git a/zellij-client/src/input_handler.rs b/zellij-client/src/input_handler.rs index 058b2bbc..b00d1280 100644 --- a/zellij-client/src/input_handler.rs +++ b/zellij-client/src/input_handler.rs @@ -5,7 +5,7 @@ use crate::{ }; use zellij_utils::{ channels::{Receiver, SenderWithContext, OPENCALLS}, - data::{InputMode, Key}, + data::{InputMode, KeyWithModifier}, errors::{ContextType, ErrorContext, FatalError}, input::{ actions::Action, @@ -96,7 +96,7 @@ impl InputHandler { &raw_bytes, Some((&self.config.keybinds, &self.mode)), ); - self.handle_key(&key, raw_bytes); + self.handle_key(&key, raw_bytes, false); }, InputEvent::Mouse(mouse_event) => { let mouse_event = @@ -106,15 +106,15 @@ impl InputHandler { InputEvent::Paste(pasted_text) => { if self.mode == InputMode::Normal || self.mode == InputMode::Locked { self.dispatch_action( - Action::Write(bracketed_paste_start.clone()), + Action::Write(None, bracketed_paste_start.clone(), false), None, ); self.dispatch_action( - Action::Write(pasted_text.as_bytes().to_vec()), + Action::Write(None, pasted_text.as_bytes().to_vec(), false), None, ); self.dispatch_action( - Action::Write(bracketed_paste_end.clone()), + Action::Write(None, bracketed_paste_end.clone(), false), None, ); } @@ -140,6 +140,12 @@ impl InputHandler { _ => {}, } }, + Ok(( + InputInstruction::KeyWithModifierEvent(key_with_modifier, raw_bytes), + _error_context, + )) => { + self.handle_key(&key_with_modifier, raw_bytes, true); + }, Ok((InputInstruction::SwitchToMode(input_mode), _error_context)) => { self.mode = input_mode; }, @@ -168,11 +174,19 @@ impl InputHandler { } } } - fn handle_key(&mut self, key: &Key, raw_bytes: Vec) { + fn handle_key( + &mut self, + key: &KeyWithModifier, + raw_bytes: Vec, + is_kitty_keyboard_protocol: bool, + ) { let keybinds = &self.config.keybinds; - for action in - keybinds.get_actions_for_key_in_mode_or_default_action(&self.mode, key, raw_bytes) - { + for action in keybinds.get_actions_for_key_in_mode_or_default_action( + &self.mode, + key, + raw_bytes, + is_kitty_keyboard_protocol, + ) { let should_exit = self.dispatch_action(action, None); if should_exit { self.should_exit = true; diff --git a/zellij-client/src/keyboard_parser.rs b/zellij-client/src/keyboard_parser.rs new file mode 100644 index 00000000..73b36d06 --- /dev/null +++ b/zellij-client/src/keyboard_parser.rs @@ -0,0 +1,1779 @@ +// for more info, please see: https://sw.kovidgoyal.net/kitty/keyboard-protocol +use zellij_utils::data::KeyWithModifier; + +#[derive(Debug)] +enum KittyKeysParsingState { + Ground, + ReceivedEscapeCharacter, + ParsingNumber, + ParsingModifiers, + DoneParsingWithU, + DoneParsingWithTilde, +} + +#[derive(Debug)] +pub struct KittyKeyboardParser { + state: KittyKeysParsingState, + number_bytes: Vec, + modifier_bytes: Vec, +} + +impl KittyKeyboardParser { + pub fn new() -> Self { + KittyKeyboardParser { + state: KittyKeysParsingState::Ground, + number_bytes: vec![], + modifier_bytes: vec![], + } + } + pub fn parse(&mut self, buffer: &[u8]) -> Option { + for byte in buffer { + if !self.advance(*byte) { + return None; + } + } + match self.state { + KittyKeysParsingState::DoneParsingWithU => { + // CSI number ; modifiers u + KeyWithModifier::from_bytes_with_u(&self.number_bytes, &self.modifier_bytes) + }, + KittyKeysParsingState::DoneParsingWithTilde => { + // CSI number ; modifiers ~ + KeyWithModifier::from_bytes_with_tilde(&self.number_bytes, &self.modifier_bytes) + }, + KittyKeysParsingState::ParsingModifiers => { + // CSI 1; modifiers [ABCDEFHPQS] + match self.modifier_bytes.pop() { + Some(last_modifier) => KeyWithModifier::from_bytes_with_no_ending_byte( + &[last_modifier], + &self.modifier_bytes, + ), + None => None, + } + }, + KittyKeysParsingState::ParsingNumber => { + KeyWithModifier::from_bytes_with_no_ending_byte( + &self.number_bytes, + &self.modifier_bytes, + ) + }, + _ => None, + } + } + pub fn advance(&mut self, byte: u8) -> bool { + // returns false if we failed parsing + match (&self.state, byte) { + (KittyKeysParsingState::Ground, 0x1b | 0x5b) => { + self.state = KittyKeysParsingState::ReceivedEscapeCharacter; + }, + (KittyKeysParsingState::ReceivedEscapeCharacter, 91) => { + self.state = KittyKeysParsingState::ParsingNumber; + }, + (KittyKeysParsingState::ParsingNumber, 59) => { + // semicolon + if &self.number_bytes == &[49] { + self.number_bytes.clear(); + } + self.state = KittyKeysParsingState::ParsingModifiers; + }, + ( + KittyKeysParsingState::ParsingNumber | KittyKeysParsingState::ParsingModifiers, + 117, + ) => { + // u + self.state = KittyKeysParsingState::DoneParsingWithU; + }, + ( + KittyKeysParsingState::ParsingNumber | KittyKeysParsingState::ParsingModifiers, + 126, + ) => { + // ~ + self.state = KittyKeysParsingState::DoneParsingWithTilde; + }, + (KittyKeysParsingState::ParsingNumber, _) => { + self.number_bytes.push(byte); + }, + (KittyKeysParsingState::ParsingModifiers, _) => { + self.modifier_bytes.push(byte); + }, + (_, _) => { + return false; + }, + } + true + } +} + +#[test] +pub fn can_parse_bare_keys() { + use zellij_utils::data::BareKey; + let key = "\u{1b}[97u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Char('a'))), + "Can parse a bare 'a' keypress" + ); + let key = "\u{1b}[49u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Char('1'))), + "Can parse a bare '1' keypress" + ); + let key = "\u{1b}[27u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Esc)), + "Can parse a bare 'ESC' keypress" + ); + let key = "\u{1b}[13u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Enter)), + "Can parse a bare 'ENTER' keypress" + ); + let key = "\u{1b}[9u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Tab)), + "Can parse a bare 'Tab' keypress" + ); + let key = "\u{1b}[127u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Backspace)), + "Can parse a bare 'Backspace' keypress" + ); + let key = "\u{1b}[57358u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::CapsLock)), + "Can parse a bare 'CapsLock' keypress" + ); + let key = "\u{1b}[57359u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::ScrollLock)), + "Can parse a bare 'ScrollLock' keypress" + ); + let key = "\u{1b}[57360u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::NumLock)), + "Can parse a bare 'NumLock' keypress" + ); + let key = "\u{1b}[57361u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::PrintScreen)), + "Can parse a bare 'PrintScreen' keypress" + ); + let key = "\u{1b}[57362u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Pause)), + "Can parse a bare 'Pause' keypress" + ); + let key = "\u{1b}[57363u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Menu)), + "Can parse a bare 'Menu' keypress" + ); + + let key = "\u{1b}[2~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Insert)), + "Can parse a bare 'Insert' keypress" + ); + let key = "\u{1b}[3~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Delete)), + "Can parse a bare 'Delete' keypress" + ); + let key = "\u{1b}[5~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::PageUp)), + "Can parse a bare 'PageUp' keypress" + ); + let key = "\u{1b}[6~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::PageDown)), + "Can parse a bare 'PageDown' keypress" + ); + let key = "\u{1b}[7~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Home)), + "Can parse a bare 'Home' keypress" + ); + let key = "\u{1b}[8~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::End)), + "Can parse a bare 'End' keypress" + ); + let key = "\u{1b}[11~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(1))), + "Can parse a bare 'F1' keypress" + ); + let key = "\u{1b}[12~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(2))), + "Can parse a bare 'F2' keypress" + ); + let key = "\u{1b}[13~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(3))), + "Can parse a bare 'F3' keypress" + ); + let key = "\u{1b}[14~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(4))), + "Can parse a bare 'F4' keypress" + ); + let key = "\u{1b}[15~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(5))), + "Can parse a bare 'F5' keypress" + ); + let key = "\u{1b}[17~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(6))), + "Can parse a bare 'F6' keypress" + ); + let key = "\u{1b}[18~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(7))), + "Can parse a bare 'F7' keypress" + ); + let key = "\u{1b}[19~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(8))), + "Can parse a bare 'F8' keypress" + ); + let key = "\u{1b}[20~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(9))), + "Can parse a bare 'F9' keypress" + ); + let key = "\u{1b}[21~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(10))), + "Can parse a bare 'F10' keypress" + ); + let key = "\u{1b}[23~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(11))), + "Can parse a bare 'F11' keypress" + ); + let key = "\u{1b}[24~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(12))), + "Can parse a bare 'F12' keypress" + ); + let key = "\u{1b}[D"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Left)), + "Can parse a bare 'Left' keypress" + ); + let key = "\u{1b}[C"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Right)), + "Can parse a bare 'Right' keypress" + ); + let key = "\u{1b}[A"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Up)), + "Can parse a bare 'Up' keypress" + ); + let key = "\u{1b}[B"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Down)), + "Can parse a bare 'Down' keypress" + ); + let key = "\u{1b}[H"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Home)), + "Can parse a bare 'Home' keypress" + ); + let key = "\u{1b}[F"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::End)), + "Can parse a bare 'End' keypress" + ); + let key = "\u{1b}[P"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(1))), + "Can parse a bare 'F1 (alternate)' keypress" + ); + let key = "\u{1b}[Q"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(2))), + "Can parse a bare 'F2 (alternate)' keypress" + ); + let key = "\u{1b}[S"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(4))), + "Can parse a bare 'F4 (alternate)' keypress" + ); +} + +#[test] +pub fn can_parse_keys_with_shift_modifier() { + use zellij_utils::data::BareKey; + let key = "\u{1b}[97;2u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Char('a')).with_shift_modifier()), + "Can parse a bare 'a' keypress with shift" + ); + let key = "\u{1b}[49;2u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Char('1')).with_shift_modifier()), + "Can parse a bare '1' keypress with shift" + ); + let key = "\u{1b}[27;2u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Esc).with_shift_modifier()), + "Can parse a bare 'ESC' keypress with shift" + ); + let key = "\u{1b}[13;2u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Enter).with_shift_modifier()), + "Can parse a bare 'ENTER' keypress with shift" + ); + let key = "\u{1b}[9;2u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Tab).with_shift_modifier()), + "Can parse a bare 'Tab' keypress with shift" + ); + let key = "\u{1b}[127;2u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Backspace).with_shift_modifier()), + "Can parse a bare 'Backspace' keypress with shift" + ); + let key = "\u{1b}[57358;2u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::CapsLock).with_shift_modifier()), + "Can parse a bare 'CapsLock' keypress with shift" + ); + let key = "\u{1b}[57359;2u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::ScrollLock).with_shift_modifier()), + "Can parse a bare 'ScrollLock' keypress with shift" + ); + let key = "\u{1b}[57360;2u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::NumLock).with_shift_modifier()), + "Can parse a bare 'NumLock' keypress with shift" + ); + let key = "\u{1b}[57361;2u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::PrintScreen).with_shift_modifier()), + "Can parse a bare 'PrintScreen' keypress with shift" + ); + let key = "\u{1b}[57362;2u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Pause).with_shift_modifier()), + "Can parse a bare 'Pause' keypress with shift" + ); + let key = "\u{1b}[57363;2u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Menu).with_shift_modifier()), + "Can parse a bare 'Menu' keypress with shift" + ); + + let key = "\u{1b}[2;2~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Insert).with_shift_modifier()), + "Can parse a bare 'Insert' keypress with shift" + ); + let key = "\u{1b}[3;2~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Delete).with_shift_modifier()), + "Can parse a bare 'Delete' keypress with shift" + ); + let key = "\u{1b}[5;2~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::PageUp).with_shift_modifier()), + "Can parse a bare 'PageUp' keypress with shift" + ); + let key = "\u{1b}[6;2~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::PageDown).with_shift_modifier()), + "Can parse a bare 'PageDown' keypress with shift" + ); + let key = "\u{1b}[7;2~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Home).with_shift_modifier()), + "Can parse a bare 'Home' keypress with shift" + ); + let key = "\u{1b}[8;2~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::End).with_shift_modifier()), + "Can parse a bare 'End' keypress with shift" + ); + let key = "\u{1b}[11;2~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(1)).with_shift_modifier()), + "Can parse a bare 'F1' keypress with shift" + ); + let key = "\u{1b}[12;2~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(2)).with_shift_modifier()), + "Can parse a bare 'F2' keypress with shift" + ); + let key = "\u{1b}[13;2~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(3)).with_shift_modifier()), + "Can parse a bare 'F3' keypress with shift" + ); + let key = "\u{1b}[14;2~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(4)).with_shift_modifier()), + "Can parse a bare 'F4' keypress with shift" + ); + let key = "\u{1b}[15;2~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(5)).with_shift_modifier()), + "Can parse a bare 'F5' keypress with shift" + ); + let key = "\u{1b}[17;2~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(6)).with_shift_modifier()), + "Can parse a bare 'F6' keypress with shift" + ); + let key = "\u{1b}[18;2~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(7)).with_shift_modifier()), + "Can parse a bare 'F7' keypress with shift" + ); + let key = "\u{1b}[19;2~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(8)).with_shift_modifier()), + "Can parse a bare 'F8' keypress with shift" + ); + let key = "\u{1b}[20;2~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(9)).with_shift_modifier()), + "Can parse a bare 'F9' keypress with shift" + ); + let key = "\u{1b}[21;2~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(10)).with_shift_modifier()), + "Can parse a bare 'F10' keypress with shift" + ); + let key = "\u{1b}[23;2~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(11)).with_shift_modifier()), + "Can parse a bare 'F11' keypress with shift" + ); + let key = "\u{1b}[24;2~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(12)).with_shift_modifier()), + "Can parse a bare 'F12' keypress with shift" + ); + let key = "\u{1b}[1;2D"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Left).with_shift_modifier()), + "Can parse a bare 'Left' keypress with shift" + ); + let key = "\u{1b}[1;2C"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Right).with_shift_modifier()), + "Can parse a bare 'Right' keypress with shift" + ); + let key = "\u{1b}[1;2A"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Up).with_shift_modifier()), + "Can parse a bare 'Up' keypress with shift" + ); + let key = "\u{1b}[1;2B"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Down).with_shift_modifier()), + "Can parse a bare 'Down' keypress with shift" + ); + let key = "\u{1b}[1;2H"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Home).with_shift_modifier()), + "Can parse a bare 'Home' keypress with shift" + ); + let key = "\u{1b}[1;2F"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::End).with_shift_modifier()), + "Can parse a bare 'End' keypress with shift" + ); + let key = "\u{1b}[1;2P"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(1)).with_shift_modifier()), + "Can parse a bare 'F1 (alternate)' keypress with shift" + ); + let key = "\u{1b}[1;2Q"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(2)).with_shift_modifier()), + "Can parse a bare 'F2 (alternate)' keypress with shift" + ); + let key = "\u{1b}[1;2S"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(4)).with_shift_modifier()), + "Can parse a bare 'F4 (alternate)' keypress with shift" + ); +} + +#[test] +pub fn can_parse_keys_with_alt_modifier() { + use zellij_utils::data::BareKey; + let key = "\u{1b}[97;3u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Char('a')).with_alt_modifier()), + "Can parse a bare 'a' keypress with alt" + ); + let key = "\u{1b}[49;3u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Char('1')).with_alt_modifier()), + "Can parse a bare '1' keypress with alt" + ); + let key = "\u{1b}[27;3u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Esc).with_alt_modifier()), + "Can parse a bare 'ESC' keypress with alt" + ); + let key = "\u{1b}[13;3u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Enter).with_alt_modifier()), + "Can parse a bare 'ENTER' keypress with alt" + ); + let key = "\u{1b}[9;3u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Tab).with_alt_modifier()), + "Can parse a bare 'Tab' keypress with alt" + ); + let key = "\u{1b}[127;3u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Backspace).with_alt_modifier()), + "Can parse a bare 'Backspace' keypress with alt" + ); + let key = "\u{1b}[57358;3u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::CapsLock).with_alt_modifier()), + "Can parse a bare 'CapsLock' keypress with alt" + ); + let key = "\u{1b}[57359;3u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::ScrollLock).with_alt_modifier()), + "Can parse a bare 'ScrollLock' keypress with alt" + ); + let key = "\u{1b}[57360;3u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::NumLock).with_alt_modifier()), + "Can parse a bare 'NumLock' keypress with alt" + ); + let key = "\u{1b}[57361;3u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::PrintScreen).with_alt_modifier()), + "Can parse a bare 'PrintScreen' keypress with alt" + ); + let key = "\u{1b}[57362;3u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Pause).with_alt_modifier()), + "Can parse a bare 'Pause' keypress with alt" + ); + let key = "\u{1b}[57363;3u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Menu).with_alt_modifier()), + "Can parse a bare 'Menu' keypress with alt" + ); + + let key = "\u{1b}[2;3~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Insert).with_alt_modifier()), + "Can parse a bare 'Insert' keypress with alt" + ); + let key = "\u{1b}[3;3~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Delete).with_alt_modifier()), + "Can parse a bare 'Delete' keypress with alt" + ); + let key = "\u{1b}[5;3~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::PageUp).with_alt_modifier()), + "Can parse a bare 'PageUp' keypress with alt" + ); + let key = "\u{1b}[6;3~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::PageDown).with_alt_modifier()), + "Can parse a bare 'PageDown' keypress with alt" + ); + let key = "\u{1b}[7;3~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Home).with_alt_modifier()), + "Can parse a bare 'Home' keypress with alt" + ); + let key = "\u{1b}[8;3~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::End).with_alt_modifier()), + "Can parse a bare 'End' keypress with alt" + ); + let key = "\u{1b}[11;3~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(1)).with_alt_modifier()), + "Can parse a bare 'F1' keypress with alt" + ); + let key = "\u{1b}[12;3~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(2)).with_alt_modifier()), + "Can parse a bare 'F2' keypress with alt" + ); + let key = "\u{1b}[13;3~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(3)).with_alt_modifier()), + "Can parse a bare 'F3' keypress with alt" + ); + let key = "\u{1b}[14;3~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(4)).with_alt_modifier()), + "Can parse a bare 'F4' keypress with alt" + ); + let key = "\u{1b}[15;3~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(5)).with_alt_modifier()), + "Can parse a bare 'F5' keypress with alt" + ); + let key = "\u{1b}[17;3~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(6)).with_alt_modifier()), + "Can parse a bare 'F6' keypress with alt" + ); + let key = "\u{1b}[18;3~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(7)).with_alt_modifier()), + "Can parse a bare 'F7' keypress with alt" + ); + let key = "\u{1b}[19;3~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(8)).with_alt_modifier()), + "Can parse a bare 'F8' keypress with alt" + ); + let key = "\u{1b}[20;3~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(9)).with_alt_modifier()), + "Can parse a bare 'F9' keypress with alt" + ); + let key = "\u{1b}[21;3~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(10)).with_alt_modifier()), + "Can parse a bare 'F10' keypress with alt" + ); + let key = "\u{1b}[23;3~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(11)).with_alt_modifier()), + "Can parse a bare 'F11' keypress with alt" + ); + let key = "\u{1b}[24;3~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(12)).with_alt_modifier()), + "Can parse a bare 'F12' keypress with alt" + ); + let key = "\u{1b}[1;3D"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Left).with_alt_modifier()), + "Can parse a bare 'Left' keypress with alt" + ); + let key = "\u{1b}[1;3C"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Right).with_alt_modifier()), + "Can parse a bare 'Right' keypress with alt" + ); + let key = "\u{1b}[1;3A"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Up).with_alt_modifier()), + "Can parse a bare 'Up' keypress with alt" + ); + let key = "\u{1b}[1;3B"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Down).with_alt_modifier()), + "Can parse a bare 'Down' keypress with alt" + ); + let key = "\u{1b}[1;3H"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Home).with_alt_modifier()), + "Can parse a bare 'Home' keypress with alt" + ); + let key = "\u{1b}[1;3F"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::End).with_alt_modifier()), + "Can parse a bare 'End' keypress with alt" + ); + let key = "\u{1b}[1;3P"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(1)).with_alt_modifier()), + "Can parse a bare 'F1 (alternate)' keypress with alt" + ); + let key = "\u{1b}[1;3Q"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(2)).with_alt_modifier()), + "Can parse a bare 'F2 (alternate)' keypress with alt" + ); + let key = "\u{1b}[1;3S"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(4)).with_alt_modifier()), + "Can parse a bare 'F4 (alternate)' keypress with alt" + ); +} + +#[test] +pub fn can_parse_keys_with_ctrl_modifier() { + use zellij_utils::data::BareKey; + let key = "\u{1b}[97;5u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Char('a')).with_ctrl_modifier()), + "Can parse a bare 'a' keypress with ctrl" + ); + let key = "\u{1b}[49;5u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Char('1')).with_ctrl_modifier()), + "Can parse a bare '1' keypress with ctrl" + ); + let key = "\u{1b}[27;5u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Esc).with_ctrl_modifier()), + "Can parse a bare 'ESC' keypress with ctrl" + ); + let key = "\u{1b}[13;5u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Enter).with_ctrl_modifier()), + "Can parse a bare 'ENTER' keypress with ctrl" + ); + let key = "\u{1b}[9;5u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Tab).with_ctrl_modifier()), + "Can parse a bare 'Tab' keypress with ctrl" + ); + let key = "\u{1b}[127;5u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Backspace).with_ctrl_modifier()), + "Can parse a bare 'Backspace' keypress with ctrl" + ); + let key = "\u{1b}[57358;5u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::CapsLock).with_ctrl_modifier()), + "Can parse a bare 'CapsLock' keypress with ctrl" + ); + let key = "\u{1b}[57359;5u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::ScrollLock).with_ctrl_modifier()), + "Can parse a bare 'ScrollLock' keypress with ctrl" + ); + let key = "\u{1b}[57360;5u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::NumLock).with_ctrl_modifier()), + "Can parse a bare 'NumLock' keypress with ctrl" + ); + let key = "\u{1b}[57361;5u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::PrintScreen).with_ctrl_modifier()), + "Can parse a bare 'PrintScreen' keypress with ctrl" + ); + let key = "\u{1b}[57362;5u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Pause).with_ctrl_modifier()), + "Can parse a bare 'Pause' keypress with ctrl" + ); + let key = "\u{1b}[57363;5u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Menu).with_ctrl_modifier()), + "Can parse a bare 'Menu' keypress with ctrl" + ); + + let key = "\u{1b}[2;5~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Insert).with_ctrl_modifier()), + "Can parse a bare 'Insert' keypress with ctrl" + ); + let key = "\u{1b}[3;5~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Delete).with_ctrl_modifier()), + "Can parse a bare 'Delete' keypress with ctrl" + ); + let key = "\u{1b}[5;5~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::PageUp).with_ctrl_modifier()), + "Can parse a bare 'PageUp' keypress with ctrl" + ); + let key = "\u{1b}[6;5~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::PageDown).with_ctrl_modifier()), + "Can parse a bare 'PageDown' keypress with ctrl" + ); + let key = "\u{1b}[7;5~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Home).with_ctrl_modifier()), + "Can parse a bare 'Home' keypress with ctrl" + ); + let key = "\u{1b}[8;5~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::End).with_ctrl_modifier()), + "Can parse a bare 'End' keypress with ctrl" + ); + let key = "\u{1b}[11;5~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(1)).with_ctrl_modifier()), + "Can parse a bare 'F1' keypress with ctrl" + ); + let key = "\u{1b}[12;5~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(2)).with_ctrl_modifier()), + "Can parse a bare 'F2' keypress with ctrl" + ); + let key = "\u{1b}[13;5~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(3)).with_ctrl_modifier()), + "Can parse a bare 'F3' keypress with ctrl" + ); + let key = "\u{1b}[14;5~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(4)).with_ctrl_modifier()), + "Can parse a bare 'F4' keypress with ctrl" + ); + let key = "\u{1b}[15;5~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(5)).with_ctrl_modifier()), + "Can parse a bare 'F5' keypress with ctrl" + ); + let key = "\u{1b}[17;5~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(6)).with_ctrl_modifier()), + "Can parse a bare 'F6' keypress with ctrl" + ); + let key = "\u{1b}[18;5~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(7)).with_ctrl_modifier()), + "Can parse a bare 'F7' keypress with ctrl" + ); + let key = "\u{1b}[19;5~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(8)).with_ctrl_modifier()), + "Can parse a bare 'F8' keypress with ctrl" + ); + let key = "\u{1b}[20;5~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(9)).with_ctrl_modifier()), + "Can parse a bare 'F9' keypress with ctrl" + ); + let key = "\u{1b}[21;5~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(10)).with_ctrl_modifier()), + "Can parse a bare 'F10' keypress with ctrl" + ); + let key = "\u{1b}[23;5~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(11)).with_ctrl_modifier()), + "Can parse a bare 'F11' keypress with ctrl" + ); + let key = "\u{1b}[24;5~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(12)).with_ctrl_modifier()), + "Can parse a bare 'F12' keypress with ctrl" + ); + let key = "\u{1b}[1;5D"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Left).with_ctrl_modifier()), + "Can parse a bare 'Left' keypress with ctrl" + ); + let key = "\u{1b}[1;5C"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Right).with_ctrl_modifier()), + "Can parse a bare 'Right' keypress with ctrl" + ); + let key = "\u{1b}[1;5A"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Up).with_ctrl_modifier()), + "Can parse a bare 'Up' keypress with ctrl" + ); + let key = "\u{1b}[1;5B"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Down).with_ctrl_modifier()), + "Can parse a bare 'Down' keypress with ctrl" + ); + let key = "\u{1b}[1;5H"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Home).with_ctrl_modifier()), + "Can parse a bare 'Home' keypress with ctrl" + ); + let key = "\u{1b}[1;5F"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::End).with_ctrl_modifier()), + "Can parse a bare 'End' keypress with ctrl" + ); + let key = "\u{1b}[1;5P"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(1)).with_ctrl_modifier()), + "Can parse a bare 'F1 (ctrlernate)' keypress with ctrl" + ); + let key = "\u{1b}[1;5Q"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(2)).with_ctrl_modifier()), + "Can parse a bare 'F2 (ctrlernate)' keypress with ctrl" + ); + let key = "\u{1b}[1;5S"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(4)).with_ctrl_modifier()), + "Can parse a bare 'F4 (ctrlernate)' keypress with ctrl" + ); +} + +#[test] +pub fn can_parse_keys_with_super_modifier() { + use zellij_utils::data::BareKey; + let key = "\u{1b}[97;9u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Char('a')).with_super_modifier()), + "Can parse a bare 'a' keypress with super" + ); + let key = "\u{1b}[49;9u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Char('1')).with_super_modifier()), + "Can parse a bare '1' keypress with super" + ); + let key = "\u{1b}[27;9u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Esc).with_super_modifier()), + "Can parse a bare 'ESC' keypress with super" + ); + let key = "\u{1b}[13;9u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Enter).with_super_modifier()), + "Can parse a bare 'ENTER' keypress with super" + ); + let key = "\u{1b}[9;9u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Tab).with_super_modifier()), + "Can parse a bare 'Tab' keypress with super" + ); + let key = "\u{1b}[127;9u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Backspace).with_super_modifier()), + "Can parse a bare 'Backspace' keypress with super" + ); + let key = "\u{1b}[57358;9u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::CapsLock).with_super_modifier()), + "Can parse a bare 'CapsLock' keypress with super" + ); + let key = "\u{1b}[57359;9u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::ScrollLock).with_super_modifier()), + "Can parse a bare 'ScrollLock' keypress with super" + ); + let key = "\u{1b}[57360;9u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::NumLock).with_super_modifier()), + "Can parse a bare 'NumLock' keypress with super" + ); + let key = "\u{1b}[57361;9u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::PrintScreen).with_super_modifier()), + "Can parse a bare 'PrintScreen' keypress with super" + ); + let key = "\u{1b}[57362;9u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Pause).with_super_modifier()), + "Can parse a bare 'Pause' keypress with super" + ); + let key = "\u{1b}[57363;9u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Menu).with_super_modifier()), + "Can parse a bare 'Menu' keypress with super" + ); + + let key = "\u{1b}[2;9~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Insert).with_super_modifier()), + "Can parse a bare 'Insert' keypress with super" + ); + let key = "\u{1b}[3;9~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Delete).with_super_modifier()), + "Can parse a bare 'Delete' keypress with super" + ); + let key = "\u{1b}[5;9~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::PageUp).with_super_modifier()), + "Can parse a bare 'PageUp' keypress with super" + ); + let key = "\u{1b}[6;9~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::PageDown).with_super_modifier()), + "Can parse a bare 'PageDown' keypress with super" + ); + let key = "\u{1b}[7;9~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Home).with_super_modifier()), + "Can parse a bare 'Home' keypress with super" + ); + let key = "\u{1b}[8;9~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::End).with_super_modifier()), + "Can parse a bare 'End' keypress with super" + ); + let key = "\u{1b}[11;9~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(1)).with_super_modifier()), + "Can parse a bare 'F1' keypress with super" + ); + let key = "\u{1b}[12;9~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(2)).with_super_modifier()), + "Can parse a bare 'F2' keypress with super" + ); + let key = "\u{1b}[13;9~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(3)).with_super_modifier()), + "Can parse a bare 'F3' keypress with super" + ); + let key = "\u{1b}[14;9~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(4)).with_super_modifier()), + "Can parse a bare 'F4' keypress with super" + ); + let key = "\u{1b}[15;9~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(5)).with_super_modifier()), + "Can parse a bare 'F5' keypress with super" + ); + let key = "\u{1b}[17;9~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(6)).with_super_modifier()), + "Can parse a bare 'F6' keypress with super" + ); + let key = "\u{1b}[18;9~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(7)).with_super_modifier()), + "Can parse a bare 'F7' keypress with super" + ); + let key = "\u{1b}[19;9~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(8)).with_super_modifier()), + "Can parse a bare 'F8' keypress with super" + ); + let key = "\u{1b}[20;9~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(9)).with_super_modifier()), + "Can parse a bare 'F9' keypress with super" + ); + let key = "\u{1b}[21;9~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(10)).with_super_modifier()), + "Can parse a bare 'F10' keypress with super" + ); + let key = "\u{1b}[23;9~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(11)).with_super_modifier()), + "Can parse a bare 'F11' keypress with super" + ); + let key = "\u{1b}[24;9~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(12)).with_super_modifier()), + "Can parse a bare 'F12' keypress with super" + ); + let key = "\u{1b}[1;9D"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Left).with_super_modifier()), + "Can parse a bare 'Left' keypress with super" + ); + let key = "\u{1b}[1;9C"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Right).with_super_modifier()), + "Can parse a bare 'Right' keypress with super" + ); + let key = "\u{1b}[1;9A"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Up).with_super_modifier()), + "Can parse a bare 'Up' keypress with super" + ); + let key = "\u{1b}[1;9B"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Down).with_super_modifier()), + "Can parse a bare 'Down' keypress with super" + ); + let key = "\u{1b}[1;9H"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::Home).with_super_modifier()), + "Can parse a bare 'Home' keypress with super" + ); + let key = "\u{1b}[1;9F"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::End).with_super_modifier()), + "Can parse a bare 'End' keypress with super" + ); + let key = "\u{1b}[1;9P"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(1)).with_super_modifier()), + "Can parse a bare 'F1 (alternate)' keypress with super" + ); + let key = "\u{1b}[1;9Q"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(2)).with_super_modifier()), + "Can parse a bare 'F2 (alternate)' keypress with super" + ); + let key = "\u{1b}[1;9S"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some(KeyWithModifier::new(BareKey::F(4)).with_super_modifier()), + "Can parse a bare 'F4 (alternate)' keypress with super" + ); +} + +#[test] +pub fn can_parse_keys_with_multiple_modifiers() { + use zellij_utils::data::BareKey; + let key = "\u{1b}[97;16u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some( + KeyWithModifier::new(BareKey::Char('a')) + .with_super_modifier() + .with_ctrl_modifier() + .with_alt_modifier() + .with_shift_modifier() + ), + "Can parse a bare 'a' keypress with all modifiers" + ); + let key = "\u{1b}[49;16u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some( + KeyWithModifier::new(BareKey::Char('1')) + .with_super_modifier() + .with_ctrl_modifier() + .with_alt_modifier() + .with_shift_modifier() + ), + "Can parse a bare '1' keypress with all modifiers" + ); + let key = "\u{1b}[27;16u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some( + KeyWithModifier::new(BareKey::Esc) + .with_super_modifier() + .with_ctrl_modifier() + .with_alt_modifier() + .with_shift_modifier() + ), + "Can parse a bare 'ESC' keypress with all modifiers" + ); + let key = "\u{1b}[13;16u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some( + KeyWithModifier::new(BareKey::Enter) + .with_super_modifier() + .with_ctrl_modifier() + .with_alt_modifier() + .with_shift_modifier() + ), + "Can parse a bare 'ENTER' keypress with all modifiers" + ); + let key = "\u{1b}[9;16u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some( + KeyWithModifier::new(BareKey::Tab) + .with_super_modifier() + .with_ctrl_modifier() + .with_alt_modifier() + .with_shift_modifier() + ), + "Can parse a bare 'Tab' keypress with all modifiers" + ); + let key = "\u{1b}[127;16u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some( + KeyWithModifier::new(BareKey::Backspace) + .with_super_modifier() + .with_ctrl_modifier() + .with_alt_modifier() + .with_shift_modifier() + ), + "Can parse a bare 'Backspace' keypress with all modifiers" + ); + let key = "\u{1b}[57358;16u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some( + KeyWithModifier::new(BareKey::CapsLock) + .with_super_modifier() + .with_ctrl_modifier() + .with_alt_modifier() + .with_shift_modifier() + ), + "Can parse a bare 'CapsLock' keypress with all modifiers" + ); + let key = "\u{1b}[57359;16u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some( + KeyWithModifier::new(BareKey::ScrollLock) + .with_super_modifier() + .with_ctrl_modifier() + .with_alt_modifier() + .with_shift_modifier() + ), + "Can parse a bare 'ScrollLock' keypress with all modifiers" + ); + let key = "\u{1b}[57360;16u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some( + KeyWithModifier::new(BareKey::NumLock) + .with_super_modifier() + .with_ctrl_modifier() + .with_alt_modifier() + .with_shift_modifier() + ), + "Can parse a bare 'NumLock' keypress with all modifiers" + ); + let key = "\u{1b}[57361;16u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some( + KeyWithModifier::new(BareKey::PrintScreen) + .with_super_modifier() + .with_ctrl_modifier() + .with_alt_modifier() + .with_shift_modifier() + ), + "Can parse a bare 'PrintScreen' keypress with all modifiers" + ); + let key = "\u{1b}[57362;16u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some( + KeyWithModifier::new(BareKey::Pause) + .with_super_modifier() + .with_ctrl_modifier() + .with_alt_modifier() + .with_shift_modifier() + ), + "Can parse a bare 'Pause' keypress with all modifiers" + ); + let key = "\u{1b}[57363;16u"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some( + KeyWithModifier::new(BareKey::Menu) + .with_super_modifier() + .with_ctrl_modifier() + .with_alt_modifier() + .with_shift_modifier() + ), + "Can parse a bare 'Menu' keypress with all modifiers" + ); + + let key = "\u{1b}[2;16~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some( + KeyWithModifier::new(BareKey::Insert) + .with_super_modifier() + .with_ctrl_modifier() + .with_alt_modifier() + .with_shift_modifier() + ), + "Can parse a bare 'Insert' keypress with all modifiers" + ); + let key = "\u{1b}[3;16~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some( + KeyWithModifier::new(BareKey::Delete) + .with_super_modifier() + .with_ctrl_modifier() + .with_alt_modifier() + .with_shift_modifier() + ), + "Can parse a bare 'Delete' keypress with all modifiers" + ); + let key = "\u{1b}[5;16~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some( + KeyWithModifier::new(BareKey::PageUp) + .with_super_modifier() + .with_ctrl_modifier() + .with_alt_modifier() + .with_shift_modifier() + ), + "Can parse a bare 'PageUp' keypress with all modifiers" + ); + let key = "\u{1b}[6;16~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some( + KeyWithModifier::new(BareKey::PageDown) + .with_super_modifier() + .with_ctrl_modifier() + .with_alt_modifier() + .with_shift_modifier() + ), + "Can parse a bare 'PageDown' keypress with all modifiers" + ); + let key = "\u{1b}[7;16~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some( + KeyWithModifier::new(BareKey::Home) + .with_super_modifier() + .with_ctrl_modifier() + .with_alt_modifier() + .with_shift_modifier() + ), + "Can parse a bare 'Home' keypress with all modifiers" + ); + let key = "\u{1b}[8;16~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some( + KeyWithModifier::new(BareKey::End) + .with_super_modifier() + .with_ctrl_modifier() + .with_alt_modifier() + .with_shift_modifier() + ), + "Can parse a bare 'End' keypress with all modifiers" + ); + let key = "\u{1b}[11;16~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some( + KeyWithModifier::new(BareKey::F(1)) + .with_super_modifier() + .with_ctrl_modifier() + .with_alt_modifier() + .with_shift_modifier() + ), + "Can parse a bare 'F1' keypress with all modifiers" + ); + let key = "\u{1b}[12;16~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some( + KeyWithModifier::new(BareKey::F(2)) + .with_super_modifier() + .with_ctrl_modifier() + .with_alt_modifier() + .with_shift_modifier() + ), + "Can parse a bare 'F2' keypress with all modifiers" + ); + let key = "\u{1b}[13;16~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some( + KeyWithModifier::new(BareKey::F(3)) + .with_super_modifier() + .with_ctrl_modifier() + .with_alt_modifier() + .with_shift_modifier() + ), + "Can parse a bare 'F3' keypress with all modifiers" + ); + let key = "\u{1b}[14;16~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some( + KeyWithModifier::new(BareKey::F(4)) + .with_super_modifier() + .with_ctrl_modifier() + .with_alt_modifier() + .with_shift_modifier() + ), + "Can parse a bare 'F4' keypress with all modifiers" + ); + let key = "\u{1b}[15;16~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some( + KeyWithModifier::new(BareKey::F(5)) + .with_super_modifier() + .with_ctrl_modifier() + .with_alt_modifier() + .with_shift_modifier() + ), + "Can parse a bare 'F5' keypress with all modifiers" + ); + let key = "\u{1b}[17;16~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some( + KeyWithModifier::new(BareKey::F(6)) + .with_super_modifier() + .with_ctrl_modifier() + .with_alt_modifier() + .with_shift_modifier() + ), + "Can parse a bare 'F6' keypress with all modifiers" + ); + let key = "\u{1b}[18;16~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some( + KeyWithModifier::new(BareKey::F(7)) + .with_super_modifier() + .with_ctrl_modifier() + .with_alt_modifier() + .with_shift_modifier() + ), + "Can parse a bare 'F7' keypress with all modifiers" + ); + let key = "\u{1b}[19;16~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some( + KeyWithModifier::new(BareKey::F(8)) + .with_super_modifier() + .with_ctrl_modifier() + .with_alt_modifier() + .with_shift_modifier() + ), + "Can parse a bare 'F8' keypress with all modifiers" + ); + let key = "\u{1b}[20;16~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some( + KeyWithModifier::new(BareKey::F(9)) + .with_super_modifier() + .with_ctrl_modifier() + .with_alt_modifier() + .with_shift_modifier() + ), + "Can parse a bare 'F9' keypress with all modifiers" + ); + let key = "\u{1b}[21;16~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some( + KeyWithModifier::new(BareKey::F(10)) + .with_super_modifier() + .with_ctrl_modifier() + .with_alt_modifier() + .with_shift_modifier() + ), + "Can parse a bare 'F10' keypress with all modifiers" + ); + let key = "\u{1b}[23;16~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some( + KeyWithModifier::new(BareKey::F(11)) + .with_super_modifier() + .with_ctrl_modifier() + .with_alt_modifier() + .with_shift_modifier() + ), + "Can parse a bare 'F11' keypress with all modifiers" + ); + let key = "\u{1b}[24;16~"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some( + KeyWithModifier::new(BareKey::F(12)) + .with_super_modifier() + .with_ctrl_modifier() + .with_alt_modifier() + .with_shift_modifier() + ), + "Can parse a bare 'F12' keypress with all modifiers" + ); + let key = "\u{1b}[1;16D"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some( + KeyWithModifier::new(BareKey::Left) + .with_super_modifier() + .with_ctrl_modifier() + .with_alt_modifier() + .with_shift_modifier() + ), + "Can parse a bare 'Left' keypress with all modifiers" + ); + let key = "\u{1b}[1;16C"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some( + KeyWithModifier::new(BareKey::Right) + .with_super_modifier() + .with_ctrl_modifier() + .with_alt_modifier() + .with_shift_modifier() + ), + "Can parse a bare 'Right' keypress with all modifiers" + ); + let key = "\u{1b}[1;16A"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some( + KeyWithModifier::new(BareKey::Up) + .with_super_modifier() + .with_ctrl_modifier() + .with_alt_modifier() + .with_shift_modifier() + ), + "Can parse a bare 'Up' keypress with all modifiers" + ); + let key = "\u{1b}[1;16B"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some( + KeyWithModifier::new(BareKey::Down) + .with_super_modifier() + .with_ctrl_modifier() + .with_alt_modifier() + .with_shift_modifier() + ), + "Can parse a bare 'Down' keypress with all modifiers" + ); + let key = "\u{1b}[1;16H"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some( + KeyWithModifier::new(BareKey::Home) + .with_super_modifier() + .with_ctrl_modifier() + .with_alt_modifier() + .with_shift_modifier() + ), + "Can parse a bare 'Home' keypress with all modifiers" + ); + let key = "\u{1b}[1;16F"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some( + KeyWithModifier::new(BareKey::End) + .with_super_modifier() + .with_ctrl_modifier() + .with_alt_modifier() + .with_shift_modifier() + ), + "Can parse a bare 'End' keypress with all modifiers" + ); + let key = "\u{1b}[1;16P"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some( + KeyWithModifier::new(BareKey::F(1)) + .with_super_modifier() + .with_ctrl_modifier() + .with_alt_modifier() + .with_shift_modifier() + ), + "Can parse a bare 'F1 (superernate)' keypress with all modifiers" + ); + let key = "\u{1b}[1;16Q"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some( + KeyWithModifier::new(BareKey::F(2)) + .with_super_modifier() + .with_ctrl_modifier() + .with_alt_modifier() + .with_shift_modifier() + ), + "Can parse a bare 'F2 (superernate)' keypress with all modifiers" + ); + let key = "\u{1b}[1;16S"; + assert_eq!( + KittyKeyboardParser::new().parse(&key.as_bytes()), + Some( + KeyWithModifier::new(BareKey::F(4)) + .with_super_modifier() + .with_ctrl_modifier() + .with_alt_modifier() + .with_shift_modifier() + ), + "Can parse a bare 'F4 (superernate)' keypress with all modifiers" + ); +} diff --git a/zellij-client/src/lib.rs b/zellij-client/src/lib.rs index 5e2f8060..e0cd195e 100644 --- a/zellij-client/src/lib.rs +++ b/zellij-client/src/lib.rs @@ -3,6 +3,7 @@ pub mod os_input_output; pub mod cli_client; mod command_is_executing; mod input_handler; +mod keyboard_parser; pub mod old_config_converter; mod stdin_ansi_parser; mod stdin_handler; @@ -24,7 +25,7 @@ use crate::{ use zellij_utils::{ channels::{self, ChannelWithContext, SenderWithContext}, consts::{set_permissions, ZELLIJ_SOCK_DIR}, - data::{ClientId, ConnectToSession, InputMode, Style}, + data::{ClientId, ConnectToSession, InputMode, KeyWithModifier, Style}, envs, errors::{ClientContext, ContextType, ErrorInstruction}, input::{config::Config, options::Options}, @@ -152,6 +153,7 @@ impl ClientInfo { #[derive(Debug, Clone)] pub(crate) enum InputInstruction { KeyEvent(InputEvent, Vec), + KeyWithModifierEvent(KeyWithModifier, Vec), SwitchToMode(InputMode), AnsiStdinInstructions(Vec), StartedParsing, @@ -177,16 +179,21 @@ pub fn start_client( } info!("Starting Zellij client!"); + let explicitly_disable_kitty_keyboard_protocol = config_options + .support_kitty_keyboard_protocol + .map(|e| !e) + .unwrap_or(false); let mut reconnect_to_session = None; let clear_client_terminal_attributes = "\u{1b}[?1l\u{1b}=\u{1b}[r\u{1b}[?1000l\u{1b}[?1002l\u{1b}[?1003l\u{1b}[?1005l\u{1b}[?1006l\u{1b}[?12l"; let take_snapshot = "\u{1b}[?1049h"; let bracketed_paste = "\u{1b}[?2004h"; + let enter_kitty_keyboard_mode = "\u{1b}[>1u"; os_input.unset_raw_mode(0).unwrap(); if !is_a_reconnect { // we don't do this for a reconnect because our controlling terminal already has the // attributes we want from it, and some terminals don't treat these atomically (looking at - // your Windows Terminal...) + // you Windows Terminal...) let _ = os_input .get_stdout_writer() .write(take_snapshot.as_bytes()) @@ -195,6 +202,12 @@ pub fn start_client( .get_stdout_writer() .write(clear_client_terminal_attributes.as_bytes()) .unwrap(); + if !explicitly_disable_kitty_keyboard_protocol { + let _ = os_input + .get_stdout_writer() + .write(enter_kitty_keyboard_mode.as_bytes()) + .unwrap(); + } } envs::set_zellij("0".to_string()); config.env.set_vars(); @@ -299,7 +312,14 @@ pub fn start_client( let os_input = os_input.clone(); let send_input_instructions = send_input_instructions.clone(); let stdin_ansi_parser = stdin_ansi_parser.clone(); - move || stdin_loop(os_input, send_input_instructions, stdin_ansi_parser) + move || { + stdin_loop( + os_input, + send_input_instructions, + stdin_ansi_parser, + explicitly_disable_kitty_keyboard_protocol, + ) + } }); let _input_thread = thread::Builder::new() @@ -533,6 +553,11 @@ pub fn start_client( info!("{}", exit_msg); os_input.unset_raw_mode(0).unwrap(); let mut stdout = os_input.get_stdout_writer(); + let exit_kitty_keyboard_mode = "\u{1b}[<1u"; + if !explicitly_disable_kitty_keyboard_protocol { + let _ = stdout.write(exit_kitty_keyboard_mode.as_bytes()).unwrap(); + stdout.flush().unwrap(); + } let _ = stdout.write(goodbye_message.as_bytes()).unwrap(); stdout.flush().unwrap(); } else { diff --git a/zellij-client/src/stdin_handler.rs b/zellij-client/src/stdin_handler.rs index eae0958b..a1235621 100644 --- a/zellij-client/src/stdin_handler.rs +++ b/zellij-client/src/stdin_handler.rs @@ -1,3 +1,4 @@ +use crate::keyboard_parser::KittyKeyboardParser; use crate::os_input_output::ClientOsApi; use crate::stdin_ansi_parser::StdinAnsiParser; use crate::InputInstruction; @@ -23,6 +24,7 @@ pub(crate) fn stdin_loop( mut os_input: Box, send_input_instructions: SenderWithContext, stdin_ansi_parser: Arc>, + explicitly_disable_kitty_keyboard_protocol: bool, ) { let mut holding_mouse = false; let mut input_parser = InputParser::new(); @@ -85,6 +87,24 @@ pub(crate) fn stdin_loop( .write_cache(ansi_stdin_events.drain(..).collect()); } current_buffer.append(&mut buf.to_vec()); + + if !explicitly_disable_kitty_keyboard_protocol { + // first we try to parse with the KittyKeyboardParser + // if we fail, we try to parse normally + match KittyKeyboardParser::new().parse(&buf) { + Some(key_with_modifier) => { + send_input_instructions + .send(InputInstruction::KeyWithModifierEvent( + key_with_modifier, + current_buffer.drain(..).collect(), + )) + .unwrap(); + continue; + }, + None => {}, + } + } + let maybe_more = false; // read_from_stdin should (hopefully) always empty the STDIN buffer completely let mut events = vec![]; input_parser.parse( diff --git a/zellij-server/src/panes/grid.rs b/zellij-server/src/panes/grid.rs index 3109cb10..8b532bb4 100644 --- a/zellij-server/src/panes/grid.rs +++ b/zellij-server/src/panes/grid.rs @@ -362,6 +362,9 @@ pub struct Grid { debug: bool, arrow_fonts: bool, styled_underlines: bool, + pub supports_kitty_keyboard_protocol: bool, // has the app requested kitty keyboard support? + explicitly_disable_kitty_keyboard_protocol: bool, // has kitty keyboard support been explicitly + // disabled by user config? } #[derive(Clone, Debug)] @@ -450,6 +453,7 @@ impl Grid { debug: bool, arrow_fonts: bool, styled_underlines: bool, + explicitly_disable_kitty_keyboard_protocol: bool, ) -> Self { let sixel_grid = SixelGrid::new(character_cell_size.clone(), sixel_image_store); // make sure this is initialized as it is used internally @@ -505,6 +509,8 @@ impl Grid { arrow_fonts, styled_underlines, lock_renders: false, + supports_kitty_keyboard_protocol: false, + explicitly_disable_kitty_keyboard_protocol, } } pub fn render_full_viewport(&mut self) { @@ -2543,6 +2549,7 @@ impl Perform for Grid { &mut self.viewport, &mut self.cursor, &mut self.sixel_grid, + &mut self.supports_kitty_keyboard_protocol, ); } self.alternate_screen_state = None; @@ -2636,6 +2643,10 @@ impl Perform for Grid { &mut self.cursor, Cursor::new(0, 0, self.styled_underlines), ); + let current_supports_kitty_keyboard_protocol = std::mem::replace( + &mut self.supports_kitty_keyboard_protocol, + false, + ); let sixel_image_store = self.sixel_grid.sixel_image_store.clone(); let alternate_sixelgrid = std::mem::replace( &mut self.sixel_grid, @@ -2646,6 +2657,7 @@ impl Perform for Grid { current_viewport, current_cursor, alternate_sixelgrid, + current_supports_kitty_keyboard_protocol, )); self.clear_viewport_before_rendering = true; self.scrollback_buffer_lines = @@ -2825,6 +2837,27 @@ impl Perform for Grid { } } else if c == 's' { self.save_cursor_position(); + } else if c == 'u' && intermediates == &[b'>'] { + // Zellij only supports the first "progressive enhancement" layer of the kitty keyboard + // protocol + if !self.explicitly_disable_kitty_keyboard_protocol { + self.supports_kitty_keyboard_protocol = true; + } + } else if c == 'u' && intermediates == &[b'<'] { + // Zellij only supports the first "progressive enhancement" layer of the kitty keyboard + // protocol + if !self.explicitly_disable_kitty_keyboard_protocol { + self.supports_kitty_keyboard_protocol = false; + } + } else if c == 'u' && intermediates == &[b'?'] { + // Zellij only supports the first "progressive enhancement" layer of the kitty keyboard + // protocol + let reply = if self.supports_kitty_keyboard_protocol { + "\u{1b}[?1u" + } else { + "\u{1b}[?0u" + }; + self.pending_messages_to_pty.push(reply.as_bytes().to_vec()); } else if c == 'u' { self.restore_cursor_position(); } else if c == '@' { @@ -3084,6 +3117,7 @@ pub struct AlternateScreenState { viewport: Vec, cursor: Cursor, sixel_grid: SixelGrid, + supports_kitty_keyboard_protocol: bool, } impl AlternateScreenState { pub fn new( @@ -3091,12 +3125,14 @@ impl AlternateScreenState { viewport: Vec, cursor: Cursor, sixel_grid: SixelGrid, + supports_kitty_keyboard_protocol: bool, ) -> Self { AlternateScreenState { lines_above, viewport, cursor, sixel_grid, + supports_kitty_keyboard_protocol, } } pub fn apply_contents_to( @@ -3105,11 +3141,16 @@ impl AlternateScreenState { viewport: &mut Vec, cursor: &mut Cursor, sixel_grid: &mut SixelGrid, + supports_kitty_keyboard_protocol: &mut bool, ) { std::mem::swap(&mut self.lines_above, lines_above); std::mem::swap(&mut self.viewport, viewport); std::mem::swap(&mut self.cursor, cursor); std::mem::swap(&mut self.sixel_grid, sixel_grid); + std::mem::swap( + &mut self.supports_kitty_keyboard_protocol, + supports_kitty_keyboard_protocol, + ); } } diff --git a/zellij-server/src/panes/plugin_pane.rs b/zellij-server/src/panes/plugin_pane.rs index 0ddcd3a2..f7ad3871 100644 --- a/zellij-server/src/panes/plugin_pane.rs +++ b/zellij-server/src/panes/plugin_pane.rs @@ -2,7 +2,12 @@ use std::collections::{BTreeSet, HashMap}; use std::time::Instant; use crate::output::{CharacterChunk, SixelImageChunk}; -use crate::panes::{grid::Grid, sixel::SixelImageStore, LinkHandler, PaneId}; +use crate::panes::{ + grid::Grid, + sixel::SixelImageStore, + terminal_pane::{BRACKETED_PASTE_BEGIN, BRACKETED_PASTE_END}, + LinkHandler, PaneId, +}; use crate::plugins::PluginInstruction; use crate::pty::VteBytes; use crate::tab::{AdjustedInput, Pane}; @@ -13,7 +18,9 @@ use crate::ui::{ use crate::ClientId; use std::cell::RefCell; use std::rc::Rc; -use zellij_utils::data::{PermissionStatus, PermissionType, PluginPermission}; +use zellij_utils::data::{ + BareKey, KeyWithModifier, PermissionStatus, PermissionType, PluginPermission, +}; use zellij_utils::pane_size::{Offset, SizeInPixels}; use zellij_utils::position::Position; use zellij_utils::{ @@ -39,6 +46,7 @@ macro_rules! get_or_create_grid { ($self:ident, $client_id:ident) => {{ let rows = $self.get_content_rows(); let cols = $self.get_content_columns(); + let explicitly_disable_kitty_keyboard_protocol = false; // N/A for plugins $self.grids.entry($client_id).or_insert_with(|| { let mut grid = Grid::new( @@ -53,6 +61,7 @@ macro_rules! get_or_create_grid { $self.debug, $self.arrow_fonts, $self.styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); grid.hide_cursor(); grid @@ -232,24 +241,54 @@ impl Pane for PluginPane { fn cursor_coordinates(&self) -> Option<(usize, usize)> { None } - fn adjust_input_to_terminal(&mut self, input_bytes: Vec) -> Option { + fn adjust_input_to_terminal( + &mut self, + key_with_modifier: &Option, + raw_input_bytes: Vec, + _raw_input_bytes_are_kitty: bool, + ) -> Option { if let Some(requesting_permissions) = &self.requesting_permissions { let permissions = requesting_permissions.permissions.clone(); - match input_bytes.as_slice() { - // Y or y - &[89] | &[121] => Some(AdjustedInput::PermissionRequestResult( - permissions, - PermissionStatus::Granted, - )), - // N or n - &[78] | &[110] => Some(AdjustedInput::PermissionRequestResult( - permissions, - PermissionStatus::Denied, - )), - _ => None, + if let Some(key_with_modifier) = key_with_modifier { + match key_with_modifier.bare_key { + BareKey::Char('y') if key_with_modifier.has_no_modifiers() => { + Some(AdjustedInput::PermissionRequestResult( + permissions, + PermissionStatus::Granted, + )) + }, + BareKey::Char('n') if key_with_modifier.has_no_modifiers() => { + Some(AdjustedInput::PermissionRequestResult( + permissions, + PermissionStatus::Denied, + )) + }, + _ => None, + } + } else { + match raw_input_bytes.as_slice() { + // Y or y + &[89] | &[121] => Some(AdjustedInput::PermissionRequestResult( + permissions, + PermissionStatus::Granted, + )), + // N or n + &[78] | &[110] => Some(AdjustedInput::PermissionRequestResult( + permissions, + PermissionStatus::Denied, + )), + _ => None, + } } + } else if let Some(key_with_modifier) = key_with_modifier { + Some(AdjustedInput::WriteKeyToPlugin(key_with_modifier.clone())) + } else if raw_input_bytes.as_slice() == BRACKETED_PASTE_BEGIN + || raw_input_bytes.as_slice() == BRACKETED_PASTE_END + { + // plugins do not need bracketed paste + None } else { - Some(AdjustedInput::WriteBytesToTerminal(input_bytes)) + Some(AdjustedInput::WriteBytesToTerminal(raw_input_bytes)) } } fn position_and_size(&self) -> PaneGeom { diff --git a/zellij-server/src/panes/terminal_pane.rs b/zellij-server/src/panes/terminal_pane.rs index ab36664f..56c7735e 100644 --- a/zellij-server/src/panes/terminal_pane.rs +++ b/zellij-server/src/panes/terminal_pane.rs @@ -16,7 +16,10 @@ use std::time::{self, Instant}; use zellij_utils::input::command::RunCommand; use zellij_utils::pane_size::Offset; use zellij_utils::{ - data::{InputMode, Palette, PaletteColor, PaneId as ZellijUtilsPaneId, Style}, + data::{ + BareKey, InputMode, KeyWithModifier, Palette, PaletteColor, PaneId as ZellijUtilsPaneId, + Style, + }, errors::prelude::*, input::layout::Run, pane_size::PaneGeom, @@ -37,8 +40,8 @@ const UP_ARROW: &[u8] = &[27, 91, 65]; const DOWN_ARROW: &[u8] = &[27, 91, 66]; const HOME_KEY: &[u8] = &[27, 91, 72]; const END_KEY: &[u8] = &[27, 91, 70]; -const BRACKETED_PASTE_BEGIN: &[u8] = &[27, 91, 50, 48, 48, 126]; -const BRACKETED_PASTE_END: &[u8] = &[27, 91, 50, 48, 49, 126]; +pub const BRACKETED_PASTE_BEGIN: &[u8] = &[27, 91, 50, 48, 48, 126]; +pub const BRACKETED_PASTE_END: &[u8] = &[27, 91, 50, 48, 49, 126]; const ENTER_NEWLINE: &[u8] = &[10]; const ESC: &[u8] = &[27]; const ENTER_CARRIAGE_RETURN: &[u8] = &[13]; @@ -190,92 +193,71 @@ impl Pane for TerminalPane { .cursor_coordinates() .map(|(x, y)| (x + left, y + top)) } - fn adjust_input_to_terminal(&mut self, input_bytes: Vec) -> Option { + fn adjust_input_to_terminal( + &mut self, + key_with_modifier: &Option, + raw_input_bytes: Vec, + raw_input_bytes_are_kitty: bool, + ) -> Option { // there are some cases in which the terminal state means that input sent to it // needs to be adjusted. // here we match against those cases - if need be, we adjust the input and if not // we send back the original input - if let Some((_exit_status, _is_first_run, run_command)) = &self.is_held { - match input_bytes.as_slice() { - ENTER_CARRIAGE_RETURN | ENTER_NEWLINE | SPACE => { - let run_command = run_command.clone(); - self.is_held = None; - self.grid.reset_terminal_state(); - self.set_should_render(true); - self.remove_banner(); - Some(AdjustedInput::ReRunCommandInThisPane(run_command)) - }, - ESC => { - // Drop to shell in the same working directory as the command was run - let working_dir = run_command.cwd.clone(); - self.is_held = None; - self.grid.reset_terminal_state(); - self.set_should_render(true); - self.remove_banner(); - Some(AdjustedInput::DropToShellInThisPane { working_dir }) - }, - CTRL_C => Some(AdjustedInput::CloseThisPane), - _ => None, - } - } else { - if self.grid.new_line_mode { - if let &[13] = input_bytes.as_slice() { - // LNM - carriage return is followed by linefeed - return Some(AdjustedInput::WriteBytesToTerminal( - "\u{0d}\u{0a}".as_bytes().to_vec(), - )); - }; - } - if self.grid.cursor_key_mode { - match input_bytes.as_slice() { - LEFT_ARROW => { - return Some(AdjustedInput::WriteBytesToTerminal( - AnsiEncoding::Left.as_vec_bytes(), - )); - }, - RIGHT_ARROW => { - return Some(AdjustedInput::WriteBytesToTerminal( - AnsiEncoding::Right.as_vec_bytes(), - )); - }, - UP_ARROW => { - return Some(AdjustedInput::WriteBytesToTerminal( - AnsiEncoding::Up.as_vec_bytes(), - )); - }, - DOWN_ARROW => { - return Some(AdjustedInput::WriteBytesToTerminal( - AnsiEncoding::Down.as_vec_bytes(), - )); - }, - HOME_KEY => { - return Some(AdjustedInput::WriteBytesToTerminal( - AnsiEncoding::Home.as_vec_bytes(), - )); - }, - END_KEY => { - return Some(AdjustedInput::WriteBytesToTerminal( - AnsiEncoding::End.as_vec_bytes(), - )); - }, - _ => {}, - }; + if !self.grid.bracketed_paste_mode { + // Zellij itself operates in bracketed paste mode, so the terminal sends these + // instructions (bracketed paste start and bracketed paste end respectively) + // when pasting input. We only need to make sure not to send them to terminal + // panes who do not work in this mode + match raw_input_bytes.as_slice() { + BRACKETED_PASTE_BEGIN | BRACKETED_PASTE_END => { + return Some(AdjustedInput::WriteBytesToTerminal(vec![])) + }, + _ => {}, } + } - if !self.grid.bracketed_paste_mode { - // Zellij itself operates in bracketed paste mode, so the terminal sends these - // instructions (bracketed paste start and bracketed paste end respectively) - // when pasting input. We only need to make sure not to send them to terminal - // panes who do not work in this mode - match input_bytes.as_slice() { - BRACKETED_PASTE_BEGIN | BRACKETED_PASTE_END => { - return Some(AdjustedInput::WriteBytesToTerminal(vec![])) - }, - _ => {}, + if self.is_held.is_some() { + if key_with_modifier + .as_ref() + .map(|k| k.is_key_without_modifier(BareKey::Enter)) + .unwrap_or(false) + { + self.handle_held_run() + } else if key_with_modifier + .as_ref() + .map(|k| k.is_key_without_modifier(BareKey::Esc)) + .unwrap_or(false) + { + self.handle_held_drop_to_shell() + } else if key_with_modifier + .as_ref() + .map(|k| k.is_key_with_ctrl_modifier(BareKey::Char('c'))) + .unwrap_or(false) + { + Some(AdjustedInput::CloseThisPane) + } else { + match raw_input_bytes.as_slice() { + ENTER_CARRIAGE_RETURN | ENTER_NEWLINE | SPACE => self.handle_held_run(), + ESC => self.handle_held_drop_to_shell(), + CTRL_C => Some(AdjustedInput::CloseThisPane), + _ => None, } } - Some(AdjustedInput::WriteBytesToTerminal(input_bytes)) + } else { + if self.grid.supports_kitty_keyboard_protocol { + self.adjust_input_to_terminal_with_kitty_keyboard_protocol( + key_with_modifier, + raw_input_bytes, + raw_input_bytes_are_kitty, + ) + } else { + self.adjust_input_to_terminal_without_kitty_keyboard_protocol( + key_with_modifier, + raw_input_bytes, + raw_input_bytes_are_kitty, + ) + } } } fn position_and_size(&self) -> PaneGeom { @@ -804,6 +786,7 @@ impl TerminalPane { debug: bool, arrow_fonts: bool, styled_underlines: bool, + explicitly_disable_keyboard_protocol: bool, ) -> TerminalPane { let initial_pane_title = initial_pane_title.unwrap_or_else(|| format!("Pane #{}", pane_index)); @@ -819,6 +802,7 @@ impl TerminalPane { debug, arrow_fonts, styled_underlines, + explicitly_disable_keyboard_protocol, ); TerminalPane { frame: HashMap::new(), @@ -910,6 +894,131 @@ impl TerminalPane { self.banner = None; } } + fn adjust_input_to_terminal_with_kitty_keyboard_protocol( + &self, + key: &Option, + raw_input_bytes: Vec, + raw_input_bytes_are_kitty: bool, + ) -> Option { + if raw_input_bytes_are_kitty { + Some(AdjustedInput::WriteBytesToTerminal(raw_input_bytes)) + } else { + // here what happens is that the host terminal is operating in non "kitty keys" mode, but + // this terminal pane *is* operating in "kitty keys" mode - so we need to serialize the "non kitty" + // key to a "kitty key" + key.as_ref() + .and_then(|k| k.serialize_kitty()) + .map(|s| AdjustedInput::WriteBytesToTerminal(s.as_bytes().to_vec())) + } + } + fn adjust_input_to_terminal_without_kitty_keyboard_protocol( + &self, + key: &Option, + raw_input_bytes: Vec, + raw_input_bytes_are_kitty: bool, + ) -> Option { + if self.grid.new_line_mode { + let key_is_enter = raw_input_bytes.as_slice() == &[13] + || key + .as_ref() + .map(|k| k.is_key_without_modifier(BareKey::Enter)) + .unwrap_or(false); + if key_is_enter { + // LNM - carriage return is followed by linefeed + return Some(AdjustedInput::WriteBytesToTerminal( + "\u{0d}\u{0a}".as_bytes().to_vec(), + )); + }; + } + if self.grid.cursor_key_mode { + let key_is_left_arrow = raw_input_bytes.as_slice() == LEFT_ARROW + || key + .as_ref() + .map(|k| k.is_key_without_modifier(BareKey::Left)) + .unwrap_or(false); + let key_is_right_arrow = raw_input_bytes.as_slice() == RIGHT_ARROW + || key + .as_ref() + .map(|k| k.is_key_without_modifier(BareKey::Right)) + .unwrap_or(false); + let key_is_up_arrow = raw_input_bytes.as_slice() == UP_ARROW + || key + .as_ref() + .map(|k| k.is_key_without_modifier(BareKey::Up)) + .unwrap_or(false); + let key_is_down_arrow = raw_input_bytes.as_slice() == DOWN_ARROW + || key + .as_ref() + .map(|k| k.is_key_without_modifier(BareKey::Down)) + .unwrap_or(false); + let key_is_home_key = raw_input_bytes.as_slice() == HOME_KEY + || key + .as_ref() + .map(|k| k.is_key_without_modifier(BareKey::Home)) + .unwrap_or(false); + let key_is_end_key = raw_input_bytes.as_slice() == END_KEY + || key + .as_ref() + .map(|k| k.is_key_without_modifier(BareKey::End)) + .unwrap_or(false); + if key_is_left_arrow { + return Some(AdjustedInput::WriteBytesToTerminal( + AnsiEncoding::Left.as_vec_bytes(), + )); + } else if key_is_right_arrow { + return Some(AdjustedInput::WriteBytesToTerminal( + AnsiEncoding::Right.as_vec_bytes(), + )); + } else if key_is_up_arrow { + return Some(AdjustedInput::WriteBytesToTerminal( + AnsiEncoding::Up.as_vec_bytes(), + )); + } else if key_is_down_arrow { + return Some(AdjustedInput::WriteBytesToTerminal( + AnsiEncoding::Down.as_vec_bytes(), + )); + } else if key_is_home_key { + return Some(AdjustedInput::WriteBytesToTerminal( + AnsiEncoding::Home.as_vec_bytes(), + )); + } else if key_is_end_key { + return Some(AdjustedInput::WriteBytesToTerminal( + AnsiEncoding::End.as_vec_bytes(), + )); + } + } + if raw_input_bytes_are_kitty { + // here what happens is that the host terminal is operating in "kitty keys" mode, but + // this terminal pane is not - so we need to serialize the kitty key to "non kitty" if + // possible - if not possible (eg. with multiple modifiers), we'll return a None here + // and write nothing to the terminal pane + key.as_ref() + .and_then(|k| k.serialize_non_kitty()) + .map(|s| AdjustedInput::WriteBytesToTerminal(s.as_bytes().to_vec())) + } else { + Some(AdjustedInput::WriteBytesToTerminal(raw_input_bytes)) + } + } + fn handle_held_run(&mut self) -> Option { + self.is_held.take().map(|(_, _, run_command)| { + self.is_held = None; + self.grid.reset_terminal_state(); + self.set_should_render(true); + self.remove_banner(); + AdjustedInput::ReRunCommandInThisPane(run_command.clone()) + }) + } + fn handle_held_drop_to_shell(&mut self) -> Option { + self.is_held.take().map(|(_, _, run_command)| { + // Drop to shell in the same working directory as the command was run + let working_dir = run_command.cwd.clone(); + self.is_held = None; + self.grid.reset_terminal_state(); + self.set_should_render(true); + self.remove_banner(); + AdjustedInput::DropToShellInThisPane { working_dir } + }) + } } #[cfg(test)] diff --git a/zellij-server/src/panes/unit/grid_tests.rs b/zellij-server/src/panes/unit/grid_tests.rs index 2459796b..4b8b10c2 100644 --- a/zellij-server/src/panes/unit/grid_tests.rs +++ b/zellij-server/src/panes/unit/grid_tests.rs @@ -32,6 +32,7 @@ fn vttest1_0() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 41, 110, @@ -44,6 +45,7 @@ fn vttest1_0() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "vttest1-0"; let content = read_fixture(fixture_name); @@ -61,6 +63,7 @@ fn vttest1_1() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 41, 110, @@ -73,6 +76,7 @@ fn vttest1_1() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "vttest1-1"; let content = read_fixture(fixture_name); @@ -90,6 +94,7 @@ fn vttest1_2() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 41, 110, @@ -102,6 +107,7 @@ fn vttest1_2() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "vttest1-2"; let content = read_fixture(fixture_name); @@ -119,6 +125,7 @@ fn vttest1_3() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 41, 110, @@ -131,6 +138,7 @@ fn vttest1_3() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "vttest1-3"; let content = read_fixture(fixture_name); @@ -148,6 +156,7 @@ fn vttest1_4() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 41, 110, @@ -160,6 +169,7 @@ fn vttest1_4() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "vttest1-4"; let content = read_fixture(fixture_name); @@ -177,6 +187,7 @@ fn vttest1_5() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 41, 110, @@ -189,6 +200,7 @@ fn vttest1_5() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "vttest1-5"; let content = read_fixture(fixture_name); @@ -206,6 +218,7 @@ fn vttest2_0() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 41, 110, @@ -218,6 +231,7 @@ fn vttest2_0() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "vttest2-0"; let content = read_fixture(fixture_name); @@ -235,6 +249,7 @@ fn vttest2_1() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 41, 110, @@ -247,6 +262,7 @@ fn vttest2_1() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "vttest2-1"; let content = read_fixture(fixture_name); @@ -264,6 +280,7 @@ fn vttest2_2() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 41, 110, @@ -276,6 +293,7 @@ fn vttest2_2() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "vttest2-2"; let content = read_fixture(fixture_name); @@ -293,6 +311,7 @@ fn vttest2_3() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 41, 110, @@ -305,6 +324,7 @@ fn vttest2_3() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "vttest2-3"; let content = read_fixture(fixture_name); @@ -322,6 +342,7 @@ fn vttest2_4() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 41, 110, @@ -334,6 +355,7 @@ fn vttest2_4() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "vttest2-4"; let content = read_fixture(fixture_name); @@ -351,6 +373,7 @@ fn vttest2_5() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 41, 110, @@ -363,6 +386,7 @@ fn vttest2_5() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "vttest2-5"; let content = read_fixture(fixture_name); @@ -380,6 +404,7 @@ fn vttest2_6() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 41, 110, @@ -392,6 +417,7 @@ fn vttest2_6() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "vttest2-6"; let content = read_fixture(fixture_name); @@ -409,6 +435,7 @@ fn vttest2_7() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 41, 110, @@ -421,6 +448,7 @@ fn vttest2_7() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "vttest2-7"; let content = read_fixture(fixture_name); @@ -438,6 +466,7 @@ fn vttest2_8() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 41, 110, @@ -450,6 +479,7 @@ fn vttest2_8() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "vttest2-8"; let content = read_fixture(fixture_name); @@ -467,6 +497,7 @@ fn vttest2_9() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 41, 110, @@ -479,6 +510,7 @@ fn vttest2_9() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "vttest2-9"; let content = read_fixture(fixture_name); @@ -496,6 +528,7 @@ fn vttest2_10() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 41, 110, @@ -508,6 +541,7 @@ fn vttest2_10() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "vttest2-10"; let content = read_fixture(fixture_name); @@ -525,6 +559,7 @@ fn vttest2_11() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 41, 110, @@ -537,6 +572,7 @@ fn vttest2_11() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "vttest2-11"; let content = read_fixture(fixture_name); @@ -554,6 +590,7 @@ fn vttest2_12() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 41, 110, @@ -566,6 +603,7 @@ fn vttest2_12() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "vttest2-12"; let content = read_fixture(fixture_name); @@ -583,6 +621,7 @@ fn vttest2_13() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 41, 110, @@ -595,6 +634,7 @@ fn vttest2_13() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "vttest2-13"; let content = read_fixture(fixture_name); @@ -612,6 +652,7 @@ fn vttest2_14() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 41, 110, @@ -624,6 +665,7 @@ fn vttest2_14() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "vttest2-14"; let content = read_fixture(fixture_name); @@ -641,6 +683,7 @@ fn vttest3_0() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 41, 110, @@ -653,6 +696,7 @@ fn vttest3_0() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "vttest3-0"; let content = read_fixture(fixture_name); @@ -670,6 +714,7 @@ fn vttest8_0() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 51, 97, @@ -682,6 +727,7 @@ fn vttest8_0() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "vttest8-0"; let content = read_fixture(fixture_name); @@ -699,6 +745,7 @@ fn vttest8_1() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 51, 97, @@ -711,6 +758,7 @@ fn vttest8_1() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "vttest8-1"; let content = read_fixture(fixture_name); @@ -728,6 +776,7 @@ fn vttest8_2() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 51, 97, @@ -740,6 +789,7 @@ fn vttest8_2() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "vttest8-2"; let content = read_fixture(fixture_name); @@ -757,6 +807,7 @@ fn vttest8_3() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 51, 97, @@ -769,6 +820,7 @@ fn vttest8_3() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "vttest8-3"; let content = read_fixture(fixture_name); @@ -786,6 +838,7 @@ fn vttest8_4() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 51, 97, @@ -798,6 +851,7 @@ fn vttest8_4() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "vttest8-4"; let content = read_fixture(fixture_name); @@ -815,6 +869,7 @@ fn vttest8_5() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 51, 97, @@ -827,6 +882,7 @@ fn vttest8_5() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "vttest8-5"; let content = read_fixture(fixture_name); @@ -844,6 +900,7 @@ fn csi_b() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 51, 97, @@ -856,6 +913,7 @@ fn csi_b() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "csi-b"; let content = read_fixture(fixture_name); @@ -873,6 +931,7 @@ fn csi_capital_i() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 51, 97, @@ -885,6 +944,7 @@ fn csi_capital_i() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "csi-capital-i"; let content = read_fixture(fixture_name); @@ -902,6 +962,7 @@ fn csi_capital_z() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 51, 97, @@ -914,6 +975,7 @@ fn csi_capital_z() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "csi-capital-z"; let content = read_fixture(fixture_name); @@ -931,6 +993,7 @@ fn terminal_reports() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 51, 97, @@ -943,6 +1006,7 @@ fn terminal_reports() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "terminal_reports"; let content = read_fixture(fixture_name); @@ -960,6 +1024,7 @@ fn wide_characters() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 21, 104, @@ -972,6 +1037,7 @@ fn wide_characters() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "wide_characters"; let content = read_fixture(fixture_name); @@ -989,6 +1055,7 @@ fn wide_characters_line_wrap() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 21, 104, @@ -1001,6 +1068,7 @@ fn wide_characters_line_wrap() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "wide_characters_line_wrap"; let content = read_fixture(fixture_name); @@ -1018,6 +1086,7 @@ fn insert_character_in_line_with_wide_character() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 21, 104, @@ -1030,6 +1099,7 @@ fn insert_character_in_line_with_wide_character() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "wide_characters_middle_line_insert"; let content = read_fixture(fixture_name); @@ -1047,6 +1117,7 @@ fn delete_char_in_middle_of_line_with_widechar() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 21, 104, @@ -1059,6 +1130,7 @@ fn delete_char_in_middle_of_line_with_widechar() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "wide-chars-delete-middle"; let content = read_fixture(fixture_name); @@ -1076,6 +1148,7 @@ fn delete_char_in_middle_of_line_with_multiple_widechars() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 21, 104, @@ -1088,6 +1161,7 @@ fn delete_char_in_middle_of_line_with_multiple_widechars() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "wide-chars-delete-middle-after-multi"; let content = read_fixture(fixture_name); @@ -1105,6 +1179,7 @@ fn fish_wide_characters_override_clock() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 21, 104, @@ -1117,6 +1192,7 @@ fn fish_wide_characters_override_clock() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "fish_wide_characters_override_clock"; let content = read_fixture(fixture_name); @@ -1134,6 +1210,7 @@ fn bash_delete_wide_characters() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 21, 104, @@ -1146,6 +1223,7 @@ fn bash_delete_wide_characters() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "bash_delete_wide_characters"; let content = read_fixture(fixture_name); @@ -1163,6 +1241,7 @@ fn delete_wide_characters_before_cursor() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 21, 104, @@ -1175,6 +1254,7 @@ fn delete_wide_characters_before_cursor() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "delete_wide_characters_before_cursor"; let content = read_fixture(fixture_name); @@ -1192,6 +1272,7 @@ fn delete_wide_characters_before_cursor_when_cursor_is_on_wide_character() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 21, 104, @@ -1204,6 +1285,7 @@ fn delete_wide_characters_before_cursor_when_cursor_is_on_wide_character() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "delete_wide_characters_before_cursor_when_cursor_is_on_wide_character"; let content = read_fixture(fixture_name); @@ -1221,6 +1303,7 @@ fn delete_wide_character_under_cursor() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 21, 104, @@ -1233,6 +1316,7 @@ fn delete_wide_character_under_cursor() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "delete_wide_character_under_cursor"; let content = read_fixture(fixture_name); @@ -1250,6 +1334,7 @@ fn replace_wide_character_under_cursor() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 21, 104, @@ -1262,6 +1347,7 @@ fn replace_wide_character_under_cursor() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "replace_wide_character_under_cursor"; let content = read_fixture(fixture_name); @@ -1279,6 +1365,7 @@ fn wrap_wide_characters() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 21, 90, @@ -1291,6 +1378,7 @@ fn wrap_wide_characters() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "wide_characters_full"; let content = read_fixture(fixture_name); @@ -1308,6 +1396,7 @@ fn wrap_wide_characters_on_size_change() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 21, 93, @@ -1320,6 +1409,7 @@ fn wrap_wide_characters_on_size_change() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "wide_characters_full"; let content = read_fixture(fixture_name); @@ -1338,6 +1428,7 @@ fn unwrap_wide_characters_on_size_change() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 21, 93, @@ -1350,6 +1441,7 @@ fn unwrap_wide_characters_on_size_change() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "wide_characters_full"; let content = read_fixture(fixture_name); @@ -1369,6 +1461,7 @@ fn wrap_wide_characters_in_the_middle_of_the_line() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 21, 91, @@ -1381,6 +1474,7 @@ fn wrap_wide_characters_in_the_middle_of_the_line() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "wide_characters_line_middle"; let content = read_fixture(fixture_name); @@ -1398,6 +1492,7 @@ fn wrap_wide_characters_at_the_end_of_the_line() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 21, 90, @@ -1410,6 +1505,7 @@ fn wrap_wide_characters_at_the_end_of_the_line() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "wide_characters_line_end"; let content = read_fixture(fixture_name); @@ -1427,6 +1523,7 @@ fn copy_selected_text_from_viewport() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 27, 125, @@ -1439,6 +1536,7 @@ fn copy_selected_text_from_viewport() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "grid_copy"; let content = read_fixture(fixture_name); @@ -1464,6 +1562,7 @@ fn copy_wrapped_selected_text_from_viewport() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 22, 73, @@ -1476,6 +1575,7 @@ fn copy_wrapped_selected_text_from_viewport() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "grid_copy_wrapped"; let content = read_fixture(fixture_name); @@ -1500,6 +1600,7 @@ fn copy_selected_text_from_lines_above() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 27, 125, @@ -1512,6 +1613,7 @@ fn copy_selected_text_from_lines_above() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "grid_copy"; let content = read_fixture(fixture_name); @@ -1537,6 +1639,7 @@ fn copy_selected_text_from_lines_below() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 27, 125, @@ -1549,6 +1652,7 @@ fn copy_selected_text_from_lines_below() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "grid_copy"; let content = read_fixture(fixture_name); @@ -1582,6 +1686,7 @@ fn run_bandwhich_from_fish_shell() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 28, 116, @@ -1594,6 +1699,7 @@ fn run_bandwhich_from_fish_shell() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "fish_and_bandwhich"; let content = read_fixture(fixture_name); @@ -1611,6 +1717,7 @@ fn fish_tab_completion_options() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 28, 116, @@ -1623,6 +1730,7 @@ fn fish_tab_completion_options() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "fish_tab_completion_options"; let content = read_fixture(fixture_name); @@ -1646,6 +1754,7 @@ pub fn fish_select_tab_completion_options() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 28, 116, @@ -1658,6 +1767,7 @@ pub fn fish_select_tab_completion_options() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "fish_select_tab_completion_options"; let content = read_fixture(fixture_name); @@ -1685,6 +1795,7 @@ pub fn vim_scroll_region_down() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 28, 116, @@ -1697,6 +1808,7 @@ pub fn vim_scroll_region_down() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "vim_scroll_region_down"; let content = read_fixture(fixture_name); @@ -1721,6 +1833,7 @@ pub fn vim_ctrl_d() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 28, 116, @@ -1733,6 +1846,7 @@ pub fn vim_ctrl_d() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "vim_ctrl_d"; let content = read_fixture(fixture_name); @@ -1756,6 +1870,7 @@ pub fn vim_ctrl_u() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 28, 116, @@ -1768,6 +1883,7 @@ pub fn vim_ctrl_u() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "vim_ctrl_u"; let content = read_fixture(fixture_name); @@ -1785,6 +1901,7 @@ pub fn htop() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 28, 116, @@ -1797,6 +1914,7 @@ pub fn htop() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "htop"; let content = read_fixture(fixture_name); @@ -1814,6 +1932,7 @@ pub fn htop_scrolling() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 28, 116, @@ -1826,6 +1945,7 @@ pub fn htop_scrolling() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "htop_scrolling"; let content = read_fixture(fixture_name); @@ -1843,6 +1963,7 @@ pub fn htop_right_scrolling() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 28, 116, @@ -1855,6 +1976,7 @@ pub fn htop_right_scrolling() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "htop_right_scrolling"; let content = read_fixture(fixture_name); @@ -1882,6 +2004,7 @@ pub fn vim_overwrite() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 28, 116, @@ -1894,6 +2017,7 @@ pub fn vim_overwrite() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "vim_overwrite"; let content = read_fixture(fixture_name); @@ -1913,6 +2037,7 @@ pub fn clear_scroll_region() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 28, 116, @@ -1925,6 +2050,7 @@ pub fn clear_scroll_region() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "clear_scroll_region"; let content = read_fixture(fixture_name); @@ -1942,6 +2068,7 @@ pub fn display_tab_characters_properly() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 28, 116, @@ -1954,6 +2081,7 @@ pub fn display_tab_characters_properly() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "tab_characters"; let content = read_fixture(fixture_name); @@ -1971,6 +2099,7 @@ pub fn neovim_insert_mode() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 28, 116, @@ -1983,6 +2112,7 @@ pub fn neovim_insert_mode() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "nvim_insert"; let content = read_fixture(fixture_name); @@ -2000,6 +2130,7 @@ pub fn bash_cursor_linewrap() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 28, 116, @@ -2012,6 +2143,7 @@ pub fn bash_cursor_linewrap() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "bash_cursor_linewrap"; let content = read_fixture(fixture_name); @@ -2031,6 +2163,7 @@ pub fn fish_paste_multiline() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 28, 149, @@ -2043,6 +2176,7 @@ pub fn fish_paste_multiline() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "fish_paste_multiline"; let content = read_fixture(fixture_name); @@ -2060,6 +2194,7 @@ pub fn git_log() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 28, 149, @@ -2072,6 +2207,7 @@ pub fn git_log() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "git_log"; let content = read_fixture(fixture_name); @@ -2091,6 +2227,7 @@ pub fn git_diff_scrollup() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 28, 149, @@ -2103,6 +2240,7 @@ pub fn git_diff_scrollup() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "git_diff_scrollup"; let content = read_fixture(fixture_name); @@ -2120,6 +2258,7 @@ pub fn emacs_longbuf() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 60, 284, @@ -2132,6 +2271,7 @@ pub fn emacs_longbuf() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "emacs_longbuf_tutorial"; let content = read_fixture(fixture_name); @@ -2149,6 +2289,7 @@ pub fn top_and_quit() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 56, 235, @@ -2161,6 +2302,7 @@ pub fn top_and_quit() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "top_and_quit"; let content = read_fixture(fixture_name); @@ -2185,6 +2327,7 @@ pub fn exa_plus_omf_theme() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 56, 235, @@ -2197,6 +2340,7 @@ pub fn exa_plus_omf_theme() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "exa_plus_omf_theme"; let content = read_fixture(fixture_name); @@ -2214,6 +2358,7 @@ pub fn scroll_up() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 10, 50, @@ -2226,6 +2371,7 @@ pub fn scroll_up() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "scrolling"; let content = read_fixture(fixture_name); @@ -2244,6 +2390,7 @@ pub fn scroll_down() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 10, 50, @@ -2256,6 +2403,7 @@ pub fn scroll_down() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "scrolling"; let content = read_fixture(fixture_name); @@ -2275,6 +2423,7 @@ pub fn scroll_up_with_line_wraps() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 10, 25, @@ -2287,6 +2436,7 @@ pub fn scroll_up_with_line_wraps() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "scrolling"; let content = read_fixture(fixture_name); @@ -2305,6 +2455,7 @@ pub fn scroll_down_with_line_wraps() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 10, 25, @@ -2317,6 +2468,7 @@ pub fn scroll_down_with_line_wraps() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "scrolling"; let content = read_fixture(fixture_name); @@ -2336,6 +2488,7 @@ pub fn scroll_up_decrease_width_and_scroll_down() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 10, 50, @@ -2348,6 +2501,7 @@ pub fn scroll_up_decrease_width_and_scroll_down() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "scrolling"; let content = read_fixture(fixture_name); @@ -2372,6 +2526,7 @@ pub fn scroll_up_increase_width_and_scroll_down() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 10, 25, @@ -2384,6 +2539,7 @@ pub fn scroll_up_increase_width_and_scroll_down() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "scrolling"; let content = read_fixture(fixture_name); @@ -2408,6 +2564,7 @@ fn saved_cursor_across_resize() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 4, 20, @@ -2420,6 +2577,7 @@ fn saved_cursor_across_resize() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let mut parse = |s, grid: &mut Grid| { for b in Vec::from(s) { @@ -2453,6 +2611,7 @@ fn saved_cursor_across_resize_longline() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 4, 20, @@ -2465,6 +2624,7 @@ fn saved_cursor_across_resize_longline() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let mut parse = |s, grid: &mut Grid| { for b in Vec::from(s) { @@ -2491,6 +2651,7 @@ fn saved_cursor_across_resize_rewrap() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 4, 4 * 8, @@ -2503,6 +2664,7 @@ fn saved_cursor_across_resize_rewrap() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let mut parse = |s, grid: &mut Grid| { for b in Vec::from(s) { @@ -2529,6 +2691,7 @@ pub fn move_cursor_below_scroll_region() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 34, 114, @@ -2541,6 +2704,7 @@ pub fn move_cursor_below_scroll_region() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "move_cursor_below_scroll_region"; let content = read_fixture(fixture_name); @@ -2558,6 +2722,7 @@ pub fn insert_wide_characters_in_existing_line() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 21, 86, @@ -2570,6 +2735,7 @@ pub fn insert_wide_characters_in_existing_line() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "chinese_characters_line_middle"; let content = read_fixture(fixture_name); @@ -2593,6 +2759,7 @@ pub fn full_screen_scroll_region_and_scroll_up() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 54, 80, @@ -2605,6 +2772,7 @@ pub fn full_screen_scroll_region_and_scroll_up() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "scroll_region_full_screen"; let content = read_fixture(fixture_name); @@ -2625,6 +2793,7 @@ pub fn ring_bell() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 134, 64, @@ -2637,6 +2806,7 @@ pub fn ring_bell() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "ring_bell"; let content = read_fixture(fixture_name); @@ -2654,6 +2824,7 @@ pub fn alternate_screen_change_size() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 20, 20, @@ -2666,6 +2837,7 @@ pub fn alternate_screen_change_size() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "alternate_screen_change_size"; let content = read_fixture(fixture_name); @@ -2687,6 +2859,7 @@ pub fn fzf_fullscreen() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 51, 112, @@ -2699,6 +2872,7 @@ pub fn fzf_fullscreen() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "fzf_fullscreen"; let content = read_fixture(fixture_name); @@ -2720,6 +2894,7 @@ pub fn replace_multiple_wide_characters_under_cursor() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 51, 112, @@ -2732,6 +2907,7 @@ pub fn replace_multiple_wide_characters_under_cursor() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "replace_multiple_wide_characters"; let content = read_fixture(fixture_name); @@ -2753,6 +2929,7 @@ pub fn replace_non_wide_characters_with_wide_characters() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 51, 112, @@ -2765,6 +2942,7 @@ pub fn replace_non_wide_characters_with_wide_characters() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "replace_non_wide_characters_with_wide_characters"; let content = read_fixture(fixture_name); @@ -2782,6 +2960,7 @@ pub fn scroll_down_ansi() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 51, 112, @@ -2794,6 +2973,7 @@ pub fn scroll_down_ansi() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "scroll_down"; let content = read_fixture(fixture_name); @@ -2811,6 +2991,7 @@ pub fn ansi_capital_t() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 51, 112, @@ -2823,6 +3004,7 @@ pub fn ansi_capital_t() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let content = "foo\u{1b}[14Tbar".as_bytes(); for byte in content { @@ -2839,6 +3021,7 @@ pub fn ansi_capital_s() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 51, 112, @@ -2851,6 +3034,7 @@ pub fn ansi_capital_s() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let content = "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nfoo\u{1b}[14Sbar".as_bytes(); for byte in content { @@ -2867,6 +3051,7 @@ fn terminal_pixel_size_reports() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 51, 97, @@ -2882,6 +3067,7 @@ fn terminal_pixel_size_reports() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "terminal_pixel_size_reports"; let content = read_fixture(fixture_name); @@ -2905,6 +3091,7 @@ fn terminal_pixel_size_reports_in_unsupported_terminals() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 51, 97, @@ -2917,6 +3104,7 @@ fn terminal_pixel_size_reports_in_unsupported_terminals() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "terminal_pixel_size_reports"; let content = read_fixture(fixture_name); @@ -2941,6 +3129,7 @@ pub fn ansi_csi_at_sign() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 51, 112, @@ -2953,6 +3142,7 @@ pub fn ansi_csi_at_sign() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let content = "foo\u{1b}[2D\u{1b}[2@".as_bytes(); for byte in content { @@ -2973,6 +3163,7 @@ pub fn sixel_images_are_reaped_when_scrolled_off() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 51, 112, @@ -2985,6 +3176,7 @@ pub fn sixel_images_are_reaped_when_scrolled_off() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let pane_content = read_fixture("sixel-image-500px.six"); for byte in pane_content { @@ -3014,6 +3206,7 @@ pub fn sixel_images_are_reaped_when_resetting() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 51, 112, @@ -3026,6 +3219,7 @@ pub fn sixel_images_are_reaped_when_resetting() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let pane_content = read_fixture("sixel-image-500px.six"); for byte in pane_content { @@ -3052,6 +3246,7 @@ pub fn sixel_image_in_alternate_buffer() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 30, 112, @@ -3064,6 +3259,7 @@ pub fn sixel_image_in_alternate_buffer() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let move_to_alternate_screen = "\u{1b}[?1049h"; @@ -3101,6 +3297,7 @@ pub fn sixel_with_image_scrolling_decsdm() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 30, 112, @@ -3113,6 +3310,7 @@ pub fn sixel_with_image_scrolling_decsdm() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); // enter DECSDM @@ -3169,6 +3367,7 @@ pub fn osc_4_background_query() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 51, 97, @@ -3181,6 +3380,7 @@ pub fn osc_4_background_query() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let content = "\u{1b}]10;?\u{1b}\\"; for byte in content.as_bytes() { @@ -3205,6 +3405,7 @@ pub fn osc_4_foreground_query() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 51, 97, @@ -3217,6 +3418,7 @@ pub fn osc_4_foreground_query() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let content = "\u{1b}]11;?\u{1b}\\"; for byte in content.as_bytes() { @@ -3243,6 +3445,7 @@ pub fn osc_4_color_query() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 51, 97, @@ -3255,6 +3458,7 @@ pub fn osc_4_color_query() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let content = "\u{1b}]4;222;?\u{1b}\\"; for byte in content.as_bytes() { @@ -3279,6 +3483,7 @@ pub fn xtsmgraphics_color_register_count() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 51, 97, @@ -3291,6 +3496,7 @@ pub fn xtsmgraphics_color_register_count() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let content = "\u{1b}[?1;1;S\u{1b}\\"; for byte in content.as_bytes() { @@ -3319,6 +3525,7 @@ pub fn xtsmgraphics_pixel_graphics_geometry() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 51, 97, @@ -3331,6 +3538,7 @@ pub fn xtsmgraphics_pixel_graphics_geometry() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let content = "\u{1b}[?2;1;S\u{1b}\\"; for byte in content.as_bytes() { @@ -3359,6 +3567,7 @@ pub fn cursor_hide_persists_through_alternate_screen() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 30, 112, @@ -3371,6 +3580,7 @@ pub fn cursor_hide_persists_through_alternate_screen() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let hide_cursor = "\u{1b}[?25l"; @@ -3413,6 +3623,7 @@ fn table_ui_component() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 41, 110, @@ -3425,6 +3636,7 @@ fn table_ui_component() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "table-ui-component"; let content = read_fixture(fixture_name); @@ -3442,6 +3654,7 @@ fn table_ui_component_with_coordinates() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 41, 110, @@ -3454,6 +3667,7 @@ fn table_ui_component_with_coordinates() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "table-ui-component-with-coordinates"; let content = read_fixture(fixture_name); @@ -3471,6 +3685,7 @@ fn ribbon_ui_component() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 41, 110, @@ -3483,6 +3698,7 @@ fn ribbon_ui_component() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "ribbon-ui-component"; let content = read_fixture(fixture_name); @@ -3500,6 +3716,7 @@ fn ribbon_ui_component_with_coordinates() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 41, 110, @@ -3512,6 +3729,7 @@ fn ribbon_ui_component_with_coordinates() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "ribbon-ui-component-with-coordinates"; let content = read_fixture(fixture_name); @@ -3529,6 +3747,7 @@ fn nested_list_ui_component() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 41, 120, @@ -3541,6 +3760,7 @@ fn nested_list_ui_component() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "nested-list-ui-component"; let content = read_fixture(fixture_name); @@ -3558,6 +3778,7 @@ fn nested_list_ui_component_with_coordinates() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 41, 120, @@ -3570,6 +3791,7 @@ fn nested_list_ui_component_with_coordinates() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "nested-list-ui-component-with-coordinates"; let content = read_fixture(fixture_name); @@ -3587,6 +3809,7 @@ fn text_ui_component() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 41, 120, @@ -3599,6 +3822,7 @@ fn text_ui_component() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "text-ui-component"; let content = read_fixture(fixture_name); @@ -3616,6 +3840,7 @@ fn text_ui_component_with_coordinates() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( 41, 120, @@ -3628,6 +3853,7 @@ fn text_ui_component_with_coordinates() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let fixture_name = "text-ui-component-with-coordinates"; let content = read_fixture(fixture_name); diff --git a/zellij-server/src/panes/unit/search_in_pane_tests.rs b/zellij-server/src/panes/unit/search_in_pane_tests.rs index 5f0d7a58..3ab06501 100644 --- a/zellij-server/src/panes/unit/search_in_pane_tests.rs +++ b/zellij-server/src/panes/unit/search_in_pane_tests.rs @@ -31,6 +31,7 @@ fn create_pane() -> TerminalPane { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut terminal_pane = TerminalPane::new( pid, fake_win_size, @@ -47,6 +48,7 @@ fn create_pane() -> TerminalPane { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); // 0 is the pane index let content = read_fixture(); terminal_pane.handle_pty_bytes(content); diff --git a/zellij-server/src/panes/unit/terminal_pane_tests.rs b/zellij-server/src/panes/unit/terminal_pane_tests.rs index ddc19a40..b568d164 100644 --- a/zellij-server/src/panes/unit/terminal_pane_tests.rs +++ b/zellij-server/src/panes/unit/terminal_pane_tests.rs @@ -39,6 +39,7 @@ pub fn scrolling_inside_a_pane() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut terminal_pane = TerminalPane::new( pid, fake_win_size, @@ -55,6 +56,7 @@ pub fn scrolling_inside_a_pane() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); // 0 is the pane index let mut text_to_fill_pane = String::new(); for i in 0..30 { @@ -87,6 +89,7 @@ pub fn sixel_image_inside_terminal_pane() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut terminal_pane = TerminalPane::new( pid, fake_win_size, @@ -103,6 +106,7 @@ pub fn sixel_image_inside_terminal_pane() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); // 0 is the pane index let sixel_image_bytes = "\u{1b}Pq #0;2;0;0;0#1;2;100;100;0#2;2;0;100;0 @@ -135,6 +139,7 @@ pub fn partial_sixel_image_inside_terminal_pane() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut terminal_pane = TerminalPane::new( pid, fake_win_size, @@ -151,6 +156,7 @@ pub fn partial_sixel_image_inside_terminal_pane() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); // 0 is the pane index let pane_content = read_fixture("sixel-image-500px.six"); terminal_pane.handle_pty_bytes(pane_content); @@ -177,6 +183,7 @@ pub fn overflowing_sixel_image_inside_terminal_pane() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut terminal_pane = TerminalPane::new( pid, fake_win_size, @@ -193,6 +200,7 @@ pub fn overflowing_sixel_image_inside_terminal_pane() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); // 0 is the pane index let pane_content = read_fixture("sixel-image-500px.six"); terminal_pane.handle_pty_bytes(pane_content); @@ -218,6 +226,7 @@ pub fn scrolling_through_a_sixel_image() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut terminal_pane = TerminalPane::new( pid, fake_win_size, @@ -234,6 +243,7 @@ pub fn scrolling_through_a_sixel_image() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); // 0 is the pane index let mut text_to_fill_pane = String::new(); for i in 0..30 { @@ -270,6 +280,7 @@ pub fn multiple_sixel_images_in_pane() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut terminal_pane = TerminalPane::new( pid, fake_win_size, @@ -286,6 +297,7 @@ pub fn multiple_sixel_images_in_pane() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); // 0 is the pane index let mut text_to_fill_pane = String::new(); for i in 0..5 { @@ -320,6 +332,7 @@ pub fn resizing_pane_with_sixel_images() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut terminal_pane = TerminalPane::new( pid, fake_win_size, @@ -336,6 +349,7 @@ pub fn resizing_pane_with_sixel_images() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); // 0 is the pane index let mut text_to_fill_pane = String::new(); for i in 0..5 { @@ -373,6 +387,7 @@ pub fn changing_character_cell_size_with_sixel_images() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut terminal_pane = TerminalPane::new( pid, fake_win_size, @@ -389,6 +404,7 @@ pub fn changing_character_cell_size_with_sixel_images() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); // 0 is the pane index let mut text_to_fill_pane = String::new(); for i in 0..5 { @@ -431,6 +447,7 @@ pub fn keep_working_after_corrupted_sixel_image() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut terminal_pane = TerminalPane::new( pid, fake_win_size, @@ -447,6 +464,7 @@ pub fn keep_working_after_corrupted_sixel_image() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); // 0 is the pane index let sixel_image_bytes = "\u{1b}PI AM CORRUPTED BWAHAHAq @@ -487,6 +505,7 @@ pub fn pane_with_frame_position_is_on_frame() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut terminal_pane = TerminalPane::new( pid, fake_win_size, @@ -503,6 +522,7 @@ pub fn pane_with_frame_position_is_on_frame() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); // 0 is the pane index terminal_pane.set_content_offset(Offset::frame(1)); @@ -579,6 +599,7 @@ pub fn pane_with_bottom_and_right_borders_position_is_on_frame() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut terminal_pane = TerminalPane::new( pid, fake_win_size, @@ -595,6 +616,7 @@ pub fn pane_with_bottom_and_right_borders_position_is_on_frame() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); // 0 is the pane index terminal_pane.set_content_offset(Offset::shift(1, 1)); @@ -671,6 +693,7 @@ pub fn frameless_pane_position_is_on_frame() { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut terminal_pane = TerminalPane::new( pid, fake_win_size, @@ -687,6 +710,7 @@ pub fn frameless_pane_position_is_on_frame() { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); // 0 is the pane index terminal_pane.set_content_offset(Offset::default()); diff --git a/zellij-server/src/plugins/unit/plugin_tests.rs b/zellij-server/src/plugins/unit/plugin_tests.rs index 1f502fff..22a1bf1f 100644 --- a/zellij-server/src/plugins/unit/plugin_tests.rs +++ b/zellij-server/src/plugins/unit/plugin_tests.rs @@ -6,7 +6,9 @@ use std::collections::BTreeMap; use std::path::PathBuf; use tempfile::tempdir; use wasmer::Store; -use zellij_utils::data::{Event, Key, PermissionStatus, PermissionType, PluginCapabilities}; +use zellij_utils::data::{ + BareKey, Event, KeyWithModifier, PermissionStatus, PermissionType, PluginCapabilities, +}; use zellij_utils::errors::ErrorContext; use zellij_utils::input::layout::{ Layout, PluginAlias, PluginUserConfiguration, RunPlugin, RunPluginLocation, RunPluginOrAlias, @@ -1016,8 +1018,8 @@ pub fn switch_to_mode_plugin_command() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Char('a')), // this triggers a SwitchToMode(Tab) command in the fixture - // plugin + Event::Key(KeyWithModifier::new(BareKey::Char('a'))), // this triggers a SwitchToMode(Tab) command in the fixture + // plugin )])); screen_thread.join().unwrap(); // this might take a while if the cache is cold teardown(); @@ -1088,8 +1090,8 @@ pub fn switch_to_mode_plugin_command_permission_denied() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Char('a')), // this triggers a SwitchToMode(Tab) command in the fixture - // plugin + Event::Key(KeyWithModifier::new(BareKey::Char('a'))), // this triggers a SwitchToMode(Tab) command in the fixture + // plugin )])); screen_thread.join().unwrap(); // this might take a while if the cache is cold teardown(); @@ -1160,8 +1162,8 @@ pub fn new_tabs_with_layout_plugin_command() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Char('b')), // this triggers a new_tabs_with_layout command in the fixture - // plugin + Event::Key(KeyWithModifier::new(BareKey::Char('b'))), // this triggers a new_tabs_with_layout command in the fixture + // plugin )])); screen_thread.join().unwrap(); // this might take a while if the cache is cold teardown(); @@ -1246,8 +1248,8 @@ pub fn new_tab_plugin_command() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Char('c')), // this triggers a new_tab command in the fixture - // plugin + Event::Key(KeyWithModifier::new(BareKey::Char('c'))), // this triggers a new_tab command in the fixture + // plugin )])); screen_thread.join().unwrap(); // this might take a while if the cache is cold teardown(); @@ -1318,7 +1320,7 @@ pub fn go_to_next_tab_plugin_command() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Char('d')), // this triggers the event in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('d'))), // this triggers the event in the fixture plugin )])); screen_thread.join().unwrap(); // this might take a while if the cache is cold teardown(); @@ -1389,7 +1391,7 @@ pub fn go_to_previous_tab_plugin_command() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Char('e')), // this triggers the event in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('e'))), // this triggers the event in the fixture plugin )])); screen_thread.join().unwrap(); // this might take a while if the cache is cold teardown(); @@ -1460,7 +1462,7 @@ pub fn resize_focused_pane_plugin_command() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Char('f')), // this triggers the event in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('f'))), // this triggers the event in the fixture plugin )])); screen_thread.join().unwrap(); // this might take a while if the cache is cold teardown(); @@ -1531,7 +1533,7 @@ pub fn resize_focused_pane_with_direction_plugin_command() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Char('g')), // this triggers the enent in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('g'))), // this triggers the enent in the fixture plugin )])); screen_thread.join().unwrap(); // this might take a while if the cache is cold teardown(); @@ -1602,7 +1604,7 @@ pub fn focus_next_pane_plugin_command() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Char('h')), // this triggers the enent in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('h'))), // this triggers the enent in the fixture plugin )])); screen_thread.join().unwrap(); // this might take a while if the cache is cold teardown(); @@ -1673,7 +1675,7 @@ pub fn focus_previous_pane_plugin_command() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Char('i')), // this triggers the enent in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('i'))), // this triggers the enent in the fixture plugin )])); screen_thread.join().unwrap(); // this might take a while if the cache is cold teardown(); @@ -1744,7 +1746,7 @@ pub fn move_focus_plugin_command() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Char('j')), // this triggers the enent in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('j'))), // this triggers the enent in the fixture plugin )])); screen_thread.join().unwrap(); // this might take a while if the cache is cold teardown(); @@ -1815,7 +1817,7 @@ pub fn move_focus_or_tab_plugin_command() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Char('k')), // this triggers the enent in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('k'))), // this triggers the enent in the fixture plugin )])); screen_thread.join().unwrap(); // this might take a while if the cache is cold teardown(); @@ -1886,7 +1888,7 @@ pub fn edit_scrollback_plugin_command() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Char('m')), // this triggers the enent in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('m'))), // this triggers the enent in the fixture plugin )])); screen_thread.join().unwrap(); // this might take a while if the cache is cold teardown(); @@ -1957,7 +1959,7 @@ pub fn write_plugin_command() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Char('n')), // this triggers the enent in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('n'))), // this triggers the enent in the fixture plugin )])); screen_thread.join().unwrap(); // this might take a while if the cache is cold teardown(); @@ -2028,7 +2030,7 @@ pub fn write_chars_plugin_command() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Char('o')), // this triggers the enent in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('o'))), // this triggers the enent in the fixture plugin )])); screen_thread.join().unwrap(); // this might take a while if the cache is cold teardown(); @@ -2099,7 +2101,7 @@ pub fn toggle_tab_plugin_command() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Char('p')), // this triggers the enent in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('p'))), // this triggers the enent in the fixture plugin )])); screen_thread.join().unwrap(); // this might take a while if the cache is cold teardown(); @@ -2170,7 +2172,7 @@ pub fn move_pane_plugin_command() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Char('q')), // this triggers the enent in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('q'))), // this triggers the enent in the fixture plugin )])); screen_thread.join().unwrap(); // this might take a while if the cache is cold teardown(); @@ -2241,7 +2243,7 @@ pub fn move_pane_with_direction_plugin_command() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Char('r')), // this triggers the enent in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('r'))), // this triggers the enent in the fixture plugin )])); screen_thread.join().unwrap(); // this might take a while if the cache is cold teardown(); @@ -2313,7 +2315,7 @@ pub fn clear_screen_plugin_command() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Char('s')), // this triggers the enent in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('s'))), // this triggers the enent in the fixture plugin )])); screen_thread.join().unwrap(); // this might take a while if the cache is cold teardown(); @@ -2385,7 +2387,7 @@ pub fn scroll_up_plugin_command() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Char('t')), // this triggers the enent in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('t'))), // this triggers the enent in the fixture plugin )])); screen_thread.join().unwrap(); // this might take a while if the cache is cold teardown(); @@ -2456,7 +2458,7 @@ pub fn scroll_down_plugin_command() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Char('u')), // this triggers the enent in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('u'))), // this triggers the enent in the fixture plugin )])); screen_thread.join().unwrap(); // this might take a while if the cache is cold teardown(); @@ -2527,7 +2529,7 @@ pub fn scroll_to_top_plugin_command() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Char('v')), // this triggers the enent in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('v'))), // this triggers the enent in the fixture plugin )])); screen_thread.join().unwrap(); // this might take a while if the cache is cold teardown(); @@ -2598,7 +2600,7 @@ pub fn scroll_to_bottom_plugin_command() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Char('w')), // this triggers the enent in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('w'))), // this triggers the enent in the fixture plugin )])); screen_thread.join().unwrap(); // this might take a while if the cache is cold teardown(); @@ -2669,7 +2671,7 @@ pub fn page_scroll_up_plugin_command() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Char('x')), // this triggers the enent in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('x'))), // this triggers the enent in the fixture plugin )])); screen_thread.join().unwrap(); // this might take a while if the cache is cold teardown(); @@ -2740,7 +2742,7 @@ pub fn page_scroll_down_plugin_command() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Char('y')), // this triggers the enent in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('y'))), // this triggers the enent in the fixture plugin )])); screen_thread.join().unwrap(); // this might take a while if the cache is cold teardown(); @@ -2811,7 +2813,7 @@ pub fn toggle_focus_fullscreen_plugin_command() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Char('z')), // this triggers the enent in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('z'))), // this triggers the enent in the fixture plugin )])); screen_thread.join().unwrap(); // this might take a while if the cache is cold teardown(); @@ -2882,7 +2884,7 @@ pub fn toggle_pane_frames_plugin_command() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Char('1')), // this triggers the enent in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('1'))), // this triggers the enent in the fixture plugin )])); screen_thread.join().unwrap(); // this might take a while if the cache is cold teardown(); @@ -2953,7 +2955,7 @@ pub fn toggle_pane_embed_or_eject_plugin_command() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Char('2')), // this triggers the enent in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('2'))), // this triggers the enent in the fixture plugin )])); screen_thread.join().unwrap(); // this might take a while if the cache is cold teardown(); @@ -3024,7 +3026,7 @@ pub fn undo_rename_pane_plugin_command() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Char('3')), // this triggers the enent in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('3'))), // this triggers the enent in the fixture plugin )])); screen_thread.join().unwrap(); // this might take a while if the cache is cold teardown(); @@ -3095,7 +3097,7 @@ pub fn close_focus_plugin_command() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Char('4')), // this triggers the enent in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('4'))), // this triggers the enent in the fixture plugin )])); screen_thread.join().unwrap(); // this might take a while if the cache is cold teardown(); @@ -3166,7 +3168,7 @@ pub fn toggle_active_tab_sync_plugin_command() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Char('5')), // this triggers the enent in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('5'))), // this triggers the enent in the fixture plugin )])); screen_thread.join().unwrap(); // this might take a while if the cache is cold teardown(); @@ -3237,7 +3239,7 @@ pub fn close_focused_tab_plugin_command() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Char('6')), // this triggers the enent in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('6'))), // this triggers the enent in the fixture plugin )])); screen_thread.join().unwrap(); // this might take a while if the cache is cold teardown(); @@ -3308,7 +3310,7 @@ pub fn undo_rename_tab_plugin_command() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Char('7')), // this triggers the enent in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('7'))), // this triggers the enent in the fixture plugin )])); screen_thread.join().unwrap(); // this might take a while if the cache is cold teardown(); @@ -3379,7 +3381,7 @@ pub fn previous_swap_layout_plugin_command() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Ctrl('a')), // this triggers the enent in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('a')).with_ctrl_modifier()), // this triggers the enent in the fixture plugin )])); screen_thread.join().unwrap(); // this might take a while if the cache is cold teardown(); @@ -3450,7 +3452,7 @@ pub fn next_swap_layout_plugin_command() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Ctrl('b')), // this triggers the enent in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('b')).with_ctrl_modifier()), // this triggers the enent in the fixture plugin )])); screen_thread.join().unwrap(); // this might take a while if the cache is cold teardown(); @@ -3521,7 +3523,7 @@ pub fn go_to_tab_name_plugin_command() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Ctrl('c')), // this triggers the enent in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('c')).with_ctrl_modifier()), // this triggers the enent in the fixture plugin )])); screen_thread.join().unwrap(); // this might take a while if the cache is cold teardown(); @@ -3592,7 +3594,7 @@ pub fn focus_or_create_tab_plugin_command() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Ctrl('d')), // this triggers the enent in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('d')).with_ctrl_modifier()), // this triggers the enent in the fixture plugin )])); screen_thread.join().unwrap(); // this might take a while if the cache is cold teardown(); @@ -3663,7 +3665,7 @@ pub fn go_to_tab() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Ctrl('e')), // this triggers the enent in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('e')).with_ctrl_modifier()), // this triggers the enent in the fixture plugin )])); screen_thread.join().unwrap(); // this might take a while if the cache is cold teardown(); @@ -3734,7 +3736,7 @@ pub fn start_or_reload_plugin() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Ctrl('f')), // this triggers the enent in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('f')).with_ctrl_modifier()), // this triggers the enent in the fixture plugin )])); screen_thread.join().unwrap(); // this might take a while if the cache is cold teardown(); @@ -3812,7 +3814,7 @@ pub fn quit_zellij_plugin_command() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Char('8')), // this triggers the enent in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('8'))), // this triggers the enent in the fixture plugin )])); server_thread.join().unwrap(); // this might take a while if the cache is cold teardown(); @@ -3890,7 +3892,7 @@ pub fn detach_plugin_command() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Char('l')), // this triggers the enent in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('l'))), // this triggers the enent in the fixture plugin )])); server_thread.join().unwrap(); // this might take a while if the cache is cold teardown(); @@ -3968,7 +3970,7 @@ pub fn open_file_floating_plugin_command() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Ctrl('h')), // this triggers the enent in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('h')).with_ctrl_modifier()), // this triggers the enent in the fixture plugin )])); pty_thread.join().unwrap(); // this might take a while if the cache is cold teardown(); @@ -4050,7 +4052,7 @@ pub fn open_file_plugin_command() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Ctrl('g')), // this triggers the enent in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('g')).with_ctrl_modifier()), // this triggers the enent in the fixture plugin )])); pty_thread.join().unwrap(); // this might take a while if the cache is cold teardown(); @@ -4133,7 +4135,7 @@ pub fn open_file_with_line_plugin_command() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Ctrl('i')), // this triggers the enent in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('i')).with_ctrl_modifier()), // this triggers the enent in the fixture plugin )])); pty_thread.join().unwrap(); // this might take a while if the cache is cold teardown(); @@ -4215,7 +4217,7 @@ pub fn open_file_with_line_floating_plugin_command() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Ctrl('j')), // this triggers the enent in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('j')).with_ctrl_modifier()), // this triggers the enent in the fixture plugin )])); pty_thread.join().unwrap(); // this might take a while if the cache is cold teardown(); @@ -4297,7 +4299,7 @@ pub fn open_terminal_plugin_command() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Ctrl('k')), // this triggers the enent in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('k')).with_ctrl_modifier()), // this triggers the enent in the fixture plugin )])); pty_thread.join().unwrap(); // this might take a while if the cache is cold teardown(); @@ -4375,7 +4377,7 @@ pub fn open_terminal_floating_plugin_command() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Ctrl('l')), // this triggers the enent in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('l')).with_ctrl_modifier()), // this triggers the enent in the fixture plugin )])); pty_thread.join().unwrap(); // this might take a while if the cache is cold teardown(); @@ -4453,7 +4455,7 @@ pub fn open_command_pane_plugin_command() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Ctrl('m')), // this triggers the enent in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('m')).with_ctrl_modifier()), // this triggers the enent in the fixture plugin )])); pty_thread.join().unwrap(); // this might take a while if the cache is cold teardown(); @@ -4531,7 +4533,7 @@ pub fn open_command_pane_floating_plugin_command() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Ctrl('n')), // this triggers the enent in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('n')).with_ctrl_modifier()), // this triggers the enent in the fixture plugin )])); pty_thread.join().unwrap(); // this might take a while if the cache is cold teardown(); @@ -4602,7 +4604,7 @@ pub fn switch_to_tab_plugin_command() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Ctrl('o')), // this triggers the enent in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('o')).with_ctrl_modifier()), // this triggers the enent in the fixture plugin )])); screen_thread.join().unwrap(); // this might take a while if the cache is cold teardown(); @@ -4673,7 +4675,7 @@ pub fn hide_self_plugin_command() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Ctrl('p')), // this triggers the enent in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('p')).with_ctrl_modifier()), // this triggers the enent in the fixture plugin )])); screen_thread.join().unwrap(); // this might take a while if the cache is cold teardown(); @@ -4743,7 +4745,7 @@ pub fn show_self_plugin_command() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Ctrl('q')), // this triggers the enent in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('q')).with_ctrl_modifier()), // this triggers the enent in the fixture plugin )])); screen_thread.join().unwrap(); // this might take a while if the cache is cold teardown(); @@ -4814,7 +4816,7 @@ pub fn close_terminal_pane_plugin_command() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Ctrl('r')), // this triggers the enent in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('r')).with_ctrl_modifier()), // this triggers the enent in the fixture plugin )])); screen_thread.join().unwrap(); // this might take a while if the cache is cold teardown(); @@ -4885,7 +4887,7 @@ pub fn close_plugin_pane_plugin_command() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Ctrl('s')), // this triggers the enent in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('s')).with_ctrl_modifier()), // this triggers the enent in the fixture plugin )])); screen_thread.join().unwrap(); // this might take a while if the cache is cold teardown(); @@ -4956,7 +4958,7 @@ pub fn focus_terminal_pane_plugin_command() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Ctrl('t')), // this triggers the enent in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('t')).with_ctrl_modifier()), // this triggers the enent in the fixture plugin )])); screen_thread.join().unwrap(); // this might take a while if the cache is cold teardown(); @@ -5027,7 +5029,7 @@ pub fn focus_plugin_pane_plugin_command() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Ctrl('u')), // this triggers the enent in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('u')).with_ctrl_modifier()), // this triggers the enent in the fixture plugin )])); screen_thread.join().unwrap(); // this might take a while if the cache is cold teardown(); @@ -5098,7 +5100,7 @@ pub fn rename_terminal_pane_plugin_command() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Ctrl('v')), // this triggers the enent in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('v')).with_ctrl_modifier()), // this triggers the enent in the fixture plugin )])); screen_thread.join().unwrap(); // this might take a while if the cache is cold teardown(); @@ -5169,7 +5171,7 @@ pub fn rename_plugin_pane_plugin_command() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Ctrl('w')), // this triggers the enent in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('w')).with_ctrl_modifier()), // this triggers the enent in the fixture plugin )])); screen_thread.join().unwrap(); // this might take a while if the cache is cold teardown(); @@ -5240,7 +5242,7 @@ pub fn rename_tab_plugin_command() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Ctrl('x')), // this triggers the enent in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('x')).with_ctrl_modifier()), // this triggers the enent in the fixture plugin )])); screen_thread.join().unwrap(); // this might take a while if the cache is cold teardown(); @@ -5320,7 +5322,7 @@ pub fn send_configuration_to_plugins() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Ctrl('z')), // this triggers the enent in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('z')).with_ctrl_modifier()), // this triggers the enent in the fixture plugin )])); screen_thread.join().unwrap(); // this might take a while if the cache is cold teardown(); @@ -5388,7 +5390,7 @@ pub fn request_plugin_permissions() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Ctrl('1')), // this triggers the enent in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('1')).with_ctrl_modifier()), // this triggers the enent in the fixture plugin )])); screen_thread.join().unwrap(); // this might take a while if the cache is cold teardown(); @@ -5480,7 +5482,7 @@ pub fn granted_permission_request_result() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Ctrl('1')), // this triggers the enent in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('1')).with_ctrl_modifier()), // this triggers the enent in the fixture plugin )])); screen_thread.join().unwrap(); teardown(); @@ -5571,7 +5573,7 @@ pub fn denied_permission_request_result() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Ctrl('1')), // this triggers the enent in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('1')).with_ctrl_modifier()), // this triggers the enent in the fixture plugin )])); screen_thread.join().unwrap(); teardown(); @@ -5642,7 +5644,7 @@ pub fn run_command_plugin_command() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Ctrl('2')), // this triggers the enent in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('2')).with_ctrl_modifier()), // this triggers the enent in the fixture plugin )])); background_jobs_thread.join().unwrap(); // this might take a while if the cache is cold teardown(); @@ -5720,7 +5722,7 @@ pub fn run_command_with_env_vars_and_cwd_plugin_command() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Ctrl('3')), // this triggers the enent in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('3')).with_ctrl_modifier()), // this triggers the enent in the fixture plugin )])); background_jobs_thread.join().unwrap(); // this might take a while if the cache is cold teardown(); @@ -5798,7 +5800,7 @@ pub fn web_request_plugin_command() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Ctrl('4')), // this triggers the enent in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('4')).with_ctrl_modifier()), // this triggers the enent in the fixture plugin )])); background_jobs_thread.join().unwrap(); // this might take a while if the cache is cold teardown(); @@ -6219,7 +6221,7 @@ pub fn switch_session_plugin_command() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Ctrl('5')), // this triggers the enent in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('5')).with_ctrl_modifier()), // this triggers the enent in the fixture plugin )])); std::thread::sleep(std::time::Duration::from_millis(500)); teardown(); @@ -6300,7 +6302,7 @@ pub fn switch_session_with_layout_plugin_command() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Ctrl('7')), // this triggers the enent in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('7')).with_ctrl_modifier()), // this triggers the enent in the fixture plugin )])); std::thread::sleep(std::time::Duration::from_millis(500)); teardown(); @@ -6381,7 +6383,7 @@ pub fn switch_session_with_layout_and_cwd_plugin_command() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Ctrl('9')), // this triggers the enent in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('9')).with_ctrl_modifier()), // this triggers the enent in the fixture plugin )])); std::thread::sleep(std::time::Duration::from_millis(500)); teardown(); @@ -6462,7 +6464,7 @@ pub fn disconnect_other_clients_plugins_command() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Ctrl('6')), // this triggers the enent in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('6')).with_ctrl_modifier()), // this triggers the enent in the fixture plugin )])); std::thread::sleep(std::time::Duration::from_millis(500)); teardown(); @@ -6547,13 +6549,13 @@ pub fn run_plugin_in_specific_cwd() { let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Ctrl('8')), // this triggers the enent in the fixture plugin + Event::Key(KeyWithModifier::new(BareKey::Char('8')).with_ctrl_modifier()), // this triggers the enent in the fixture plugin )])); std::thread::sleep(std::time::Duration::from_millis(500)); let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![( None, Some(client_id), - Event::Key(Key::Char('8')), // this sends this quit command so tha the test exits cleanly + Event::Key(KeyWithModifier::new(BareKey::Char('8'))), // this sends this quit command so tha the test exits cleanly )])); teardown(); server_thread.join().unwrap(); // this might take a while if the cache is cold diff --git a/zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__write_chars_plugin_command.snap b/zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__write_chars_plugin_command.snap index 8c881def..50edf7ad 100644 --- a/zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__write_chars_plugin_command.snap +++ b/zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__write_chars_plugin_command.snap @@ -1,15 +1,17 @@ --- source: zellij-server/src/plugins/./unit/plugin_tests.rs -assertion_line: 1449 +assertion_line: 2047 expression: "format!(\"{:#?}\", new_tab_event)" --- Some( WriteCharacter( + None, [ 102, 111, 111, ], + false, 1, ), ) diff --git a/zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__write_plugin_command.snap b/zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__write_plugin_command.snap index 7f8f3622..1075fffe 100644 --- a/zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__write_plugin_command.snap +++ b/zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__write_plugin_command.snap @@ -1,15 +1,17 @@ --- source: zellij-server/src/plugins/./unit/plugin_tests.rs -assertion_line: 1117 +assertion_line: 1976 expression: "format!(\"{:#?}\", new_tab_event)" --- Some( WriteCharacter( + None, [ 102, 111, 111, ], + false, 1, ), ) diff --git a/zellij-server/src/plugins/wasm_bridge.rs b/zellij-server/src/plugins/wasm_bridge.rs index ae40fe6f..a9ba489c 100644 --- a/zellij-server/src/plugins/wasm_bridge.rs +++ b/zellij-server/src/plugins/wasm_bridge.rs @@ -543,8 +543,6 @@ impl WasmBridge { mut updates: Vec<(Option, Option, Event)>, shutdown_sender: Sender<()>, ) -> Result<()> { - let err_context = || "failed to update plugin state".to_string(); - let plugins_to_update: Vec<( PluginId, ClientId, diff --git a/zellij-server/src/plugins/zellij_exports.rs b/zellij-server/src/plugins/zellij_exports.rs index 1e169f84..8ec4064f 100644 --- a/zellij-server/src/plugins/zellij_exports.rs +++ b/zellij-server/src/plugins/zellij_exports.rs @@ -1051,7 +1051,7 @@ fn edit_scrollback(env: &ForeignFunctionEnv) { fn write(env: &ForeignFunctionEnv, bytes: Vec) { let error_msg = || format!("failed to write in plugin {}", env.plugin_env.name()); - let action = Action::Write(bytes); + let action = Action::Write(None, bytes, false); apply_action!(action, error_msg, env); } diff --git a/zellij-server/src/route.rs b/zellij-server/src/route.rs index fc50fd2c..19f11ccb 100644 --- a/zellij-server/src/route.rs +++ b/zellij-server/src/route.rs @@ -64,12 +64,17 @@ pub(crate) fn route_action( .send_to_screen(ScreenInstruction::ToggleTab(client_id)) .with_context(err_context)?; }, - Action::Write(val) => { + Action::Write(key_with_modifier, raw_bytes, is_kitty_keyboard_protocol) => { senders .send_to_screen(ScreenInstruction::ClearScroll(client_id)) .with_context(err_context)?; senders - .send_to_screen(ScreenInstruction::WriteCharacter(val, client_id)) + .send_to_screen(ScreenInstruction::WriteCharacter( + key_with_modifier, + raw_bytes, + is_kitty_keyboard_protocol, + client_id, + )) .with_context(err_context)?; }, Action::WriteChars(val) => { @@ -78,7 +83,9 @@ pub(crate) fn route_action( .with_context(err_context)?; let val = val.into_bytes(); senders - .send_to_screen(ScreenInstruction::WriteCharacter(val, client_id)) + .send_to_screen(ScreenInstruction::WriteCharacter( + None, val, false, client_id, + )) .with_context(err_context)?; }, Action::SwitchToMode(mode) => { diff --git a/zellij-server/src/screen.rs b/zellij-server/src/screen.rs index 75d34562..8cf16dd8 100644 --- a/zellij-server/src/screen.rs +++ b/zellij-server/src/screen.rs @@ -9,7 +9,7 @@ use std::time::Duration; use log::{debug, warn}; use zellij_utils::data::{ - Direction, PaneManifest, PluginPermission, Resize, ResizeStrategy, SessionInfo, + Direction, KeyWithModifier, PaneManifest, PluginPermission, Resize, ResizeStrategy, SessionInfo, }; use zellij_utils::errors::prelude::*; use zellij_utils::input::command::RunCommand; @@ -158,7 +158,8 @@ pub enum ScreenInstruction { ToggleFloatingPanes(ClientId, Option), HorizontalSplit(PaneId, Option, HoldForCommand, ClientId), VerticalSplit(PaneId, Option, HoldForCommand, ClientId), - WriteCharacter(Vec, ClientId), + WriteCharacter(Option, Vec, bool, ClientId), // bool -> + // is_kitty_keyboard_protocol Resize(ClientId, ResizeStrategy), SwitchFocus(ClientId), FocusNextPane(ClientId), @@ -621,6 +622,7 @@ pub(crate) struct Screen { arrow_fonts: bool, layout_dir: Option, default_layout_name: Option, + explicitly_disable_kitty_keyboard_protocol: bool, } impl Screen { @@ -644,6 +646,7 @@ impl Screen { styled_underlines: bool, arrow_fonts: bool, layout_dir: Option, + explicitly_disable_kitty_keyboard_protocol: bool, ) -> Self { let session_name = mode_info.session_name.clone().unwrap_or_default(); let session_info = SessionInfo::new(session_name.clone()); @@ -684,6 +687,7 @@ impl Screen { arrow_fonts, resurrectable_sessions, layout_dir, + explicitly_disable_kitty_keyboard_protocol, } } @@ -1232,6 +1236,7 @@ impl Screen { self.debug, self.arrow_fonts, self.styled_underlines, + self.explicitly_disable_kitty_keyboard_protocol, ); self.tabs.insert(tab_index, tab); Ok(()) @@ -2317,6 +2322,13 @@ pub(crate) fn screen_thread_main( config_options.copy_on_select.unwrap_or(true), ); let styled_underlines = config_options.styled_underlines.unwrap_or(true); + let explicitly_disable_kitty_keyboard_protocol = config_options + .support_kitty_keyboard_protocol + .map(|e| !e) // this is due to the config options wording, if + // "support_kitty_keyboard_protocol" is true, + // explicitly_disable_kitty_keyboard_protocol is false and vice versa + .unwrap_or(false); // by default, we try to support this if the terminal supports it and + // the program running inside a pane requests it let thread_senders = bus.senders.clone(); let mut screen = Screen::new( @@ -2345,6 +2357,7 @@ pub(crate) fn screen_thread_main( styled_underlines, arrow_fonts, layout_dir, + explicitly_disable_kitty_keyboard_protocol, ); let mut pending_tab_ids: HashSet = HashSet::new(); @@ -2536,15 +2549,20 @@ pub(crate) fn screen_thread_main( screen.log_and_report_session_state()?; screen.render(None)?; }, - ScreenInstruction::WriteCharacter(bytes, client_id) => { + ScreenInstruction::WriteCharacter( + key_with_modifier, + raw_bytes, + is_kitty_keyboard_protocol, + client_id, + ) => { let mut state_changed = false; active_tab_and_connected_client_id!( screen, client_id, |tab: &mut Tab, client_id: ClientId| { let write_result = match tab.is_sync_panes_active() { - true => tab.write_to_terminals_on_current_tab(bytes, client_id), - false => tab.write_to_active_terminal(bytes, client_id), + true => tab.write_to_terminals_on_current_tab(&key_with_modifier, raw_bytes, is_kitty_keyboard_protocol, client_id), + false => tab.write_to_active_terminal(&key_with_modifier, raw_bytes, is_kitty_keyboard_protocol, client_id), }; if let Ok(true) = write_result { state_changed = true; diff --git a/zellij-server/src/tab/layout_applier.rs b/zellij-server/src/tab/layout_applier.rs index 93188be7..0a001af3 100644 --- a/zellij-server/src/tab/layout_applier.rs +++ b/zellij-server/src/tab/layout_applier.rs @@ -41,6 +41,7 @@ pub struct LayoutApplier<'a> { debug: bool, arrow_fonts: bool, styled_underlines: bool, + explicitly_disable_kitty_keyboard_protocol: bool, } impl<'a> LayoutApplier<'a> { @@ -63,6 +64,7 @@ impl<'a> LayoutApplier<'a> { debug: bool, arrow_fonts: bool, styled_underlines: bool, + explicitly_disable_kitty_keyboard_protocol: bool, ) -> Self { let viewport = viewport.clone(); let senders = senders.clone(); @@ -94,6 +96,7 @@ impl<'a> LayoutApplier<'a> { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, } } pub fn apply_layout( @@ -330,6 +333,7 @@ impl<'a> LayoutApplier<'a> { self.debug, self.arrow_fonts, self.styled_underlines, + self.explicitly_disable_kitty_keyboard_protocol, ); if let Some(pane_initial_contents) = &layout.pane_initial_contents { new_pane.handle_pty_bytes(pane_initial_contents.as_bytes().into()); @@ -448,6 +452,7 @@ impl<'a> LayoutApplier<'a> { self.debug, self.arrow_fonts, self.styled_underlines, + self.explicitly_disable_kitty_keyboard_protocol, ); if let Some(pane_initial_contents) = &floating_pane_layout.pane_initial_contents { new_pane.handle_pty_bytes(pane_initial_contents.as_bytes().into()); diff --git a/zellij-server/src/tab/mod.rs b/zellij-server/src/tab/mod.rs index 089ba2e1..a548cc9e 100644 --- a/zellij-server/src/tab/mod.rs +++ b/zellij-server/src/tab/mod.rs @@ -11,7 +11,8 @@ use std::env::temp_dir; use std::path::PathBuf; use uuid::Uuid; use zellij_utils::data::{ - Direction, PaneInfo, PermissionStatus, PermissionType, PluginPermission, ResizeStrategy, + Direction, KeyWithModifier, PaneInfo, PermissionStatus, PermissionType, PluginPermission, + ResizeStrategy, }; use zellij_utils::errors::prelude::*; use zellij_utils::input::command::RunCommand; @@ -187,6 +188,7 @@ pub(crate) struct Tab { debug: bool, arrow_fonts: bool, styled_underlines: bool, + explicitly_disable_kitty_keyboard_protocol: bool, } #[derive(Clone, Debug, Default, Serialize, Deserialize)] @@ -215,7 +217,12 @@ pub trait Pane { fn handle_pty_bytes(&mut self, _bytes: VteBytes) {} fn handle_plugin_bytes(&mut self, _client_id: ClientId, _bytes: VteBytes) {} fn cursor_coordinates(&self) -> Option<(usize, usize)>; - fn adjust_input_to_terminal(&mut self, _input_bytes: Vec) -> Option { + fn adjust_input_to_terminal( + &mut self, + _key_with_modifier: &Option, + _raw_input_bytes: Vec, + _raw_input_bytes_are_kitty: bool, + ) -> Option { None } fn position_and_size(&self) -> PaneGeom; @@ -487,6 +494,7 @@ pub enum AdjustedInput { PermissionRequestResult(Vec, PermissionStatus), CloseThisPane, DropToShellInThisPane { working_dir: Option }, + WriteKeyToPlugin(KeyWithModifier), } pub fn get_next_terminal_position( tiled_panes: &TiledPanes, @@ -537,6 +545,7 @@ impl Tab { debug: bool, arrow_fonts: bool, styled_underlines: bool, + explicitly_disable_kitty_keyboard_protocol: bool, ) -> Self { let name = if name.is_empty() { format!("Tab #{}", index + 1) @@ -627,6 +636,7 @@ impl Tab { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, } } @@ -660,6 +670,7 @@ impl Tab { self.debug, self.arrow_fonts, self.styled_underlines, + self.explicitly_disable_kitty_keyboard_protocol, ) .apply_layout( layout, @@ -723,6 +734,7 @@ impl Tab { self.debug, self.arrow_fonts, self.styled_underlines, + self.explicitly_disable_kitty_keyboard_protocol, ) .apply_floating_panes_layout_to_existing_panes( &layout_candidate, @@ -779,6 +791,7 @@ impl Tab { self.debug, self.arrow_fonts, self.styled_underlines, + self.explicitly_disable_kitty_keyboard_protocol, ) .apply_tiled_panes_layout_to_existing_panes( &layout_candidate, @@ -1084,6 +1097,7 @@ impl Tab { self.debug, self.arrow_fonts, self.styled_underlines, + self.explicitly_disable_kitty_keyboard_protocol, )) as Box }, PaneId::Plugin(plugin_pid) => { @@ -1146,6 +1160,7 @@ impl Tab { self.debug, self.arrow_fonts, self.styled_underlines, + self.explicitly_disable_kitty_keyboard_protocol, ); new_pane.update_name("EDITING SCROLLBACK"); // we do this here and not in the // constructor so it won't be overrided @@ -1220,6 +1235,7 @@ impl Tab { self.debug, self.arrow_fonts, self.styled_underlines, + self.explicitly_disable_kitty_keyboard_protocol, ); let replaced_pane = if self.floating_panes.panes_contain(&old_pane_id) { self.floating_panes @@ -1344,6 +1360,7 @@ impl Tab { self.debug, self.arrow_fonts, self.styled_underlines, + self.explicitly_disable_kitty_keyboard_protocol, ); self.tiled_panes .split_pane_horizontally(pid, Box::new(new_terminal), client_id); @@ -1403,6 +1420,7 @@ impl Tab { self.debug, self.arrow_fonts, self.styled_underlines, + self.explicitly_disable_kitty_keyboard_protocol, ); self.tiled_panes .split_pane_vertically(pid, Box::new(new_terminal), client_id); @@ -1591,7 +1609,7 @@ impl Tab { let messages_to_pty = terminal_output.drain_messages_to_pty(); let clipboard_update = terminal_output.drain_clipboard_update(); for message in messages_to_pty { - self.write_to_pane_id(message, PaneId::Terminal(pid), None) + self.write_to_pane_id_without_preprocessing(message, PaneId::Terminal(pid)) .with_context(err_context)?; } if let Some(string) = clipboard_update { @@ -1604,7 +1622,9 @@ impl Tab { pub fn write_to_terminals_on_current_tab( &mut self, - input_bytes: Vec, + key_with_modifier: &Option, + raw_input_bytes: Vec, + raw_input_bytes_are_kitty: bool, client_id: ClientId, ) -> Result { // returns true if a UI update should be triggered (eg. when closing a command pane with @@ -1613,7 +1633,13 @@ impl Tab { let pane_ids = self.get_static_and_floating_pane_ids(); for pane_id in pane_ids { let ui_change_triggered = self - .write_to_pane_id(input_bytes.clone(), pane_id, Some(client_id)) + .write_to_pane_id( + key_with_modifier, + raw_input_bytes.clone(), + raw_input_bytes_are_kitty, + pane_id, + Some(client_id), + ) .context("failed to write to terminals on current tab")?; if ui_change_triggered { should_trigger_ui_change = true; @@ -1624,14 +1650,16 @@ impl Tab { pub fn write_to_active_terminal( &mut self, - input_bytes: Vec, + key_with_modifier: &Option, + raw_input_bytes: Vec, + raw_input_bytes_are_kitty: bool, client_id: ClientId, ) -> Result { // returns true if a UI update should be triggered (eg. if a command pane // was closed with ctrl-c) let err_context = || { format!( - "failed to write to active terminal for client {client_id} - msg: {input_bytes:?}" + "failed to write to active terminal for client {client_id} - msg: {raw_input_bytes:?}" ) }; @@ -1651,9 +1679,15 @@ impl Tab { .get_active_pane_id(client_id) .with_context(err_context)? }; - // Can't use 'err_context' here since it borrows 'input_bytes' - self.write_to_pane_id(input_bytes, pane_id, Some(client_id)) - .with_context(|| format!("failed to write to active terminal for client {client_id}")) + // Can't use 'err_context' here since it borrows 'raw_input_bytes' + self.write_to_pane_id( + key_with_modifier, + raw_input_bytes, + raw_input_bytes_are_kitty, + pane_id, + Some(client_id), + ) + .with_context(|| format!("failed to write to active terminal for client {client_id}")) } pub fn write_to_terminal_at( @@ -1670,7 +1704,7 @@ impl Tab { .get_pane_id_at(position, false) .with_context(err_context)?; if let Some(pane_id) = pane_id { - self.write_to_pane_id(input_bytes, pane_id, Some(client_id)) + self.write_to_pane_id(&None, input_bytes, false, pane_id, Some(client_id)) .with_context(err_context)?; return Ok(()); } @@ -1680,7 +1714,7 @@ impl Tab { .get_pane_id_at(position, false) .with_context(err_context)?; if let Some(pane_id) = pane_id { - self.write_to_pane_id(input_bytes, pane_id, Some(client_id)) + self.write_to_pane_id(&None, input_bytes, false, pane_id, Some(client_id)) .with_context(err_context)?; return Ok(()); } @@ -1689,7 +1723,9 @@ impl Tab { pub fn write_to_pane_id( &mut self, - input_bytes: Vec, + key_with_modifier: &Option, + raw_input_bytes: Vec, + raw_input_bytes_are_kitty: bool, pane_id: PaneId, client_id: Option, ) -> Result { @@ -1720,7 +1756,11 @@ impl Tab { match pane_id { PaneId::Terminal(active_terminal_id) => { - match active_terminal.adjust_input_to_terminal(input_bytes) { + match active_terminal.adjust_input_to_terminal( + key_with_modifier, + raw_input_bytes, + raw_input_bytes_are_kitty, + ) { Some(AdjustedInput::WriteBytesToTerminal(adjusted_input)) => { self.senders .send_to_pty_writer(PtyWriteInstruction::Write( @@ -1758,12 +1798,26 @@ impl Tab { None => {}, } }, - PaneId::Plugin(pid) => match active_terminal.adjust_input_to_terminal(input_bytes) { + PaneId::Plugin(pid) => match active_terminal.adjust_input_to_terminal( + key_with_modifier, + raw_input_bytes, + raw_input_bytes_are_kitty, + ) { + Some(AdjustedInput::WriteKeyToPlugin(key_with_modifier)) => { + self.senders + .send_to_plugin(PluginInstruction::Update(vec![( + Some(pid), + client_id, + Event::Key(key_with_modifier), + )])) + .with_context(err_context)?; + }, Some(AdjustedInput::WriteBytesToTerminal(adjusted_input)) => { let mut plugin_updates = vec![]; for key in parse_keys(&adjusted_input) { plugin_updates.push((Some(pid), client_id, Event::Key(key))); } + log::info!("plugin_updates: {:?}", plugin_updates); self.senders .send_to_plugin(PluginInstruction::Update(plugin_updates)) .with_context(err_context)?; @@ -1787,6 +1841,32 @@ impl Tab { } Ok(should_update_ui) } + pub fn write_to_pane_id_without_preprocessing( + &mut self, + raw_input_bytes: Vec, + pane_id: PaneId, + ) -> Result { + // returns true if we need to update the UI (eg. when a command pane is closed with ctrl-c) + let err_context = || format!("failed to write to pane with id {pane_id:?}"); + + let mut should_update_ui = false; + + match pane_id { + PaneId::Terminal(active_terminal_id) => { + self.senders + .send_to_pty_writer(PtyWriteInstruction::Write( + raw_input_bytes, + active_terminal_id, + )) + .with_context(err_context)?; + should_update_ui = true; + }, + PaneId::Plugin(_pid) => { + log::error!("Unsupported plugin action"); + }, + } + Ok(should_update_ui) + } pub fn get_active_terminal_cursor_position( &self, client_id: ClientId, @@ -2889,8 +2969,13 @@ impl Tab { let relative_position = pane.relative_position(position); if let Some(mouse_event) = pane.mouse_left_click(&relative_position, false) { if !pane.position_is_on_frame(position) { - self.write_to_active_terminal(mouse_event.into_bytes(), client_id) - .with_context(err_context)?; + self.write_to_active_terminal( + &None, + mouse_event.into_bytes(), + false, + client_id, + ) + .with_context(err_context)?; } } else { pane.start_selection(&relative_position, client_id); @@ -2919,8 +3004,13 @@ impl Tab { let relative_position = pane.relative_position(position); if let Some(mouse_event) = pane.mouse_right_click(&relative_position, false) { if !pane.position_is_on_frame(position) { - self.write_to_active_terminal(mouse_event.into_bytes(), client_id) - .with_context(err_context)?; + self.write_to_active_terminal( + &None, + mouse_event.into_bytes(), + false, + client_id, + ) + .with_context(err_context)?; } } else { pane.handle_right_click(&relative_position, client_id); @@ -2946,8 +3036,13 @@ impl Tab { let relative_position = pane.relative_position(position); if let Some(mouse_event) = pane.mouse_middle_click(&relative_position, false) { if !pane.position_is_on_frame(position) { - self.write_to_active_terminal(mouse_event.into_bytes(), client_id) - .with_context(err_context)?; + self.write_to_active_terminal( + &None, + mouse_event.into_bytes(), + false, + client_id, + ) + .with_context(err_context)?; } } }; @@ -3006,7 +3101,7 @@ impl Tab { ); if let Some(mouse_event) = active_pane.mouse_right_click_release(&relative_position) { - self.write_to_active_terminal(mouse_event.into_bytes(), client_id) + self.write_to_active_terminal(&None, mouse_event.into_bytes(), false, client_id) .with_context(err_context)?; } } @@ -3039,7 +3134,7 @@ impl Tab { ); if let Some(mouse_event) = active_pane.mouse_middle_click_release(&relative_position) { - self.write_to_active_terminal(mouse_event.into_bytes(), client_id) + self.write_to_active_terminal(&None, mouse_event.into_bytes(), false, client_id) .with_context(err_context)?; } } @@ -3084,7 +3179,7 @@ impl Tab { ); if let Some(mouse_event) = active_pane.mouse_left_click_release(&relative_position) { - self.write_to_active_terminal(mouse_event.into_bytes(), client_id) + self.write_to_active_terminal(&None, mouse_event.into_bytes(), false, client_id) .with_context(err_context)?; } else { let relative_position = active_pane.relative_position(position); @@ -3163,8 +3258,13 @@ impl Tab { .min(active_pane.get_content_rows() as isize), ); if let Some(mouse_event) = active_pane.mouse_left_click(&relative_position, true) { - self.write_to_active_terminal(mouse_event.into_bytes(), client_id) - .with_context(err_context)?; + self.write_to_active_terminal( + &None, + mouse_event.into_bytes(), + false, + client_id, + ) + .with_context(err_context)?; return Ok(true); // we need to re-render in this case so the selection disappears } } else if selecting { @@ -3210,8 +3310,13 @@ impl Tab { .min(active_pane.get_content_rows() as isize), ); if let Some(mouse_event) = active_pane.mouse_right_click(&relative_position, true) { - self.write_to_active_terminal(mouse_event.into_bytes(), client_id) - .with_context(err_context)?; + self.write_to_active_terminal( + &None, + mouse_event.into_bytes(), + false, + client_id, + ) + .with_context(err_context)?; return Ok(true); // we need to re-render in this case so the selection disappears } } @@ -3254,8 +3359,13 @@ impl Tab { ); if let Some(mouse_event) = active_pane.mouse_middle_click(&relative_position, true) { - self.write_to_active_terminal(mouse_event.into_bytes(), client_id) - .with_context(err_context)?; + self.write_to_active_terminal( + &None, + mouse_event.into_bytes(), + false, + client_id, + ) + .with_context(err_context)?; return Ok(true); // we need to re-render in this case so the selection disappears } } diff --git a/zellij-server/src/tab/unit/tab_integration_tests.rs b/zellij-server/src/tab/unit/tab_integration_tests.rs index f8953235..ba62daa0 100644 --- a/zellij-server/src/tab/unit/tab_integration_tests.rs +++ b/zellij-server/src/tab/unit/tab_integration_tests.rs @@ -226,6 +226,7 @@ fn create_new_tab(size: Size, default_mode: ModeInfo) -> Tab { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut tab = Tab::new( index, position, @@ -251,6 +252,7 @@ fn create_new_tab(size: Size, default_mode: ModeInfo) -> Tab { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); tab.apply_layout( TiledPaneLayout::default(), @@ -303,6 +305,7 @@ fn create_new_tab_with_swap_layouts( let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut tab = Tab::new( index, position, @@ -328,6 +331,7 @@ fn create_new_tab_with_swap_layouts( debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let ( base_layout, @@ -382,6 +386,7 @@ fn create_new_tab_with_os_api( let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut tab = Tab::new( index, position, @@ -407,6 +412,7 @@ fn create_new_tab_with_os_api( debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); tab.apply_layout( TiledPaneLayout::default(), @@ -447,6 +453,7 @@ fn create_new_tab_with_layout(size: Size, default_mode: ModeInfo, layout: &str) let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut tab = Tab::new( index, position, @@ -472,6 +479,7 @@ fn create_new_tab_with_layout(size: Size, default_mode: ModeInfo, layout: &str) debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let pane_ids = tab_layout .extract_run_instructions() @@ -526,6 +534,7 @@ fn create_new_tab_with_mock_pty_writer( let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut tab = Tab::new( index, position, @@ -551,6 +560,7 @@ fn create_new_tab_with_mock_pty_writer( debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); tab.apply_layout( TiledPaneLayout::default(), @@ -596,6 +606,7 @@ fn create_new_tab_with_sixel_support( let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut tab = Tab::new( index, position, @@ -621,6 +632,7 @@ fn create_new_tab_with_sixel_support( debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); tab.apply_layout( TiledPaneLayout::default(), @@ -659,6 +671,7 @@ fn take_snapshot(ansi_instructions: &str, rows: usize, columns: usize, palette: let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( rows, columns, @@ -671,6 +684,7 @@ fn take_snapshot(ansi_instructions: &str, rows: usize, columns: usize, palette: debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let mut vte_parser = vte::Parser::new(); for &byte in ansi_instructions.as_bytes() { @@ -694,6 +708,7 @@ fn take_snapshot_with_sixel( let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( rows, columns, @@ -706,6 +721,7 @@ fn take_snapshot_with_sixel( debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let mut vte_parser = vte::Parser::new(); for &byte in ansi_instructions.as_bytes() { @@ -726,6 +742,7 @@ fn take_snapshot_and_cursor_position( let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( rows, columns, @@ -738,6 +755,7 @@ fn take_snapshot_and_cursor_position( debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let mut vte_parser = vte::Parser::new(); for &byte in ansi_instructions.as_bytes() { @@ -2882,11 +2900,11 @@ fn pane_bracketed_paste_ignored_when_not_in_bracketed_paste_mode() { let bracketed_paste_start = vec![27, 91, 50, 48, 48, 126]; // \u{1b}[200~ let bracketed_paste_end = vec![27, 91, 50, 48, 49, 126]; // \u{1b}[201 - tab.write_to_active_terminal(bracketed_paste_start, client_id) + tab.write_to_active_terminal(&None, bracketed_paste_start, false, client_id) .unwrap(); - tab.write_to_active_terminal("test".as_bytes().to_vec(), client_id) + tab.write_to_active_terminal(&None, "test".as_bytes().to_vec(), false, client_id) .unwrap(); - tab.write_to_active_terminal(bracketed_paste_end, client_id) + tab.write_to_active_terminal(&None, bracketed_paste_end, false, client_id) .unwrap(); pty_instruction_bus.exit(); diff --git a/zellij-server/src/tab/unit/tab_tests.rs b/zellij-server/src/tab/unit/tab_tests.rs index d1a3c020..5ad917ea 100644 --- a/zellij-server/src/tab/unit/tab_tests.rs +++ b/zellij-server/src/tab/unit/tab_tests.rs @@ -167,6 +167,7 @@ fn create_new_tab(size: Size) -> Tab { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut tab = Tab::new( index, position, @@ -192,6 +193,7 @@ fn create_new_tab(size: Size) -> Tab { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); tab.apply_layout( TiledPaneLayout::default(), @@ -229,6 +231,7 @@ fn create_new_tab_with_layout(size: Size, layout: TiledPaneLayout) -> Tab { let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut tab = Tab::new( index, position, @@ -254,6 +257,7 @@ fn create_new_tab_with_layout(size: Size, layout: TiledPaneLayout) -> Tab { debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let mut new_terminal_ids = vec![]; for i in 0..layout.extract_run_instructions().len() { @@ -297,6 +301,7 @@ fn create_new_tab_with_cell_size( let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut tab = Tab::new( index, position, @@ -322,6 +327,7 @@ fn create_new_tab_with_cell_size( debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); tab.apply_layout( TiledPaneLayout::default(), @@ -352,8 +358,14 @@ fn write_to_suppressed_pane() { // Make sure it's suppressed now tab.suppressed_panes.get(&PaneId::Terminal(2)).unwrap(); // Write content to it - tab.write_to_pane_id(vec![34, 127, 31, 82, 17, 182], PaneId::Terminal(2), None) - .unwrap(); + tab.write_to_pane_id( + &None, + vec![34, 127, 31, 82, 17, 182], + false, + PaneId::Terminal(2), + None, + ) + .unwrap(); } #[test] diff --git a/zellij-server/src/unit/screen_tests.rs b/zellij-server/src/unit/screen_tests.rs index 50df6a29..bb26b5f4 100644 --- a/zellij-server/src/unit/screen_tests.rs +++ b/zellij-server/src/unit/screen_tests.rs @@ -70,6 +70,7 @@ fn take_snapshots_and_cursor_coordinates_from_render_events<'a>( let debug = false; let arrow_fonts = true; let styled_underlines = true; + let explicitly_disable_kitty_keyboard_protocol = false; let mut grid = Grid::new( screen_size.rows, screen_size.cols, @@ -82,6 +83,7 @@ fn take_snapshots_and_cursor_coordinates_from_render_events<'a>( debug, arrow_fonts, styled_underlines, + explicitly_disable_kitty_keyboard_protocol, ); let snapshots: Vec<(Option<(usize, usize)>, String)> = all_events .filter_map(|server_instruction| { @@ -252,6 +254,7 @@ fn create_new_screen(size: Size) -> Screen { let debug = false; let styled_underlines = true; let arrow_fonts = true; + let explicitly_disable_kitty_keyboard_protocol = false; let screen = Screen::new( bus, &client_attributes, @@ -271,6 +274,7 @@ fn create_new_screen(size: Size) -> Screen { styled_underlines, arrow_fonts, layout_dir, + explicitly_disable_kitty_keyboard_protocol, ); screen } diff --git a/zellij-utils/Cargo.toml b/zellij-utils/Cargo.toml index 4cb9db77..94411a15 100644 --- a/zellij-utils/Cargo.toml +++ b/zellij-utils/Cargo.toml @@ -43,6 +43,7 @@ thiserror = "1.0.30" unicode-width = "0.1.8" url = { version = "2.2.2", features = ["serde"] } uuid = { version = "1.4.1", features = ["serde", "v4"] } +bitflags = "2.5.0" vte = { version = "0.11.0", default-features = false } #[cfg(not(target_family = "wasm"))] diff --git a/zellij-utils/assets/config/default.kdl b/zellij-utils/assets/config/default.kdl index 0d49686e..e830cd09 100644 --- a/zellij-utils/assets/config/default.kdl +++ b/zellij-utils/assets/config/default.kdl @@ -363,3 +363,8 @@ plugins { // Default: false // // disable_session_metadata true + +// Enable or disable support for the enhanced Kitty Keyboard Protocol (the host terminal must also support it) +// Default: true (if the host terminal supports it) +// +// support_kitty_keyboard_protocol false diff --git a/zellij-utils/assets/plugins/compact-bar.wasm b/zellij-utils/assets/plugins/compact-bar.wasm index c4296d9f..e585f4ab 100755 Binary files a/zellij-utils/assets/plugins/compact-bar.wasm and b/zellij-utils/assets/plugins/compact-bar.wasm differ diff --git a/zellij-utils/assets/plugins/fixture-plugin-for-tests.wasm b/zellij-utils/assets/plugins/fixture-plugin-for-tests.wasm index 0d0ce2c2..bb260003 100755 Binary files a/zellij-utils/assets/plugins/fixture-plugin-for-tests.wasm and b/zellij-utils/assets/plugins/fixture-plugin-for-tests.wasm differ diff --git a/zellij-utils/assets/plugins/session-manager.wasm b/zellij-utils/assets/plugins/session-manager.wasm index f2e91623..7d2fad73 100755 Binary files a/zellij-utils/assets/plugins/session-manager.wasm and b/zellij-utils/assets/plugins/session-manager.wasm differ diff --git a/zellij-utils/assets/plugins/status-bar.wasm b/zellij-utils/assets/plugins/status-bar.wasm index fe9fea19..4e882917 100755 Binary files a/zellij-utils/assets/plugins/status-bar.wasm and b/zellij-utils/assets/plugins/status-bar.wasm differ diff --git a/zellij-utils/assets/plugins/strider.wasm b/zellij-utils/assets/plugins/strider.wasm index fb425f36..a339363c 100755 Binary files a/zellij-utils/assets/plugins/strider.wasm and b/zellij-utils/assets/plugins/strider.wasm differ diff --git a/zellij-utils/assets/plugins/tab-bar.wasm b/zellij-utils/assets/plugins/tab-bar.wasm index 00758ffb..afb73e8a 100755 Binary files a/zellij-utils/assets/plugins/tab-bar.wasm and b/zellij-utils/assets/plugins/tab-bar.wasm differ diff --git a/zellij-utils/assets/prost/api.key.rs b/zellij-utils/assets/prost/api.key.rs index 186f41c1..92c47492 100644 --- a/zellij-utils/assets/prost/api.key.rs +++ b/zellij-utils/assets/prost/api.key.rs @@ -3,6 +3,8 @@ pub struct Key { #[prost(enumeration = "key::KeyModifier", optional, tag = "1")] pub modifier: ::core::option::Option, + #[prost(enumeration = "key::KeyModifier", repeated, tag = "4")] + pub additional_modifiers: ::prost::alloc::vec::Vec, #[prost(oneof = "key::MainKey", tags = "2, 3")] pub main_key: ::core::option::Option, } @@ -23,6 +25,8 @@ pub mod key { pub enum KeyModifier { Ctrl = 0, Alt = 1, + Shift = 2, + Super = 3, } impl KeyModifier { /// String value of the enum field names used in the ProtoBuf definition. @@ -33,6 +37,8 @@ pub mod key { match self { KeyModifier::Ctrl => "CTRL", KeyModifier::Alt => "ALT", + KeyModifier::Shift => "SHIFT", + KeyModifier::Super => "SUPER", } } /// Creates an enum from field names used in the ProtoBuf definition. @@ -40,6 +46,8 @@ pub mod key { match value { "CTRL" => Some(Self::Ctrl), "ALT" => Some(Self::Alt), + "SHIFT" => Some(Self::Shift), + "SUPER" => Some(Self::Super), _ => None, } } @@ -82,6 +90,13 @@ pub mod key { F12 = 22, Tab = 23, Esc = 24, + CapsLock = 25, + ScrollLock = 26, + NumLock = 27, + PrintScreen = 28, + Pause = 29, + Menu = 30, + Enter = 31, } impl NamedKey { /// String value of the enum field names used in the ProtoBuf definition. @@ -115,6 +130,13 @@ pub mod key { NamedKey::F12 => "F12", NamedKey::Tab => "Tab", NamedKey::Esc => "Esc", + NamedKey::CapsLock => "CapsLock", + NamedKey::ScrollLock => "ScrollLock", + NamedKey::NumLock => "NumLock", + NamedKey::PrintScreen => "PrintScreen", + NamedKey::Pause => "Pause", + NamedKey::Menu => "Menu", + NamedKey::Enter => "Enter", } } /// Creates an enum from field names used in the ProtoBuf definition. @@ -145,6 +167,13 @@ pub mod key { "F12" => Some(Self::F12), "Tab" => Some(Self::Tab), "Esc" => Some(Self::Esc), + "CapsLock" => Some(Self::CapsLock), + "ScrollLock" => Some(Self::ScrollLock), + "NumLock" => Some(Self::NumLock), + "PrintScreen" => Some(Self::PrintScreen), + "Pause" => Some(Self::Pause), + "Menu" => Some(Self::Menu), + "Enter" => Some(Self::Enter), _ => None, } } diff --git a/zellij-utils/src/data.rs b/zellij-utils/src/data.rs index c09c0d43..2625b252 100644 --- a/zellij-utils/src/data.rs +++ b/zellij-utils/src/data.rs @@ -3,14 +3,20 @@ use crate::input::config::ConversionError; use crate::input::layout::SplitSize; use clap::ArgEnum; use serde::{Deserialize, Serialize}; -use std::collections::{BTreeMap, HashMap, HashSet}; +use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet}; use std::fmt; use std::fs::Metadata; use std::path::{Path, PathBuf}; -use std::str::FromStr; +use std::str::{self, FromStr}; use std::time::Duration; use strum_macros::{Display, EnumDiscriminants, EnumIter, EnumString, ToString}; +#[cfg(not(target_family = "wasm"))] +use termwiz::{ + escape::csi::KittyKeyboardFlags, + input::{KeyCode, KeyCodeEncodeModes, KeyboardEncoding, Modifiers}, +}; + pub type ClientId = u16; // TODO: merge with crate type? pub fn client_id_to_colors( @@ -37,13 +43,107 @@ pub fn single_client_color(colors: Palette) -> (PaletteColor, PaletteColor) { (colors.green, colors.black) } -// TODO: Add a shortened string representation (beyond `Display::fmt` below) that can be used when -// screen space is scarce. Useful for e.g. "ENTER", "SPACE", "TAB" to display as Unicode -// representations instead. -// NOTE: Do not reorder the key variants since that influences what the `status_bar` plugin -// displays! -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, PartialOrd, Ord)] -pub enum Key { +impl FromStr for KeyWithModifier { + type Err = Box; + fn from_str(key_str: &str) -> Result { + let mut key_string_parts: Vec<&str> = key_str.split_ascii_whitespace().collect(); + let bare_key: BareKey = BareKey::from_str(key_string_parts.pop().ok_or("empty key")?)?; + let mut key_modifiers: BTreeSet = BTreeSet::new(); + for stringified_modifier in key_string_parts { + key_modifiers.insert(KeyModifier::from_str(stringified_modifier)?); + } + Ok(KeyWithModifier { + bare_key, + key_modifiers, + }) + } +} + +#[derive(Debug, Clone, Eq, Serialize, Deserialize, PartialOrd, Ord)] +pub struct KeyWithModifier { + pub bare_key: BareKey, + pub key_modifiers: BTreeSet, +} + +impl PartialEq for KeyWithModifier { + fn eq(&self, other: &Self) -> bool { + match (self.bare_key, other.bare_key) { + (BareKey::Char(self_char), BareKey::Char(other_char)) + if self_char.to_ascii_lowercase() == other_char.to_ascii_lowercase() => + { + let mut self_cloned = self.clone(); + let mut other_cloned = other.clone(); + if self_char.is_ascii_uppercase() { + self_cloned.bare_key = BareKey::Char(self_char.to_ascii_lowercase()); + self_cloned.key_modifiers.insert(KeyModifier::Shift); + } + if other_char.is_ascii_uppercase() { + other_cloned.bare_key = BareKey::Char(self_char.to_ascii_lowercase()); + other_cloned.key_modifiers.insert(KeyModifier::Shift); + } + self_cloned.bare_key == other_cloned.bare_key + && self_cloned.key_modifiers == other_cloned.key_modifiers + }, + _ => self.bare_key == other.bare_key && self.key_modifiers == other.key_modifiers, + } + } +} + +impl Hash for KeyWithModifier { + fn hash(&self, state: &mut H) { + match self.bare_key { + BareKey::Char(character) if character.is_ascii_uppercase() => { + let mut to_hash = self.clone(); + to_hash.bare_key = BareKey::Char(character.to_ascii_lowercase()); + to_hash.key_modifiers.insert(KeyModifier::Shift); + to_hash.bare_key.hash(state); + to_hash.key_modifiers.hash(state); + }, + _ => { + self.bare_key.hash(state); + self.key_modifiers.hash(state); + }, + } + } +} + +impl fmt::Display for KeyWithModifier { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + if self.key_modifiers.is_empty() { + write!(f, "{}", self.bare_key) + } else { + write!( + f, + "{} {}", + self.key_modifiers + .iter() + .map(|m| m.to_string()) + .collect::>() + .join("-"), + self.bare_key + ) + } + } +} + +#[cfg(not(target_family = "wasm"))] +impl Into for &KeyModifier { + fn into(self) -> Modifiers { + match self { + KeyModifier::Shift => Modifiers::SHIFT, + KeyModifier::Alt => Modifiers::ALT, + KeyModifier::Ctrl => Modifiers::CTRL, + KeyModifier::Super => Modifiers::SUPER, + KeyModifier::Hyper => Modifiers::NONE, + KeyModifier::Meta => Modifiers::NONE, + KeyModifier::CapsLock => Modifiers::NONE, + KeyModifier::NumLock => Modifiers::NONE, + } + } +} + +#[derive(Eq, Clone, Copy, Debug, PartialEq, Hash, Deserialize, Serialize, PartialOrd, Ord)] +pub enum BareKey { PageDown, PageUp, Left, @@ -57,149 +157,398 @@ pub enum Key { Insert, F(u8), Char(char), - Alt(CharOrArrow), - Ctrl(char), - BackTab, - Null, + Tab, Esc, - AltF(u8), - CtrlF(u8), + Enter, + CapsLock, + ScrollLock, + NumLock, + PrintScreen, + Pause, + Menu, } -impl FromStr for Key { +impl fmt::Display for BareKey { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + BareKey::PageDown => write!(f, "PgDn"), + BareKey::PageUp => write!(f, "PgUp"), + BareKey::Left => write!(f, "←"), + BareKey::Down => write!(f, "↓"), + BareKey::Up => write!(f, "↑"), + BareKey::Right => write!(f, "→"), + BareKey::Home => write!(f, "HOME"), + BareKey::End => write!(f, "END"), + BareKey::Backspace => write!(f, "BACKSPACE"), + BareKey::Delete => write!(f, "DEL"), + BareKey::Insert => write!(f, "INS"), + BareKey::F(index) => write!(f, "F{}", index), + BareKey::Char(' ') => write!(f, "SPACE"), + BareKey::Char(character) => write!(f, "{}", character), + BareKey::Tab => write!(f, "TAB"), + BareKey::Esc => write!(f, "ESC"), + BareKey::Enter => write!(f, "ENTER"), + BareKey::CapsLock => write!(f, "CAPSlOCK"), + BareKey::ScrollLock => write!(f, "SCROLLlOCK"), + BareKey::NumLock => write!(f, "NUMLOCK"), + BareKey::PrintScreen => write!(f, "PRINTSCREEN"), + BareKey::Pause => write!(f, "PAUSE"), + BareKey::Menu => write!(f, "MENU"), + } + } +} + +impl FromStr for BareKey { type Err = Box; fn from_str(key_str: &str) -> Result { - let mut modifier: Option<&str> = None; - let mut main_key: Option<&str> = None; - for (index, part) in key_str.split_ascii_whitespace().enumerate() { - if index == 0 && (part == "Ctrl" || part == "Alt") { - modifier = Some(part); - } else if main_key.is_none() { - main_key = Some(part) + match key_str.to_ascii_lowercase().as_str() { + "pagedown" => Ok(BareKey::PageDown), + "pageup" => Ok(BareKey::PageUp), + "left" => Ok(BareKey::Left), + "down" => Ok(BareKey::Down), + "up" => Ok(BareKey::Up), + "right" => Ok(BareKey::Right), + "home" => Ok(BareKey::Home), + "end" => Ok(BareKey::End), + "backspace" => Ok(BareKey::Backspace), + "delete" => Ok(BareKey::Delete), + "insert" => Ok(BareKey::Insert), + "f1" => Ok(BareKey::F(1)), + "f2" => Ok(BareKey::F(2)), + "f3" => Ok(BareKey::F(3)), + "f4" => Ok(BareKey::F(4)), + "f5" => Ok(BareKey::F(5)), + "f6" => Ok(BareKey::F(6)), + "f7" => Ok(BareKey::F(7)), + "f8" => Ok(BareKey::F(8)), + "f9" => Ok(BareKey::F(9)), + "f10" => Ok(BareKey::F(10)), + "f11" => Ok(BareKey::F(11)), + "f12" => Ok(BareKey::F(12)), + "tab" => Ok(BareKey::Tab), + "esc" => Ok(BareKey::Esc), + "enter" => Ok(BareKey::Enter), + "capsLock" => Ok(BareKey::CapsLock), + "scrollLock" => Ok(BareKey::ScrollLock), + "numlock" => Ok(BareKey::NumLock), + "printscreen" => Ok(BareKey::PrintScreen), + "pause" => Ok(BareKey::Pause), + "menu" => Ok(BareKey::Menu), + "space" => Ok(BareKey::Char(' ')), + _ => { + if key_str.chars().count() == 1 { + if let Some(character) = key_str.chars().next() { + return Ok(BareKey::Char(character)); + } + } + Err("unsupported key".into()) + }, + } + } +} + +#[derive( + Eq, Clone, Copy, Debug, PartialEq, Hash, Deserialize, Serialize, PartialOrd, Ord, ToString, +)] +pub enum KeyModifier { + Ctrl, + Alt, + Shift, + Super, + Hyper, + Meta, + CapsLock, + NumLock, +} + +impl FromStr for KeyModifier { + type Err = Box; + fn from_str(key_str: &str) -> Result { + match key_str.to_ascii_lowercase().as_str() { + "shift" => Ok(KeyModifier::Shift), + "alt" => Ok(KeyModifier::Alt), + "ctrl" => Ok(KeyModifier::Ctrl), + "super" => Ok(KeyModifier::Super), + _ => Err("unsupported modifier".into()), + } + } +} + +impl BareKey { + pub fn from_bytes_with_u(bytes: &[u8]) -> Option { + match str::from_utf8(bytes) { + Ok("27") => Some(BareKey::Esc), + Ok("13") => Some(BareKey::Enter), + Ok("9") => Some(BareKey::Tab), + Ok("127") => Some(BareKey::Backspace), + Ok("57358") => Some(BareKey::CapsLock), + Ok("57359") => Some(BareKey::ScrollLock), + Ok("57360") => Some(BareKey::NumLock), + Ok("57361") => Some(BareKey::PrintScreen), + Ok("57362") => Some(BareKey::Pause), + Ok("57363") => Some(BareKey::Menu), + Ok(num) => u8::from_str_radix(num, 10) + .ok() + .map(|n| BareKey::Char((n as char).to_ascii_lowercase())), + _ => None, + } + } + pub fn from_bytes_with_tilde(bytes: &[u8]) -> Option { + match str::from_utf8(bytes) { + Ok("2") => Some(BareKey::Insert), + Ok("3") => Some(BareKey::Delete), + Ok("5") => Some(BareKey::PageUp), + Ok("6") => Some(BareKey::PageDown), + Ok("7") => Some(BareKey::Home), + Ok("8") => Some(BareKey::End), + Ok("11") => Some(BareKey::F(1)), + Ok("12") => Some(BareKey::F(2)), + Ok("13") => Some(BareKey::F(3)), + Ok("14") => Some(BareKey::F(4)), + Ok("15") => Some(BareKey::F(5)), + Ok("17") => Some(BareKey::F(6)), + Ok("18") => Some(BareKey::F(7)), + Ok("19") => Some(BareKey::F(8)), + Ok("20") => Some(BareKey::F(9)), + Ok("21") => Some(BareKey::F(10)), + Ok("23") => Some(BareKey::F(11)), + Ok("24") => Some(BareKey::F(12)), + _ => None, + } + } + pub fn from_bytes_with_no_ending_byte(bytes: &[u8]) -> Option { + match str::from_utf8(bytes) { + Ok("1D") | Ok("D") => Some(BareKey::Left), + Ok("1C") | Ok("C") => Some(BareKey::Right), + Ok("1A") | Ok("A") => Some(BareKey::Up), + Ok("1B") | Ok("B") => Some(BareKey::Down), + Ok("1H") | Ok("H") => Some(BareKey::Home), + Ok("1F") | Ok("F") => Some(BareKey::End), + Ok("1P") | Ok("P") => Some(BareKey::F(1)), + Ok("1Q") | Ok("Q") => Some(BareKey::F(2)), + Ok("1S") | Ok("S") => Some(BareKey::F(4)), + _ => None, + } + } +} + +bitflags::bitflags! { + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + struct ModifierFlags: u8 { + const SHIFT = 0b0000_0001; + const ALT = 0b0000_0010; + const CONTROL = 0b0000_0100; + const SUPER = 0b0000_1000; + const HYPER = 0b0001_0000; + const META = 0b0010_0000; + const CAPS_LOCK = 0b0100_0000; + const NUM_LOCK = 0b1000_0000; + } +} + +impl KeyModifier { + pub fn from_bytes(bytes: &[u8]) -> BTreeSet { + let modifier_flags = str::from_utf8(bytes) + .ok() // convert to string: (eg. "16") + .and_then(|s| u8::from_str_radix(&s, 10).ok()) // convert to u8: (eg. 16) + .map(|s| s.saturating_sub(1)) // subtract 1: (eg. 15) + .and_then(|b| ModifierFlags::from_bits(b)); // bitflags: (0b0000_1111: Shift, Alt, Control, Super) + let mut key_modifiers = BTreeSet::new(); + if let Some(modifier_flags) = modifier_flags { + for name in modifier_flags.iter() { + match name { + ModifierFlags::SHIFT => key_modifiers.insert(KeyModifier::Shift), + ModifierFlags::ALT => key_modifiers.insert(KeyModifier::Alt), + ModifierFlags::CONTROL => key_modifiers.insert(KeyModifier::Ctrl), + ModifierFlags::SUPER => key_modifiers.insert(KeyModifier::Super), + ModifierFlags::HYPER => key_modifiers.insert(KeyModifier::Hyper), + ModifierFlags::META => key_modifiers.insert(KeyModifier::Meta), + ModifierFlags::CAPS_LOCK => key_modifiers.insert(KeyModifier::CapsLock), + ModifierFlags::NUM_LOCK => key_modifiers.insert(KeyModifier::NumLock), + _ => false, + }; } } - match (modifier, main_key) { - (Some("Ctrl"), Some(main_key)) if main_key == "@" || main_key == "Space" => { - Ok(Key::Char('\x00')) - }, - (Some("Ctrl"), Some(main_key)) => { - parse_main_key(main_key, key_str, Key::Ctrl, Key::CtrlF) - }, - (Some("Alt"), Some(main_key)) => { - match main_key { - // why crate::data::Direction and not just Direction? - // Because it's a different type that we export in this wasm mandated soup - we - // don't like it either! This will be solved as we chip away at our tech-debt - "Left" => Ok(Key::Alt(CharOrArrow::Direction(Direction::Left))), - "Right" => Ok(Key::Alt(CharOrArrow::Direction(Direction::Right))), - "Up" => Ok(Key::Alt(CharOrArrow::Direction(Direction::Up))), - "Down" => Ok(Key::Alt(CharOrArrow::Direction(Direction::Down))), - _ => parse_main_key( - main_key, - key_str, - |c| Key::Alt(CharOrArrow::Char(c)), - Key::AltF, - ), - } - }, - (None, Some(main_key)) => match main_key { - "Backspace" => Ok(Key::Backspace), - "Left" => Ok(Key::Left), - "Right" => Ok(Key::Right), - "Up" => Ok(Key::Up), - "Down" => Ok(Key::Down), - "Home" => Ok(Key::Home), - "End" => Ok(Key::End), - "PageUp" => Ok(Key::PageUp), - "PageDown" => Ok(Key::PageDown), - "Tab" => Ok(Key::BackTab), - "Delete" => Ok(Key::Delete), - "Insert" => Ok(Key::Insert), - "Space" => Ok(Key::Char(' ')), - "Enter" => Ok(Key::Char('\n')), - "Esc" => Ok(Key::Esc), - _ => parse_main_key(main_key, key_str, Key::Char, Key::F), - }, - _ => Err(format!("Failed to parse key: {}", key_str).into()), - } + key_modifiers } } -fn parse_main_key( - main_key: &str, - key_str: &str, - to_char_key: impl FnOnce(char) -> Key, - to_fn_key: impl FnOnce(u8) -> Key, -) -> Result> { - let mut key_chars = main_key.chars(); - let key_count = main_key.chars().count(); - if key_count == 1 { - let key_char = key_chars.next().unwrap(); - Ok(to_char_key(key_char)) - } else if key_count > 1 { - if let Some(first_char) = key_chars.next() { - if first_char == 'F' { - let f_index: String = key_chars.collect(); - let f_index: u8 = f_index - .parse() - .map_err(|e| format!("Failed to parse F index: {}", e))?; - if f_index >= 1 && f_index <= 12 { - return Ok(to_fn_key(f_index)); - } +impl KeyWithModifier { + pub fn new(bare_key: BareKey) -> Self { + KeyWithModifier { + bare_key, + key_modifiers: BTreeSet::new(), + } + } + pub fn new_with_modifiers(bare_key: BareKey, key_modifiers: BTreeSet) -> Self { + KeyWithModifier { + bare_key, + key_modifiers, + } + } + pub fn with_shift_modifier(mut self) -> Self { + self.key_modifiers.insert(KeyModifier::Shift); + self + } + pub fn with_alt_modifier(mut self) -> Self { + self.key_modifiers.insert(KeyModifier::Alt); + self + } + pub fn with_ctrl_modifier(mut self) -> Self { + self.key_modifiers.insert(KeyModifier::Ctrl); + self + } + pub fn with_super_modifier(mut self) -> Self { + self.key_modifiers.insert(KeyModifier::Super); + self + } + pub fn from_bytes_with_u(number_bytes: &[u8], modifier_bytes: &[u8]) -> Option { + // CSI number ; modifiers u + let bare_key = BareKey::from_bytes_with_u(number_bytes); + match bare_key { + Some(bare_key) => { + let key_modifiers = KeyModifier::from_bytes(modifier_bytes); + Some(KeyWithModifier { + bare_key, + key_modifiers, + }) + }, + _ => None, + } + } + pub fn from_bytes_with_tilde(number_bytes: &[u8], modifier_bytes: &[u8]) -> Option { + // CSI number ; modifiers ~ + let bare_key = BareKey::from_bytes_with_tilde(number_bytes); + match bare_key { + Some(bare_key) => { + let key_modifiers = KeyModifier::from_bytes(modifier_bytes); + Some(KeyWithModifier { + bare_key, + key_modifiers, + }) + }, + _ => None, + } + } + pub fn from_bytes_with_no_ending_byte( + number_bytes: &[u8], + modifier_bytes: &[u8], + ) -> Option { + // CSI 1; modifiers [ABCDEFHPQS] + let bare_key = BareKey::from_bytes_with_no_ending_byte(number_bytes); + match bare_key { + Some(bare_key) => { + let key_modifiers = KeyModifier::from_bytes(modifier_bytes); + Some(KeyWithModifier { + bare_key, + key_modifiers, + }) + }, + _ => None, + } + } + pub fn strip_common_modifiers(&self, common_modifiers: &Vec) -> Self { + let common_modifiers: BTreeSet<&KeyModifier> = common_modifiers.into_iter().collect(); + KeyWithModifier { + bare_key: self.bare_key.clone(), + key_modifiers: self + .key_modifiers + .iter() + .filter(|m| !common_modifiers.contains(m)) + .cloned() + .collect(), + } + } + pub fn is_key_without_modifier(&self, key: BareKey) -> bool { + self.bare_key == key && self.key_modifiers.is_empty() + } + pub fn is_key_with_ctrl_modifier(&self, key: BareKey) -> bool { + self.bare_key == key && self.key_modifiers.contains(&KeyModifier::Ctrl) + } + pub fn is_key_with_alt_modifier(&self, key: BareKey) -> bool { + self.bare_key == key && self.key_modifiers.contains(&KeyModifier::Alt) + } + pub fn is_key_with_shift_modifier(&self, key: BareKey) -> bool { + self.bare_key == key && self.key_modifiers.contains(&KeyModifier::Shift) + } + pub fn is_key_with_super_modifier(&self, key: BareKey) -> bool { + self.bare_key == key && self.key_modifiers.contains(&KeyModifier::Super) + } + #[cfg(not(target_family = "wasm"))] + pub fn to_termwiz_modifiers(&self) -> Modifiers { + let mut modifiers = Modifiers::empty(); + for modifier in &self.key_modifiers { + modifiers.set(modifier.into(), true); + } + modifiers + } + #[cfg(not(target_family = "wasm"))] + pub fn to_termwiz_keycode(&self) -> KeyCode { + match self.bare_key { + BareKey::PageDown => KeyCode::PageDown, + BareKey::PageUp => KeyCode::PageUp, + BareKey::Left => KeyCode::LeftArrow, + BareKey::Down => KeyCode::DownArrow, + BareKey::Up => KeyCode::UpArrow, + BareKey::Right => KeyCode::RightArrow, + BareKey::Home => KeyCode::Home, + BareKey::End => KeyCode::End, + BareKey::Backspace => KeyCode::Backspace, + BareKey::Delete => KeyCode::Delete, + BareKey::Insert => KeyCode::Insert, + BareKey::F(index) => KeyCode::Function(index), + BareKey::Char(character) => KeyCode::Char(character), + BareKey::Tab => KeyCode::Tab, + BareKey::Esc => KeyCode::Escape, + BareKey::Enter => KeyCode::Enter, + BareKey::CapsLock => KeyCode::CapsLock, + BareKey::ScrollLock => KeyCode::ScrollLock, + BareKey::NumLock => KeyCode::NumLock, + BareKey::PrintScreen => KeyCode::PrintScreen, + BareKey::Pause => KeyCode::Pause, + BareKey::Menu => KeyCode::Menu, + } + } + #[cfg(not(target_family = "wasm"))] + pub fn serialize_non_kitty(&self) -> Option { + let modifiers = self.to_termwiz_modifiers(); + let key_code_encode_modes = KeyCodeEncodeModes { + encoding: KeyboardEncoding::Xterm, + // all these flags are false because they have been dealt with before this + // serialization + application_cursor_keys: false, + newline_mode: false, + modify_other_keys: None, + }; + self.to_termwiz_keycode() + .encode(modifiers, key_code_encode_modes, true) + .ok() + } + #[cfg(not(target_family = "wasm"))] + pub fn serialize_kitty(&self) -> Option { + let modifiers = self.to_termwiz_modifiers(); + let key_code_encode_modes = KeyCodeEncodeModes { + encoding: KeyboardEncoding::Kitty(KittyKeyboardFlags::DISAMBIGUATE_ESCAPE_CODES), + // all these flags are false because they have been dealt with before this + // serialization + application_cursor_keys: false, + newline_mode: false, + modify_other_keys: None, + }; + self.to_termwiz_keycode() + .encode(modifiers, key_code_encode_modes, true) + .ok() + } + pub fn has_no_modifiers(&self) -> bool { + self.key_modifiers.is_empty() + } + pub fn has_modifiers(&self, modifiers: &[KeyModifier]) -> bool { + for modifier in modifiers { + if !self.key_modifiers.contains(modifier) { + return false; } } - Err(format!("Failed to parse key: {}", key_str).into()) - } else { - Err(format!("Failed to parse key: {}", key_str).into()) - } -} - -impl fmt::Display for Key { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self { - Key::Backspace => write!(f, "BACKSPACE"), - Key::Left => write!(f, "{}", Direction::Left), - Key::Right => write!(f, "{}", Direction::Right), - Key::Up => write!(f, "{}", Direction::Up), - Key::Down => write!(f, "{}", Direction::Down), - Key::Home => write!(f, "HOME"), - Key::End => write!(f, "END"), - Key::PageUp => write!(f, "PgUp"), - Key::PageDown => write!(f, "PgDn"), - Key::BackTab => write!(f, "TAB"), - Key::Delete => write!(f, "DEL"), - Key::Insert => write!(f, "INS"), - Key::F(n) => write!(f, "F{}", n), - Key::Char(c) => match c { - '\n' => write!(f, "ENTER"), - '\t' => write!(f, "TAB"), - ' ' => write!(f, "SPACE"), - '\x00' => write!(f, "Ctrl+SPACE"), - _ => write!(f, "{}", c), - }, - Key::Alt(c) => write!(f, "Alt+{}", c), - Key::Ctrl(c) => write!(f, "Ctrl+{}", Key::Char(*c)), - Key::AltF(n) => write!(f, "Alt+F{}", n), - Key::CtrlF(n) => write!(f, "Ctrl+F{}", n), - Key::Null => write!(f, "NULL"), - Key::Esc => write!(f, "ESC"), - } - } -} - -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, PartialOrd, Ord)] -#[serde(untagged)] -pub enum CharOrArrow { - Char(char), - Direction(Direction), -} - -impl fmt::Display for CharOrArrow { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self { - CharOrArrow::Char(c) => write!(f, "{}", Key::Char(*c)), - CharOrArrow::Direction(d) => write!(f, "{}", d), - } + true } } @@ -493,7 +842,7 @@ pub enum Event { TabUpdate(Vec), PaneUpdate(PaneManifest), /// A key was pressed while the user is focused on this plugin's pane - Key(Key), + Key(KeyWithModifier), /// A mouse event happened while the user is focused on this plugin's pane Mouse(Mouse), /// A timer expired set by the `set_timeout` method exported by `zellij-tile`. @@ -756,7 +1105,7 @@ pub struct Style { } // FIXME: Poor devs hashtable since HashTable can't derive `Default`... -pub type KeybindsVec = Vec<(InputMode, Vec<(Key, Vec)>)>; +pub type KeybindsVec = Vec<(InputMode, Vec<(KeyWithModifier, Vec)>)>; /// Provides information helpful in rendering the Zellij controls for UI bars #[derive(Default, Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] @@ -769,11 +1118,11 @@ pub struct ModeInfo { } impl ModeInfo { - pub fn get_mode_keybinds(&self) -> Vec<(Key, Vec)> { + pub fn get_mode_keybinds(&self) -> Vec<(KeyWithModifier, Vec)> { self.get_keybinds_for_mode(self.mode) } - pub fn get_keybinds_for_mode(&self, mode: InputMode) -> Vec<(Key, Vec)> { + pub fn get_keybinds_for_mode(&self, mode: InputMode) -> Vec<(KeyWithModifier, Vec)> { for (vec_mode, map) in &self.keybinds { if mode == *vec_mode { return map.to_vec(); diff --git a/zellij-utils/src/input/actions.rs b/zellij-utils/src/input/actions.rs index 7cc3dd30..cf2f3710 100644 --- a/zellij-utils/src/input/actions.rs +++ b/zellij-utils/src/input/actions.rs @@ -6,7 +6,7 @@ use super::layout::{ SwapFloatingLayout, SwapTiledLayout, TiledPaneLayout, }; use crate::cli::CliAction; -use crate::data::{Direction, Resize}; +use crate::data::{Direction, KeyWithModifier, Resize}; use crate::data::{FloatingPaneCoordinates, InputMode}; use crate::home::{find_default_config_dir, get_layout_dir}; use crate::input::config::{Config, ConfigError, KdlError}; @@ -102,7 +102,7 @@ pub enum Action { /// Quit Zellij. Quit, /// Write to the terminal. - Write(Vec), + Write(Option, Vec, bool), // bool -> is_kitty_keyboard_protocol /// Write Characters to the terminal. WriteChars(String), /// Switch to the specified input mode. @@ -317,7 +317,7 @@ impl Action { config: Option, ) -> Result, String> { match cli_action { - CliAction::Write { bytes } => Ok(vec![Action::Write(bytes)]), + CliAction::Write { bytes } => Ok(vec![Action::Write(None, bytes, false)]), CliAction::WriteChars { chars } => Ok(vec![Action::WriteChars(chars)]), CliAction::Resize { resize, direction } => Ok(vec![Action::Resize(resize, direction)]), CliAction::FocusNextPane => Ok(vec![Action::FocusNextPane]), diff --git a/zellij-utils/src/input/keybinds.rs b/zellij-utils/src/input/keybinds.rs index ab13f711..af923056 100644 --- a/zellij-utils/src/input/keybinds.rs +++ b/zellij-utils/src/input/keybinds.rs @@ -1,14 +1,14 @@ use std::collections::{BTreeMap, HashMap}; use super::actions::Action; -use crate::data::{InputMode, Key, KeybindsVec}; +use crate::data::{InputMode, KeyWithModifier, KeybindsVec}; use serde::{Deserialize, Serialize}; use std::fmt; /// Used in the config struct #[derive(Clone, PartialEq, Deserialize, Serialize, Default)] -pub struct Keybinds(pub HashMap>>); +pub struct Keybinds(pub HashMap>>); impl fmt::Debug for Keybinds { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { @@ -25,7 +25,11 @@ impl fmt::Debug for Keybinds { } impl Keybinds { - pub fn get_actions_for_key_in_mode(&self, mode: &InputMode, key: &Key) -> Option<&Vec> { + pub fn get_actions_for_key_in_mode( + &self, + mode: &InputMode, + key: &KeyWithModifier, + ) -> Option<&Vec> { self.0 .get(mode) .and_then(|normal_mode_keybindings| normal_mode_keybindings.get(key)) @@ -33,21 +37,40 @@ impl Keybinds { pub fn get_actions_for_key_in_mode_or_default_action( &self, mode: &InputMode, - key: &Key, + key_with_modifier: &KeyWithModifier, raw_bytes: Vec, + key_is_kitty_protocol: bool, ) -> Vec { self.0 .get(mode) - .and_then(|normal_mode_keybindings| normal_mode_keybindings.get(key)) + .and_then(|normal_mode_keybindings| normal_mode_keybindings.get(key_with_modifier)) .cloned() - .unwrap_or_else(|| vec![self.default_action_for_mode(mode, raw_bytes)]) + .unwrap_or_else(|| { + vec![self.default_action_for_mode( + mode, + Some(key_with_modifier), + raw_bytes, + key_is_kitty_protocol, + )] + }) } - pub fn get_input_mode_mut(&mut self, input_mode: &InputMode) -> &mut HashMap> { + pub fn get_input_mode_mut( + &mut self, + input_mode: &InputMode, + ) -> &mut HashMap> { self.0.entry(*input_mode).or_insert_with(HashMap::new) } - pub fn default_action_for_mode(&self, mode: &InputMode, raw_bytes: Vec) -> Action { + pub fn default_action_for_mode( + &self, + mode: &InputMode, + key_with_modifier: Option<&KeyWithModifier>, + raw_bytes: Vec, + key_is_kitty_protocol: bool, + ) -> Action { match *mode { - InputMode::Normal | InputMode::Locked => Action::Write(raw_bytes), + InputMode::Normal | InputMode::Locked => { + Action::Write(key_with_modifier.cloned(), raw_bytes, key_is_kitty_protocol) + }, InputMode::RenameTab => Action::TabNameInput(raw_bytes), InputMode::RenamePane => Action::PaneNameInput(raw_bytes), InputMode::EnterSearch => Action::SearchInput(raw_bytes), @@ -57,7 +80,7 @@ impl Keybinds { pub fn to_keybinds_vec(&self) -> KeybindsVec { let mut ret = vec![]; for (mode, mode_binds) in &self.0 { - let mut mode_binds_vec: Vec<(Key, Vec)> = vec![]; + let mut mode_binds_vec: Vec<(KeyWithModifier, Vec)> = vec![]; for (key, actions) in mode_binds { mode_binds_vec.push((key.clone(), actions.clone())); } diff --git a/zellij-utils/src/input/mod.rs b/zellij-utils/src/input/mod.rs index 31481377..c85bebc1 100644 --- a/zellij-utils/src/input/mod.rs +++ b/zellij-utils/src/input/mod.rs @@ -18,13 +18,14 @@ pub use not_wasm::*; #[cfg(not(target_family = "wasm"))] mod not_wasm { use crate::{ - data::{CharOrArrow, Direction, InputMode, Key, ModeInfo, PluginCapabilities}, + data::{BareKey, InputMode, KeyModifier, KeyWithModifier, ModeInfo, PluginCapabilities}, envs, ipc::ClientAttributes, }; use termwiz::input::{InputEvent, InputParser, KeyCode, KeyEvent, Modifiers}; use super::keybinds::Keybinds; + use std::collections::BTreeSet; /// Creates a [`ModeInfo`] struct indicating the current [`InputMode`] and its keybinds /// (as pairs of [`String`]s). @@ -45,7 +46,8 @@ mod not_wasm { } } - pub fn parse_keys(input_bytes: &[u8]) -> Vec { + // used for parsing keys to plugins + pub fn parse_keys(input_bytes: &[u8]) -> Vec { let mut ret = vec![]; let mut input_parser = InputParser::new(); // this is the termwiz InputParser let maybe_more = false; @@ -58,9 +60,9 @@ mod not_wasm { ret } - fn key_is_bound(key: Key, keybinds: &Keybinds, mode: &InputMode) -> bool { + fn key_is_bound(key: &KeyWithModifier, keybinds: &Keybinds, mode: &InputMode) -> bool { keybinds - .get_actions_for_key_in_mode(mode, &key) + .get_actions_for_key_in_mode(mode, key) .map_or(false, |actions| !actions.is_empty()) } @@ -70,81 +72,68 @@ mod not_wasm { event: KeyEvent, raw_bytes: &[u8], keybinds_mode: Option<(&Keybinds, &InputMode)>, - ) -> Key { - let modifiers = event.modifiers; + ) -> KeyWithModifier { + let termwiz_modifiers = event.modifiers; // *** THIS IS WHERE WE SHOULD WORK AROUND ISSUES WITH TERMWIZ *** if raw_bytes == [8] { - return Key::Ctrl('h'); + return KeyWithModifier::new(BareKey::Char('h')).with_ctrl_modifier(); }; if raw_bytes == [10] { if let Some((keybinds, mode)) = keybinds_mode { - if key_is_bound(Key::Ctrl('j'), keybinds, mode) { - return Key::Ctrl('j'); + let ctrl_j = KeyWithModifier::new(BareKey::Char('j')).with_ctrl_modifier(); + if key_is_bound(&ctrl_j, keybinds, mode) { + return ctrl_j; } } } + let mut modifiers = BTreeSet::new(); + if termwiz_modifiers.contains(Modifiers::CTRL) { + modifiers.insert(KeyModifier::Ctrl); + } + if termwiz_modifiers.contains(Modifiers::ALT) { + modifiers.insert(KeyModifier::Alt); + } + if termwiz_modifiers.contains(Modifiers::SHIFT) { + modifiers.insert(KeyModifier::Shift); + } match event.key { KeyCode::Char(c) => { - if modifiers.contains(Modifiers::CTRL) { - Key::Ctrl(c.to_lowercase().next().unwrap_or_default()) - } else if modifiers.contains(Modifiers::ALT) { - Key::Alt(CharOrArrow::Char(c)) + if c == '\0' { + // NUL character, probably ctrl-space + KeyWithModifier::new(BareKey::Char(' ')).with_ctrl_modifier() } else { - Key::Char(c) + KeyWithModifier::new_with_modifiers(BareKey::Char(c), modifiers) } }, - KeyCode::Backspace => Key::Backspace, + KeyCode::Backspace => { + KeyWithModifier::new_with_modifiers(BareKey::Backspace, modifiers) + }, KeyCode::LeftArrow | KeyCode::ApplicationLeftArrow => { - if modifiers.contains(Modifiers::ALT) { - Key::Alt(CharOrArrow::Direction(Direction::Left)) - } else { - Key::Left - } + KeyWithModifier::new_with_modifiers(BareKey::Left, modifiers) }, KeyCode::RightArrow | KeyCode::ApplicationRightArrow => { - if modifiers.contains(Modifiers::ALT) { - Key::Alt(CharOrArrow::Direction(Direction::Right)) - } else { - Key::Right - } + KeyWithModifier::new_with_modifiers(BareKey::Right, modifiers) }, KeyCode::UpArrow | KeyCode::ApplicationUpArrow => { - if modifiers.contains(Modifiers::ALT) { - //Key::AltPlusUpArrow - Key::Alt(CharOrArrow::Direction(Direction::Up)) - } else { - Key::Up - } + KeyWithModifier::new_with_modifiers(BareKey::Up, modifiers) }, KeyCode::DownArrow | KeyCode::ApplicationDownArrow => { - if modifiers.contains(Modifiers::ALT) { - Key::Alt(CharOrArrow::Direction(Direction::Down)) - } else { - Key::Down - } + KeyWithModifier::new_with_modifiers(BareKey::Down, modifiers) }, - KeyCode::Home => Key::Home, - KeyCode::End => Key::End, - KeyCode::PageUp => Key::PageUp, - KeyCode::PageDown => Key::PageDown, - KeyCode::Tab => Key::BackTab, // TODO: ??? - KeyCode::Delete => Key::Delete, - KeyCode::Insert => Key::Insert, - KeyCode::Function(n) => { - if modifiers.contains(Modifiers::ALT) { - Key::AltF(n) - } else if modifiers.contains(Modifiers::CTRL) { - Key::CtrlF(n) - } else { - Key::F(n) - } - }, - KeyCode::Escape => Key::Esc, - KeyCode::Enter => Key::Char('\n'), - _ => Key::Esc, // there are other keys we can implement here, but we might need additional terminal support to implement them, not just exhausting this enum + KeyCode::Home => KeyWithModifier::new_with_modifiers(BareKey::Home, modifiers), + KeyCode::End => KeyWithModifier::new_with_modifiers(BareKey::End, modifiers), + KeyCode::PageUp => KeyWithModifier::new_with_modifiers(BareKey::PageUp, modifiers), + KeyCode::PageDown => KeyWithModifier::new_with_modifiers(BareKey::PageDown, modifiers), + KeyCode::Tab => KeyWithModifier::new_with_modifiers(BareKey::Tab, modifiers), + KeyCode::Delete => KeyWithModifier::new_with_modifiers(BareKey::Delete, modifiers), + KeyCode::Insert => KeyWithModifier::new_with_modifiers(BareKey::Insert, modifiers), + KeyCode::Function(n) => KeyWithModifier::new_with_modifiers(BareKey::F(n), modifiers), + KeyCode::Escape => KeyWithModifier::new_with_modifiers(BareKey::Esc, modifiers), + KeyCode::Enter => KeyWithModifier::new_with_modifiers(BareKey::Enter, modifiers), + _ => KeyWithModifier::new(BareKey::Esc), } } } diff --git a/zellij-utils/src/input/options.rs b/zellij-utils/src/input/options.rs index 343bdb09..c571bcae 100644 --- a/zellij-utils/src/input/options.rs +++ b/zellij-utils/src/input/options.rs @@ -155,6 +155,12 @@ pub struct Options { /// If true, will disable writing session metadata to disk #[clap(long, value_parser)] pub disable_session_metadata: Option, + + /// Whether to enable support for the Kitty keyboard protocol (must also be supported by the + /// host terminal), defaults to true if the terminal supports it + #[clap(long, value_parser)] + #[serde(default)] + pub support_kitty_keyboard_protocol: Option, } #[derive(ArgEnum, Deserialize, Serialize, Debug, Clone, Copy, PartialEq)] @@ -230,6 +236,9 @@ impl Options { let disable_session_metadata = other .disable_session_metadata .or(self.disable_session_metadata); + let support_kitty_keyboard_protocol = other + .support_kitty_keyboard_protocol + .or(self.support_kitty_keyboard_protocol); Options { simplified_ui, @@ -258,6 +267,7 @@ impl Options { styled_underlines, serialization_interval, disable_session_metadata, + support_kitty_keyboard_protocol, } } @@ -313,6 +323,9 @@ impl Options { let disable_session_metadata = other .disable_session_metadata .or(self.disable_session_metadata); + let support_kitty_keyboard_protocol = other + .support_kitty_keyboard_protocol + .or(self.support_kitty_keyboard_protocol); Options { simplified_ui, @@ -341,6 +354,7 @@ impl Options { styled_underlines, serialization_interval, disable_session_metadata, + support_kitty_keyboard_protocol, } } @@ -405,6 +419,7 @@ impl From for Options { scrollback_lines_to_serialize: opts.scrollback_lines_to_serialize, styled_underlines: opts.styled_underlines, serialization_interval: opts.serialization_interval, + support_kitty_keyboard_protocol: opts.support_kitty_keyboard_protocol, ..Default::default() } } diff --git a/zellij-utils/src/input/unit/keybinds_test.rs b/zellij-utils/src/input/unit/keybinds_test.rs index 36c81cf8..3e183d91 100644 --- a/zellij-utils/src/input/unit/keybinds_test.rs +++ b/zellij-utils/src/input/unit/keybinds_test.rs @@ -1,6 +1,6 @@ use super::super::actions::*; use super::super::keybinds::*; -use crate::data::{self, CharOrArrow, Direction, Key}; +use crate::data::{BareKey, Direction, KeyWithModifier}; use crate::input::config::Config; use insta::assert_snapshot; use strum::IntoEnumIterator; @@ -15,9 +15,10 @@ fn can_define_keybindings_in_configfile() { } "#; let config = Config::from_kdl(config_contents, None).unwrap(); - let ctrl_g_normal_mode_action = config - .keybinds - .get_actions_for_key_in_mode(&InputMode::Normal, &Key::Ctrl('g')); + let ctrl_g_normal_mode_action = config.keybinds.get_actions_for_key_in_mode( + &InputMode::Normal, + &KeyWithModifier::new(BareKey::Char('g')).with_ctrl_modifier(), + ); assert_eq!( ctrl_g_normal_mode_action, Some(&vec![Action::SwitchToMode(InputMode::Locked)]), @@ -37,11 +38,12 @@ fn can_define_multiple_keybinds_for_same_action() { let config = Config::from_kdl(config_contents, None).unwrap(); let alt_h_normal_mode_action = config.keybinds.get_actions_for_key_in_mode( &InputMode::Normal, - &Key::Alt(CharOrArrow::Direction(data::Direction::Left)), + &KeyWithModifier::new(BareKey::Left).with_alt_modifier(), + ); + let alt_left_normal_mode_action = config.keybinds.get_actions_for_key_in_mode( + &InputMode::Normal, + &KeyWithModifier::new(BareKey::Char('h')).with_alt_modifier(), ); - let alt_left_normal_mode_action = config - .keybinds - .get_actions_for_key_in_mode(&InputMode::Normal, &Key::Alt(CharOrArrow::Char('h'))); assert_eq!( alt_h_normal_mode_action, Some(&vec![Action::MoveFocusOrTab(Direction::Left)]), @@ -66,7 +68,7 @@ fn can_define_series_of_actions_for_same_keybinding() { let config = Config::from_kdl(config_contents, None).unwrap(); let z_in_pane_mode = config .keybinds - .get_actions_for_key_in_mode(&InputMode::Pane, &Key::Char('z')); + .get_actions_for_key_in_mode(&InputMode::Pane, &KeyWithModifier::new(BareKey::Char('z'))); assert_eq!( z_in_pane_mode, Some(&vec![ @@ -90,7 +92,7 @@ fn keybindings_bind_order_is_preserved() { let config = Config::from_kdl(config_contents, None).unwrap(); let z_in_pane_mode = config .keybinds - .get_actions_for_key_in_mode(&InputMode::Pane, &Key::Char('z')); + .get_actions_for_key_in_mode(&InputMode::Pane, &KeyWithModifier::new(BareKey::Char('z'))); assert_eq!( z_in_pane_mode, Some(&vec![Action::SwitchToMode(InputMode::Resize)]), @@ -111,10 +113,10 @@ fn uppercase_and_lowercase_keybindings_are_distinct() { let config = Config::from_kdl(config_contents, None).unwrap(); let z_in_pane_mode = config .keybinds - .get_actions_for_key_in_mode(&InputMode::Pane, &Key::Char('z')); + .get_actions_for_key_in_mode(&InputMode::Pane, &KeyWithModifier::new(BareKey::Char('z'))); let uppercase_z_in_pane_mode = config .keybinds - .get_actions_for_key_in_mode(&InputMode::Pane, &Key::Char('Z')); + .get_actions_for_key_in_mode(&InputMode::Pane, &KeyWithModifier::new(BareKey::Char('Z'))); assert_eq!( z_in_pane_mode, Some(&vec![ @@ -150,7 +152,7 @@ fn can_override_keybindings() { let config = Config::from_kdl(config_contents, Some(default_config)).unwrap(); let z_in_pane_mode = config .keybinds - .get_actions_for_key_in_mode(&InputMode::Pane, &Key::Char('z')); + .get_actions_for_key_in_mode(&InputMode::Pane, &KeyWithModifier::new(BareKey::Char('z'))); assert_eq!( z_in_pane_mode, Some(&vec![Action::SwitchToMode(InputMode::Resize)]), @@ -180,10 +182,10 @@ fn can_add_to_default_keybindings() { let config = Config::from_kdl(config_contents, Some(default_config)).unwrap(); let z_in_pane_mode = config .keybinds - .get_actions_for_key_in_mode(&InputMode::Pane, &Key::Char('z')); + .get_actions_for_key_in_mode(&InputMode::Pane, &KeyWithModifier::new(BareKey::Char('z'))); let r_in_pane_mode = config .keybinds - .get_actions_for_key_in_mode(&InputMode::Pane, &Key::Char('r')); + .get_actions_for_key_in_mode(&InputMode::Pane, &KeyWithModifier::new(BareKey::Char('r'))); assert_eq!( z_in_pane_mode, Some(&vec![ @@ -223,18 +225,20 @@ fn can_clear_default_keybindings() { "#; let default_config = Config::from_kdl(default_config_contents, None).unwrap(); let config = Config::from_kdl(config_contents, Some(default_config)).unwrap(); - let ctrl_g_normal_mode_action = config - .keybinds - .get_actions_for_key_in_mode(&InputMode::Normal, &Key::Ctrl('g')); + let ctrl_g_normal_mode_action = config.keybinds.get_actions_for_key_in_mode( + &InputMode::Normal, + &KeyWithModifier::new(BareKey::Char('g')).with_ctrl_modifier(), + ); let z_in_pane_mode = config .keybinds - .get_actions_for_key_in_mode(&InputMode::Pane, &Key::Char('z')); - let ctrl_r_in_normal_mode = config - .keybinds - .get_actions_for_key_in_mode(&InputMode::Normal, &Key::Ctrl('r')); + .get_actions_for_key_in_mode(&InputMode::Pane, &KeyWithModifier::new(BareKey::Char('z'))); + let ctrl_r_in_normal_mode = config.keybinds.get_actions_for_key_in_mode( + &InputMode::Normal, + &KeyWithModifier::new(BareKey::Char('r')).with_ctrl_modifier(), + ); let r_in_pane_mode = config .keybinds - .get_actions_for_key_in_mode(&InputMode::Pane, &Key::Char('r')); + .get_actions_for_key_in_mode(&InputMode::Pane, &KeyWithModifier::new(BareKey::Char('r'))); assert_eq!( ctrl_g_normal_mode_action, None, "Keybinding from normal mode in default config cleared" @@ -276,15 +280,16 @@ fn can_clear_default_keybindings_per_single_mode() { "#; let default_config = Config::from_kdl(default_config_contents, None).unwrap(); let config = Config::from_kdl(config_contents, Some(default_config)).unwrap(); - let ctrl_g_normal_mode_action = config - .keybinds - .get_actions_for_key_in_mode(&InputMode::Normal, &Key::Ctrl('g')); + let ctrl_g_normal_mode_action = config.keybinds.get_actions_for_key_in_mode( + &InputMode::Normal, + &KeyWithModifier::new(BareKey::Char('g')).with_ctrl_modifier(), + ); let z_in_pane_mode = config .keybinds - .get_actions_for_key_in_mode(&InputMode::Pane, &Key::Char('z')); + .get_actions_for_key_in_mode(&InputMode::Pane, &KeyWithModifier::new(BareKey::Char('z'))); let r_in_pane_mode = config .keybinds - .get_actions_for_key_in_mode(&InputMode::Pane, &Key::Char('r')); + .get_actions_for_key_in_mode(&InputMode::Pane, &KeyWithModifier::new(BareKey::Char('r'))); assert_eq!( ctrl_g_normal_mode_action, Some(&vec![Action::SwitchToMode(InputMode::Locked)]), @@ -325,21 +330,23 @@ fn can_unbind_multiple_keys_globally() { "#; let default_config = Config::from_kdl(default_config_contents, None).unwrap(); let config = Config::from_kdl(config_contents, Some(default_config)).unwrap(); - let ctrl_g_normal_mode_action = config - .keybinds - .get_actions_for_key_in_mode(&InputMode::Normal, &Key::Ctrl('g')); - let ctrl_g_pane_mode_action = config - .keybinds - .get_actions_for_key_in_mode(&InputMode::Pane, &Key::Ctrl('g')); + let ctrl_g_normal_mode_action = config.keybinds.get_actions_for_key_in_mode( + &InputMode::Normal, + &KeyWithModifier::new(BareKey::Char('g')).with_ctrl_modifier(), + ); + let ctrl_g_pane_mode_action = config.keybinds.get_actions_for_key_in_mode( + &InputMode::Pane, + &KeyWithModifier::new(BareKey::Char('g')).with_ctrl_modifier(), + ); let r_in_pane_mode = config .keybinds - .get_actions_for_key_in_mode(&InputMode::Pane, &Key::Char('r')); + .get_actions_for_key_in_mode(&InputMode::Pane, &KeyWithModifier::new(BareKey::Char('r'))); let z_in_pane_mode = config .keybinds - .get_actions_for_key_in_mode(&InputMode::Pane, &Key::Char('z')); + .get_actions_for_key_in_mode(&InputMode::Pane, &KeyWithModifier::new(BareKey::Char('z'))); let t_in_pane_mode = config .keybinds - .get_actions_for_key_in_mode(&InputMode::Pane, &Key::Char('t')); + .get_actions_for_key_in_mode(&InputMode::Pane, &KeyWithModifier::new(BareKey::Char('t'))); assert_eq!( ctrl_g_normal_mode_action, None, "First keybind uncleared in one mode" @@ -385,21 +392,23 @@ fn can_unbind_multiple_keys_per_single_mode() { "#; let default_config = Config::from_kdl(default_config_contents, None).unwrap(); let config = Config::from_kdl(config_contents, Some(default_config)).unwrap(); - let ctrl_g_normal_mode_action = config - .keybinds - .get_actions_for_key_in_mode(&InputMode::Normal, &Key::Ctrl('g')); - let ctrl_g_pane_mode_action = config - .keybinds - .get_actions_for_key_in_mode(&InputMode::Pane, &Key::Ctrl('g')); + let ctrl_g_normal_mode_action = config.keybinds.get_actions_for_key_in_mode( + &InputMode::Normal, + &KeyWithModifier::new(BareKey::Char('g')).with_ctrl_modifier(), + ); + let ctrl_g_pane_mode_action = config.keybinds.get_actions_for_key_in_mode( + &InputMode::Pane, + &KeyWithModifier::new(BareKey::Char('g')).with_ctrl_modifier(), + ); let r_in_pane_mode = config .keybinds - .get_actions_for_key_in_mode(&InputMode::Pane, &Key::Char('r')); + .get_actions_for_key_in_mode(&InputMode::Pane, &KeyWithModifier::new(BareKey::Char('r'))); let z_in_pane_mode = config .keybinds - .get_actions_for_key_in_mode(&InputMode::Pane, &Key::Char('z')); + .get_actions_for_key_in_mode(&InputMode::Pane, &KeyWithModifier::new(BareKey::Char('z'))); let t_in_pane_mode = config .keybinds - .get_actions_for_key_in_mode(&InputMode::Pane, &Key::Char('t')); + .get_actions_for_key_in_mode(&InputMode::Pane, &KeyWithModifier::new(BareKey::Char('t'))); assert_eq!( ctrl_g_normal_mode_action, Some(&vec![Action::SwitchToMode(InputMode::Locked)]), @@ -436,9 +445,10 @@ fn can_define_shared_keybinds_for_all_modes() { "#; let config = Config::from_kdl(config_contents, None).unwrap(); for mode in InputMode::iter() { - let action_in_mode = config - .keybinds - .get_actions_for_key_in_mode(&mode, &Key::Ctrl('g')); + let action_in_mode = config.keybinds.get_actions_for_key_in_mode( + &mode, + &KeyWithModifier::new(BareKey::Char('g')).with_ctrl_modifier(), + ); assert_eq!( action_in_mode, Some(&vec![Action::SwitchToMode(InputMode::Locked)]), @@ -458,9 +468,10 @@ fn can_define_shared_keybinds_with_exclusion() { "#; let config = Config::from_kdl(config_contents, None).unwrap(); for mode in InputMode::iter() { - let action_in_mode = config - .keybinds - .get_actions_for_key_in_mode(&mode, &Key::Ctrl('g')); + let action_in_mode = config.keybinds.get_actions_for_key_in_mode( + &mode, + &KeyWithModifier::new(BareKey::Char('g')).with_ctrl_modifier(), + ); if mode == InputMode::Locked { assert_eq!(action_in_mode, None, "Keybind unbound in excluded mode"); } else { @@ -484,9 +495,10 @@ fn can_define_shared_keybinds_with_inclusion() { "#; let config = Config::from_kdl(config_contents, None).unwrap(); for mode in InputMode::iter() { - let action_in_mode = config - .keybinds - .get_actions_for_key_in_mode(&mode, &Key::Ctrl('g')); + let action_in_mode = config.keybinds.get_actions_for_key_in_mode( + &mode, + &KeyWithModifier::new(BareKey::Char('g')).with_ctrl_modifier(), + ); if mode == InputMode::Normal || mode == InputMode::Resize || mode == InputMode::Pane { assert_eq!( action_in_mode, @@ -512,7 +524,7 @@ fn keybindings_unbinds_happen_after_binds() { let config = Config::from_kdl(config_contents, None).unwrap(); let z_in_pane_mode = config .keybinds - .get_actions_for_key_in_mode(&InputMode::Pane, &Key::Char('z')); + .get_actions_for_key_in_mode(&InputMode::Pane, &KeyWithModifier::new(BareKey::Char('z'))); assert_eq!(z_in_pane_mode, None, "Key was ultimately unbound"); } diff --git a/zellij-utils/src/kdl/mod.rs b/zellij-utils/src/kdl/mod.rs index 59c6705d..288c09f7 100644 --- a/zellij-utils/src/kdl/mod.rs +++ b/zellij-utils/src/kdl/mod.rs @@ -1,7 +1,7 @@ mod kdl_layout_parser; use crate::data::{ - Direction, FloatingPaneCoordinates, InputMode, Key, LayoutInfo, Palette, PaletteColor, - PaneInfo, PaneManifest, PermissionType, Resize, SessionInfo, TabInfo, + Direction, FloatingPaneCoordinates, InputMode, KeyWithModifier, LayoutInfo, Palette, + PaletteColor, PaneInfo, PaneManifest, PermissionType, Resize, SessionInfo, TabInfo, }; use crate::envs::EnvironmentVariables; use crate::home::{find_default_config_dir, get_layout_dir}; @@ -320,7 +320,7 @@ macro_rules! keys_from_kdl { kdl_string_arguments!($kdl_node) .iter() .map(|k| { - Key::from_str(k).map_err(|_| { + KeyWithModifier::from_str(k).map_err(|_| { ConfigError::new_kdl_error( format!("Invalid key: '{}'", k), $kdl_node.span().offset(), @@ -388,7 +388,7 @@ impl Action { action_node: &KdlNode, ) -> Result { match action_name { - "Write" => Ok(Action::Write(bytes)), + "Write" => Ok(Action::Write(None, bytes, false)), "PaneNameInput" => Ok(Action::PaneNameInput(bytes)), "TabNameInput" => Ok(Action::TabNameInput(bytes)), "SearchInput" => Ok(Action::SearchInput(bytes)), @@ -1614,6 +1614,11 @@ impl Options { let disable_session_metadata = kdl_property_first_arg_as_bool_or_error!(kdl_options, "disable_session_metadata") .map(|(v, _)| v); + let support_kitty_keyboard_protocol = kdl_property_first_arg_as_bool_or_error!( + kdl_options, + "support_kitty_keyboard_protocol" + ) + .map(|(v, _)| v); Ok(Options { simplified_ui, theme, @@ -1641,6 +1646,7 @@ impl Options { styled_underlines, serialization_interval, disable_session_metadata, + support_kitty_keyboard_protocol, }) } } @@ -1735,7 +1741,7 @@ impl EnvironmentVariables { impl Keybinds { fn bind_keys_in_block( block: &KdlNode, - input_mode_keybinds: &mut HashMap>, + input_mode_keybinds: &mut HashMap>, config_options: &Options, ) -> Result<(), ConfigError> { let all_nodes = kdl_children_nodes_or_error!(block, "no keybinding block for mode"); @@ -1823,10 +1829,10 @@ impl Keybinds { } fn bind_actions_for_each_key( key_block: &KdlNode, - input_mode_keybinds: &mut HashMap>, + input_mode_keybinds: &mut HashMap>, config_options: &Options, ) -> Result<(), ConfigError> { - let keys: Vec = keys_from_kdl!(key_block); + let keys: Vec = keys_from_kdl!(key_block); let actions: Vec = actions_from_kdl!(key_block, config_options); for key in keys { input_mode_keybinds.insert(key, actions.clone()); @@ -1835,9 +1841,9 @@ impl Keybinds { } fn unbind_keys( key_block: &KdlNode, - input_mode_keybinds: &mut HashMap>, + input_mode_keybinds: &mut HashMap>, ) -> Result<(), ConfigError> { - let keys: Vec = keys_from_kdl!(key_block); + let keys: Vec = keys_from_kdl!(key_block); for key in keys { input_mode_keybinds.remove(&key); } @@ -1847,7 +1853,7 @@ impl Keybinds { global_unbind: &KdlNode, keybinds_from_config: &mut Keybinds, ) -> Result<(), ConfigError> { - let keys: Vec = keys_from_kdl!(global_unbind); + let keys: Vec = keys_from_kdl!(global_unbind); for mode in keybinds_from_config.0.values_mut() { for key in &keys { mode.remove(&key); @@ -1858,7 +1864,7 @@ impl Keybinds { fn input_mode_keybindings<'a>( mode: &KdlNode, keybinds_from_config: &'a mut Keybinds, - ) -> Result<&'a mut HashMap>, ConfigError> { + ) -> Result<&'a mut HashMap>, ConfigError> { let mode_name = kdl_name!(mode); let input_mode = InputMode::from_str(mode_name).map_err(|_| { ConfigError::new_kdl_error( diff --git a/zellij-utils/src/plugin_api/action.rs b/zellij-utils/src/plugin_api/action.rs index 9262541a..d148541e 100644 --- a/zellij-utils/src/plugin_api/action.rs +++ b/zellij-utils/src/plugin_api/action.rs @@ -37,7 +37,7 @@ impl TryFrom for Action { }, Some(ProtobufActionName::Write) => match protobuf_action.optional_payload { Some(OptionalPayload::WritePayload(write_payload)) => { - Ok(Action::Write(write_payload.bytes_to_write)) + Ok(Action::Write(None, write_payload.bytes_to_write, false)) }, _ => Err("Wrong payload for Action::Write"), }, @@ -719,7 +719,7 @@ impl TryFrom for ProtobufAction { name: ProtobufActionName::Quit as i32, optional_payload: None, }), - Action::Write(bytes) => Ok(ProtobufAction { + Action::Write(_, bytes, _) => Ok(ProtobufAction { name: ProtobufActionName::Write as i32, optional_payload: Some(OptionalPayload::WritePayload(WritePayload { bytes_to_write: bytes, diff --git a/zellij-utils/src/plugin_api/event.rs b/zellij-utils/src/plugin_api/event.rs index f4df31f2..e8966533 100644 --- a/zellij-utils/src/plugin_api/event.rs +++ b/zellij-utils/src/plugin_api/event.rs @@ -16,8 +16,9 @@ pub use super::generated_api::api::{ }; #[allow(hidden_glob_reexports)] use crate::data::{ - CopyDestination, Event, EventType, FileMetadata, InputMode, Key, LayoutInfo, ModeInfo, Mouse, - PaneInfo, PaneManifest, PermissionStatus, PluginCapabilities, SessionInfo, Style, TabInfo, + CopyDestination, Event, EventType, FileMetadata, InputMode, KeyWithModifier, LayoutInfo, + ModeInfo, Mouse, PaneInfo, PaneManifest, PermissionStatus, PluginCapabilities, SessionInfo, + Style, TabInfo, }; use crate::errors::prelude::*; @@ -812,29 +813,30 @@ impl TryFrom for ModeInfo { ProtobufInputMode::from_i32(protobuf_mode_update_payload.current_mode) .ok_or("Malformed InputMode in the ModeUpdate Event")? .try_into()?; - let keybinds: Vec<(InputMode, Vec<(Key, Vec)>)> = protobuf_mode_update_payload - .keybinds - .iter_mut() - .filter_map(|k| { - let input_mode: InputMode = ProtobufInputMode::from_i32(k.mode) - .ok_or("Malformed InputMode in the ModeUpdate Event") - .ok()? - .try_into() - .ok()?; - let mut keybinds: Vec<(Key, Vec)> = vec![]; - for mut protobuf_keybind in k.key_bind.drain(..) { - let key: Key = protobuf_keybind.key.unwrap().try_into().ok()?; - let mut actions: Vec = vec![]; - for action in protobuf_keybind.action.drain(..) { - if let Ok(action) = action.try_into() { - actions.push(action); + let keybinds: Vec<(InputMode, Vec<(KeyWithModifier, Vec)>)> = + protobuf_mode_update_payload + .keybinds + .iter_mut() + .filter_map(|k| { + let input_mode: InputMode = ProtobufInputMode::from_i32(k.mode) + .ok_or("Malformed InputMode in the ModeUpdate Event") + .ok()? + .try_into() + .ok()?; + let mut keybinds: Vec<(KeyWithModifier, Vec)> = vec![]; + for mut protobuf_keybind in k.key_bind.drain(..) { + let key: KeyWithModifier = protobuf_keybind.key.unwrap().try_into().ok()?; + let mut actions: Vec = vec![]; + for action in protobuf_keybind.action.drain(..) { + if let Ok(action) = action.try_into() { + actions.push(action); + } } + keybinds.push((key, actions)); } - keybinds.push((key, actions)); - } - Some((input_mode, keybinds)) - }) - .collect(); + Some((input_mode, keybinds)) + }) + .collect(); let style: Style = protobuf_mode_update_payload .style .and_then(|m| m.try_into().ok()) @@ -1047,7 +1049,7 @@ fn serialize_mode_update_event() { #[test] fn serialize_mode_update_event_with_non_default_values() { - use crate::data::{Direction, Palette, PaletteColor, ThemeHue}; + use crate::data::{BareKey, Palette, PaletteColor, ThemeHue}; use prost::Message; let mode_update_event = Event::ModeUpdate(ModeInfo { mode: InputMode::Locked, @@ -1055,14 +1057,14 @@ fn serialize_mode_update_event_with_non_default_values() { ( InputMode::Locked, vec![( - Key::Alt(crate::data::CharOrArrow::Char('b')), + KeyWithModifier::new(BareKey::Char('b')).with_alt_modifier(), vec![Action::SwitchToMode(InputMode::Normal)], )], ), ( InputMode::Tab, vec![( - Key::Alt(crate::data::CharOrArrow::Direction(Direction::Up)), + KeyWithModifier::new(BareKey::Up).with_alt_modifier(), vec![Action::SwitchToMode(InputMode::Pane)], )], ), @@ -1070,13 +1072,16 @@ fn serialize_mode_update_event_with_non_default_values() { InputMode::Pane, vec![ ( - Key::Ctrl('b'), + KeyWithModifier::new(BareKey::Char('b')).with_ctrl_modifier(), vec![ Action::SwitchToMode(InputMode::Tmux), - Action::Write(vec![10]), + Action::Write(None, vec![10], false), ], ), - (Key::Char('a'), vec![Action::WriteChars("foo".to_owned())]), + ( + KeyWithModifier::new(BareKey::Char('a')), + vec![Action::WriteChars("foo".to_owned())], + ), ], ), ], @@ -1192,8 +1197,9 @@ fn serialize_pane_update_event() { #[test] fn serialize_key_event() { + use crate::data::BareKey; use prost::Message; - let key_event = Event::Key(Key::Ctrl('a')); + let key_event = Event::Key(KeyWithModifier::new(BareKey::Char('a')).with_ctrl_modifier()); let protobuf_event: ProtobufEvent = key_event.clone().try_into().unwrap(); let serialized_protobuf_event = protobuf_event.encode_to_vec(); let deserialized_protobuf_event: ProtobufEvent = diff --git a/zellij-utils/src/plugin_api/key.proto b/zellij-utils/src/plugin_api/key.proto index 9a573483..5a5a5819 100644 --- a/zellij-utils/src/plugin_api/key.proto +++ b/zellij-utils/src/plugin_api/key.proto @@ -6,6 +6,8 @@ message Key { enum KeyModifier { CTRL = 0; ALT = 1; + SHIFT = 2; + SUPER = 3; } enum NamedKey { @@ -34,6 +36,13 @@ message Key { F12 = 22; Tab = 23; Esc = 24; + CapsLock = 25; + ScrollLock = 26; + NumLock = 27; + PrintScreen = 28; + Pause = 29; + Menu = 30; + Enter = 31; } enum Char { @@ -80,4 +89,5 @@ message Key { NamedKey key = 2; Char char = 3; } + repeated KeyModifier additional_modifiers = 4; } diff --git a/zellij-utils/src/plugin_api/key.rs b/zellij-utils/src/plugin_api/key.rs index c5ce1087..f6b75f80 100644 --- a/zellij-utils/src/plugin_api/key.rs +++ b/zellij-utils/src/plugin_api/key.rs @@ -1,258 +1,184 @@ pub use super::generated_api::api::key::{ - key::{KeyModifier, MainKey, NamedKey}, + key::{ + KeyModifier as ProtobufKeyModifier, MainKey as ProtobufMainKey, + NamedKey as ProtobufNamedKey, + }, Key as ProtobufKey, }; -use crate::data::{CharOrArrow, Direction, Key}; +use crate::data::{BareKey, KeyModifier, KeyWithModifier}; +use std::collections::BTreeSet; use std::convert::TryFrom; -impl TryFrom for Key { +impl TryFrom for BareKey { + type Error = &'static str; + fn try_from(protobuf_main_key: ProtobufMainKey) -> Result { + match protobuf_main_key { + ProtobufMainKey::Char(character) => Ok(BareKey::Char(char_index_to_char(character))), + ProtobufMainKey::Key(key_index) => { + let key = ProtobufNamedKey::from_i32(key_index).ok_or("invalid_key")?; + Ok(named_key_to_bare_key(key)) + }, + } + } +} + +impl TryFrom for ProtobufMainKey { + type Error = &'static str; + fn try_from(bare_key: BareKey) -> Result { + match bare_key { + BareKey::PageDown => Ok(ProtobufMainKey::Key(ProtobufNamedKey::PageDown as i32)), + BareKey::PageUp => Ok(ProtobufMainKey::Key(ProtobufNamedKey::PageUp as i32)), + BareKey::Left => Ok(ProtobufMainKey::Key(ProtobufNamedKey::LeftArrow as i32)), + BareKey::Down => Ok(ProtobufMainKey::Key(ProtobufNamedKey::DownArrow as i32)), + BareKey::Up => Ok(ProtobufMainKey::Key(ProtobufNamedKey::UpArrow as i32)), + BareKey::Right => Ok(ProtobufMainKey::Key(ProtobufNamedKey::RightArrow as i32)), + BareKey::Home => Ok(ProtobufMainKey::Key(ProtobufNamedKey::Home as i32)), + BareKey::End => Ok(ProtobufMainKey::Key(ProtobufNamedKey::End as i32)), + BareKey::Backspace => Ok(ProtobufMainKey::Key(ProtobufNamedKey::Backspace as i32)), + BareKey::Delete => Ok(ProtobufMainKey::Key(ProtobufNamedKey::Delete as i32)), + BareKey::Insert => Ok(ProtobufMainKey::Key(ProtobufNamedKey::Insert as i32)), + BareKey::F(f_index) => fn_index_to_main_key(f_index), + BareKey::Char(character) => Ok(ProtobufMainKey::Char(character as i32)), + BareKey::Tab => Ok(ProtobufMainKey::Key(ProtobufNamedKey::Tab as i32)), + BareKey::Esc => Ok(ProtobufMainKey::Key(ProtobufNamedKey::Esc as i32)), + BareKey::Enter => Ok(ProtobufMainKey::Key(ProtobufNamedKey::Enter as i32)), + BareKey::CapsLock => Ok(ProtobufMainKey::Key(ProtobufNamedKey::CapsLock as i32)), + BareKey::ScrollLock => Ok(ProtobufMainKey::Key(ProtobufNamedKey::ScrollLock as i32)), + BareKey::NumLock => Ok(ProtobufMainKey::Key(ProtobufNamedKey::NumLock as i32)), + BareKey::PrintScreen => Ok(ProtobufMainKey::Key(ProtobufNamedKey::PrintScreen as i32)), + BareKey::Pause => Ok(ProtobufMainKey::Key(ProtobufNamedKey::Pause as i32)), + BareKey::Menu => Ok(ProtobufMainKey::Key(ProtobufNamedKey::Menu as i32)), + } + } +} + +impl TryFrom for KeyModifier { + type Error = &'static str; + fn try_from(protobuf_key_modifier: ProtobufKeyModifier) -> Result { + match protobuf_key_modifier { + ProtobufKeyModifier::Ctrl => Ok(KeyModifier::Ctrl), + ProtobufKeyModifier::Alt => Ok(KeyModifier::Alt), + ProtobufKeyModifier::Shift => Ok(KeyModifier::Shift), + ProtobufKeyModifier::Super => Ok(KeyModifier::Super), + } + } +} + +impl TryFrom for ProtobufKeyModifier { + type Error = &'static str; + fn try_from(key_modifier: KeyModifier) -> Result { + match key_modifier { + KeyModifier::Ctrl => Ok(ProtobufKeyModifier::Ctrl), + KeyModifier::Alt => Ok(ProtobufKeyModifier::Alt), + KeyModifier::Shift => Ok(ProtobufKeyModifier::Shift), + KeyModifier::Super => Ok(ProtobufKeyModifier::Super), + _ => Err("unsupported key modifier"), // TODO: test this so we don't crash if we have a + // Capslock or something + } + } +} + +impl TryFrom for KeyWithModifier { type Error = &'static str; fn try_from(protobuf_key: ProtobufKey) -> Result { - let key_modifier = parse_optional_modifier(&protobuf_key); - match key_modifier { - Some(KeyModifier::Ctrl) => { - if let Ok(character) = char_from_main_key(protobuf_key.main_key.clone()) { - Ok(Key::Ctrl(character)) - } else { - let index = fn_index_from_main_key(protobuf_key.main_key)?; - Ok(Key::CtrlF(index)) - } - }, - Some(KeyModifier::Alt) => { - if let Ok(char_or_arrow) = CharOrArrow::from_main_key(protobuf_key.main_key.clone()) - { - Ok(Key::Alt(char_or_arrow)) - } else { - let index = fn_index_from_main_key(protobuf_key.main_key)?; - Ok(Key::AltF(index)) - } - }, - None => match protobuf_key.main_key.as_ref().ok_or("invalid key")? { - MainKey::Char(_key_index) => { - let character = char_from_main_key(protobuf_key.main_key)?; - Ok(Key::Char(character)) - }, - MainKey::Key(key_index) => { - let key = NamedKey::from_i32(*key_index).ok_or("invalid_key")?; - Ok(named_key_to_key(key)) - }, - }, + let bare_key = protobuf_key + .main_key + .ok_or("Key must have main_key")? + .try_into()?; + let mut key_modifiers = BTreeSet::new(); + if let Some(main_modifier) = protobuf_key.modifier { + key_modifiers.insert( + ProtobufKeyModifier::from_i32(main_modifier) + .ok_or("invalid key modifier")? + .try_into()?, + ); } + for key_modifier in protobuf_key.additional_modifiers { + key_modifiers.insert( + ProtobufKeyModifier::from_i32(key_modifier) + .ok_or("invalid key modifier")? + .try_into()?, + ); + } + Ok(KeyWithModifier { + bare_key, + key_modifiers, + }) } } -impl TryFrom for ProtobufKey { +impl TryFrom for ProtobufKey { type Error = &'static str; - fn try_from(key: Key) -> Result { - match key { - Key::PageDown => Ok(ProtobufKey { - modifier: None, - main_key: Some(MainKey::Key(NamedKey::PageDown as i32)), - }), - Key::PageUp => Ok(ProtobufKey { - modifier: None, - main_key: Some(MainKey::Key(NamedKey::PageUp as i32)), - }), - Key::Left => Ok(ProtobufKey { - modifier: None, - main_key: Some(MainKey::Key(NamedKey::LeftArrow as i32)), - }), - Key::Down => Ok(ProtobufKey { - modifier: None, - main_key: Some(MainKey::Key(NamedKey::DownArrow as i32)), - }), - Key::Up => Ok(ProtobufKey { - modifier: None, - main_key: Some(MainKey::Key(NamedKey::UpArrow as i32)), - }), - Key::Right => Ok(ProtobufKey { - modifier: None, - main_key: Some(MainKey::Key(NamedKey::RightArrow as i32)), - }), - Key::Home => Ok(ProtobufKey { - modifier: None, - main_key: Some(MainKey::Key(NamedKey::Home as i32)), - }), - Key::End => Ok(ProtobufKey { - modifier: None, - main_key: Some(MainKey::Key(NamedKey::End as i32)), - }), - Key::Backspace => Ok(ProtobufKey { - modifier: None, - main_key: Some(MainKey::Key(NamedKey::Backspace as i32)), - }), - Key::Delete => Ok(ProtobufKey { - modifier: None, - main_key: Some(MainKey::Key(NamedKey::Delete as i32)), - }), - Key::Insert => Ok(ProtobufKey { - modifier: None, - main_key: Some(MainKey::Key(NamedKey::Insert as i32)), - }), - Key::F(index) => Ok(ProtobufKey { - modifier: None, - main_key: Some(fn_index_to_main_key(index)?), - }), - Key::CtrlF(index) => Ok(ProtobufKey { - modifier: Some(KeyModifier::Ctrl as i32), - main_key: Some(fn_index_to_main_key(index)?), - }), - Key::AltF(index) => Ok(ProtobufKey { - modifier: Some(KeyModifier::Alt as i32), - main_key: Some(fn_index_to_main_key(index)?), - }), - Key::Char(character) => Ok(ProtobufKey { - modifier: None, - main_key: Some(MainKey::Char((character as u8) as i32)), - }), - Key::Alt(char_or_arrow) => { - let main_key = match char_or_arrow { - CharOrArrow::Char(character) => MainKey::Char((character as u8) as i32), - CharOrArrow::Direction(Direction::Left) => { - MainKey::Key(NamedKey::LeftArrow as i32) - }, - CharOrArrow::Direction(Direction::Right) => { - MainKey::Key(NamedKey::RightArrow as i32) - }, - CharOrArrow::Direction(Direction::Up) => MainKey::Key(NamedKey::UpArrow as i32), - CharOrArrow::Direction(Direction::Down) => { - MainKey::Key(NamedKey::DownArrow as i32) - }, - }; - Ok(ProtobufKey { - modifier: Some(KeyModifier::Alt as i32), - main_key: Some(main_key), - }) - }, - Key::Ctrl(character) => Ok(ProtobufKey { - modifier: Some(KeyModifier::Ctrl as i32), - main_key: Some(MainKey::Char((character as u8) as i32)), - }), - Key::BackTab => Ok(ProtobufKey { - modifier: None, - main_key: Some(MainKey::Key(NamedKey::Tab as i32)), - }), - Key::Null => { - Ok(ProtobufKey { - modifier: None, - main_key: None, // TODO: does this break deserialization? - }) - }, - Key::Esc => Ok(ProtobufKey { - modifier: None, - main_key: Some(MainKey::Key(NamedKey::Esc as i32)), - }), + fn try_from(key_with_modifier: KeyWithModifier) -> Result { + let mut modifiers: Vec = vec![]; + for key_modifier in key_with_modifier.key_modifiers { + modifiers.push(key_modifier.try_into()?); } + + Ok(ProtobufKey { + main_key: Some(key_with_modifier.bare_key.try_into()?), + modifier: modifiers.pop().map(|m| m as i32), + additional_modifiers: modifiers.into_iter().map(|m| m as i32).collect(), + }) } } -fn fn_index_to_main_key(index: u8) -> Result { +fn fn_index_to_main_key(index: u8) -> Result { match index { - 1 => Ok(MainKey::Key(NamedKey::F1 as i32)), - 2 => Ok(MainKey::Key(NamedKey::F2 as i32)), - 3 => Ok(MainKey::Key(NamedKey::F3 as i32)), - 4 => Ok(MainKey::Key(NamedKey::F4 as i32)), - 5 => Ok(MainKey::Key(NamedKey::F5 as i32)), - 6 => Ok(MainKey::Key(NamedKey::F6 as i32)), - 7 => Ok(MainKey::Key(NamedKey::F7 as i32)), - 8 => Ok(MainKey::Key(NamedKey::F8 as i32)), - 9 => Ok(MainKey::Key(NamedKey::F9 as i32)), - 10 => Ok(MainKey::Key(NamedKey::F10 as i32)), - 11 => Ok(MainKey::Key(NamedKey::F11 as i32)), - 12 => Ok(MainKey::Key(NamedKey::F12 as i32)), + 1 => Ok(ProtobufMainKey::Key(ProtobufNamedKey::F1 as i32)), + 2 => Ok(ProtobufMainKey::Key(ProtobufNamedKey::F2 as i32)), + 3 => Ok(ProtobufMainKey::Key(ProtobufNamedKey::F3 as i32)), + 4 => Ok(ProtobufMainKey::Key(ProtobufNamedKey::F4 as i32)), + 5 => Ok(ProtobufMainKey::Key(ProtobufNamedKey::F5 as i32)), + 6 => Ok(ProtobufMainKey::Key(ProtobufNamedKey::F6 as i32)), + 7 => Ok(ProtobufMainKey::Key(ProtobufNamedKey::F7 as i32)), + 8 => Ok(ProtobufMainKey::Key(ProtobufNamedKey::F8 as i32)), + 9 => Ok(ProtobufMainKey::Key(ProtobufNamedKey::F9 as i32)), + 10 => Ok(ProtobufMainKey::Key(ProtobufNamedKey::F10 as i32)), + 11 => Ok(ProtobufMainKey::Key(ProtobufNamedKey::F11 as i32)), + 12 => Ok(ProtobufMainKey::Key(ProtobufNamedKey::F12 as i32)), _ => Err("Invalid key"), } } -impl CharOrArrow { - pub fn from_main_key( - main_key: std::option::Option, - ) -> Result { - match main_key { - Some(MainKey::Char(encoded_key)) => { - Ok(CharOrArrow::Char(char_index_to_char(encoded_key))) - }, - Some(MainKey::Key(key_index)) => match NamedKey::from_i32(key_index) { - Some(NamedKey::LeftArrow) => Ok(CharOrArrow::Direction(Direction::Left)), - Some(NamedKey::RightArrow) => Ok(CharOrArrow::Direction(Direction::Right)), - Some(NamedKey::UpArrow) => Ok(CharOrArrow::Direction(Direction::Up)), - Some(NamedKey::DownArrow) => Ok(CharOrArrow::Direction(Direction::Down)), - _ => Err("Unsupported key"), - }, - _ => { - return Err("Unsupported key"); - }, - } - } -} - -fn parse_optional_modifier(m: &ProtobufKey) -> Option { - match m.modifier { - Some(modifier) => KeyModifier::from_i32(modifier), - _ => None, - } -} - fn char_index_to_char(char_index: i32) -> char { char_index as u8 as char } -fn char_from_main_key(main_key: Option) -> Result { - match main_key { - Some(MainKey::Char(encoded_key)) => { - return Ok(char_index_to_char(encoded_key)); - }, - _ => { - return Err("Unsupported key"); - }, - } -} - -fn fn_index_from_main_key(main_key: Option) -> Result { - match main_key { - Some(MainKey::Key(n)) if n == NamedKey::F1 as i32 => Ok(1), - Some(MainKey::Key(n)) if n == NamedKey::F2 as i32 => Ok(2), - Some(MainKey::Key(n)) if n == NamedKey::F3 as i32 => Ok(3), - Some(MainKey::Key(n)) if n == NamedKey::F4 as i32 => Ok(4), - Some(MainKey::Key(n)) if n == NamedKey::F5 as i32 => Ok(5), - Some(MainKey::Key(n)) if n == NamedKey::F6 as i32 => Ok(6), - Some(MainKey::Key(n)) if n == NamedKey::F7 as i32 => Ok(7), - Some(MainKey::Key(n)) if n == NamedKey::F8 as i32 => Ok(8), - Some(MainKey::Key(n)) if n == NamedKey::F9 as i32 => Ok(9), - Some(MainKey::Key(n)) if n == NamedKey::F10 as i32 => Ok(10), - Some(MainKey::Key(n)) if n == NamedKey::F11 as i32 => Ok(11), - Some(MainKey::Key(n)) if n == NamedKey::F12 as i32 => Ok(12), - _ => Err("Unsupported key"), - } -} - -fn named_key_to_key(named_key: NamedKey) -> Key { +fn named_key_to_bare_key(named_key: ProtobufNamedKey) -> BareKey { match named_key { - NamedKey::PageDown => Key::PageDown, - NamedKey::PageUp => Key::PageUp, - NamedKey::LeftArrow => Key::Left, - NamedKey::DownArrow => Key::Down, - NamedKey::UpArrow => Key::Up, - NamedKey::RightArrow => Key::Right, - NamedKey::Home => Key::Home, - NamedKey::End => Key::End, - NamedKey::Backspace => Key::Backspace, - NamedKey::Delete => Key::Delete, - NamedKey::Insert => Key::Insert, - NamedKey::F1 => Key::F(1), - NamedKey::F2 => Key::F(2), - NamedKey::F3 => Key::F(3), - NamedKey::F4 => Key::F(4), - NamedKey::F5 => Key::F(5), - NamedKey::F6 => Key::F(6), - NamedKey::F7 => Key::F(7), - NamedKey::F8 => Key::F(8), - NamedKey::F9 => Key::F(9), - NamedKey::F10 => Key::F(10), - NamedKey::F11 => Key::F(11), - NamedKey::F12 => Key::F(12), - NamedKey::Tab => Key::BackTab, - NamedKey::Esc => Key::Esc, + ProtobufNamedKey::PageDown => BareKey::PageDown, + ProtobufNamedKey::PageUp => BareKey::PageUp, + ProtobufNamedKey::LeftArrow => BareKey::Left, + ProtobufNamedKey::DownArrow => BareKey::Down, + ProtobufNamedKey::UpArrow => BareKey::Up, + ProtobufNamedKey::RightArrow => BareKey::Right, + ProtobufNamedKey::Home => BareKey::Home, + ProtobufNamedKey::End => BareKey::End, + ProtobufNamedKey::Backspace => BareKey::Backspace, + ProtobufNamedKey::Delete => BareKey::Delete, + ProtobufNamedKey::Insert => BareKey::Insert, + ProtobufNamedKey::F1 => BareKey::F(1), + ProtobufNamedKey::F2 => BareKey::F(2), + ProtobufNamedKey::F3 => BareKey::F(3), + ProtobufNamedKey::F4 => BareKey::F(4), + ProtobufNamedKey::F5 => BareKey::F(5), + ProtobufNamedKey::F6 => BareKey::F(6), + ProtobufNamedKey::F7 => BareKey::F(7), + ProtobufNamedKey::F8 => BareKey::F(8), + ProtobufNamedKey::F9 => BareKey::F(9), + ProtobufNamedKey::F10 => BareKey::F(10), + ProtobufNamedKey::F11 => BareKey::F(11), + ProtobufNamedKey::F12 => BareKey::F(12), + ProtobufNamedKey::Tab => BareKey::Tab, + ProtobufNamedKey::Esc => BareKey::Esc, + ProtobufNamedKey::CapsLock => BareKey::CapsLock, + ProtobufNamedKey::ScrollLock => BareKey::ScrollLock, + ProtobufNamedKey::PrintScreen => BareKey::PrintScreen, + ProtobufNamedKey::Pause => BareKey::Pause, + ProtobufNamedKey::Menu => BareKey::Menu, + ProtobufNamedKey::NumLock => BareKey::NumLock, + ProtobufNamedKey::Enter => BareKey::Enter, } } diff --git a/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__cli_arguments_override_config_options.snap b/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__cli_arguments_override_config_options.snap index 6f44a340..155ffb81 100644 --- a/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__cli_arguments_override_config_options.snap +++ b/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__cli_arguments_override_config_options.snap @@ -1,6 +1,6 @@ --- source: zellij-utils/src/setup.rs -assertion_line: 713 +assertion_line: 740 expression: "format!(\"{:#?}\", options)" --- Options { @@ -32,4 +32,5 @@ Options { styled_underlines: None, serialization_interval: None, disable_session_metadata: None, + support_kitty_keyboard_protocol: None, } diff --git a/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__cli_arguments_override_layout_options.snap b/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__cli_arguments_override_layout_options.snap index c1325576..682e6459 100644 --- a/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__cli_arguments_override_layout_options.snap +++ b/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__cli_arguments_override_layout_options.snap @@ -1,6 +1,6 @@ --- source: zellij-utils/src/setup.rs -assertion_line: 741 +assertion_line: 768 expression: "format!(\"{:#?}\", options)" --- Options { @@ -32,4 +32,5 @@ Options { styled_underlines: None, serialization_interval: None, disable_session_metadata: None, + support_kitty_keyboard_protocol: None, } diff --git a/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__default_config_with_no_cli_arguments-3.snap b/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__default_config_with_no_cli_arguments-3.snap index ec9ea10b..127a7d70 100644 --- a/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__default_config_with_no_cli_arguments-3.snap +++ b/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__default_config_with_no_cli_arguments-3.snap @@ -1,6 +1,6 @@ --- source: zellij-utils/src/setup.rs -assertion_line: 700 +assertion_line: 727 expression: "format!(\"{:#?}\", options)" --- Options { @@ -30,4 +30,5 @@ Options { styled_underlines: None, serialization_interval: None, disable_session_metadata: None, + support_kitty_keyboard_protocol: None, } diff --git a/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__default_config_with_no_cli_arguments.snap b/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__default_config_with_no_cli_arguments.snap index dda409d6..09e02f71 100644 --- a/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__default_config_with_no_cli_arguments.snap +++ b/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__default_config_with_no_cli_arguments.snap @@ -1,228 +1,321 @@ --- source: zellij-utils/src/setup.rs -assertion_line: 698 +assertion_line: 725 expression: "format!(\"{:#?}\", config)" --- Config { keybinds: { Normal: { - Alt( - Char( + KeyWithModifier { + bare_key: Left, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Down, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Up, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Right, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( '+', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Increase, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '-', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Decrease, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '=', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Increase, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '[', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ PreviousSwapLayout, ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( ']', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ NextSwapLayout, ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( + 'b', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Tmux, + ), + ], + KeyWithModifier { + bare_key: Char( + 'g', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Locked, + ), + ], + KeyWithModifier { + bare_key: Char( 'h', ), - ): [ + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Move, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Alt, + }, + }: [ MoveFocusOrTab( Left, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'i', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveTab( Left, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'j', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveFocus( Down, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'k', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveFocus( Up, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'l', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveFocusOrTab( Right, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'n', ), - ): [ + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Resize, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Alt, + }, + }: [ NewPane( None, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'o', ), - ): [ - MoveTab( - Right, - ), - ], - Alt( - Direction( - Left, - ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Direction( - Right, - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Direction( - Up, - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Direction( - Down, - ), - ): [ - MoveFocus( - Down, - ), - ], - Ctrl( - 'b', - ): [ - SwitchToMode( - Tmux, - ), - ], - Ctrl( - 'g', - ): [ - SwitchToMode( - Locked, - ), - ], - Ctrl( - 'h', - ): [ - SwitchToMode( - Move, - ), - ], - Ctrl( - 'n', - ): [ - SwitchToMode( - Resize, - ), - ], - Ctrl( - 'o', - ): [ + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Session, ), ], - Ctrl( - 'p', - ): [ + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'p', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Pane, ), ], - Ctrl( - 'q', - ): [ + KeyWithModifier { + bare_key: Char( + 'q', + ), + key_modifiers: { + Ctrl, + }, + }: [ Quit, ], - Ctrl( - 's', - ): [ + KeyWithModifier { + bare_key: Char( + 's', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Scroll, ), ], - Ctrl( - 't', - ): [ + KeyWithModifier { + bare_key: Char( + 't', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Tab, ), ], }, Locked: { - Ctrl( - 'g', - ): [ + KeyWithModifier { + bare_key: Char( + 'g', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Normal, ), ], }, Resize: { - Left: [ + KeyWithModifier { + bare_key: Left, + key_modifiers: {}, + }: [ Resize( Increase, Some( @@ -230,383 +323,633 @@ Config { ), ), ], - Down: [ - Resize( - Increase, - Some( - Down, - ), - ), - ], - Up: [ - Resize( - Increase, - Some( - Up, - ), - ), - ], - Right: [ - Resize( - Increase, - Some( - Right, - ), - ), - ], - Char( - '\n', - ): [ - SwitchToMode( - Normal, - ), - ], - Char( - '+', - ): [ - Resize( - Increase, - None, - ), - ], - Char( - '-', - ): [ - Resize( - Decrease, - None, - ), - ], - Char( - '=', - ): [ - Resize( - Increase, - None, - ), - ], - Char( - 'H', - ): [ - Resize( - Decrease, - Some( - Left, - ), - ), - ], - Char( - 'J', - ): [ - Resize( - Decrease, - Some( - Down, - ), - ), - ], - Char( - 'K', - ): [ - Resize( - Decrease, - Some( - Up, - ), - ), - ], - Char( - 'L', - ): [ - Resize( - Decrease, - Some( - Right, - ), - ), - ], - Char( - 'h', - ): [ - Resize( - Increase, - Some( - Left, - ), - ), - ], - Char( - 'j', - ): [ - Resize( - Increase, - Some( - Down, - ), - ), - ], - Char( - 'k', - ): [ - Resize( - Increase, - Some( - Up, - ), - ), - ], - Char( - 'l', - ): [ - Resize( - Increase, - Some( - Right, - ), - ), - ], - Alt( - Char( - '+', - ), - ): [ - Resize( - Increase, - None, - ), - ], - Alt( - Char( - '-', - ), - ): [ - Resize( - Decrease, - None, - ), - ], - Alt( - Char( - '=', - ), - ): [ - Resize( - Increase, - None, - ), - ], - Alt( - Char( - '[', - ), - ): [ - PreviousSwapLayout, - ], - Alt( - Char( - ']', - ), - ): [ - NextSwapLayout, - ], - Alt( - Char( - 'h', - ), - ): [ + KeyWithModifier { + bare_key: Left, + key_modifiers: { + Alt, + }, + }: [ MoveFocusOrTab( Left, ), ], - Alt( - Char( - 'i', - ), - ): [ - MoveTab( - Left, + KeyWithModifier { + bare_key: Down, + key_modifiers: {}, + }: [ + Resize( + Increase, + Some( + Down, + ), ), ], - Alt( - Char( - 'j', - ), - ): [ + KeyWithModifier { + bare_key: Down, + key_modifiers: { + Alt, + }, + }: [ MoveFocus( Down, ), ], - Alt( - Char( - 'k', + KeyWithModifier { + bare_key: Up, + key_modifiers: {}, + }: [ + Resize( + Increase, + Some( + Up, + ), ), - ): [ + ], + KeyWithModifier { + bare_key: Up, + key_modifiers: { + Alt, + }, + }: [ MoveFocus( Up, ), ], - Alt( - Char( - 'l', + KeyWithModifier { + bare_key: Right, + key_modifiers: {}, + }: [ + Resize( + Increase, + Some( + Right, + ), ), - ): [ + ], + KeyWithModifier { + bare_key: Right, + key_modifiers: { + Alt, + }, + }: [ MoveFocusOrTab( Right, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( + '+', + ), + key_modifiers: {}, + }: [ + Resize( + Increase, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '+', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Increase, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '-', + ), + key_modifiers: {}, + }: [ + Resize( + Decrease, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '-', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Decrease, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '=', + ), + key_modifiers: {}, + }: [ + Resize( + Increase, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '=', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Increase, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + 'H', + ), + key_modifiers: {}, + }: [ + Resize( + Decrease, + Some( + Left, + ), + ), + ], + KeyWithModifier { + bare_key: Char( + 'J', + ), + key_modifiers: {}, + }: [ + Resize( + Decrease, + Some( + Down, + ), + ), + ], + KeyWithModifier { + bare_key: Char( + 'K', + ), + key_modifiers: {}, + }: [ + Resize( + Decrease, + Some( + Up, + ), + ), + ], + KeyWithModifier { + bare_key: Char( + 'L', + ), + key_modifiers: {}, + }: [ + Resize( + Decrease, + Some( + Right, + ), + ), + ], + KeyWithModifier { + bare_key: Char( + '[', + ), + key_modifiers: { + Alt, + }, + }: [ + PreviousSwapLayout, + ], + KeyWithModifier { + bare_key: Char( + ']', + ), + key_modifiers: { + Alt, + }, + }: [ + NextSwapLayout, + ], + KeyWithModifier { + bare_key: Char( + 'b', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Tmux, + ), + ], + KeyWithModifier { + bare_key: Char( + 'g', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Locked, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: {}, + }: [ + Resize( + Increase, + Some( + Left, + ), + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Move, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Char( + 'i', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Char( + 'j', + ), + key_modifiers: {}, + }: [ + Resize( + Increase, + Some( + Down, + ), + ), + ], + KeyWithModifier { + bare_key: Char( + 'j', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Char( + 'k', + ), + key_modifiers: {}, + }: [ + Resize( + Increase, + Some( + Up, + ), + ), + ], + KeyWithModifier { + bare_key: Char( + 'k', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Char( + 'l', + ), + key_modifiers: {}, + }: [ + Resize( + Increase, + Some( + Right, + ), + ), + ], + KeyWithModifier { + bare_key: Char( + 'l', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( 'n', ), - ): [ + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Alt, + }, + }: [ NewPane( None, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'o', ), - ): [ - MoveTab( - Right, - ), - ], - Alt( - Direction( - Left, - ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Direction( - Right, - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Direction( - Up, - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Direction( - Down, - ), - ): [ - MoveFocus( - Down, - ), - ], - Ctrl( - 'b', - ): [ - SwitchToMode( - Tmux, - ), - ], - Ctrl( - 'g', - ): [ - SwitchToMode( - Locked, - ), - ], - Ctrl( - 'h', - ): [ - SwitchToMode( - Move, - ), - ], - Ctrl( - 'n', - ): [ - SwitchToMode( - Normal, - ), - ], - Ctrl( - 'o', - ): [ + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Session, ), ], - Ctrl( - 'p', - ): [ + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'p', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Pane, ), ], - Ctrl( - 'q', - ): [ + KeyWithModifier { + bare_key: Char( + 'q', + ), + key_modifiers: { + Ctrl, + }, + }: [ Quit, ], - Ctrl( - 's', - ): [ + KeyWithModifier { + bare_key: Char( + 's', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Scroll, ), ], - Ctrl( - 't', - ): [ + KeyWithModifier { + bare_key: Char( + 't', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Tab, ), ], - Esc: [ + KeyWithModifier { + bare_key: Esc, + key_modifiers: {}, + }: [ + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Enter, + key_modifiers: {}, + }: [ SwitchToMode( Normal, ), ], }, Pane: { - Left: [ + KeyWithModifier { + bare_key: Left, + key_modifiers: {}, + }: [ MoveFocus( Left, ), ], - Down: [ + KeyWithModifier { + bare_key: Left, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Down, + key_modifiers: {}, + }: [ MoveFocus( Down, ), ], - Up: [ + KeyWithModifier { + bare_key: Down, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Up, + key_modifiers: {}, + }: [ MoveFocus( Up, ), ], - Right: [ + KeyWithModifier { + bare_key: Up, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Right, + key_modifiers: {}, + }: [ MoveFocus( Right, ), ], - Char( - '\n', - ): [ - SwitchToMode( - Normal, + KeyWithModifier { + bare_key: Right, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, ), ], - Char( - 'c', - ): [ + KeyWithModifier { + bare_key: Char( + '+', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Increase, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '-', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Decrease, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '=', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Increase, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '[', + ), + key_modifiers: { + Alt, + }, + }: [ + PreviousSwapLayout, + ], + KeyWithModifier { + bare_key: Char( + ']', + ), + key_modifiers: { + Alt, + }, + }: [ + NextSwapLayout, + ], + KeyWithModifier { + bare_key: Char( + 'b', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Tmux, + ), + ], + KeyWithModifier { + bare_key: Char( + 'c', + ), + key_modifiers: {}, + }: [ SwitchToMode( RenamePane, ), @@ -616,9 +959,12 @@ Config { ], ), ], - Char( - 'd', - ): [ + KeyWithModifier { + bare_key: Char( + 'd', + ), + key_modifiers: {}, + }: [ NewPane( Some( Down, @@ -629,53 +975,158 @@ Config { Normal, ), ], - Char( - 'e', - ): [ + KeyWithModifier { + bare_key: Char( + 'e', + ), + key_modifiers: {}, + }: [ TogglePaneEmbedOrFloating, SwitchToMode( Normal, ), ], - Char( - 'f', - ): [ + KeyWithModifier { + bare_key: Char( + 'f', + ), + key_modifiers: {}, + }: [ ToggleFocusFullscreen, SwitchToMode( Normal, ), ], - Char( - 'h', - ): [ + KeyWithModifier { + bare_key: Char( + 'g', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Locked, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: {}, + }: [ MoveFocus( Left, ), ], - Char( - 'j', - ): [ + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Move, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Char( + 'i', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Char( + 'j', + ), + key_modifiers: {}, + }: [ MoveFocus( Down, ), ], - Char( - 'k', - ): [ + KeyWithModifier { + bare_key: Char( + 'j', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Char( + 'k', + ), + key_modifiers: {}, + }: [ MoveFocus( Up, ), ], - Char( - 'l', - ): [ + KeyWithModifier { + bare_key: Char( + 'k', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Char( + 'l', + ), + key_modifiers: {}, + }: [ MoveFocus( Right, ), ], - Char( - 'n', - ): [ + KeyWithModifier { + bare_key: Char( + 'l', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: {}, + }: [ NewPane( None, None, @@ -684,14 +1135,91 @@ Config { Normal, ), ], - Char( - 'p', - ): [ + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Resize, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Alt, + }, + }: [ + NewPane( + None, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Session, + ), + ], + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'p', + ), + key_modifiers: {}, + }: [ SwitchFocus, ], - Char( - 'r', - ): [ + KeyWithModifier { + bare_key: Char( + 'p', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Char( + 'q', + ), + key_modifiers: { + Ctrl, + }, + }: [ + Quit, + ], + KeyWithModifier { + bare_key: Char( + 'r', + ), + key_modifiers: {}, + }: [ NewPane( Some( Right, @@ -702,264 +1230,177 @@ Config { Normal, ), ], - Char( - 'w', - ): [ + KeyWithModifier { + bare_key: Char( + 's', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Scroll, + ), + ], + KeyWithModifier { + bare_key: Char( + 't', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Tab, + ), + ], + KeyWithModifier { + bare_key: Char( + 'w', + ), + key_modifiers: {}, + }: [ ToggleFloatingPanes, SwitchToMode( Normal, ), ], - Char( - 'x', - ): [ + KeyWithModifier { + bare_key: Char( + 'x', + ), + key_modifiers: {}, + }: [ CloseFocus, SwitchToMode( Normal, ), ], - Char( - 'z', - ): [ + KeyWithModifier { + bare_key: Char( + 'z', + ), + key_modifiers: {}, + }: [ TogglePaneFrames, SwitchToMode( Normal, ), ], - Alt( - Char( - '+', - ), - ): [ - Resize( - Increase, - None, - ), - ], - Alt( - Char( - '-', - ), - ): [ - Resize( - Decrease, - None, - ), - ], - Alt( - Char( - '=', - ), - ): [ - Resize( - Increase, - None, - ), - ], - Alt( - Char( - '[', - ), - ): [ - PreviousSwapLayout, - ], - Alt( - Char( - ']', - ), - ): [ - NextSwapLayout, - ], - Alt( - Char( - 'h', - ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Char( - 'i', - ), - ): [ - MoveTab( - Left, - ), - ], - Alt( - Char( - 'j', - ), - ): [ - MoveFocus( - Down, - ), - ], - Alt( - Char( - 'k', - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Char( - 'l', - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Char( - 'n', - ), - ): [ - NewPane( - None, - None, - ), - ], - Alt( - Char( - 'o', - ), - ): [ - MoveTab( - Right, - ), - ], - Alt( - Direction( - Left, - ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Direction( - Right, - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Direction( - Up, - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Direction( - Down, - ), - ): [ - MoveFocus( - Down, - ), - ], - Ctrl( - 'b', - ): [ - SwitchToMode( - Tmux, - ), - ], - Ctrl( - 'g', - ): [ - SwitchToMode( - Locked, - ), - ], - Ctrl( - 'h', - ): [ - SwitchToMode( - Move, - ), - ], - Ctrl( - 'n', - ): [ - SwitchToMode( - Resize, - ), - ], - Ctrl( - 'o', - ): [ - SwitchToMode( - Session, - ), - ], - Ctrl( - 'p', - ): [ + KeyWithModifier { + bare_key: Esc, + key_modifiers: {}, + }: [ SwitchToMode( Normal, ), ], - Ctrl( - 'q', - ): [ - Quit, - ], - Ctrl( - 's', - ): [ - SwitchToMode( - Scroll, - ), - ], - Ctrl( - 't', - ): [ - SwitchToMode( - Tab, - ), - ], - Esc: [ + KeyWithModifier { + bare_key: Enter, + key_modifiers: {}, + }: [ SwitchToMode( Normal, ), ], }, Tab: { - Left: [ + KeyWithModifier { + bare_key: Left, + key_modifiers: {}, + }: [ GoToPreviousTab, ], - Down: [ - GoToNextTab, - ], - Up: [ - GoToPreviousTab, - ], - Right: [ - GoToNextTab, - ], - Char( - '\n', - ): [ - SwitchToMode( - Normal, + KeyWithModifier { + bare_key: Left, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, ), ], - Char( - '1', - ): [ + KeyWithModifier { + bare_key: Down, + key_modifiers: {}, + }: [ + GoToNextTab, + ], + KeyWithModifier { + bare_key: Down, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Up, + key_modifiers: {}, + }: [ + GoToPreviousTab, + ], + KeyWithModifier { + bare_key: Up, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Right, + key_modifiers: {}, + }: [ + GoToNextTab, + ], + KeyWithModifier { + bare_key: Right, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + '+', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Increase, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '-', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Decrease, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '1', + ), + key_modifiers: {}, + }: [ GoToTab( 1, ), @@ -967,9 +1408,12 @@ Config { Normal, ), ], - Char( - '2', - ): [ + KeyWithModifier { + bare_key: Char( + '2', + ), + key_modifiers: {}, + }: [ GoToTab( 2, ), @@ -977,9 +1421,12 @@ Config { Normal, ), ], - Char( - '3', - ): [ + KeyWithModifier { + bare_key: Char( + '3', + ), + key_modifiers: {}, + }: [ GoToTab( 3, ), @@ -987,9 +1434,12 @@ Config { Normal, ), ], - Char( - '4', - ): [ + KeyWithModifier { + bare_key: Char( + '4', + ), + key_modifiers: {}, + }: [ GoToTab( 4, ), @@ -997,9 +1447,12 @@ Config { Normal, ), ], - Char( - '5', - ): [ + KeyWithModifier { + bare_key: Char( + '5', + ), + key_modifiers: {}, + }: [ GoToTab( 5, ), @@ -1007,9 +1460,12 @@ Config { Normal, ), ], - Char( - '6', - ): [ + KeyWithModifier { + bare_key: Char( + '6', + ), + key_modifiers: {}, + }: [ GoToTab( 6, ), @@ -1017,9 +1473,12 @@ Config { Normal, ), ], - Char( - '7', - ): [ + KeyWithModifier { + bare_key: Char( + '7', + ), + key_modifiers: {}, + }: [ GoToTab( 7, ), @@ -1027,9 +1486,12 @@ Config { Normal, ), ], - Char( - '8', - ): [ + KeyWithModifier { + bare_key: Char( + '8', + ), + key_modifiers: {}, + }: [ GoToTab( 8, ), @@ -1037,9 +1499,12 @@ Config { Normal, ), ], - Char( - '9', - ): [ + KeyWithModifier { + bare_key: Char( + '9', + ), + key_modifiers: {}, + }: [ GoToTab( 9, ), @@ -1047,53 +1512,206 @@ Config { Normal, ), ], - Char( - '[', - ): [ + KeyWithModifier { + bare_key: Char( + '=', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Increase, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '[', + ), + key_modifiers: {}, + }: [ BreakPaneLeft, SwitchToMode( Normal, ), ], - Char( - ']', - ): [ + KeyWithModifier { + bare_key: Char( + '[', + ), + key_modifiers: { + Alt, + }, + }: [ + PreviousSwapLayout, + ], + KeyWithModifier { + bare_key: Char( + ']', + ), + key_modifiers: {}, + }: [ BreakPaneRight, SwitchToMode( Normal, ), ], - Char( - 'b', - ): [ + KeyWithModifier { + bare_key: Char( + ']', + ), + key_modifiers: { + Alt, + }, + }: [ + NextSwapLayout, + ], + KeyWithModifier { + bare_key: Char( + 'b', + ), + key_modifiers: {}, + }: [ BreakPane, SwitchToMode( Normal, ), ], - Char( - 'h', - ): [ + KeyWithModifier { + bare_key: Char( + 'b', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Tmux, + ), + ], + KeyWithModifier { + bare_key: Char( + 'g', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Locked, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: {}, + }: [ GoToPreviousTab, ], - Char( - 'j', - ): [ + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Move, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Char( + 'i', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Char( + 'j', + ), + key_modifiers: {}, + }: [ GoToNextTab, ], - Char( - 'k', - ): [ + KeyWithModifier { + bare_key: Char( + 'j', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Char( + 'k', + ), + key_modifiers: {}, + }: [ GoToPreviousTab, ], - Char( - 'l', - ): [ + KeyWithModifier { + bare_key: Char( + 'k', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Char( + 'l', + ), + key_modifiers: {}, + }: [ GoToNextTab, ], - Char( - 'n', - ): [ + KeyWithModifier { + bare_key: Char( + 'l', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: {}, + }: [ NewTab( None, [], @@ -1105,9 +1723,83 @@ Config { Normal, ), ], - Char( - 'r', - ): [ + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Resize, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Alt, + }, + }: [ + NewPane( + None, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Session, + ), + ], + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'p', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Pane, + ), + ], + KeyWithModifier { + bare_key: Char( + 'q', + ), + key_modifiers: { + Ctrl, + }, + }: [ + Quit, + ], + KeyWithModifier { + bare_key: Char( + 'r', + ), + key_modifiers: {}, + }: [ SwitchToMode( RenameTab, ), @@ -1117,298 +1809,456 @@ Config { ], ), ], - Char( - 's', - ): [ + KeyWithModifier { + bare_key: Char( + 's', + ), + key_modifiers: {}, + }: [ ToggleActiveSyncTab, SwitchToMode( Normal, ), ], - Char( - 'x', - ): [ + KeyWithModifier { + bare_key: Char( + 's', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Scroll, + ), + ], + KeyWithModifier { + bare_key: Char( + 't', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Char( + 'x', + ), + key_modifiers: {}, + }: [ CloseTab, SwitchToMode( Normal, ), ], - Alt( - Char( - '+', - ), - ): [ - Resize( - Increase, - None, - ), + KeyWithModifier { + bare_key: Tab, + key_modifiers: {}, + }: [ + ToggleTab, ], - Alt( - Char( - '-', - ), - ): [ - Resize( - Decrease, - None, - ), - ], - Alt( - Char( - '=', - ), - ): [ - Resize( - Increase, - None, - ), - ], - Alt( - Char( - '[', - ), - ): [ - PreviousSwapLayout, - ], - Alt( - Char( - ']', - ), - ): [ - NextSwapLayout, - ], - Alt( - Char( - 'h', - ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Char( - 'i', - ), - ): [ - MoveTab( - Left, - ), - ], - Alt( - Char( - 'j', - ), - ): [ - MoveFocus( - Down, - ), - ], - Alt( - Char( - 'k', - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Char( - 'l', - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Char( - 'n', - ), - ): [ - NewPane( - None, - None, - ), - ], - Alt( - Char( - 'o', - ), - ): [ - MoveTab( - Right, - ), - ], - Alt( - Direction( - Left, - ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Direction( - Right, - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Direction( - Up, - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Direction( - Down, - ), - ): [ - MoveFocus( - Down, - ), - ], - Ctrl( - 'b', - ): [ - SwitchToMode( - Tmux, - ), - ], - Ctrl( - 'g', - ): [ - SwitchToMode( - Locked, - ), - ], - Ctrl( - 'h', - ): [ - SwitchToMode( - Move, - ), - ], - Ctrl( - 'n', - ): [ - SwitchToMode( - Resize, - ), - ], - Ctrl( - 'o', - ): [ - SwitchToMode( - Session, - ), - ], - Ctrl( - 'p', - ): [ - SwitchToMode( - Pane, - ), - ], - Ctrl( - 'q', - ): [ - Quit, - ], - Ctrl( - 's', - ): [ - SwitchToMode( - Scroll, - ), - ], - Ctrl( - 't', - ): [ + KeyWithModifier { + bare_key: Esc, + key_modifiers: {}, + }: [ SwitchToMode( Normal, ), ], - BackTab: [ - ToggleTab, - ], - Esc: [ + KeyWithModifier { + bare_key: Enter, + key_modifiers: {}, + }: [ SwitchToMode( Normal, ), ], }, Scroll: { - PageDown: [ + KeyWithModifier { + bare_key: PageDown, + key_modifiers: {}, + }: [ PageScrollDown, ], - PageUp: [ + KeyWithModifier { + bare_key: PageUp, + key_modifiers: {}, + }: [ PageScrollUp, ], - Left: [ + KeyWithModifier { + bare_key: Left, + key_modifiers: {}, + }: [ PageScrollUp, ], - Down: [ + KeyWithModifier { + bare_key: Left, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Down, + key_modifiers: {}, + }: [ ScrollDown, ], - Up: [ + KeyWithModifier { + bare_key: Down, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Up, + key_modifiers: {}, + }: [ ScrollUp, ], - Right: [ + KeyWithModifier { + bare_key: Up, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Right, + key_modifiers: {}, + }: [ PageScrollDown, ], - Char( - '\n', - ): [ + KeyWithModifier { + bare_key: Right, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + '+', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Increase, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '-', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Decrease, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '=', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Increase, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '[', + ), + key_modifiers: { + Alt, + }, + }: [ + PreviousSwapLayout, + ], + KeyWithModifier { + bare_key: Char( + ']', + ), + key_modifiers: { + Alt, + }, + }: [ + NextSwapLayout, + ], + KeyWithModifier { + bare_key: Char( + 'b', + ), + key_modifiers: { + Ctrl, + }, + }: [ + PageScrollUp, + ], + KeyWithModifier { + bare_key: Char( + 'c', + ), + key_modifiers: { + Ctrl, + }, + }: [ + ScrollToBottom, SwitchToMode( Normal, ), ], - Char( - 'd', - ): [ + KeyWithModifier { + bare_key: Char( + 'd', + ), + key_modifiers: {}, + }: [ HalfPageScrollDown, ], - Char( - 'e', - ): [ + KeyWithModifier { + bare_key: Char( + 'e', + ), + key_modifiers: {}, + }: [ EditScrollback, SwitchToMode( Normal, ), ], - Char( - 'h', - ): [ - PageScrollUp, - ], - Char( - 'j', - ): [ - ScrollDown, - ], - Char( - 'k', - ): [ - ScrollUp, - ], - Char( - 'l', - ): [ + KeyWithModifier { + bare_key: Char( + 'f', + ), + key_modifiers: { + Ctrl, + }, + }: [ PageScrollDown, ], - Char( - 's', - ): [ + KeyWithModifier { + bare_key: Char( + 'g', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Locked, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: {}, + }: [ + PageScrollUp, + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Move, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Char( + 'i', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Char( + 'j', + ), + key_modifiers: {}, + }: [ + ScrollDown, + ], + KeyWithModifier { + bare_key: Char( + 'j', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Char( + 'k', + ), + key_modifiers: {}, + }: [ + ScrollUp, + ], + KeyWithModifier { + bare_key: Char( + 'k', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Char( + 'l', + ), + key_modifiers: {}, + }: [ + PageScrollDown, + ], + KeyWithModifier { + bare_key: Char( + 'l', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Resize, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Alt, + }, + }: [ + NewPane( + None, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Session, + ), + ], + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'p', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Pane, + ), + ], + KeyWithModifier { + bare_key: Char( + 'q', + ), + key_modifiers: { + Ctrl, + }, + }: [ + Quit, + ], + KeyWithModifier { + bare_key: Char( + 's', + ), + key_modifiers: {}, + }: [ SwitchToMode( EnterSearch, ), @@ -1418,1242 +2268,1785 @@ Config { ], ), ], - Char( - 'u', - ): [ - HalfPageScrollUp, - ], - Alt( - Char( - '+', + KeyWithModifier { + bare_key: Char( + 's', ), - ): [ - Resize( - Increase, - None, - ), - ], - Alt( - Char( - '-', - ), - ): [ - Resize( - Decrease, - None, - ), - ], - Alt( - Char( - '=', - ), - ): [ - Resize( - Increase, - None, - ), - ], - Alt( - Char( - '[', - ), - ): [ - PreviousSwapLayout, - ], - Alt( - Char( - ']', - ), - ): [ - NextSwapLayout, - ], - Alt( - Char( - 'h', - ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Char( - 'i', - ), - ): [ - MoveTab( - Left, - ), - ], - Alt( - Char( - 'j', - ), - ): [ - MoveFocus( - Down, - ), - ], - Alt( - Char( - 'k', - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Char( - 'l', - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Char( - 'n', - ), - ): [ - NewPane( - None, - None, - ), - ], - Alt( - Char( - 'o', - ), - ): [ - MoveTab( - Right, - ), - ], - Alt( - Direction( - Left, - ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Direction( - Right, - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Direction( - Up, - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Direction( - Down, - ), - ): [ - MoveFocus( - Down, - ), - ], - Ctrl( - 'b', - ): [ - PageScrollUp, - ], - Ctrl( - 'c', - ): [ - ScrollToBottom, + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Normal, ), ], - Ctrl( - 'f', - ): [ - PageScrollDown, - ], - Ctrl( - 'g', - ): [ - SwitchToMode( - Locked, + KeyWithModifier { + bare_key: Char( + 't', ), - ], - Ctrl( - 'h', - ): [ - SwitchToMode( - Move, - ), - ], - Ctrl( - 'n', - ): [ - SwitchToMode( - Resize, - ), - ], - Ctrl( - 'o', - ): [ - SwitchToMode( - Session, - ), - ], - Ctrl( - 'p', - ): [ - SwitchToMode( - Pane, - ), - ], - Ctrl( - 'q', - ): [ - Quit, - ], - Ctrl( - 's', - ): [ - SwitchToMode( - Normal, - ), - ], - Ctrl( - 't', - ): [ + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Tab, ), ], - Esc: [ + KeyWithModifier { + bare_key: Char( + 'u', + ), + key_modifiers: {}, + }: [ + HalfPageScrollUp, + ], + KeyWithModifier { + bare_key: Esc, + key_modifiers: {}, + }: [ + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Enter, + key_modifiers: {}, + }: [ SwitchToMode( Normal, ), ], }, EnterSearch: { - Char( - '\n', - ): [ - SwitchToMode( - Search, + KeyWithModifier { + bare_key: Left, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Down, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Up, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Right, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( '+', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Increase, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '-', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Decrease, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '=', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Increase, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '[', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ PreviousSwapLayout, ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( ']', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ NextSwapLayout, ], - Alt( - Char( - 'h', + KeyWithModifier { + bare_key: Char( + 'b', ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Char( - 'i', - ), - ): [ - MoveTab( - Left, - ), - ], - Alt( - Char( - 'j', - ), - ): [ - MoveFocus( - Down, - ), - ], - Alt( - Char( - 'k', - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Char( - 'l', - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Char( - 'n', - ), - ): [ - NewPane( - None, - None, - ), - ], - Alt( - Char( - 'o', - ), - ): [ - MoveTab( - Right, - ), - ], - Alt( - Direction( - Left, - ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Direction( - Right, - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Direction( - Up, - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Direction( - Down, - ), - ): [ - MoveFocus( - Down, - ), - ], - Ctrl( - 'b', - ): [ + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Tmux, ), ], - Ctrl( - 'c', - ): [ + KeyWithModifier { + bare_key: Char( + 'c', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Scroll, ), ], - Ctrl( - 'g', - ): [ + KeyWithModifier { + bare_key: Char( + 'g', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Locked, ), ], - Ctrl( - 'h', - ): [ + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Move, ), ], - Ctrl( - 'n', - ): [ - SwitchToMode( - Resize, - ), - ], - Ctrl( - 'o', - ): [ - SwitchToMode( - Session, - ), - ], - Ctrl( - 'p', - ): [ - SwitchToMode( - Pane, - ), - ], - Ctrl( - 'q', - ): [ - Quit, - ], - Ctrl( - 's', - ): [ - SwitchToMode( - Scroll, - ), - ], - Ctrl( - 't', - ): [ - SwitchToMode( - Tab, - ), - ], - Esc: [ - SwitchToMode( - Scroll, - ), - ], - }, - Search: { - PageDown: [ - PageScrollDown, - ], - PageUp: [ - PageScrollUp, - ], - Left: [ - PageScrollUp, - ], - Down: [ - ScrollDown, - ], - Up: [ - ScrollUp, - ], - Right: [ - PageScrollDown, - ], - Char( - '\n', - ): [ - SwitchToMode( - Normal, - ), - ], - Char( - 'c', - ): [ - SearchToggleOption( - CaseSensitivity, - ), - ], - Char( - 'd', - ): [ - HalfPageScrollDown, - ], - Char( - 'h', - ): [ - PageScrollUp, - ], - Char( - 'j', - ): [ - ScrollDown, - ], - Char( - 'k', - ): [ - ScrollUp, - ], - Char( - 'l', - ): [ - PageScrollDown, - ], - Char( - 'n', - ): [ - Search( - Down, - ), - ], - Char( - 'o', - ): [ - SearchToggleOption( - WholeWord, - ), - ], - Char( - 'p', - ): [ - Search( - Up, - ), - ], - Char( - 'u', - ): [ - HalfPageScrollUp, - ], - Char( - 'w', - ): [ - SearchToggleOption( - Wrap, - ), - ], - Alt( - Char( - '+', - ), - ): [ - Resize( - Increase, - None, - ), - ], - Alt( - Char( - '-', - ), - ): [ - Resize( - Decrease, - None, - ), - ], - Alt( - Char( - '=', - ), - ): [ - Resize( - Increase, - None, - ), - ], - Alt( - Char( - '[', - ), - ): [ - PreviousSwapLayout, - ], - Alt( - Char( - ']', - ), - ): [ - NextSwapLayout, - ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'h', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveFocusOrTab( Left, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'i', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveTab( Left, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'j', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveFocus( Down, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'k', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveFocus( Up, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'l', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveFocusOrTab( Right, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'n', ), - ): [ + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Resize, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Alt, + }, + }: [ NewPane( None, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'o', ), - ): [ + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Session, + ), + ], + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Alt, + }, + }: [ MoveTab( Right, ), ], - Alt( - Direction( - Left, + KeyWithModifier { + bare_key: Char( + 'p', ), - ): [ - MoveFocusOrTab( - Left, + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Pane, ), ], - Alt( - Direction( - Right, + KeyWithModifier { + bare_key: Char( + 'q', ), - ): [ - MoveFocusOrTab( - Right, + key_modifiers: { + Ctrl, + }, + }: [ + Quit, + ], + KeyWithModifier { + bare_key: Char( + 's', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Scroll, ), ], - Alt( - Direction( - Up, + KeyWithModifier { + bare_key: Char( + 't', ), - ): [ - MoveFocus( - Up, + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Tab, ), ], - Alt( - Direction( - Down, - ), - ): [ - MoveFocus( - Down, + KeyWithModifier { + bare_key: Esc, + key_modifiers: {}, + }: [ + SwitchToMode( + Scroll, ), ], - Ctrl( - 'b', - ): [ + KeyWithModifier { + bare_key: Enter, + key_modifiers: {}, + }: [ + SwitchToMode( + Search, + ), + ], + }, + Search: { + KeyWithModifier { + bare_key: PageDown, + key_modifiers: {}, + }: [ + PageScrollDown, + ], + KeyWithModifier { + bare_key: PageUp, + key_modifiers: {}, + }: [ PageScrollUp, ], - Ctrl( - 'c', - ): [ + KeyWithModifier { + bare_key: Left, + key_modifiers: {}, + }: [ + PageScrollUp, + ], + KeyWithModifier { + bare_key: Left, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Down, + key_modifiers: {}, + }: [ + ScrollDown, + ], + KeyWithModifier { + bare_key: Down, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Up, + key_modifiers: {}, + }: [ + ScrollUp, + ], + KeyWithModifier { + bare_key: Up, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Right, + key_modifiers: {}, + }: [ + PageScrollDown, + ], + KeyWithModifier { + bare_key: Right, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + '+', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Increase, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '-', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Decrease, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '=', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Increase, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '[', + ), + key_modifiers: { + Alt, + }, + }: [ + PreviousSwapLayout, + ], + KeyWithModifier { + bare_key: Char( + ']', + ), + key_modifiers: { + Alt, + }, + }: [ + NextSwapLayout, + ], + KeyWithModifier { + bare_key: Char( + 'b', + ), + key_modifiers: { + Ctrl, + }, + }: [ + PageScrollUp, + ], + KeyWithModifier { + bare_key: Char( + 'c', + ), + key_modifiers: {}, + }: [ + SearchToggleOption( + CaseSensitivity, + ), + ], + KeyWithModifier { + bare_key: Char( + 'c', + ), + key_modifiers: { + Ctrl, + }, + }: [ ScrollToBottom, SwitchToMode( Normal, ), ], - Ctrl( - 'f', - ): [ + KeyWithModifier { + bare_key: Char( + 'd', + ), + key_modifiers: {}, + }: [ + HalfPageScrollDown, + ], + KeyWithModifier { + bare_key: Char( + 'f', + ), + key_modifiers: { + Ctrl, + }, + }: [ PageScrollDown, ], - Ctrl( - 'g', - ): [ + KeyWithModifier { + bare_key: Char( + 'g', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Locked, ), ], - Ctrl( - 'h', - ): [ + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: {}, + }: [ + PageScrollUp, + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Move, ), ], - Ctrl( - 'n', - ): [ + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Char( + 'i', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Char( + 'j', + ), + key_modifiers: {}, + }: [ + ScrollDown, + ], + KeyWithModifier { + bare_key: Char( + 'j', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Char( + 'k', + ), + key_modifiers: {}, + }: [ + ScrollUp, + ], + KeyWithModifier { + bare_key: Char( + 'k', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Char( + 'l', + ), + key_modifiers: {}, + }: [ + PageScrollDown, + ], + KeyWithModifier { + bare_key: Char( + 'l', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: {}, + }: [ + Search( + Down, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Resize, ), ], - Ctrl( - 'o', - ): [ + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Alt, + }, + }: [ + NewPane( + None, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: {}, + }: [ + SearchToggleOption( + WholeWord, + ), + ], + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Session, ), ], - Ctrl( - 'p', - ): [ + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'p', + ), + key_modifiers: {}, + }: [ + Search( + Up, + ), + ], + KeyWithModifier { + bare_key: Char( + 'p', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Pane, ), ], - Ctrl( - 'q', - ): [ + KeyWithModifier { + bare_key: Char( + 'q', + ), + key_modifiers: { + Ctrl, + }, + }: [ Quit, ], - Ctrl( - 's', - ): [ + KeyWithModifier { + bare_key: Char( + 's', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Normal, ), ], - Ctrl( - 't', - ): [ + KeyWithModifier { + bare_key: Char( + 't', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Tab, ), ], - Esc: [ + KeyWithModifier { + bare_key: Char( + 'u', + ), + key_modifiers: {}, + }: [ + HalfPageScrollUp, + ], + KeyWithModifier { + bare_key: Char( + 'w', + ), + key_modifiers: {}, + }: [ + SearchToggleOption( + Wrap, + ), + ], + KeyWithModifier { + bare_key: Esc, + key_modifiers: {}, + }: [ + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Enter, + key_modifiers: {}, + }: [ SwitchToMode( Normal, ), ], }, RenameTab: { - Char( - '\n', - ): [ - SwitchToMode( - Normal, + KeyWithModifier { + bare_key: Left, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Down, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Up, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Right, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( '+', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Increase, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '-', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Decrease, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '=', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Increase, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '[', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ PreviousSwapLayout, ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( ']', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ NextSwapLayout, ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( + 'b', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Tmux, + ), + ], + KeyWithModifier { + bare_key: Char( + 'c', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Char( + 'g', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Locked, + ), + ], + KeyWithModifier { + bare_key: Char( 'h', ), - ): [ + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Move, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Alt, + }, + }: [ MoveFocusOrTab( Left, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'i', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveTab( Left, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'j', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveFocus( Down, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'k', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveFocus( Up, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'l', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveFocusOrTab( Right, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'n', ), - ): [ + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Resize, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Alt, + }, + }: [ NewPane( None, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'o', ), - ): [ - MoveTab( - Right, - ), - ], - Alt( - Direction( - Left, - ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Direction( - Right, - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Direction( - Up, - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Direction( - Down, - ), - ): [ - MoveFocus( - Down, - ), - ], - Ctrl( - 'b', - ): [ - SwitchToMode( - Tmux, - ), - ], - Ctrl( - 'c', - ): [ - SwitchToMode( - Normal, - ), - ], - Ctrl( - 'g', - ): [ - SwitchToMode( - Locked, - ), - ], - Ctrl( - 'h', - ): [ - SwitchToMode( - Move, - ), - ], - Ctrl( - 'n', - ): [ - SwitchToMode( - Resize, - ), - ], - Ctrl( - 'o', - ): [ + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Session, ), ], - Ctrl( - 'p', - ): [ + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'p', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Pane, ), ], - Ctrl( - 'q', - ): [ + KeyWithModifier { + bare_key: Char( + 'q', + ), + key_modifiers: { + Ctrl, + }, + }: [ Quit, ], - Ctrl( - 's', - ): [ + KeyWithModifier { + bare_key: Char( + 's', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Scroll, ), ], - Ctrl( - 't', - ): [ + KeyWithModifier { + bare_key: Char( + 't', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Tab, ), ], - Esc: [ + KeyWithModifier { + bare_key: Esc, + key_modifiers: {}, + }: [ UndoRenameTab, SwitchToMode( Tab, ), ], - }, - RenamePane: { - Char( - '\n', - ): [ + KeyWithModifier { + bare_key: Enter, + key_modifiers: {}, + }: [ SwitchToMode( Normal, ), ], - Alt( - Char( + }, + RenamePane: { + KeyWithModifier { + bare_key: Left, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Down, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Up, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Right, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( '+', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Increase, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '-', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Decrease, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '=', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Increase, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '[', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ PreviousSwapLayout, ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( ']', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ NextSwapLayout, ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( + 'b', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Tmux, + ), + ], + KeyWithModifier { + bare_key: Char( + 'c', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Char( + 'g', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Locked, + ), + ], + KeyWithModifier { + bare_key: Char( 'h', ), - ): [ + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Move, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Alt, + }, + }: [ MoveFocusOrTab( Left, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'i', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveTab( Left, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'j', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveFocus( Down, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'k', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveFocus( Up, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'l', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveFocusOrTab( Right, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'n', ), - ): [ + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Resize, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Alt, + }, + }: [ NewPane( None, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'o', ), - ): [ - MoveTab( - Right, - ), - ], - Alt( - Direction( - Left, - ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Direction( - Right, - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Direction( - Up, - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Direction( - Down, - ), - ): [ - MoveFocus( - Down, - ), - ], - Ctrl( - 'b', - ): [ - SwitchToMode( - Tmux, - ), - ], - Ctrl( - 'c', - ): [ - SwitchToMode( - Normal, - ), - ], - Ctrl( - 'g', - ): [ - SwitchToMode( - Locked, - ), - ], - Ctrl( - 'h', - ): [ - SwitchToMode( - Move, - ), - ], - Ctrl( - 'n', - ): [ - SwitchToMode( - Resize, - ), - ], - Ctrl( - 'o', - ): [ + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Session, ), ], - Ctrl( - 'p', - ): [ + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'p', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Pane, ), ], - Ctrl( - 'q', - ): [ + KeyWithModifier { + bare_key: Char( + 'q', + ), + key_modifiers: { + Ctrl, + }, + }: [ Quit, ], - Ctrl( - 's', - ): [ + KeyWithModifier { + bare_key: Char( + 's', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Scroll, ), ], - Ctrl( - 't', - ): [ + KeyWithModifier { + bare_key: Char( + 't', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Tab, ), ], - Esc: [ + KeyWithModifier { + bare_key: Esc, + key_modifiers: {}, + }: [ UndoRenamePane, SwitchToMode( Pane, ), ], - }, - Session: { - Char( - '\n', - ): [ + KeyWithModifier { + bare_key: Enter, + key_modifiers: {}, + }: [ SwitchToMode( Normal, ), ], - Char( - 'd', - ): [ + }, + Session: { + KeyWithModifier { + bare_key: Left, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Down, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Up, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Right, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + '+', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Increase, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '-', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Decrease, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '=', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Increase, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '[', + ), + key_modifiers: { + Alt, + }, + }: [ + PreviousSwapLayout, + ], + KeyWithModifier { + bare_key: Char( + ']', + ), + key_modifiers: { + Alt, + }, + }: [ + NextSwapLayout, + ], + KeyWithModifier { + bare_key: Char( + 'b', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Tmux, + ), + ], + KeyWithModifier { + bare_key: Char( + 'd', + ), + key_modifiers: {}, + }: [ Detach, ], - Char( - 'w', - ): [ + KeyWithModifier { + bare_key: Char( + 'g', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Locked, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Move, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Char( + 'i', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Char( + 'j', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Char( + 'k', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Char( + 'l', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Resize, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Alt, + }, + }: [ + NewPane( + None, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'p', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Pane, + ), + ], + KeyWithModifier { + bare_key: Char( + 'q', + ), + key_modifiers: { + Ctrl, + }, + }: [ + Quit, + ], + KeyWithModifier { + bare_key: Char( + 's', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Scroll, + ), + ], + KeyWithModifier { + bare_key: Char( + 't', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Tab, + ), + ], + KeyWithModifier { + bare_key: Char( + 'w', + ), + key_modifiers: {}, + }: [ LaunchOrFocusPlugin( Alias( PluginAlias { @@ -2676,738 +4069,758 @@ Config { Normal, ), ], - Alt( - Char( - '+', - ), - ): [ - Resize( - Increase, - None, - ), - ], - Alt( - Char( - '-', - ), - ): [ - Resize( - Decrease, - None, - ), - ], - Alt( - Char( - '=', - ), - ): [ - Resize( - Increase, - None, - ), - ], - Alt( - Char( - '[', - ), - ): [ - PreviousSwapLayout, - ], - Alt( - Char( - ']', - ), - ): [ - NextSwapLayout, - ], - Alt( - Char( - 'h', - ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Char( - 'i', - ), - ): [ - MoveTab( - Left, - ), - ], - Alt( - Char( - 'j', - ), - ): [ - MoveFocus( - Down, - ), - ], - Alt( - Char( - 'k', - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Char( - 'l', - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Char( - 'n', - ), - ): [ - NewPane( - None, - None, - ), - ], - Alt( - Char( - 'o', - ), - ): [ - MoveTab( - Right, - ), - ], - Alt( - Direction( - Left, - ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Direction( - Right, - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Direction( - Up, - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Direction( - Down, - ), - ): [ - MoveFocus( - Down, - ), - ], - Ctrl( - 'b', - ): [ - SwitchToMode( - Tmux, - ), - ], - Ctrl( - 'g', - ): [ - SwitchToMode( - Locked, - ), - ], - Ctrl( - 'h', - ): [ - SwitchToMode( - Move, - ), - ], - Ctrl( - 'n', - ): [ - SwitchToMode( - Resize, - ), - ], - Ctrl( - 'o', - ): [ + KeyWithModifier { + bare_key: Esc, + key_modifiers: {}, + }: [ SwitchToMode( Normal, ), ], - Ctrl( - 'p', - ): [ - SwitchToMode( - Pane, - ), - ], - Ctrl( - 'q', - ): [ - Quit, - ], - Ctrl( - 's', - ): [ - SwitchToMode( - Scroll, - ), - ], - Ctrl( - 't', - ): [ - SwitchToMode( - Tab, - ), - ], - Esc: [ + KeyWithModifier { + bare_key: Enter, + key_modifiers: {}, + }: [ SwitchToMode( Normal, ), ], }, Move: { - Left: [ + KeyWithModifier { + bare_key: Left, + key_modifiers: {}, + }: [ MovePane( Some( Left, ), ), ], - Down: [ + KeyWithModifier { + bare_key: Left, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Down, + key_modifiers: {}, + }: [ MovePane( Some( Down, ), ), ], - Up: [ + KeyWithModifier { + bare_key: Down, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Up, + key_modifiers: {}, + }: [ MovePane( Some( Up, ), ), ], - Right: [ + KeyWithModifier { + bare_key: Up, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Right, + key_modifiers: {}, + }: [ MovePane( Some( Right, ), ), ], - Char( - '\n', - ): [ - SwitchToMode( - Normal, + KeyWithModifier { + bare_key: Right, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, ), ], - Char( - 'h', - ): [ - MovePane( - Some( - Left, - ), - ), - ], - Char( - 'j', - ): [ - MovePane( - Some( - Down, - ), - ), - ], - Char( - 'k', - ): [ - MovePane( - Some( - Up, - ), - ), - ], - Char( - 'l', - ): [ - MovePane( - Some( - Right, - ), - ), - ], - Char( - 'n', - ): [ - MovePane( - None, - ), - ], - Char( - 'p', - ): [ - MovePaneBackwards, - ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '+', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Increase, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '-', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Decrease, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '=', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Increase, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '[', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ PreviousSwapLayout, ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( ']', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ NextSwapLayout, ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( + 'b', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Tmux, + ), + ], + KeyWithModifier { + bare_key: Char( + 'g', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Locked, + ), + ], + KeyWithModifier { + bare_key: Char( 'h', ), - ): [ + key_modifiers: {}, + }: [ + MovePane( + Some( + Left, + ), + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Alt, + }, + }: [ MoveFocusOrTab( Left, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'i', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveTab( Left, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'j', ), - ): [ + key_modifiers: {}, + }: [ + MovePane( + Some( + Down, + ), + ), + ], + KeyWithModifier { + bare_key: Char( + 'j', + ), + key_modifiers: { + Alt, + }, + }: [ MoveFocus( Down, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'k', ), - ): [ + key_modifiers: {}, + }: [ + MovePane( + Some( + Up, + ), + ), + ], + KeyWithModifier { + bare_key: Char( + 'k', + ), + key_modifiers: { + Alt, + }, + }: [ MoveFocus( Up, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'l', ), - ): [ + key_modifiers: {}, + }: [ + MovePane( + Some( + Right, + ), + ), + ], + KeyWithModifier { + bare_key: Char( + 'l', + ), + key_modifiers: { + Alt, + }, + }: [ MoveFocusOrTab( Right, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'n', ), - ): [ + key_modifiers: {}, + }: [ + MovePane( + None, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Resize, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Alt, + }, + }: [ NewPane( None, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'o', ), - ): [ - MoveTab( - Right, - ), - ], - Alt( - Direction( - Left, - ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Direction( - Right, - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Direction( - Up, - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Direction( - Down, - ), - ): [ - MoveFocus( - Down, - ), - ], - Ctrl( - 'b', - ): [ - SwitchToMode( - Tmux, - ), - ], - Ctrl( - 'g', - ): [ - SwitchToMode( - Locked, - ), - ], - Ctrl( - 'h', - ): [ - SwitchToMode( - Normal, - ), - ], - Ctrl( - 'n', - ): [ - SwitchToMode( - Resize, - ), - ], - Ctrl( - 'o', - ): [ + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Session, ), ], - Ctrl( - 'p', - ): [ + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'p', + ), + key_modifiers: {}, + }: [ + MovePaneBackwards, + ], + KeyWithModifier { + bare_key: Char( + 'p', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Pane, ), ], - Ctrl( - 'q', - ): [ + KeyWithModifier { + bare_key: Char( + 'q', + ), + key_modifiers: { + Ctrl, + }, + }: [ Quit, ], - Ctrl( - 's', - ): [ + KeyWithModifier { + bare_key: Char( + 's', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Scroll, ), ], - Ctrl( - 't', - ): [ + KeyWithModifier { + bare_key: Char( + 't', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Tab, ), ], - BackTab: [ + KeyWithModifier { + bare_key: Tab, + key_modifiers: {}, + }: [ MovePane( None, ), ], - Esc: [ + KeyWithModifier { + bare_key: Esc, + key_modifiers: {}, + }: [ + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Enter, + key_modifiers: {}, + }: [ SwitchToMode( Normal, ), ], }, Prompt: { - Char( - '\n', - ): [ - SwitchToMode( - Normal, + KeyWithModifier { + bare_key: Left, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Down, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Up, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Right, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( '+', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Increase, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '-', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Decrease, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '=', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Increase, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '[', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ PreviousSwapLayout, ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( ']', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ NextSwapLayout, ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( + 'b', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Tmux, + ), + ], + KeyWithModifier { + bare_key: Char( + 'g', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Locked, + ), + ], + KeyWithModifier { + bare_key: Char( 'h', ), - ): [ + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Move, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Alt, + }, + }: [ MoveFocusOrTab( Left, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'i', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveTab( Left, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'j', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveFocus( Down, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'k', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveFocus( Up, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'l', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveFocusOrTab( Right, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'n', ), - ): [ + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Resize, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Alt, + }, + }: [ NewPane( None, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'o', ), - ): [ - MoveTab( - Right, - ), - ], - Alt( - Direction( - Left, - ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Direction( - Right, - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Direction( - Up, - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Direction( - Down, - ), - ): [ - MoveFocus( - Down, - ), - ], - Ctrl( - 'b', - ): [ - SwitchToMode( - Tmux, - ), - ], - Ctrl( - 'g', - ): [ - SwitchToMode( - Locked, - ), - ], - Ctrl( - 'h', - ): [ - SwitchToMode( - Move, - ), - ], - Ctrl( - 'n', - ): [ - SwitchToMode( - Resize, - ), - ], - Ctrl( - 'o', - ): [ + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Session, ), ], - Ctrl( - 'p', - ): [ + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'p', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Pane, ), ], - Ctrl( - 'q', - ): [ + KeyWithModifier { + bare_key: Char( + 'q', + ), + key_modifiers: { + Ctrl, + }, + }: [ Quit, ], - Ctrl( - 's', - ): [ + KeyWithModifier { + bare_key: Char( + 's', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Scroll, ), ], - Ctrl( - 't', - ): [ + KeyWithModifier { + bare_key: Char( + 't', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Tab, ), ], - Esc: [ + KeyWithModifier { + bare_key: Esc, + key_modifiers: {}, + }: [ + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Enter, + key_modifiers: {}, + }: [ SwitchToMode( Normal, ), ], }, Tmux: { - Left: [ + KeyWithModifier { + bare_key: Left, + key_modifiers: {}, + }: [ MoveFocus( Left, ), @@ -3415,7 +4828,20 @@ Config { Normal, ), ], - Down: [ + KeyWithModifier { + bare_key: Left, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Down, + key_modifiers: {}, + }: [ MoveFocus( Down, ), @@ -3423,7 +4849,20 @@ Config { Normal, ), ], - Up: [ + KeyWithModifier { + bare_key: Down, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Up, + key_modifiers: {}, + }: [ MoveFocus( Up, ), @@ -3431,7 +4870,20 @@ Config { Normal, ), ], - Right: [ + KeyWithModifier { + bare_key: Up, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Right, + key_modifiers: {}, + }: [ MoveFocus( Right, ), @@ -3439,21 +4891,30 @@ Config { Normal, ), ], - Char( - '\n', - ): [ - SwitchToMode( - Normal, + KeyWithModifier { + bare_key: Right, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, ), ], - Char( - ' ', - ): [ + KeyWithModifier { + bare_key: Char( + ' ', + ), + key_modifiers: {}, + }: [ NextSwapLayout, ], - Char( - '"', - ): [ + KeyWithModifier { + bare_key: Char( + '"', + ), + key_modifiers: {}, + }: [ NewPane( Some( Down, @@ -3464,9 +4925,12 @@ Config { Normal, ), ], - Char( - '%', - ): [ + KeyWithModifier { + bare_key: Char( + '%', + ), + key_modifiers: {}, + }: [ NewPane( Some( Right, @@ -3477,23 +4941,110 @@ Config { Normal, ), ], - Char( - ',', - ): [ + KeyWithModifier { + bare_key: Char( + '+', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Increase, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + ',', + ), + key_modifiers: {}, + }: [ SwitchToMode( RenameTab, ), ], - Char( - '[', - ): [ + KeyWithModifier { + bare_key: Char( + '-', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Decrease, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '=', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Increase, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '[', + ), + key_modifiers: {}, + }: [ SwitchToMode( Scroll, ), ], - Char( - 'c', - ): [ + KeyWithModifier { + bare_key: Char( + '[', + ), + key_modifiers: { + Alt, + }, + }: [ + PreviousSwapLayout, + ], + KeyWithModifier { + bare_key: Char( + ']', + ), + key_modifiers: { + Alt, + }, + }: [ + NextSwapLayout, + ], + KeyWithModifier { + bare_key: Char( + 'b', + ), + key_modifiers: { + Ctrl, + }, + }: [ + Write( + None, + [ + 2, + ], + false, + ), + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Char( + 'c', + ), + key_modifiers: {}, + }: [ NewTab( None, [], @@ -3505,14 +5056,32 @@ Config { Normal, ), ], - Char( - 'd', - ): [ + KeyWithModifier { + bare_key: Char( + 'd', + ), + key_modifiers: {}, + }: [ Detach, ], - Char( - 'h', - ): [ + KeyWithModifier { + bare_key: Char( + 'g', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Locked, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: {}, + }: [ MoveFocus( Left, ), @@ -3520,9 +5089,48 @@ Config { Normal, ), ], - Char( - 'j', - ): [ + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Move, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Char( + 'i', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Char( + 'j', + ), + key_modifiers: {}, + }: [ MoveFocus( Down, ), @@ -3530,9 +5138,24 @@ Config { Normal, ), ], - Char( - 'k', - ): [ + KeyWithModifier { + bare_key: Char( + 'j', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Char( + 'k', + ), + key_modifiers: {}, + }: [ MoveFocus( Up, ), @@ -3540,9 +5163,24 @@ Config { Normal, ), ], - Char( - 'l', - ): [ + KeyWithModifier { + bare_key: Char( + 'k', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Char( + 'l', + ), + key_modifiers: {}, + }: [ MoveFocus( Right, ), @@ -3550,254 +5188,177 @@ Config { Normal, ), ], - Char( - 'n', - ): [ + KeyWithModifier { + bare_key: Char( + 'l', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: {}, + }: [ GoToNextTab, SwitchToMode( Normal, ), ], - Char( - 'o', - ): [ - FocusNextPane, - ], - Char( - 'p', - ): [ - GoToPreviousTab, - SwitchToMode( - Normal, - ), - ], - Char( - 'x', - ): [ - CloseFocus, - SwitchToMode( - Normal, - ), - ], - Char( - 'z', - ): [ - ToggleFocusFullscreen, - SwitchToMode( - Normal, - ), - ], - Alt( - Char( - '+', - ), - ): [ - Resize( - Increase, - None, - ), - ], - Alt( - Char( - '-', - ), - ): [ - Resize( - Decrease, - None, - ), - ], - Alt( - Char( - '=', - ), - ): [ - Resize( - Increase, - None, - ), - ], - Alt( - Char( - '[', - ), - ): [ - PreviousSwapLayout, - ], - Alt( - Char( - ']', - ), - ): [ - NextSwapLayout, - ], - Alt( - Char( - 'h', - ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Char( - 'i', - ), - ): [ - MoveTab( - Left, - ), - ], - Alt( - Char( - 'j', - ), - ): [ - MoveFocus( - Down, - ), - ], - Alt( - Char( - 'k', - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Char( - 'l', - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'n', ), - ): [ + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Resize, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Alt, + }, + }: [ NewPane( None, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'o', ), - ): [ - MoveTab( - Right, - ), + key_modifiers: {}, + }: [ + FocusNextPane, ], - Alt( - Direction( - Left, + KeyWithModifier { + bare_key: Char( + 'o', ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Direction( - Right, - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Direction( - Up, - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Direction( - Down, - ), - ): [ - MoveFocus( - Down, - ), - ], - Ctrl( - 'b', - ): [ - Write( - [ - 2, - ], - ), - SwitchToMode( - Normal, - ), - ], - Ctrl( - 'g', - ): [ - SwitchToMode( - Locked, - ), - ], - Ctrl( - 'h', - ): [ - SwitchToMode( - Move, - ), - ], - Ctrl( - 'n', - ): [ - SwitchToMode( - Resize, - ), - ], - Ctrl( - 'o', - ): [ + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Session, ), ], - Ctrl( - 'p', - ): [ + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'p', + ), + key_modifiers: {}, + }: [ + GoToPreviousTab, + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Char( + 'p', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Pane, ), ], - Ctrl( - 'q', - ): [ + KeyWithModifier { + bare_key: Char( + 'q', + ), + key_modifiers: { + Ctrl, + }, + }: [ Quit, ], - Ctrl( - 's', - ): [ + KeyWithModifier { + bare_key: Char( + 's', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Scroll, ), ], - Ctrl( - 't', - ): [ + KeyWithModifier { + bare_key: Char( + 't', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Tab, ), ], - Esc: [ + KeyWithModifier { + bare_key: Char( + 'x', + ), + key_modifiers: {}, + }: [ + CloseFocus, + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Char( + 'z', + ), + key_modifiers: {}, + }: [ + ToggleFocusFullscreen, + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Esc, + key_modifiers: {}, + }: [ + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Enter, + key_modifiers: {}, + }: [ SwitchToMode( Normal, ), @@ -3831,6 +5392,7 @@ Config { styled_underlines: None, serialization_interval: None, disable_session_metadata: None, + support_kitty_keyboard_protocol: None, }, themes: {}, plugins: PluginAliases { diff --git a/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_env_vars_override_config_env_vars.snap b/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_env_vars_override_config_env_vars.snap index 068d455b..6a4cb7f9 100644 --- a/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_env_vars_override_config_env_vars.snap +++ b/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_env_vars_override_config_env_vars.snap @@ -1,228 +1,321 @@ --- source: zellij-utils/src/setup.rs -assertion_line: 756 +assertion_line: 783 expression: "format!(\"{:#?}\", config)" --- Config { keybinds: { Normal: { - Alt( - Char( + KeyWithModifier { + bare_key: Left, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Down, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Up, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Right, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( '+', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Increase, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '-', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Decrease, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '=', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Increase, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '[', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ PreviousSwapLayout, ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( ']', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ NextSwapLayout, ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( + 'b', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Tmux, + ), + ], + KeyWithModifier { + bare_key: Char( + 'g', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Locked, + ), + ], + KeyWithModifier { + bare_key: Char( 'h', ), - ): [ + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Move, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Alt, + }, + }: [ MoveFocusOrTab( Left, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'i', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveTab( Left, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'j', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveFocus( Down, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'k', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveFocus( Up, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'l', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveFocusOrTab( Right, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'n', ), - ): [ + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Resize, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Alt, + }, + }: [ NewPane( None, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'o', ), - ): [ - MoveTab( - Right, - ), - ], - Alt( - Direction( - Left, - ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Direction( - Right, - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Direction( - Up, - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Direction( - Down, - ), - ): [ - MoveFocus( - Down, - ), - ], - Ctrl( - 'b', - ): [ - SwitchToMode( - Tmux, - ), - ], - Ctrl( - 'g', - ): [ - SwitchToMode( - Locked, - ), - ], - Ctrl( - 'h', - ): [ - SwitchToMode( - Move, - ), - ], - Ctrl( - 'n', - ): [ - SwitchToMode( - Resize, - ), - ], - Ctrl( - 'o', - ): [ + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Session, ), ], - Ctrl( - 'p', - ): [ + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'p', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Pane, ), ], - Ctrl( - 'q', - ): [ + KeyWithModifier { + bare_key: Char( + 'q', + ), + key_modifiers: { + Ctrl, + }, + }: [ Quit, ], - Ctrl( - 's', - ): [ + KeyWithModifier { + bare_key: Char( + 's', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Scroll, ), ], - Ctrl( - 't', - ): [ + KeyWithModifier { + bare_key: Char( + 't', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Tab, ), ], }, Locked: { - Ctrl( - 'g', - ): [ + KeyWithModifier { + bare_key: Char( + 'g', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Normal, ), ], }, Resize: { - Left: [ + KeyWithModifier { + bare_key: Left, + key_modifiers: {}, + }: [ Resize( Increase, Some( @@ -230,383 +323,633 @@ Config { ), ), ], - Down: [ - Resize( - Increase, - Some( - Down, - ), - ), - ], - Up: [ - Resize( - Increase, - Some( - Up, - ), - ), - ], - Right: [ - Resize( - Increase, - Some( - Right, - ), - ), - ], - Char( - '\n', - ): [ - SwitchToMode( - Normal, - ), - ], - Char( - '+', - ): [ - Resize( - Increase, - None, - ), - ], - Char( - '-', - ): [ - Resize( - Decrease, - None, - ), - ], - Char( - '=', - ): [ - Resize( - Increase, - None, - ), - ], - Char( - 'H', - ): [ - Resize( - Decrease, - Some( - Left, - ), - ), - ], - Char( - 'J', - ): [ - Resize( - Decrease, - Some( - Down, - ), - ), - ], - Char( - 'K', - ): [ - Resize( - Decrease, - Some( - Up, - ), - ), - ], - Char( - 'L', - ): [ - Resize( - Decrease, - Some( - Right, - ), - ), - ], - Char( - 'h', - ): [ - Resize( - Increase, - Some( - Left, - ), - ), - ], - Char( - 'j', - ): [ - Resize( - Increase, - Some( - Down, - ), - ), - ], - Char( - 'k', - ): [ - Resize( - Increase, - Some( - Up, - ), - ), - ], - Char( - 'l', - ): [ - Resize( - Increase, - Some( - Right, - ), - ), - ], - Alt( - Char( - '+', - ), - ): [ - Resize( - Increase, - None, - ), - ], - Alt( - Char( - '-', - ), - ): [ - Resize( - Decrease, - None, - ), - ], - Alt( - Char( - '=', - ), - ): [ - Resize( - Increase, - None, - ), - ], - Alt( - Char( - '[', - ), - ): [ - PreviousSwapLayout, - ], - Alt( - Char( - ']', - ), - ): [ - NextSwapLayout, - ], - Alt( - Char( - 'h', - ), - ): [ + KeyWithModifier { + bare_key: Left, + key_modifiers: { + Alt, + }, + }: [ MoveFocusOrTab( Left, ), ], - Alt( - Char( - 'i', - ), - ): [ - MoveTab( - Left, + KeyWithModifier { + bare_key: Down, + key_modifiers: {}, + }: [ + Resize( + Increase, + Some( + Down, + ), ), ], - Alt( - Char( - 'j', - ), - ): [ + KeyWithModifier { + bare_key: Down, + key_modifiers: { + Alt, + }, + }: [ MoveFocus( Down, ), ], - Alt( - Char( - 'k', + KeyWithModifier { + bare_key: Up, + key_modifiers: {}, + }: [ + Resize( + Increase, + Some( + Up, + ), ), - ): [ + ], + KeyWithModifier { + bare_key: Up, + key_modifiers: { + Alt, + }, + }: [ MoveFocus( Up, ), ], - Alt( - Char( - 'l', + KeyWithModifier { + bare_key: Right, + key_modifiers: {}, + }: [ + Resize( + Increase, + Some( + Right, + ), ), - ): [ + ], + KeyWithModifier { + bare_key: Right, + key_modifiers: { + Alt, + }, + }: [ MoveFocusOrTab( Right, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( + '+', + ), + key_modifiers: {}, + }: [ + Resize( + Increase, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '+', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Increase, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '-', + ), + key_modifiers: {}, + }: [ + Resize( + Decrease, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '-', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Decrease, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '=', + ), + key_modifiers: {}, + }: [ + Resize( + Increase, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '=', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Increase, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + 'H', + ), + key_modifiers: {}, + }: [ + Resize( + Decrease, + Some( + Left, + ), + ), + ], + KeyWithModifier { + bare_key: Char( + 'J', + ), + key_modifiers: {}, + }: [ + Resize( + Decrease, + Some( + Down, + ), + ), + ], + KeyWithModifier { + bare_key: Char( + 'K', + ), + key_modifiers: {}, + }: [ + Resize( + Decrease, + Some( + Up, + ), + ), + ], + KeyWithModifier { + bare_key: Char( + 'L', + ), + key_modifiers: {}, + }: [ + Resize( + Decrease, + Some( + Right, + ), + ), + ], + KeyWithModifier { + bare_key: Char( + '[', + ), + key_modifiers: { + Alt, + }, + }: [ + PreviousSwapLayout, + ], + KeyWithModifier { + bare_key: Char( + ']', + ), + key_modifiers: { + Alt, + }, + }: [ + NextSwapLayout, + ], + KeyWithModifier { + bare_key: Char( + 'b', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Tmux, + ), + ], + KeyWithModifier { + bare_key: Char( + 'g', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Locked, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: {}, + }: [ + Resize( + Increase, + Some( + Left, + ), + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Move, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Char( + 'i', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Char( + 'j', + ), + key_modifiers: {}, + }: [ + Resize( + Increase, + Some( + Down, + ), + ), + ], + KeyWithModifier { + bare_key: Char( + 'j', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Char( + 'k', + ), + key_modifiers: {}, + }: [ + Resize( + Increase, + Some( + Up, + ), + ), + ], + KeyWithModifier { + bare_key: Char( + 'k', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Char( + 'l', + ), + key_modifiers: {}, + }: [ + Resize( + Increase, + Some( + Right, + ), + ), + ], + KeyWithModifier { + bare_key: Char( + 'l', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( 'n', ), - ): [ + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Alt, + }, + }: [ NewPane( None, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'o', ), - ): [ - MoveTab( - Right, - ), - ], - Alt( - Direction( - Left, - ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Direction( - Right, - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Direction( - Up, - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Direction( - Down, - ), - ): [ - MoveFocus( - Down, - ), - ], - Ctrl( - 'b', - ): [ - SwitchToMode( - Tmux, - ), - ], - Ctrl( - 'g', - ): [ - SwitchToMode( - Locked, - ), - ], - Ctrl( - 'h', - ): [ - SwitchToMode( - Move, - ), - ], - Ctrl( - 'n', - ): [ - SwitchToMode( - Normal, - ), - ], - Ctrl( - 'o', - ): [ + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Session, ), ], - Ctrl( - 'p', - ): [ + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'p', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Pane, ), ], - Ctrl( - 'q', - ): [ + KeyWithModifier { + bare_key: Char( + 'q', + ), + key_modifiers: { + Ctrl, + }, + }: [ Quit, ], - Ctrl( - 's', - ): [ + KeyWithModifier { + bare_key: Char( + 's', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Scroll, ), ], - Ctrl( - 't', - ): [ + KeyWithModifier { + bare_key: Char( + 't', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Tab, ), ], - Esc: [ + KeyWithModifier { + bare_key: Esc, + key_modifiers: {}, + }: [ + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Enter, + key_modifiers: {}, + }: [ SwitchToMode( Normal, ), ], }, Pane: { - Left: [ + KeyWithModifier { + bare_key: Left, + key_modifiers: {}, + }: [ MoveFocus( Left, ), ], - Down: [ + KeyWithModifier { + bare_key: Left, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Down, + key_modifiers: {}, + }: [ MoveFocus( Down, ), ], - Up: [ + KeyWithModifier { + bare_key: Down, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Up, + key_modifiers: {}, + }: [ MoveFocus( Up, ), ], - Right: [ + KeyWithModifier { + bare_key: Up, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Right, + key_modifiers: {}, + }: [ MoveFocus( Right, ), ], - Char( - '\n', - ): [ - SwitchToMode( - Normal, + KeyWithModifier { + bare_key: Right, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, ), ], - Char( - 'c', - ): [ + KeyWithModifier { + bare_key: Char( + '+', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Increase, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '-', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Decrease, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '=', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Increase, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '[', + ), + key_modifiers: { + Alt, + }, + }: [ + PreviousSwapLayout, + ], + KeyWithModifier { + bare_key: Char( + ']', + ), + key_modifiers: { + Alt, + }, + }: [ + NextSwapLayout, + ], + KeyWithModifier { + bare_key: Char( + 'b', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Tmux, + ), + ], + KeyWithModifier { + bare_key: Char( + 'c', + ), + key_modifiers: {}, + }: [ SwitchToMode( RenamePane, ), @@ -616,9 +959,12 @@ Config { ], ), ], - Char( - 'd', - ): [ + KeyWithModifier { + bare_key: Char( + 'd', + ), + key_modifiers: {}, + }: [ NewPane( Some( Down, @@ -629,53 +975,158 @@ Config { Normal, ), ], - Char( - 'e', - ): [ + KeyWithModifier { + bare_key: Char( + 'e', + ), + key_modifiers: {}, + }: [ TogglePaneEmbedOrFloating, SwitchToMode( Normal, ), ], - Char( - 'f', - ): [ + KeyWithModifier { + bare_key: Char( + 'f', + ), + key_modifiers: {}, + }: [ ToggleFocusFullscreen, SwitchToMode( Normal, ), ], - Char( - 'h', - ): [ + KeyWithModifier { + bare_key: Char( + 'g', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Locked, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: {}, + }: [ MoveFocus( Left, ), ], - Char( - 'j', - ): [ + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Move, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Char( + 'i', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Char( + 'j', + ), + key_modifiers: {}, + }: [ MoveFocus( Down, ), ], - Char( - 'k', - ): [ + KeyWithModifier { + bare_key: Char( + 'j', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Char( + 'k', + ), + key_modifiers: {}, + }: [ MoveFocus( Up, ), ], - Char( - 'l', - ): [ + KeyWithModifier { + bare_key: Char( + 'k', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Char( + 'l', + ), + key_modifiers: {}, + }: [ MoveFocus( Right, ), ], - Char( - 'n', - ): [ + KeyWithModifier { + bare_key: Char( + 'l', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: {}, + }: [ NewPane( None, None, @@ -684,14 +1135,91 @@ Config { Normal, ), ], - Char( - 'p', - ): [ + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Resize, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Alt, + }, + }: [ + NewPane( + None, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Session, + ), + ], + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'p', + ), + key_modifiers: {}, + }: [ SwitchFocus, ], - Char( - 'r', - ): [ + KeyWithModifier { + bare_key: Char( + 'p', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Char( + 'q', + ), + key_modifiers: { + Ctrl, + }, + }: [ + Quit, + ], + KeyWithModifier { + bare_key: Char( + 'r', + ), + key_modifiers: {}, + }: [ NewPane( Some( Right, @@ -702,264 +1230,177 @@ Config { Normal, ), ], - Char( - 'w', - ): [ + KeyWithModifier { + bare_key: Char( + 's', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Scroll, + ), + ], + KeyWithModifier { + bare_key: Char( + 't', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Tab, + ), + ], + KeyWithModifier { + bare_key: Char( + 'w', + ), + key_modifiers: {}, + }: [ ToggleFloatingPanes, SwitchToMode( Normal, ), ], - Char( - 'x', - ): [ + KeyWithModifier { + bare_key: Char( + 'x', + ), + key_modifiers: {}, + }: [ CloseFocus, SwitchToMode( Normal, ), ], - Char( - 'z', - ): [ + KeyWithModifier { + bare_key: Char( + 'z', + ), + key_modifiers: {}, + }: [ TogglePaneFrames, SwitchToMode( Normal, ), ], - Alt( - Char( - '+', - ), - ): [ - Resize( - Increase, - None, - ), - ], - Alt( - Char( - '-', - ), - ): [ - Resize( - Decrease, - None, - ), - ], - Alt( - Char( - '=', - ), - ): [ - Resize( - Increase, - None, - ), - ], - Alt( - Char( - '[', - ), - ): [ - PreviousSwapLayout, - ], - Alt( - Char( - ']', - ), - ): [ - NextSwapLayout, - ], - Alt( - Char( - 'h', - ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Char( - 'i', - ), - ): [ - MoveTab( - Left, - ), - ], - Alt( - Char( - 'j', - ), - ): [ - MoveFocus( - Down, - ), - ], - Alt( - Char( - 'k', - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Char( - 'l', - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Char( - 'n', - ), - ): [ - NewPane( - None, - None, - ), - ], - Alt( - Char( - 'o', - ), - ): [ - MoveTab( - Right, - ), - ], - Alt( - Direction( - Left, - ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Direction( - Right, - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Direction( - Up, - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Direction( - Down, - ), - ): [ - MoveFocus( - Down, - ), - ], - Ctrl( - 'b', - ): [ - SwitchToMode( - Tmux, - ), - ], - Ctrl( - 'g', - ): [ - SwitchToMode( - Locked, - ), - ], - Ctrl( - 'h', - ): [ - SwitchToMode( - Move, - ), - ], - Ctrl( - 'n', - ): [ - SwitchToMode( - Resize, - ), - ], - Ctrl( - 'o', - ): [ - SwitchToMode( - Session, - ), - ], - Ctrl( - 'p', - ): [ + KeyWithModifier { + bare_key: Esc, + key_modifiers: {}, + }: [ SwitchToMode( Normal, ), ], - Ctrl( - 'q', - ): [ - Quit, - ], - Ctrl( - 's', - ): [ - SwitchToMode( - Scroll, - ), - ], - Ctrl( - 't', - ): [ - SwitchToMode( - Tab, - ), - ], - Esc: [ + KeyWithModifier { + bare_key: Enter, + key_modifiers: {}, + }: [ SwitchToMode( Normal, ), ], }, Tab: { - Left: [ + KeyWithModifier { + bare_key: Left, + key_modifiers: {}, + }: [ GoToPreviousTab, ], - Down: [ - GoToNextTab, - ], - Up: [ - GoToPreviousTab, - ], - Right: [ - GoToNextTab, - ], - Char( - '\n', - ): [ - SwitchToMode( - Normal, + KeyWithModifier { + bare_key: Left, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, ), ], - Char( - '1', - ): [ + KeyWithModifier { + bare_key: Down, + key_modifiers: {}, + }: [ + GoToNextTab, + ], + KeyWithModifier { + bare_key: Down, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Up, + key_modifiers: {}, + }: [ + GoToPreviousTab, + ], + KeyWithModifier { + bare_key: Up, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Right, + key_modifiers: {}, + }: [ + GoToNextTab, + ], + KeyWithModifier { + bare_key: Right, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + '+', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Increase, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '-', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Decrease, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '1', + ), + key_modifiers: {}, + }: [ GoToTab( 1, ), @@ -967,9 +1408,12 @@ Config { Normal, ), ], - Char( - '2', - ): [ + KeyWithModifier { + bare_key: Char( + '2', + ), + key_modifiers: {}, + }: [ GoToTab( 2, ), @@ -977,9 +1421,12 @@ Config { Normal, ), ], - Char( - '3', - ): [ + KeyWithModifier { + bare_key: Char( + '3', + ), + key_modifiers: {}, + }: [ GoToTab( 3, ), @@ -987,9 +1434,12 @@ Config { Normal, ), ], - Char( - '4', - ): [ + KeyWithModifier { + bare_key: Char( + '4', + ), + key_modifiers: {}, + }: [ GoToTab( 4, ), @@ -997,9 +1447,12 @@ Config { Normal, ), ], - Char( - '5', - ): [ + KeyWithModifier { + bare_key: Char( + '5', + ), + key_modifiers: {}, + }: [ GoToTab( 5, ), @@ -1007,9 +1460,12 @@ Config { Normal, ), ], - Char( - '6', - ): [ + KeyWithModifier { + bare_key: Char( + '6', + ), + key_modifiers: {}, + }: [ GoToTab( 6, ), @@ -1017,9 +1473,12 @@ Config { Normal, ), ], - Char( - '7', - ): [ + KeyWithModifier { + bare_key: Char( + '7', + ), + key_modifiers: {}, + }: [ GoToTab( 7, ), @@ -1027,9 +1486,12 @@ Config { Normal, ), ], - Char( - '8', - ): [ + KeyWithModifier { + bare_key: Char( + '8', + ), + key_modifiers: {}, + }: [ GoToTab( 8, ), @@ -1037,9 +1499,12 @@ Config { Normal, ), ], - Char( - '9', - ): [ + KeyWithModifier { + bare_key: Char( + '9', + ), + key_modifiers: {}, + }: [ GoToTab( 9, ), @@ -1047,53 +1512,206 @@ Config { Normal, ), ], - Char( - '[', - ): [ + KeyWithModifier { + bare_key: Char( + '=', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Increase, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '[', + ), + key_modifiers: {}, + }: [ BreakPaneLeft, SwitchToMode( Normal, ), ], - Char( - ']', - ): [ + KeyWithModifier { + bare_key: Char( + '[', + ), + key_modifiers: { + Alt, + }, + }: [ + PreviousSwapLayout, + ], + KeyWithModifier { + bare_key: Char( + ']', + ), + key_modifiers: {}, + }: [ BreakPaneRight, SwitchToMode( Normal, ), ], - Char( - 'b', - ): [ + KeyWithModifier { + bare_key: Char( + ']', + ), + key_modifiers: { + Alt, + }, + }: [ + NextSwapLayout, + ], + KeyWithModifier { + bare_key: Char( + 'b', + ), + key_modifiers: {}, + }: [ BreakPane, SwitchToMode( Normal, ), ], - Char( - 'h', - ): [ + KeyWithModifier { + bare_key: Char( + 'b', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Tmux, + ), + ], + KeyWithModifier { + bare_key: Char( + 'g', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Locked, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: {}, + }: [ GoToPreviousTab, ], - Char( - 'j', - ): [ + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Move, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Char( + 'i', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Char( + 'j', + ), + key_modifiers: {}, + }: [ GoToNextTab, ], - Char( - 'k', - ): [ + KeyWithModifier { + bare_key: Char( + 'j', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Char( + 'k', + ), + key_modifiers: {}, + }: [ GoToPreviousTab, ], - Char( - 'l', - ): [ + KeyWithModifier { + bare_key: Char( + 'k', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Char( + 'l', + ), + key_modifiers: {}, + }: [ GoToNextTab, ], - Char( - 'n', - ): [ + KeyWithModifier { + bare_key: Char( + 'l', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: {}, + }: [ NewTab( None, [], @@ -1105,9 +1723,83 @@ Config { Normal, ), ], - Char( - 'r', - ): [ + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Resize, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Alt, + }, + }: [ + NewPane( + None, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Session, + ), + ], + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'p', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Pane, + ), + ], + KeyWithModifier { + bare_key: Char( + 'q', + ), + key_modifiers: { + Ctrl, + }, + }: [ + Quit, + ], + KeyWithModifier { + bare_key: Char( + 'r', + ), + key_modifiers: {}, + }: [ SwitchToMode( RenameTab, ), @@ -1117,298 +1809,456 @@ Config { ], ), ], - Char( - 's', - ): [ + KeyWithModifier { + bare_key: Char( + 's', + ), + key_modifiers: {}, + }: [ ToggleActiveSyncTab, SwitchToMode( Normal, ), ], - Char( - 'x', - ): [ + KeyWithModifier { + bare_key: Char( + 's', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Scroll, + ), + ], + KeyWithModifier { + bare_key: Char( + 't', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Char( + 'x', + ), + key_modifiers: {}, + }: [ CloseTab, SwitchToMode( Normal, ), ], - Alt( - Char( - '+', - ), - ): [ - Resize( - Increase, - None, - ), + KeyWithModifier { + bare_key: Tab, + key_modifiers: {}, + }: [ + ToggleTab, ], - Alt( - Char( - '-', - ), - ): [ - Resize( - Decrease, - None, - ), - ], - Alt( - Char( - '=', - ), - ): [ - Resize( - Increase, - None, - ), - ], - Alt( - Char( - '[', - ), - ): [ - PreviousSwapLayout, - ], - Alt( - Char( - ']', - ), - ): [ - NextSwapLayout, - ], - Alt( - Char( - 'h', - ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Char( - 'i', - ), - ): [ - MoveTab( - Left, - ), - ], - Alt( - Char( - 'j', - ), - ): [ - MoveFocus( - Down, - ), - ], - Alt( - Char( - 'k', - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Char( - 'l', - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Char( - 'n', - ), - ): [ - NewPane( - None, - None, - ), - ], - Alt( - Char( - 'o', - ), - ): [ - MoveTab( - Right, - ), - ], - Alt( - Direction( - Left, - ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Direction( - Right, - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Direction( - Up, - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Direction( - Down, - ), - ): [ - MoveFocus( - Down, - ), - ], - Ctrl( - 'b', - ): [ - SwitchToMode( - Tmux, - ), - ], - Ctrl( - 'g', - ): [ - SwitchToMode( - Locked, - ), - ], - Ctrl( - 'h', - ): [ - SwitchToMode( - Move, - ), - ], - Ctrl( - 'n', - ): [ - SwitchToMode( - Resize, - ), - ], - Ctrl( - 'o', - ): [ - SwitchToMode( - Session, - ), - ], - Ctrl( - 'p', - ): [ - SwitchToMode( - Pane, - ), - ], - Ctrl( - 'q', - ): [ - Quit, - ], - Ctrl( - 's', - ): [ - SwitchToMode( - Scroll, - ), - ], - Ctrl( - 't', - ): [ + KeyWithModifier { + bare_key: Esc, + key_modifiers: {}, + }: [ SwitchToMode( Normal, ), ], - BackTab: [ - ToggleTab, - ], - Esc: [ + KeyWithModifier { + bare_key: Enter, + key_modifiers: {}, + }: [ SwitchToMode( Normal, ), ], }, Scroll: { - PageDown: [ + KeyWithModifier { + bare_key: PageDown, + key_modifiers: {}, + }: [ PageScrollDown, ], - PageUp: [ + KeyWithModifier { + bare_key: PageUp, + key_modifiers: {}, + }: [ PageScrollUp, ], - Left: [ + KeyWithModifier { + bare_key: Left, + key_modifiers: {}, + }: [ PageScrollUp, ], - Down: [ + KeyWithModifier { + bare_key: Left, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Down, + key_modifiers: {}, + }: [ ScrollDown, ], - Up: [ + KeyWithModifier { + bare_key: Down, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Up, + key_modifiers: {}, + }: [ ScrollUp, ], - Right: [ + KeyWithModifier { + bare_key: Up, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Right, + key_modifiers: {}, + }: [ PageScrollDown, ], - Char( - '\n', - ): [ + KeyWithModifier { + bare_key: Right, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + '+', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Increase, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '-', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Decrease, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '=', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Increase, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '[', + ), + key_modifiers: { + Alt, + }, + }: [ + PreviousSwapLayout, + ], + KeyWithModifier { + bare_key: Char( + ']', + ), + key_modifiers: { + Alt, + }, + }: [ + NextSwapLayout, + ], + KeyWithModifier { + bare_key: Char( + 'b', + ), + key_modifiers: { + Ctrl, + }, + }: [ + PageScrollUp, + ], + KeyWithModifier { + bare_key: Char( + 'c', + ), + key_modifiers: { + Ctrl, + }, + }: [ + ScrollToBottom, SwitchToMode( Normal, ), ], - Char( - 'd', - ): [ + KeyWithModifier { + bare_key: Char( + 'd', + ), + key_modifiers: {}, + }: [ HalfPageScrollDown, ], - Char( - 'e', - ): [ + KeyWithModifier { + bare_key: Char( + 'e', + ), + key_modifiers: {}, + }: [ EditScrollback, SwitchToMode( Normal, ), ], - Char( - 'h', - ): [ - PageScrollUp, - ], - Char( - 'j', - ): [ - ScrollDown, - ], - Char( - 'k', - ): [ - ScrollUp, - ], - Char( - 'l', - ): [ + KeyWithModifier { + bare_key: Char( + 'f', + ), + key_modifiers: { + Ctrl, + }, + }: [ PageScrollDown, ], - Char( - 's', - ): [ + KeyWithModifier { + bare_key: Char( + 'g', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Locked, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: {}, + }: [ + PageScrollUp, + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Move, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Char( + 'i', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Char( + 'j', + ), + key_modifiers: {}, + }: [ + ScrollDown, + ], + KeyWithModifier { + bare_key: Char( + 'j', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Char( + 'k', + ), + key_modifiers: {}, + }: [ + ScrollUp, + ], + KeyWithModifier { + bare_key: Char( + 'k', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Char( + 'l', + ), + key_modifiers: {}, + }: [ + PageScrollDown, + ], + KeyWithModifier { + bare_key: Char( + 'l', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Resize, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Alt, + }, + }: [ + NewPane( + None, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Session, + ), + ], + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'p', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Pane, + ), + ], + KeyWithModifier { + bare_key: Char( + 'q', + ), + key_modifiers: { + Ctrl, + }, + }: [ + Quit, + ], + KeyWithModifier { + bare_key: Char( + 's', + ), + key_modifiers: {}, + }: [ SwitchToMode( EnterSearch, ), @@ -1418,1242 +2268,1785 @@ Config { ], ), ], - Char( - 'u', - ): [ - HalfPageScrollUp, - ], - Alt( - Char( - '+', + KeyWithModifier { + bare_key: Char( + 's', ), - ): [ - Resize( - Increase, - None, - ), - ], - Alt( - Char( - '-', - ), - ): [ - Resize( - Decrease, - None, - ), - ], - Alt( - Char( - '=', - ), - ): [ - Resize( - Increase, - None, - ), - ], - Alt( - Char( - '[', - ), - ): [ - PreviousSwapLayout, - ], - Alt( - Char( - ']', - ), - ): [ - NextSwapLayout, - ], - Alt( - Char( - 'h', - ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Char( - 'i', - ), - ): [ - MoveTab( - Left, - ), - ], - Alt( - Char( - 'j', - ), - ): [ - MoveFocus( - Down, - ), - ], - Alt( - Char( - 'k', - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Char( - 'l', - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Char( - 'n', - ), - ): [ - NewPane( - None, - None, - ), - ], - Alt( - Char( - 'o', - ), - ): [ - MoveTab( - Right, - ), - ], - Alt( - Direction( - Left, - ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Direction( - Right, - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Direction( - Up, - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Direction( - Down, - ), - ): [ - MoveFocus( - Down, - ), - ], - Ctrl( - 'b', - ): [ - PageScrollUp, - ], - Ctrl( - 'c', - ): [ - ScrollToBottom, + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Normal, ), ], - Ctrl( - 'f', - ): [ - PageScrollDown, - ], - Ctrl( - 'g', - ): [ - SwitchToMode( - Locked, + KeyWithModifier { + bare_key: Char( + 't', ), - ], - Ctrl( - 'h', - ): [ - SwitchToMode( - Move, - ), - ], - Ctrl( - 'n', - ): [ - SwitchToMode( - Resize, - ), - ], - Ctrl( - 'o', - ): [ - SwitchToMode( - Session, - ), - ], - Ctrl( - 'p', - ): [ - SwitchToMode( - Pane, - ), - ], - Ctrl( - 'q', - ): [ - Quit, - ], - Ctrl( - 's', - ): [ - SwitchToMode( - Normal, - ), - ], - Ctrl( - 't', - ): [ + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Tab, ), ], - Esc: [ + KeyWithModifier { + bare_key: Char( + 'u', + ), + key_modifiers: {}, + }: [ + HalfPageScrollUp, + ], + KeyWithModifier { + bare_key: Esc, + key_modifiers: {}, + }: [ + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Enter, + key_modifiers: {}, + }: [ SwitchToMode( Normal, ), ], }, EnterSearch: { - Char( - '\n', - ): [ - SwitchToMode( - Search, + KeyWithModifier { + bare_key: Left, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Down, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Up, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Right, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( '+', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Increase, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '-', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Decrease, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '=', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Increase, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '[', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ PreviousSwapLayout, ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( ']', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ NextSwapLayout, ], - Alt( - Char( - 'h', + KeyWithModifier { + bare_key: Char( + 'b', ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Char( - 'i', - ), - ): [ - MoveTab( - Left, - ), - ], - Alt( - Char( - 'j', - ), - ): [ - MoveFocus( - Down, - ), - ], - Alt( - Char( - 'k', - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Char( - 'l', - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Char( - 'n', - ), - ): [ - NewPane( - None, - None, - ), - ], - Alt( - Char( - 'o', - ), - ): [ - MoveTab( - Right, - ), - ], - Alt( - Direction( - Left, - ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Direction( - Right, - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Direction( - Up, - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Direction( - Down, - ), - ): [ - MoveFocus( - Down, - ), - ], - Ctrl( - 'b', - ): [ + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Tmux, ), ], - Ctrl( - 'c', - ): [ + KeyWithModifier { + bare_key: Char( + 'c', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Scroll, ), ], - Ctrl( - 'g', - ): [ + KeyWithModifier { + bare_key: Char( + 'g', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Locked, ), ], - Ctrl( - 'h', - ): [ + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Move, ), ], - Ctrl( - 'n', - ): [ - SwitchToMode( - Resize, - ), - ], - Ctrl( - 'o', - ): [ - SwitchToMode( - Session, - ), - ], - Ctrl( - 'p', - ): [ - SwitchToMode( - Pane, - ), - ], - Ctrl( - 'q', - ): [ - Quit, - ], - Ctrl( - 's', - ): [ - SwitchToMode( - Scroll, - ), - ], - Ctrl( - 't', - ): [ - SwitchToMode( - Tab, - ), - ], - Esc: [ - SwitchToMode( - Scroll, - ), - ], - }, - Search: { - PageDown: [ - PageScrollDown, - ], - PageUp: [ - PageScrollUp, - ], - Left: [ - PageScrollUp, - ], - Down: [ - ScrollDown, - ], - Up: [ - ScrollUp, - ], - Right: [ - PageScrollDown, - ], - Char( - '\n', - ): [ - SwitchToMode( - Normal, - ), - ], - Char( - 'c', - ): [ - SearchToggleOption( - CaseSensitivity, - ), - ], - Char( - 'd', - ): [ - HalfPageScrollDown, - ], - Char( - 'h', - ): [ - PageScrollUp, - ], - Char( - 'j', - ): [ - ScrollDown, - ], - Char( - 'k', - ): [ - ScrollUp, - ], - Char( - 'l', - ): [ - PageScrollDown, - ], - Char( - 'n', - ): [ - Search( - Down, - ), - ], - Char( - 'o', - ): [ - SearchToggleOption( - WholeWord, - ), - ], - Char( - 'p', - ): [ - Search( - Up, - ), - ], - Char( - 'u', - ): [ - HalfPageScrollUp, - ], - Char( - 'w', - ): [ - SearchToggleOption( - Wrap, - ), - ], - Alt( - Char( - '+', - ), - ): [ - Resize( - Increase, - None, - ), - ], - Alt( - Char( - '-', - ), - ): [ - Resize( - Decrease, - None, - ), - ], - Alt( - Char( - '=', - ), - ): [ - Resize( - Increase, - None, - ), - ], - Alt( - Char( - '[', - ), - ): [ - PreviousSwapLayout, - ], - Alt( - Char( - ']', - ), - ): [ - NextSwapLayout, - ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'h', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveFocusOrTab( Left, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'i', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveTab( Left, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'j', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveFocus( Down, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'k', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveFocus( Up, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'l', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveFocusOrTab( Right, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'n', ), - ): [ + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Resize, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Alt, + }, + }: [ NewPane( None, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'o', ), - ): [ + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Session, + ), + ], + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Alt, + }, + }: [ MoveTab( Right, ), ], - Alt( - Direction( - Left, + KeyWithModifier { + bare_key: Char( + 'p', ), - ): [ - MoveFocusOrTab( - Left, + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Pane, ), ], - Alt( - Direction( - Right, + KeyWithModifier { + bare_key: Char( + 'q', ), - ): [ - MoveFocusOrTab( - Right, + key_modifiers: { + Ctrl, + }, + }: [ + Quit, + ], + KeyWithModifier { + bare_key: Char( + 's', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Scroll, ), ], - Alt( - Direction( - Up, + KeyWithModifier { + bare_key: Char( + 't', ), - ): [ - MoveFocus( - Up, + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Tab, ), ], - Alt( - Direction( - Down, - ), - ): [ - MoveFocus( - Down, + KeyWithModifier { + bare_key: Esc, + key_modifiers: {}, + }: [ + SwitchToMode( + Scroll, ), ], - Ctrl( - 'b', - ): [ + KeyWithModifier { + bare_key: Enter, + key_modifiers: {}, + }: [ + SwitchToMode( + Search, + ), + ], + }, + Search: { + KeyWithModifier { + bare_key: PageDown, + key_modifiers: {}, + }: [ + PageScrollDown, + ], + KeyWithModifier { + bare_key: PageUp, + key_modifiers: {}, + }: [ PageScrollUp, ], - Ctrl( - 'c', - ): [ + KeyWithModifier { + bare_key: Left, + key_modifiers: {}, + }: [ + PageScrollUp, + ], + KeyWithModifier { + bare_key: Left, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Down, + key_modifiers: {}, + }: [ + ScrollDown, + ], + KeyWithModifier { + bare_key: Down, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Up, + key_modifiers: {}, + }: [ + ScrollUp, + ], + KeyWithModifier { + bare_key: Up, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Right, + key_modifiers: {}, + }: [ + PageScrollDown, + ], + KeyWithModifier { + bare_key: Right, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + '+', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Increase, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '-', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Decrease, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '=', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Increase, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '[', + ), + key_modifiers: { + Alt, + }, + }: [ + PreviousSwapLayout, + ], + KeyWithModifier { + bare_key: Char( + ']', + ), + key_modifiers: { + Alt, + }, + }: [ + NextSwapLayout, + ], + KeyWithModifier { + bare_key: Char( + 'b', + ), + key_modifiers: { + Ctrl, + }, + }: [ + PageScrollUp, + ], + KeyWithModifier { + bare_key: Char( + 'c', + ), + key_modifiers: {}, + }: [ + SearchToggleOption( + CaseSensitivity, + ), + ], + KeyWithModifier { + bare_key: Char( + 'c', + ), + key_modifiers: { + Ctrl, + }, + }: [ ScrollToBottom, SwitchToMode( Normal, ), ], - Ctrl( - 'f', - ): [ + KeyWithModifier { + bare_key: Char( + 'd', + ), + key_modifiers: {}, + }: [ + HalfPageScrollDown, + ], + KeyWithModifier { + bare_key: Char( + 'f', + ), + key_modifiers: { + Ctrl, + }, + }: [ PageScrollDown, ], - Ctrl( - 'g', - ): [ + KeyWithModifier { + bare_key: Char( + 'g', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Locked, ), ], - Ctrl( - 'h', - ): [ + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: {}, + }: [ + PageScrollUp, + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Move, ), ], - Ctrl( - 'n', - ): [ + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Char( + 'i', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Char( + 'j', + ), + key_modifiers: {}, + }: [ + ScrollDown, + ], + KeyWithModifier { + bare_key: Char( + 'j', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Char( + 'k', + ), + key_modifiers: {}, + }: [ + ScrollUp, + ], + KeyWithModifier { + bare_key: Char( + 'k', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Char( + 'l', + ), + key_modifiers: {}, + }: [ + PageScrollDown, + ], + KeyWithModifier { + bare_key: Char( + 'l', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: {}, + }: [ + Search( + Down, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Resize, ), ], - Ctrl( - 'o', - ): [ + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Alt, + }, + }: [ + NewPane( + None, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: {}, + }: [ + SearchToggleOption( + WholeWord, + ), + ], + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Session, ), ], - Ctrl( - 'p', - ): [ + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'p', + ), + key_modifiers: {}, + }: [ + Search( + Up, + ), + ], + KeyWithModifier { + bare_key: Char( + 'p', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Pane, ), ], - Ctrl( - 'q', - ): [ + KeyWithModifier { + bare_key: Char( + 'q', + ), + key_modifiers: { + Ctrl, + }, + }: [ Quit, ], - Ctrl( - 's', - ): [ + KeyWithModifier { + bare_key: Char( + 's', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Normal, ), ], - Ctrl( - 't', - ): [ + KeyWithModifier { + bare_key: Char( + 't', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Tab, ), ], - Esc: [ + KeyWithModifier { + bare_key: Char( + 'u', + ), + key_modifiers: {}, + }: [ + HalfPageScrollUp, + ], + KeyWithModifier { + bare_key: Char( + 'w', + ), + key_modifiers: {}, + }: [ + SearchToggleOption( + Wrap, + ), + ], + KeyWithModifier { + bare_key: Esc, + key_modifiers: {}, + }: [ + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Enter, + key_modifiers: {}, + }: [ SwitchToMode( Normal, ), ], }, RenameTab: { - Char( - '\n', - ): [ - SwitchToMode( - Normal, + KeyWithModifier { + bare_key: Left, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Down, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Up, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Right, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( '+', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Increase, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '-', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Decrease, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '=', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Increase, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '[', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ PreviousSwapLayout, ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( ']', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ NextSwapLayout, ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( + 'b', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Tmux, + ), + ], + KeyWithModifier { + bare_key: Char( + 'c', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Char( + 'g', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Locked, + ), + ], + KeyWithModifier { + bare_key: Char( 'h', ), - ): [ + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Move, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Alt, + }, + }: [ MoveFocusOrTab( Left, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'i', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveTab( Left, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'j', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveFocus( Down, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'k', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveFocus( Up, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'l', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveFocusOrTab( Right, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'n', ), - ): [ + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Resize, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Alt, + }, + }: [ NewPane( None, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'o', ), - ): [ - MoveTab( - Right, - ), - ], - Alt( - Direction( - Left, - ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Direction( - Right, - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Direction( - Up, - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Direction( - Down, - ), - ): [ - MoveFocus( - Down, - ), - ], - Ctrl( - 'b', - ): [ - SwitchToMode( - Tmux, - ), - ], - Ctrl( - 'c', - ): [ - SwitchToMode( - Normal, - ), - ], - Ctrl( - 'g', - ): [ - SwitchToMode( - Locked, - ), - ], - Ctrl( - 'h', - ): [ - SwitchToMode( - Move, - ), - ], - Ctrl( - 'n', - ): [ - SwitchToMode( - Resize, - ), - ], - Ctrl( - 'o', - ): [ + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Session, ), ], - Ctrl( - 'p', - ): [ + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'p', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Pane, ), ], - Ctrl( - 'q', - ): [ + KeyWithModifier { + bare_key: Char( + 'q', + ), + key_modifiers: { + Ctrl, + }, + }: [ Quit, ], - Ctrl( - 's', - ): [ + KeyWithModifier { + bare_key: Char( + 's', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Scroll, ), ], - Ctrl( - 't', - ): [ + KeyWithModifier { + bare_key: Char( + 't', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Tab, ), ], - Esc: [ + KeyWithModifier { + bare_key: Esc, + key_modifiers: {}, + }: [ UndoRenameTab, SwitchToMode( Tab, ), ], - }, - RenamePane: { - Char( - '\n', - ): [ + KeyWithModifier { + bare_key: Enter, + key_modifiers: {}, + }: [ SwitchToMode( Normal, ), ], - Alt( - Char( + }, + RenamePane: { + KeyWithModifier { + bare_key: Left, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Down, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Up, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Right, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( '+', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Increase, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '-', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Decrease, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '=', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Increase, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '[', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ PreviousSwapLayout, ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( ']', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ NextSwapLayout, ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( + 'b', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Tmux, + ), + ], + KeyWithModifier { + bare_key: Char( + 'c', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Char( + 'g', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Locked, + ), + ], + KeyWithModifier { + bare_key: Char( 'h', ), - ): [ + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Move, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Alt, + }, + }: [ MoveFocusOrTab( Left, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'i', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveTab( Left, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'j', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveFocus( Down, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'k', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveFocus( Up, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'l', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveFocusOrTab( Right, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'n', ), - ): [ + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Resize, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Alt, + }, + }: [ NewPane( None, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'o', ), - ): [ - MoveTab( - Right, - ), - ], - Alt( - Direction( - Left, - ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Direction( - Right, - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Direction( - Up, - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Direction( - Down, - ), - ): [ - MoveFocus( - Down, - ), - ], - Ctrl( - 'b', - ): [ - SwitchToMode( - Tmux, - ), - ], - Ctrl( - 'c', - ): [ - SwitchToMode( - Normal, - ), - ], - Ctrl( - 'g', - ): [ - SwitchToMode( - Locked, - ), - ], - Ctrl( - 'h', - ): [ - SwitchToMode( - Move, - ), - ], - Ctrl( - 'n', - ): [ - SwitchToMode( - Resize, - ), - ], - Ctrl( - 'o', - ): [ + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Session, ), ], - Ctrl( - 'p', - ): [ + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'p', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Pane, ), ], - Ctrl( - 'q', - ): [ + KeyWithModifier { + bare_key: Char( + 'q', + ), + key_modifiers: { + Ctrl, + }, + }: [ Quit, ], - Ctrl( - 's', - ): [ + KeyWithModifier { + bare_key: Char( + 's', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Scroll, ), ], - Ctrl( - 't', - ): [ + KeyWithModifier { + bare_key: Char( + 't', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Tab, ), ], - Esc: [ + KeyWithModifier { + bare_key: Esc, + key_modifiers: {}, + }: [ UndoRenamePane, SwitchToMode( Pane, ), ], - }, - Session: { - Char( - '\n', - ): [ + KeyWithModifier { + bare_key: Enter, + key_modifiers: {}, + }: [ SwitchToMode( Normal, ), ], - Char( - 'd', - ): [ + }, + Session: { + KeyWithModifier { + bare_key: Left, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Down, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Up, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Right, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + '+', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Increase, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '-', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Decrease, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '=', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Increase, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '[', + ), + key_modifiers: { + Alt, + }, + }: [ + PreviousSwapLayout, + ], + KeyWithModifier { + bare_key: Char( + ']', + ), + key_modifiers: { + Alt, + }, + }: [ + NextSwapLayout, + ], + KeyWithModifier { + bare_key: Char( + 'b', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Tmux, + ), + ], + KeyWithModifier { + bare_key: Char( + 'd', + ), + key_modifiers: {}, + }: [ Detach, ], - Char( - 'w', - ): [ + KeyWithModifier { + bare_key: Char( + 'g', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Locked, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Move, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Char( + 'i', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Char( + 'j', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Char( + 'k', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Char( + 'l', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Resize, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Alt, + }, + }: [ + NewPane( + None, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'p', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Pane, + ), + ], + KeyWithModifier { + bare_key: Char( + 'q', + ), + key_modifiers: { + Ctrl, + }, + }: [ + Quit, + ], + KeyWithModifier { + bare_key: Char( + 's', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Scroll, + ), + ], + KeyWithModifier { + bare_key: Char( + 't', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Tab, + ), + ], + KeyWithModifier { + bare_key: Char( + 'w', + ), + key_modifiers: {}, + }: [ LaunchOrFocusPlugin( Alias( PluginAlias { @@ -2676,738 +4069,758 @@ Config { Normal, ), ], - Alt( - Char( - '+', - ), - ): [ - Resize( - Increase, - None, - ), - ], - Alt( - Char( - '-', - ), - ): [ - Resize( - Decrease, - None, - ), - ], - Alt( - Char( - '=', - ), - ): [ - Resize( - Increase, - None, - ), - ], - Alt( - Char( - '[', - ), - ): [ - PreviousSwapLayout, - ], - Alt( - Char( - ']', - ), - ): [ - NextSwapLayout, - ], - Alt( - Char( - 'h', - ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Char( - 'i', - ), - ): [ - MoveTab( - Left, - ), - ], - Alt( - Char( - 'j', - ), - ): [ - MoveFocus( - Down, - ), - ], - Alt( - Char( - 'k', - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Char( - 'l', - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Char( - 'n', - ), - ): [ - NewPane( - None, - None, - ), - ], - Alt( - Char( - 'o', - ), - ): [ - MoveTab( - Right, - ), - ], - Alt( - Direction( - Left, - ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Direction( - Right, - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Direction( - Up, - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Direction( - Down, - ), - ): [ - MoveFocus( - Down, - ), - ], - Ctrl( - 'b', - ): [ - SwitchToMode( - Tmux, - ), - ], - Ctrl( - 'g', - ): [ - SwitchToMode( - Locked, - ), - ], - Ctrl( - 'h', - ): [ - SwitchToMode( - Move, - ), - ], - Ctrl( - 'n', - ): [ - SwitchToMode( - Resize, - ), - ], - Ctrl( - 'o', - ): [ + KeyWithModifier { + bare_key: Esc, + key_modifiers: {}, + }: [ SwitchToMode( Normal, ), ], - Ctrl( - 'p', - ): [ - SwitchToMode( - Pane, - ), - ], - Ctrl( - 'q', - ): [ - Quit, - ], - Ctrl( - 's', - ): [ - SwitchToMode( - Scroll, - ), - ], - Ctrl( - 't', - ): [ - SwitchToMode( - Tab, - ), - ], - Esc: [ + KeyWithModifier { + bare_key: Enter, + key_modifiers: {}, + }: [ SwitchToMode( Normal, ), ], }, Move: { - Left: [ + KeyWithModifier { + bare_key: Left, + key_modifiers: {}, + }: [ MovePane( Some( Left, ), ), ], - Down: [ + KeyWithModifier { + bare_key: Left, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Down, + key_modifiers: {}, + }: [ MovePane( Some( Down, ), ), ], - Up: [ + KeyWithModifier { + bare_key: Down, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Up, + key_modifiers: {}, + }: [ MovePane( Some( Up, ), ), ], - Right: [ + KeyWithModifier { + bare_key: Up, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Right, + key_modifiers: {}, + }: [ MovePane( Some( Right, ), ), ], - Char( - '\n', - ): [ - SwitchToMode( - Normal, + KeyWithModifier { + bare_key: Right, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, ), ], - Char( - 'h', - ): [ - MovePane( - Some( - Left, - ), - ), - ], - Char( - 'j', - ): [ - MovePane( - Some( - Down, - ), - ), - ], - Char( - 'k', - ): [ - MovePane( - Some( - Up, - ), - ), - ], - Char( - 'l', - ): [ - MovePane( - Some( - Right, - ), - ), - ], - Char( - 'n', - ): [ - MovePane( - None, - ), - ], - Char( - 'p', - ): [ - MovePaneBackwards, - ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '+', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Increase, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '-', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Decrease, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '=', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Increase, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '[', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ PreviousSwapLayout, ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( ']', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ NextSwapLayout, ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( + 'b', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Tmux, + ), + ], + KeyWithModifier { + bare_key: Char( + 'g', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Locked, + ), + ], + KeyWithModifier { + bare_key: Char( 'h', ), - ): [ + key_modifiers: {}, + }: [ + MovePane( + Some( + Left, + ), + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Alt, + }, + }: [ MoveFocusOrTab( Left, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'i', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveTab( Left, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'j', ), - ): [ + key_modifiers: {}, + }: [ + MovePane( + Some( + Down, + ), + ), + ], + KeyWithModifier { + bare_key: Char( + 'j', + ), + key_modifiers: { + Alt, + }, + }: [ MoveFocus( Down, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'k', ), - ): [ + key_modifiers: {}, + }: [ + MovePane( + Some( + Up, + ), + ), + ], + KeyWithModifier { + bare_key: Char( + 'k', + ), + key_modifiers: { + Alt, + }, + }: [ MoveFocus( Up, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'l', ), - ): [ + key_modifiers: {}, + }: [ + MovePane( + Some( + Right, + ), + ), + ], + KeyWithModifier { + bare_key: Char( + 'l', + ), + key_modifiers: { + Alt, + }, + }: [ MoveFocusOrTab( Right, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'n', ), - ): [ + key_modifiers: {}, + }: [ + MovePane( + None, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Resize, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Alt, + }, + }: [ NewPane( None, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'o', ), - ): [ - MoveTab( - Right, - ), - ], - Alt( - Direction( - Left, - ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Direction( - Right, - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Direction( - Up, - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Direction( - Down, - ), - ): [ - MoveFocus( - Down, - ), - ], - Ctrl( - 'b', - ): [ - SwitchToMode( - Tmux, - ), - ], - Ctrl( - 'g', - ): [ - SwitchToMode( - Locked, - ), - ], - Ctrl( - 'h', - ): [ - SwitchToMode( - Normal, - ), - ], - Ctrl( - 'n', - ): [ - SwitchToMode( - Resize, - ), - ], - Ctrl( - 'o', - ): [ + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Session, ), ], - Ctrl( - 'p', - ): [ + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'p', + ), + key_modifiers: {}, + }: [ + MovePaneBackwards, + ], + KeyWithModifier { + bare_key: Char( + 'p', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Pane, ), ], - Ctrl( - 'q', - ): [ + KeyWithModifier { + bare_key: Char( + 'q', + ), + key_modifiers: { + Ctrl, + }, + }: [ Quit, ], - Ctrl( - 's', - ): [ + KeyWithModifier { + bare_key: Char( + 's', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Scroll, ), ], - Ctrl( - 't', - ): [ + KeyWithModifier { + bare_key: Char( + 't', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Tab, ), ], - BackTab: [ + KeyWithModifier { + bare_key: Tab, + key_modifiers: {}, + }: [ MovePane( None, ), ], - Esc: [ + KeyWithModifier { + bare_key: Esc, + key_modifiers: {}, + }: [ + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Enter, + key_modifiers: {}, + }: [ SwitchToMode( Normal, ), ], }, Prompt: { - Char( - '\n', - ): [ - SwitchToMode( - Normal, + KeyWithModifier { + bare_key: Left, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Down, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Up, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Right, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( '+', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Increase, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '-', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Decrease, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '=', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Increase, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '[', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ PreviousSwapLayout, ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( ']', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ NextSwapLayout, ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( + 'b', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Tmux, + ), + ], + KeyWithModifier { + bare_key: Char( + 'g', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Locked, + ), + ], + KeyWithModifier { + bare_key: Char( 'h', ), - ): [ + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Move, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Alt, + }, + }: [ MoveFocusOrTab( Left, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'i', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveTab( Left, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'j', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveFocus( Down, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'k', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveFocus( Up, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'l', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveFocusOrTab( Right, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'n', ), - ): [ + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Resize, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Alt, + }, + }: [ NewPane( None, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'o', ), - ): [ - MoveTab( - Right, - ), - ], - Alt( - Direction( - Left, - ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Direction( - Right, - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Direction( - Up, - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Direction( - Down, - ), - ): [ - MoveFocus( - Down, - ), - ], - Ctrl( - 'b', - ): [ - SwitchToMode( - Tmux, - ), - ], - Ctrl( - 'g', - ): [ - SwitchToMode( - Locked, - ), - ], - Ctrl( - 'h', - ): [ - SwitchToMode( - Move, - ), - ], - Ctrl( - 'n', - ): [ - SwitchToMode( - Resize, - ), - ], - Ctrl( - 'o', - ): [ + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Session, ), ], - Ctrl( - 'p', - ): [ + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'p', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Pane, ), ], - Ctrl( - 'q', - ): [ + KeyWithModifier { + bare_key: Char( + 'q', + ), + key_modifiers: { + Ctrl, + }, + }: [ Quit, ], - Ctrl( - 's', - ): [ + KeyWithModifier { + bare_key: Char( + 's', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Scroll, ), ], - Ctrl( - 't', - ): [ + KeyWithModifier { + bare_key: Char( + 't', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Tab, ), ], - Esc: [ + KeyWithModifier { + bare_key: Esc, + key_modifiers: {}, + }: [ + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Enter, + key_modifiers: {}, + }: [ SwitchToMode( Normal, ), ], }, Tmux: { - Left: [ + KeyWithModifier { + bare_key: Left, + key_modifiers: {}, + }: [ MoveFocus( Left, ), @@ -3415,7 +4828,20 @@ Config { Normal, ), ], - Down: [ + KeyWithModifier { + bare_key: Left, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Down, + key_modifiers: {}, + }: [ MoveFocus( Down, ), @@ -3423,7 +4849,20 @@ Config { Normal, ), ], - Up: [ + KeyWithModifier { + bare_key: Down, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Up, + key_modifiers: {}, + }: [ MoveFocus( Up, ), @@ -3431,7 +4870,20 @@ Config { Normal, ), ], - Right: [ + KeyWithModifier { + bare_key: Up, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Right, + key_modifiers: {}, + }: [ MoveFocus( Right, ), @@ -3439,21 +4891,30 @@ Config { Normal, ), ], - Char( - '\n', - ): [ - SwitchToMode( - Normal, + KeyWithModifier { + bare_key: Right, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, ), ], - Char( - ' ', - ): [ + KeyWithModifier { + bare_key: Char( + ' ', + ), + key_modifiers: {}, + }: [ NextSwapLayout, ], - Char( - '"', - ): [ + KeyWithModifier { + bare_key: Char( + '"', + ), + key_modifiers: {}, + }: [ NewPane( Some( Down, @@ -3464,9 +4925,12 @@ Config { Normal, ), ], - Char( - '%', - ): [ + KeyWithModifier { + bare_key: Char( + '%', + ), + key_modifiers: {}, + }: [ NewPane( Some( Right, @@ -3477,23 +4941,110 @@ Config { Normal, ), ], - Char( - ',', - ): [ + KeyWithModifier { + bare_key: Char( + '+', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Increase, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + ',', + ), + key_modifiers: {}, + }: [ SwitchToMode( RenameTab, ), ], - Char( - '[', - ): [ + KeyWithModifier { + bare_key: Char( + '-', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Decrease, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '=', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Increase, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '[', + ), + key_modifiers: {}, + }: [ SwitchToMode( Scroll, ), ], - Char( - 'c', - ): [ + KeyWithModifier { + bare_key: Char( + '[', + ), + key_modifiers: { + Alt, + }, + }: [ + PreviousSwapLayout, + ], + KeyWithModifier { + bare_key: Char( + ']', + ), + key_modifiers: { + Alt, + }, + }: [ + NextSwapLayout, + ], + KeyWithModifier { + bare_key: Char( + 'b', + ), + key_modifiers: { + Ctrl, + }, + }: [ + Write( + None, + [ + 2, + ], + false, + ), + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Char( + 'c', + ), + key_modifiers: {}, + }: [ NewTab( None, [], @@ -3505,14 +5056,32 @@ Config { Normal, ), ], - Char( - 'd', - ): [ + KeyWithModifier { + bare_key: Char( + 'd', + ), + key_modifiers: {}, + }: [ Detach, ], - Char( - 'h', - ): [ + KeyWithModifier { + bare_key: Char( + 'g', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Locked, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: {}, + }: [ MoveFocus( Left, ), @@ -3520,9 +5089,48 @@ Config { Normal, ), ], - Char( - 'j', - ): [ + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Move, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Char( + 'i', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Char( + 'j', + ), + key_modifiers: {}, + }: [ MoveFocus( Down, ), @@ -3530,9 +5138,24 @@ Config { Normal, ), ], - Char( - 'k', - ): [ + KeyWithModifier { + bare_key: Char( + 'j', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Char( + 'k', + ), + key_modifiers: {}, + }: [ MoveFocus( Up, ), @@ -3540,9 +5163,24 @@ Config { Normal, ), ], - Char( - 'l', - ): [ + KeyWithModifier { + bare_key: Char( + 'k', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Char( + 'l', + ), + key_modifiers: {}, + }: [ MoveFocus( Right, ), @@ -3550,254 +5188,177 @@ Config { Normal, ), ], - Char( - 'n', - ): [ + KeyWithModifier { + bare_key: Char( + 'l', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: {}, + }: [ GoToNextTab, SwitchToMode( Normal, ), ], - Char( - 'o', - ): [ - FocusNextPane, - ], - Char( - 'p', - ): [ - GoToPreviousTab, - SwitchToMode( - Normal, - ), - ], - Char( - 'x', - ): [ - CloseFocus, - SwitchToMode( - Normal, - ), - ], - Char( - 'z', - ): [ - ToggleFocusFullscreen, - SwitchToMode( - Normal, - ), - ], - Alt( - Char( - '+', - ), - ): [ - Resize( - Increase, - None, - ), - ], - Alt( - Char( - '-', - ), - ): [ - Resize( - Decrease, - None, - ), - ], - Alt( - Char( - '=', - ), - ): [ - Resize( - Increase, - None, - ), - ], - Alt( - Char( - '[', - ), - ): [ - PreviousSwapLayout, - ], - Alt( - Char( - ']', - ), - ): [ - NextSwapLayout, - ], - Alt( - Char( - 'h', - ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Char( - 'i', - ), - ): [ - MoveTab( - Left, - ), - ], - Alt( - Char( - 'j', - ), - ): [ - MoveFocus( - Down, - ), - ], - Alt( - Char( - 'k', - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Char( - 'l', - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'n', ), - ): [ + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Resize, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Alt, + }, + }: [ NewPane( None, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'o', ), - ): [ - MoveTab( - Right, - ), + key_modifiers: {}, + }: [ + FocusNextPane, ], - Alt( - Direction( - Left, + KeyWithModifier { + bare_key: Char( + 'o', ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Direction( - Right, - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Direction( - Up, - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Direction( - Down, - ), - ): [ - MoveFocus( - Down, - ), - ], - Ctrl( - 'b', - ): [ - Write( - [ - 2, - ], - ), - SwitchToMode( - Normal, - ), - ], - Ctrl( - 'g', - ): [ - SwitchToMode( - Locked, - ), - ], - Ctrl( - 'h', - ): [ - SwitchToMode( - Move, - ), - ], - Ctrl( - 'n', - ): [ - SwitchToMode( - Resize, - ), - ], - Ctrl( - 'o', - ): [ + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Session, ), ], - Ctrl( - 'p', - ): [ + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'p', + ), + key_modifiers: {}, + }: [ + GoToPreviousTab, + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Char( + 'p', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Pane, ), ], - Ctrl( - 'q', - ): [ + KeyWithModifier { + bare_key: Char( + 'q', + ), + key_modifiers: { + Ctrl, + }, + }: [ Quit, ], - Ctrl( - 's', - ): [ + KeyWithModifier { + bare_key: Char( + 's', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Scroll, ), ], - Ctrl( - 't', - ): [ + KeyWithModifier { + bare_key: Char( + 't', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Tab, ), ], - Esc: [ + KeyWithModifier { + bare_key: Char( + 'x', + ), + key_modifiers: {}, + }: [ + CloseFocus, + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Char( + 'z', + ), + key_modifiers: {}, + }: [ + ToggleFocusFullscreen, + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Esc, + key_modifiers: {}, + }: [ + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Enter, + key_modifiers: {}, + }: [ SwitchToMode( Normal, ), @@ -3831,6 +5392,7 @@ Config { styled_underlines: None, serialization_interval: None, disable_session_metadata: None, + support_kitty_keyboard_protocol: None, }, themes: {}, plugins: PluginAliases { diff --git a/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_keybinds_override_config_keybinds.snap b/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_keybinds_override_config_keybinds.snap index 58b4c9c4..d533e426 100644 --- a/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_keybinds_override_config_keybinds.snap +++ b/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_keybinds_override_config_keybinds.snap @@ -1,60 +1,89 @@ --- source: zellij-utils/src/setup.rs -assertion_line: 798 +assertion_line: 825 expression: "format!(\"{:#?}\", config)" --- Config { keybinds: { Normal: { - Char( - 'b', - ): [ + KeyWithModifier { + bare_key: Char( + 'b', + ), + key_modifiers: {}, + }: [ SwitchToMode( Session, ), ], - Ctrl( - 'b', - ): [ + KeyWithModifier { + bare_key: Char( + 'b', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Resize, ), ], - Ctrl( - 'c', - ): [ + KeyWithModifier { + bare_key: Char( + 'c', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Resize, ), ], }, Resize: { - Char( - 'b', - ): [ + KeyWithModifier { + bare_key: Char( + 'b', + ), + key_modifiers: {}, + }: [ SwitchToMode( Locked, ), ], - Ctrl( - 'c', - ): [ + KeyWithModifier { + bare_key: Char( + 'c', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Resize, ), ], }, Scroll: { - Char( - 'b', - ): [ + KeyWithModifier { + bare_key: Char( + 'b', + ), + key_modifiers: {}, + }: [ SwitchToMode( Locked, ), ], - Ctrl( - 'c', - ): [ + KeyWithModifier { + bare_key: Char( + 'c', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Resize, ), @@ -88,6 +117,7 @@ Config { styled_underlines: None, serialization_interval: None, disable_session_metadata: None, + support_kitty_keyboard_protocol: None, }, themes: {}, plugins: PluginAliases { diff --git a/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_options_override_config_options.snap b/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_options_override_config_options.snap index 72150ee2..604752e8 100644 --- a/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_options_override_config_options.snap +++ b/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_options_override_config_options.snap @@ -1,6 +1,6 @@ --- source: zellij-utils/src/setup.rs -assertion_line: 723 +assertion_line: 750 expression: "format!(\"{:#?}\", options)" --- Options { @@ -32,4 +32,5 @@ Options { styled_underlines: None, serialization_interval: None, disable_session_metadata: None, + support_kitty_keyboard_protocol: None, } diff --git a/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_themes_override_config_themes.snap b/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_themes_override_config_themes.snap index 5e22821e..2cb867e7 100644 --- a/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_themes_override_config_themes.snap +++ b/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_themes_override_config_themes.snap @@ -1,228 +1,321 @@ --- source: zellij-utils/src/setup.rs -assertion_line: 784 +assertion_line: 811 expression: "format!(\"{:#?}\", config)" --- Config { keybinds: { Normal: { - Alt( - Char( + KeyWithModifier { + bare_key: Left, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Down, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Up, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Right, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( '+', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Increase, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '-', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Decrease, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '=', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Increase, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '[', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ PreviousSwapLayout, ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( ']', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ NextSwapLayout, ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( + 'b', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Tmux, + ), + ], + KeyWithModifier { + bare_key: Char( + 'g', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Locked, + ), + ], + KeyWithModifier { + bare_key: Char( 'h', ), - ): [ + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Move, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Alt, + }, + }: [ MoveFocusOrTab( Left, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'i', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveTab( Left, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'j', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveFocus( Down, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'k', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveFocus( Up, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'l', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveFocusOrTab( Right, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'n', ), - ): [ + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Resize, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Alt, + }, + }: [ NewPane( None, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'o', ), - ): [ - MoveTab( - Right, - ), - ], - Alt( - Direction( - Left, - ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Direction( - Right, - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Direction( - Up, - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Direction( - Down, - ), - ): [ - MoveFocus( - Down, - ), - ], - Ctrl( - 'b', - ): [ - SwitchToMode( - Tmux, - ), - ], - Ctrl( - 'g', - ): [ - SwitchToMode( - Locked, - ), - ], - Ctrl( - 'h', - ): [ - SwitchToMode( - Move, - ), - ], - Ctrl( - 'n', - ): [ - SwitchToMode( - Resize, - ), - ], - Ctrl( - 'o', - ): [ + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Session, ), ], - Ctrl( - 'p', - ): [ + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'p', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Pane, ), ], - Ctrl( - 'q', - ): [ + KeyWithModifier { + bare_key: Char( + 'q', + ), + key_modifiers: { + Ctrl, + }, + }: [ Quit, ], - Ctrl( - 's', - ): [ + KeyWithModifier { + bare_key: Char( + 's', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Scroll, ), ], - Ctrl( - 't', - ): [ + KeyWithModifier { + bare_key: Char( + 't', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Tab, ), ], }, Locked: { - Ctrl( - 'g', - ): [ + KeyWithModifier { + bare_key: Char( + 'g', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Normal, ), ], }, Resize: { - Left: [ + KeyWithModifier { + bare_key: Left, + key_modifiers: {}, + }: [ Resize( Increase, Some( @@ -230,383 +323,633 @@ Config { ), ), ], - Down: [ - Resize( - Increase, - Some( - Down, - ), - ), - ], - Up: [ - Resize( - Increase, - Some( - Up, - ), - ), - ], - Right: [ - Resize( - Increase, - Some( - Right, - ), - ), - ], - Char( - '\n', - ): [ - SwitchToMode( - Normal, - ), - ], - Char( - '+', - ): [ - Resize( - Increase, - None, - ), - ], - Char( - '-', - ): [ - Resize( - Decrease, - None, - ), - ], - Char( - '=', - ): [ - Resize( - Increase, - None, - ), - ], - Char( - 'H', - ): [ - Resize( - Decrease, - Some( - Left, - ), - ), - ], - Char( - 'J', - ): [ - Resize( - Decrease, - Some( - Down, - ), - ), - ], - Char( - 'K', - ): [ - Resize( - Decrease, - Some( - Up, - ), - ), - ], - Char( - 'L', - ): [ - Resize( - Decrease, - Some( - Right, - ), - ), - ], - Char( - 'h', - ): [ - Resize( - Increase, - Some( - Left, - ), - ), - ], - Char( - 'j', - ): [ - Resize( - Increase, - Some( - Down, - ), - ), - ], - Char( - 'k', - ): [ - Resize( - Increase, - Some( - Up, - ), - ), - ], - Char( - 'l', - ): [ - Resize( - Increase, - Some( - Right, - ), - ), - ], - Alt( - Char( - '+', - ), - ): [ - Resize( - Increase, - None, - ), - ], - Alt( - Char( - '-', - ), - ): [ - Resize( - Decrease, - None, - ), - ], - Alt( - Char( - '=', - ), - ): [ - Resize( - Increase, - None, - ), - ], - Alt( - Char( - '[', - ), - ): [ - PreviousSwapLayout, - ], - Alt( - Char( - ']', - ), - ): [ - NextSwapLayout, - ], - Alt( - Char( - 'h', - ), - ): [ + KeyWithModifier { + bare_key: Left, + key_modifiers: { + Alt, + }, + }: [ MoveFocusOrTab( Left, ), ], - Alt( - Char( - 'i', - ), - ): [ - MoveTab( - Left, + KeyWithModifier { + bare_key: Down, + key_modifiers: {}, + }: [ + Resize( + Increase, + Some( + Down, + ), ), ], - Alt( - Char( - 'j', - ), - ): [ + KeyWithModifier { + bare_key: Down, + key_modifiers: { + Alt, + }, + }: [ MoveFocus( Down, ), ], - Alt( - Char( - 'k', + KeyWithModifier { + bare_key: Up, + key_modifiers: {}, + }: [ + Resize( + Increase, + Some( + Up, + ), ), - ): [ + ], + KeyWithModifier { + bare_key: Up, + key_modifiers: { + Alt, + }, + }: [ MoveFocus( Up, ), ], - Alt( - Char( - 'l', + KeyWithModifier { + bare_key: Right, + key_modifiers: {}, + }: [ + Resize( + Increase, + Some( + Right, + ), ), - ): [ + ], + KeyWithModifier { + bare_key: Right, + key_modifiers: { + Alt, + }, + }: [ MoveFocusOrTab( Right, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( + '+', + ), + key_modifiers: {}, + }: [ + Resize( + Increase, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '+', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Increase, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '-', + ), + key_modifiers: {}, + }: [ + Resize( + Decrease, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '-', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Decrease, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '=', + ), + key_modifiers: {}, + }: [ + Resize( + Increase, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '=', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Increase, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + 'H', + ), + key_modifiers: {}, + }: [ + Resize( + Decrease, + Some( + Left, + ), + ), + ], + KeyWithModifier { + bare_key: Char( + 'J', + ), + key_modifiers: {}, + }: [ + Resize( + Decrease, + Some( + Down, + ), + ), + ], + KeyWithModifier { + bare_key: Char( + 'K', + ), + key_modifiers: {}, + }: [ + Resize( + Decrease, + Some( + Up, + ), + ), + ], + KeyWithModifier { + bare_key: Char( + 'L', + ), + key_modifiers: {}, + }: [ + Resize( + Decrease, + Some( + Right, + ), + ), + ], + KeyWithModifier { + bare_key: Char( + '[', + ), + key_modifiers: { + Alt, + }, + }: [ + PreviousSwapLayout, + ], + KeyWithModifier { + bare_key: Char( + ']', + ), + key_modifiers: { + Alt, + }, + }: [ + NextSwapLayout, + ], + KeyWithModifier { + bare_key: Char( + 'b', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Tmux, + ), + ], + KeyWithModifier { + bare_key: Char( + 'g', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Locked, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: {}, + }: [ + Resize( + Increase, + Some( + Left, + ), + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Move, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Char( + 'i', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Char( + 'j', + ), + key_modifiers: {}, + }: [ + Resize( + Increase, + Some( + Down, + ), + ), + ], + KeyWithModifier { + bare_key: Char( + 'j', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Char( + 'k', + ), + key_modifiers: {}, + }: [ + Resize( + Increase, + Some( + Up, + ), + ), + ], + KeyWithModifier { + bare_key: Char( + 'k', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Char( + 'l', + ), + key_modifiers: {}, + }: [ + Resize( + Increase, + Some( + Right, + ), + ), + ], + KeyWithModifier { + bare_key: Char( + 'l', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( 'n', ), - ): [ + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Alt, + }, + }: [ NewPane( None, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'o', ), - ): [ - MoveTab( - Right, - ), - ], - Alt( - Direction( - Left, - ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Direction( - Right, - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Direction( - Up, - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Direction( - Down, - ), - ): [ - MoveFocus( - Down, - ), - ], - Ctrl( - 'b', - ): [ - SwitchToMode( - Tmux, - ), - ], - Ctrl( - 'g', - ): [ - SwitchToMode( - Locked, - ), - ], - Ctrl( - 'h', - ): [ - SwitchToMode( - Move, - ), - ], - Ctrl( - 'n', - ): [ - SwitchToMode( - Normal, - ), - ], - Ctrl( - 'o', - ): [ + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Session, ), ], - Ctrl( - 'p', - ): [ + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'p', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Pane, ), ], - Ctrl( - 'q', - ): [ + KeyWithModifier { + bare_key: Char( + 'q', + ), + key_modifiers: { + Ctrl, + }, + }: [ Quit, ], - Ctrl( - 's', - ): [ + KeyWithModifier { + bare_key: Char( + 's', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Scroll, ), ], - Ctrl( - 't', - ): [ + KeyWithModifier { + bare_key: Char( + 't', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Tab, ), ], - Esc: [ + KeyWithModifier { + bare_key: Esc, + key_modifiers: {}, + }: [ + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Enter, + key_modifiers: {}, + }: [ SwitchToMode( Normal, ), ], }, Pane: { - Left: [ + KeyWithModifier { + bare_key: Left, + key_modifiers: {}, + }: [ MoveFocus( Left, ), ], - Down: [ + KeyWithModifier { + bare_key: Left, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Down, + key_modifiers: {}, + }: [ MoveFocus( Down, ), ], - Up: [ + KeyWithModifier { + bare_key: Down, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Up, + key_modifiers: {}, + }: [ MoveFocus( Up, ), ], - Right: [ + KeyWithModifier { + bare_key: Up, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Right, + key_modifiers: {}, + }: [ MoveFocus( Right, ), ], - Char( - '\n', - ): [ - SwitchToMode( - Normal, + KeyWithModifier { + bare_key: Right, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, ), ], - Char( - 'c', - ): [ + KeyWithModifier { + bare_key: Char( + '+', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Increase, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '-', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Decrease, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '=', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Increase, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '[', + ), + key_modifiers: { + Alt, + }, + }: [ + PreviousSwapLayout, + ], + KeyWithModifier { + bare_key: Char( + ']', + ), + key_modifiers: { + Alt, + }, + }: [ + NextSwapLayout, + ], + KeyWithModifier { + bare_key: Char( + 'b', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Tmux, + ), + ], + KeyWithModifier { + bare_key: Char( + 'c', + ), + key_modifiers: {}, + }: [ SwitchToMode( RenamePane, ), @@ -616,9 +959,12 @@ Config { ], ), ], - Char( - 'd', - ): [ + KeyWithModifier { + bare_key: Char( + 'd', + ), + key_modifiers: {}, + }: [ NewPane( Some( Down, @@ -629,53 +975,158 @@ Config { Normal, ), ], - Char( - 'e', - ): [ + KeyWithModifier { + bare_key: Char( + 'e', + ), + key_modifiers: {}, + }: [ TogglePaneEmbedOrFloating, SwitchToMode( Normal, ), ], - Char( - 'f', - ): [ + KeyWithModifier { + bare_key: Char( + 'f', + ), + key_modifiers: {}, + }: [ ToggleFocusFullscreen, SwitchToMode( Normal, ), ], - Char( - 'h', - ): [ + KeyWithModifier { + bare_key: Char( + 'g', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Locked, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: {}, + }: [ MoveFocus( Left, ), ], - Char( - 'j', - ): [ + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Move, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Char( + 'i', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Char( + 'j', + ), + key_modifiers: {}, + }: [ MoveFocus( Down, ), ], - Char( - 'k', - ): [ + KeyWithModifier { + bare_key: Char( + 'j', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Char( + 'k', + ), + key_modifiers: {}, + }: [ MoveFocus( Up, ), ], - Char( - 'l', - ): [ + KeyWithModifier { + bare_key: Char( + 'k', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Char( + 'l', + ), + key_modifiers: {}, + }: [ MoveFocus( Right, ), ], - Char( - 'n', - ): [ + KeyWithModifier { + bare_key: Char( + 'l', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: {}, + }: [ NewPane( None, None, @@ -684,14 +1135,91 @@ Config { Normal, ), ], - Char( - 'p', - ): [ + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Resize, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Alt, + }, + }: [ + NewPane( + None, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Session, + ), + ], + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'p', + ), + key_modifiers: {}, + }: [ SwitchFocus, ], - Char( - 'r', - ): [ + KeyWithModifier { + bare_key: Char( + 'p', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Char( + 'q', + ), + key_modifiers: { + Ctrl, + }, + }: [ + Quit, + ], + KeyWithModifier { + bare_key: Char( + 'r', + ), + key_modifiers: {}, + }: [ NewPane( Some( Right, @@ -702,264 +1230,177 @@ Config { Normal, ), ], - Char( - 'w', - ): [ + KeyWithModifier { + bare_key: Char( + 's', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Scroll, + ), + ], + KeyWithModifier { + bare_key: Char( + 't', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Tab, + ), + ], + KeyWithModifier { + bare_key: Char( + 'w', + ), + key_modifiers: {}, + }: [ ToggleFloatingPanes, SwitchToMode( Normal, ), ], - Char( - 'x', - ): [ + KeyWithModifier { + bare_key: Char( + 'x', + ), + key_modifiers: {}, + }: [ CloseFocus, SwitchToMode( Normal, ), ], - Char( - 'z', - ): [ + KeyWithModifier { + bare_key: Char( + 'z', + ), + key_modifiers: {}, + }: [ TogglePaneFrames, SwitchToMode( Normal, ), ], - Alt( - Char( - '+', - ), - ): [ - Resize( - Increase, - None, - ), - ], - Alt( - Char( - '-', - ), - ): [ - Resize( - Decrease, - None, - ), - ], - Alt( - Char( - '=', - ), - ): [ - Resize( - Increase, - None, - ), - ], - Alt( - Char( - '[', - ), - ): [ - PreviousSwapLayout, - ], - Alt( - Char( - ']', - ), - ): [ - NextSwapLayout, - ], - Alt( - Char( - 'h', - ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Char( - 'i', - ), - ): [ - MoveTab( - Left, - ), - ], - Alt( - Char( - 'j', - ), - ): [ - MoveFocus( - Down, - ), - ], - Alt( - Char( - 'k', - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Char( - 'l', - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Char( - 'n', - ), - ): [ - NewPane( - None, - None, - ), - ], - Alt( - Char( - 'o', - ), - ): [ - MoveTab( - Right, - ), - ], - Alt( - Direction( - Left, - ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Direction( - Right, - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Direction( - Up, - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Direction( - Down, - ), - ): [ - MoveFocus( - Down, - ), - ], - Ctrl( - 'b', - ): [ - SwitchToMode( - Tmux, - ), - ], - Ctrl( - 'g', - ): [ - SwitchToMode( - Locked, - ), - ], - Ctrl( - 'h', - ): [ - SwitchToMode( - Move, - ), - ], - Ctrl( - 'n', - ): [ - SwitchToMode( - Resize, - ), - ], - Ctrl( - 'o', - ): [ - SwitchToMode( - Session, - ), - ], - Ctrl( - 'p', - ): [ + KeyWithModifier { + bare_key: Esc, + key_modifiers: {}, + }: [ SwitchToMode( Normal, ), ], - Ctrl( - 'q', - ): [ - Quit, - ], - Ctrl( - 's', - ): [ - SwitchToMode( - Scroll, - ), - ], - Ctrl( - 't', - ): [ - SwitchToMode( - Tab, - ), - ], - Esc: [ + KeyWithModifier { + bare_key: Enter, + key_modifiers: {}, + }: [ SwitchToMode( Normal, ), ], }, Tab: { - Left: [ + KeyWithModifier { + bare_key: Left, + key_modifiers: {}, + }: [ GoToPreviousTab, ], - Down: [ - GoToNextTab, - ], - Up: [ - GoToPreviousTab, - ], - Right: [ - GoToNextTab, - ], - Char( - '\n', - ): [ - SwitchToMode( - Normal, + KeyWithModifier { + bare_key: Left, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, ), ], - Char( - '1', - ): [ + KeyWithModifier { + bare_key: Down, + key_modifiers: {}, + }: [ + GoToNextTab, + ], + KeyWithModifier { + bare_key: Down, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Up, + key_modifiers: {}, + }: [ + GoToPreviousTab, + ], + KeyWithModifier { + bare_key: Up, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Right, + key_modifiers: {}, + }: [ + GoToNextTab, + ], + KeyWithModifier { + bare_key: Right, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + '+', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Increase, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '-', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Decrease, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '1', + ), + key_modifiers: {}, + }: [ GoToTab( 1, ), @@ -967,9 +1408,12 @@ Config { Normal, ), ], - Char( - '2', - ): [ + KeyWithModifier { + bare_key: Char( + '2', + ), + key_modifiers: {}, + }: [ GoToTab( 2, ), @@ -977,9 +1421,12 @@ Config { Normal, ), ], - Char( - '3', - ): [ + KeyWithModifier { + bare_key: Char( + '3', + ), + key_modifiers: {}, + }: [ GoToTab( 3, ), @@ -987,9 +1434,12 @@ Config { Normal, ), ], - Char( - '4', - ): [ + KeyWithModifier { + bare_key: Char( + '4', + ), + key_modifiers: {}, + }: [ GoToTab( 4, ), @@ -997,9 +1447,12 @@ Config { Normal, ), ], - Char( - '5', - ): [ + KeyWithModifier { + bare_key: Char( + '5', + ), + key_modifiers: {}, + }: [ GoToTab( 5, ), @@ -1007,9 +1460,12 @@ Config { Normal, ), ], - Char( - '6', - ): [ + KeyWithModifier { + bare_key: Char( + '6', + ), + key_modifiers: {}, + }: [ GoToTab( 6, ), @@ -1017,9 +1473,12 @@ Config { Normal, ), ], - Char( - '7', - ): [ + KeyWithModifier { + bare_key: Char( + '7', + ), + key_modifiers: {}, + }: [ GoToTab( 7, ), @@ -1027,9 +1486,12 @@ Config { Normal, ), ], - Char( - '8', - ): [ + KeyWithModifier { + bare_key: Char( + '8', + ), + key_modifiers: {}, + }: [ GoToTab( 8, ), @@ -1037,9 +1499,12 @@ Config { Normal, ), ], - Char( - '9', - ): [ + KeyWithModifier { + bare_key: Char( + '9', + ), + key_modifiers: {}, + }: [ GoToTab( 9, ), @@ -1047,53 +1512,206 @@ Config { Normal, ), ], - Char( - '[', - ): [ + KeyWithModifier { + bare_key: Char( + '=', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Increase, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '[', + ), + key_modifiers: {}, + }: [ BreakPaneLeft, SwitchToMode( Normal, ), ], - Char( - ']', - ): [ + KeyWithModifier { + bare_key: Char( + '[', + ), + key_modifiers: { + Alt, + }, + }: [ + PreviousSwapLayout, + ], + KeyWithModifier { + bare_key: Char( + ']', + ), + key_modifiers: {}, + }: [ BreakPaneRight, SwitchToMode( Normal, ), ], - Char( - 'b', - ): [ + KeyWithModifier { + bare_key: Char( + ']', + ), + key_modifiers: { + Alt, + }, + }: [ + NextSwapLayout, + ], + KeyWithModifier { + bare_key: Char( + 'b', + ), + key_modifiers: {}, + }: [ BreakPane, SwitchToMode( Normal, ), ], - Char( - 'h', - ): [ + KeyWithModifier { + bare_key: Char( + 'b', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Tmux, + ), + ], + KeyWithModifier { + bare_key: Char( + 'g', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Locked, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: {}, + }: [ GoToPreviousTab, ], - Char( - 'j', - ): [ + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Move, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Char( + 'i', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Char( + 'j', + ), + key_modifiers: {}, + }: [ GoToNextTab, ], - Char( - 'k', - ): [ + KeyWithModifier { + bare_key: Char( + 'j', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Char( + 'k', + ), + key_modifiers: {}, + }: [ GoToPreviousTab, ], - Char( - 'l', - ): [ + KeyWithModifier { + bare_key: Char( + 'k', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Char( + 'l', + ), + key_modifiers: {}, + }: [ GoToNextTab, ], - Char( - 'n', - ): [ + KeyWithModifier { + bare_key: Char( + 'l', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: {}, + }: [ NewTab( None, [], @@ -1105,9 +1723,83 @@ Config { Normal, ), ], - Char( - 'r', - ): [ + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Resize, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Alt, + }, + }: [ + NewPane( + None, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Session, + ), + ], + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'p', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Pane, + ), + ], + KeyWithModifier { + bare_key: Char( + 'q', + ), + key_modifiers: { + Ctrl, + }, + }: [ + Quit, + ], + KeyWithModifier { + bare_key: Char( + 'r', + ), + key_modifiers: {}, + }: [ SwitchToMode( RenameTab, ), @@ -1117,298 +1809,456 @@ Config { ], ), ], - Char( - 's', - ): [ + KeyWithModifier { + bare_key: Char( + 's', + ), + key_modifiers: {}, + }: [ ToggleActiveSyncTab, SwitchToMode( Normal, ), ], - Char( - 'x', - ): [ + KeyWithModifier { + bare_key: Char( + 's', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Scroll, + ), + ], + KeyWithModifier { + bare_key: Char( + 't', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Char( + 'x', + ), + key_modifiers: {}, + }: [ CloseTab, SwitchToMode( Normal, ), ], - Alt( - Char( - '+', - ), - ): [ - Resize( - Increase, - None, - ), + KeyWithModifier { + bare_key: Tab, + key_modifiers: {}, + }: [ + ToggleTab, ], - Alt( - Char( - '-', - ), - ): [ - Resize( - Decrease, - None, - ), - ], - Alt( - Char( - '=', - ), - ): [ - Resize( - Increase, - None, - ), - ], - Alt( - Char( - '[', - ), - ): [ - PreviousSwapLayout, - ], - Alt( - Char( - ']', - ), - ): [ - NextSwapLayout, - ], - Alt( - Char( - 'h', - ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Char( - 'i', - ), - ): [ - MoveTab( - Left, - ), - ], - Alt( - Char( - 'j', - ), - ): [ - MoveFocus( - Down, - ), - ], - Alt( - Char( - 'k', - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Char( - 'l', - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Char( - 'n', - ), - ): [ - NewPane( - None, - None, - ), - ], - Alt( - Char( - 'o', - ), - ): [ - MoveTab( - Right, - ), - ], - Alt( - Direction( - Left, - ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Direction( - Right, - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Direction( - Up, - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Direction( - Down, - ), - ): [ - MoveFocus( - Down, - ), - ], - Ctrl( - 'b', - ): [ - SwitchToMode( - Tmux, - ), - ], - Ctrl( - 'g', - ): [ - SwitchToMode( - Locked, - ), - ], - Ctrl( - 'h', - ): [ - SwitchToMode( - Move, - ), - ], - Ctrl( - 'n', - ): [ - SwitchToMode( - Resize, - ), - ], - Ctrl( - 'o', - ): [ - SwitchToMode( - Session, - ), - ], - Ctrl( - 'p', - ): [ - SwitchToMode( - Pane, - ), - ], - Ctrl( - 'q', - ): [ - Quit, - ], - Ctrl( - 's', - ): [ - SwitchToMode( - Scroll, - ), - ], - Ctrl( - 't', - ): [ + KeyWithModifier { + bare_key: Esc, + key_modifiers: {}, + }: [ SwitchToMode( Normal, ), ], - BackTab: [ - ToggleTab, - ], - Esc: [ + KeyWithModifier { + bare_key: Enter, + key_modifiers: {}, + }: [ SwitchToMode( Normal, ), ], }, Scroll: { - PageDown: [ + KeyWithModifier { + bare_key: PageDown, + key_modifiers: {}, + }: [ PageScrollDown, ], - PageUp: [ + KeyWithModifier { + bare_key: PageUp, + key_modifiers: {}, + }: [ PageScrollUp, ], - Left: [ + KeyWithModifier { + bare_key: Left, + key_modifiers: {}, + }: [ PageScrollUp, ], - Down: [ + KeyWithModifier { + bare_key: Left, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Down, + key_modifiers: {}, + }: [ ScrollDown, ], - Up: [ + KeyWithModifier { + bare_key: Down, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Up, + key_modifiers: {}, + }: [ ScrollUp, ], - Right: [ + KeyWithModifier { + bare_key: Up, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Right, + key_modifiers: {}, + }: [ PageScrollDown, ], - Char( - '\n', - ): [ + KeyWithModifier { + bare_key: Right, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + '+', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Increase, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '-', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Decrease, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '=', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Increase, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '[', + ), + key_modifiers: { + Alt, + }, + }: [ + PreviousSwapLayout, + ], + KeyWithModifier { + bare_key: Char( + ']', + ), + key_modifiers: { + Alt, + }, + }: [ + NextSwapLayout, + ], + KeyWithModifier { + bare_key: Char( + 'b', + ), + key_modifiers: { + Ctrl, + }, + }: [ + PageScrollUp, + ], + KeyWithModifier { + bare_key: Char( + 'c', + ), + key_modifiers: { + Ctrl, + }, + }: [ + ScrollToBottom, SwitchToMode( Normal, ), ], - Char( - 'd', - ): [ + KeyWithModifier { + bare_key: Char( + 'd', + ), + key_modifiers: {}, + }: [ HalfPageScrollDown, ], - Char( - 'e', - ): [ + KeyWithModifier { + bare_key: Char( + 'e', + ), + key_modifiers: {}, + }: [ EditScrollback, SwitchToMode( Normal, ), ], - Char( - 'h', - ): [ - PageScrollUp, - ], - Char( - 'j', - ): [ - ScrollDown, - ], - Char( - 'k', - ): [ - ScrollUp, - ], - Char( - 'l', - ): [ + KeyWithModifier { + bare_key: Char( + 'f', + ), + key_modifiers: { + Ctrl, + }, + }: [ PageScrollDown, ], - Char( - 's', - ): [ + KeyWithModifier { + bare_key: Char( + 'g', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Locked, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: {}, + }: [ + PageScrollUp, + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Move, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Char( + 'i', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Char( + 'j', + ), + key_modifiers: {}, + }: [ + ScrollDown, + ], + KeyWithModifier { + bare_key: Char( + 'j', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Char( + 'k', + ), + key_modifiers: {}, + }: [ + ScrollUp, + ], + KeyWithModifier { + bare_key: Char( + 'k', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Char( + 'l', + ), + key_modifiers: {}, + }: [ + PageScrollDown, + ], + KeyWithModifier { + bare_key: Char( + 'l', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Resize, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Alt, + }, + }: [ + NewPane( + None, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Session, + ), + ], + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'p', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Pane, + ), + ], + KeyWithModifier { + bare_key: Char( + 'q', + ), + key_modifiers: { + Ctrl, + }, + }: [ + Quit, + ], + KeyWithModifier { + bare_key: Char( + 's', + ), + key_modifiers: {}, + }: [ SwitchToMode( EnterSearch, ), @@ -1418,1242 +2268,1785 @@ Config { ], ), ], - Char( - 'u', - ): [ - HalfPageScrollUp, - ], - Alt( - Char( - '+', + KeyWithModifier { + bare_key: Char( + 's', ), - ): [ - Resize( - Increase, - None, - ), - ], - Alt( - Char( - '-', - ), - ): [ - Resize( - Decrease, - None, - ), - ], - Alt( - Char( - '=', - ), - ): [ - Resize( - Increase, - None, - ), - ], - Alt( - Char( - '[', - ), - ): [ - PreviousSwapLayout, - ], - Alt( - Char( - ']', - ), - ): [ - NextSwapLayout, - ], - Alt( - Char( - 'h', - ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Char( - 'i', - ), - ): [ - MoveTab( - Left, - ), - ], - Alt( - Char( - 'j', - ), - ): [ - MoveFocus( - Down, - ), - ], - Alt( - Char( - 'k', - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Char( - 'l', - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Char( - 'n', - ), - ): [ - NewPane( - None, - None, - ), - ], - Alt( - Char( - 'o', - ), - ): [ - MoveTab( - Right, - ), - ], - Alt( - Direction( - Left, - ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Direction( - Right, - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Direction( - Up, - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Direction( - Down, - ), - ): [ - MoveFocus( - Down, - ), - ], - Ctrl( - 'b', - ): [ - PageScrollUp, - ], - Ctrl( - 'c', - ): [ - ScrollToBottom, + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Normal, ), ], - Ctrl( - 'f', - ): [ - PageScrollDown, - ], - Ctrl( - 'g', - ): [ - SwitchToMode( - Locked, + KeyWithModifier { + bare_key: Char( + 't', ), - ], - Ctrl( - 'h', - ): [ - SwitchToMode( - Move, - ), - ], - Ctrl( - 'n', - ): [ - SwitchToMode( - Resize, - ), - ], - Ctrl( - 'o', - ): [ - SwitchToMode( - Session, - ), - ], - Ctrl( - 'p', - ): [ - SwitchToMode( - Pane, - ), - ], - Ctrl( - 'q', - ): [ - Quit, - ], - Ctrl( - 's', - ): [ - SwitchToMode( - Normal, - ), - ], - Ctrl( - 't', - ): [ + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Tab, ), ], - Esc: [ + KeyWithModifier { + bare_key: Char( + 'u', + ), + key_modifiers: {}, + }: [ + HalfPageScrollUp, + ], + KeyWithModifier { + bare_key: Esc, + key_modifiers: {}, + }: [ + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Enter, + key_modifiers: {}, + }: [ SwitchToMode( Normal, ), ], }, EnterSearch: { - Char( - '\n', - ): [ - SwitchToMode( - Search, + KeyWithModifier { + bare_key: Left, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Down, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Up, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Right, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( '+', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Increase, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '-', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Decrease, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '=', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Increase, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '[', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ PreviousSwapLayout, ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( ']', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ NextSwapLayout, ], - Alt( - Char( - 'h', + KeyWithModifier { + bare_key: Char( + 'b', ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Char( - 'i', - ), - ): [ - MoveTab( - Left, - ), - ], - Alt( - Char( - 'j', - ), - ): [ - MoveFocus( - Down, - ), - ], - Alt( - Char( - 'k', - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Char( - 'l', - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Char( - 'n', - ), - ): [ - NewPane( - None, - None, - ), - ], - Alt( - Char( - 'o', - ), - ): [ - MoveTab( - Right, - ), - ], - Alt( - Direction( - Left, - ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Direction( - Right, - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Direction( - Up, - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Direction( - Down, - ), - ): [ - MoveFocus( - Down, - ), - ], - Ctrl( - 'b', - ): [ + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Tmux, ), ], - Ctrl( - 'c', - ): [ + KeyWithModifier { + bare_key: Char( + 'c', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Scroll, ), ], - Ctrl( - 'g', - ): [ + KeyWithModifier { + bare_key: Char( + 'g', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Locked, ), ], - Ctrl( - 'h', - ): [ + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Move, ), ], - Ctrl( - 'n', - ): [ - SwitchToMode( - Resize, - ), - ], - Ctrl( - 'o', - ): [ - SwitchToMode( - Session, - ), - ], - Ctrl( - 'p', - ): [ - SwitchToMode( - Pane, - ), - ], - Ctrl( - 'q', - ): [ - Quit, - ], - Ctrl( - 's', - ): [ - SwitchToMode( - Scroll, - ), - ], - Ctrl( - 't', - ): [ - SwitchToMode( - Tab, - ), - ], - Esc: [ - SwitchToMode( - Scroll, - ), - ], - }, - Search: { - PageDown: [ - PageScrollDown, - ], - PageUp: [ - PageScrollUp, - ], - Left: [ - PageScrollUp, - ], - Down: [ - ScrollDown, - ], - Up: [ - ScrollUp, - ], - Right: [ - PageScrollDown, - ], - Char( - '\n', - ): [ - SwitchToMode( - Normal, - ), - ], - Char( - 'c', - ): [ - SearchToggleOption( - CaseSensitivity, - ), - ], - Char( - 'd', - ): [ - HalfPageScrollDown, - ], - Char( - 'h', - ): [ - PageScrollUp, - ], - Char( - 'j', - ): [ - ScrollDown, - ], - Char( - 'k', - ): [ - ScrollUp, - ], - Char( - 'l', - ): [ - PageScrollDown, - ], - Char( - 'n', - ): [ - Search( - Down, - ), - ], - Char( - 'o', - ): [ - SearchToggleOption( - WholeWord, - ), - ], - Char( - 'p', - ): [ - Search( - Up, - ), - ], - Char( - 'u', - ): [ - HalfPageScrollUp, - ], - Char( - 'w', - ): [ - SearchToggleOption( - Wrap, - ), - ], - Alt( - Char( - '+', - ), - ): [ - Resize( - Increase, - None, - ), - ], - Alt( - Char( - '-', - ), - ): [ - Resize( - Decrease, - None, - ), - ], - Alt( - Char( - '=', - ), - ): [ - Resize( - Increase, - None, - ), - ], - Alt( - Char( - '[', - ), - ): [ - PreviousSwapLayout, - ], - Alt( - Char( - ']', - ), - ): [ - NextSwapLayout, - ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'h', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveFocusOrTab( Left, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'i', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveTab( Left, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'j', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveFocus( Down, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'k', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveFocus( Up, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'l', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveFocusOrTab( Right, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'n', ), - ): [ + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Resize, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Alt, + }, + }: [ NewPane( None, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'o', ), - ): [ + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Session, + ), + ], + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Alt, + }, + }: [ MoveTab( Right, ), ], - Alt( - Direction( - Left, + KeyWithModifier { + bare_key: Char( + 'p', ), - ): [ - MoveFocusOrTab( - Left, + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Pane, ), ], - Alt( - Direction( - Right, + KeyWithModifier { + bare_key: Char( + 'q', ), - ): [ - MoveFocusOrTab( - Right, + key_modifiers: { + Ctrl, + }, + }: [ + Quit, + ], + KeyWithModifier { + bare_key: Char( + 's', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Scroll, ), ], - Alt( - Direction( - Up, + KeyWithModifier { + bare_key: Char( + 't', ), - ): [ - MoveFocus( - Up, + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Tab, ), ], - Alt( - Direction( - Down, - ), - ): [ - MoveFocus( - Down, + KeyWithModifier { + bare_key: Esc, + key_modifiers: {}, + }: [ + SwitchToMode( + Scroll, ), ], - Ctrl( - 'b', - ): [ + KeyWithModifier { + bare_key: Enter, + key_modifiers: {}, + }: [ + SwitchToMode( + Search, + ), + ], + }, + Search: { + KeyWithModifier { + bare_key: PageDown, + key_modifiers: {}, + }: [ + PageScrollDown, + ], + KeyWithModifier { + bare_key: PageUp, + key_modifiers: {}, + }: [ PageScrollUp, ], - Ctrl( - 'c', - ): [ + KeyWithModifier { + bare_key: Left, + key_modifiers: {}, + }: [ + PageScrollUp, + ], + KeyWithModifier { + bare_key: Left, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Down, + key_modifiers: {}, + }: [ + ScrollDown, + ], + KeyWithModifier { + bare_key: Down, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Up, + key_modifiers: {}, + }: [ + ScrollUp, + ], + KeyWithModifier { + bare_key: Up, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Right, + key_modifiers: {}, + }: [ + PageScrollDown, + ], + KeyWithModifier { + bare_key: Right, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + '+', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Increase, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '-', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Decrease, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '=', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Increase, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '[', + ), + key_modifiers: { + Alt, + }, + }: [ + PreviousSwapLayout, + ], + KeyWithModifier { + bare_key: Char( + ']', + ), + key_modifiers: { + Alt, + }, + }: [ + NextSwapLayout, + ], + KeyWithModifier { + bare_key: Char( + 'b', + ), + key_modifiers: { + Ctrl, + }, + }: [ + PageScrollUp, + ], + KeyWithModifier { + bare_key: Char( + 'c', + ), + key_modifiers: {}, + }: [ + SearchToggleOption( + CaseSensitivity, + ), + ], + KeyWithModifier { + bare_key: Char( + 'c', + ), + key_modifiers: { + Ctrl, + }, + }: [ ScrollToBottom, SwitchToMode( Normal, ), ], - Ctrl( - 'f', - ): [ + KeyWithModifier { + bare_key: Char( + 'd', + ), + key_modifiers: {}, + }: [ + HalfPageScrollDown, + ], + KeyWithModifier { + bare_key: Char( + 'f', + ), + key_modifiers: { + Ctrl, + }, + }: [ PageScrollDown, ], - Ctrl( - 'g', - ): [ + KeyWithModifier { + bare_key: Char( + 'g', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Locked, ), ], - Ctrl( - 'h', - ): [ + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: {}, + }: [ + PageScrollUp, + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Move, ), ], - Ctrl( - 'n', - ): [ + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Char( + 'i', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Char( + 'j', + ), + key_modifiers: {}, + }: [ + ScrollDown, + ], + KeyWithModifier { + bare_key: Char( + 'j', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Char( + 'k', + ), + key_modifiers: {}, + }: [ + ScrollUp, + ], + KeyWithModifier { + bare_key: Char( + 'k', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Char( + 'l', + ), + key_modifiers: {}, + }: [ + PageScrollDown, + ], + KeyWithModifier { + bare_key: Char( + 'l', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: {}, + }: [ + Search( + Down, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Resize, ), ], - Ctrl( - 'o', - ): [ + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Alt, + }, + }: [ + NewPane( + None, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: {}, + }: [ + SearchToggleOption( + WholeWord, + ), + ], + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Session, ), ], - Ctrl( - 'p', - ): [ + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'p', + ), + key_modifiers: {}, + }: [ + Search( + Up, + ), + ], + KeyWithModifier { + bare_key: Char( + 'p', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Pane, ), ], - Ctrl( - 'q', - ): [ + KeyWithModifier { + bare_key: Char( + 'q', + ), + key_modifiers: { + Ctrl, + }, + }: [ Quit, ], - Ctrl( - 's', - ): [ + KeyWithModifier { + bare_key: Char( + 's', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Normal, ), ], - Ctrl( - 't', - ): [ + KeyWithModifier { + bare_key: Char( + 't', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Tab, ), ], - Esc: [ + KeyWithModifier { + bare_key: Char( + 'u', + ), + key_modifiers: {}, + }: [ + HalfPageScrollUp, + ], + KeyWithModifier { + bare_key: Char( + 'w', + ), + key_modifiers: {}, + }: [ + SearchToggleOption( + Wrap, + ), + ], + KeyWithModifier { + bare_key: Esc, + key_modifiers: {}, + }: [ + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Enter, + key_modifiers: {}, + }: [ SwitchToMode( Normal, ), ], }, RenameTab: { - Char( - '\n', - ): [ - SwitchToMode( - Normal, + KeyWithModifier { + bare_key: Left, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Down, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Up, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Right, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( '+', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Increase, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '-', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Decrease, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '=', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Increase, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '[', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ PreviousSwapLayout, ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( ']', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ NextSwapLayout, ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( + 'b', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Tmux, + ), + ], + KeyWithModifier { + bare_key: Char( + 'c', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Char( + 'g', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Locked, + ), + ], + KeyWithModifier { + bare_key: Char( 'h', ), - ): [ + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Move, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Alt, + }, + }: [ MoveFocusOrTab( Left, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'i', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveTab( Left, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'j', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveFocus( Down, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'k', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveFocus( Up, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'l', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveFocusOrTab( Right, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'n', ), - ): [ + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Resize, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Alt, + }, + }: [ NewPane( None, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'o', ), - ): [ - MoveTab( - Right, - ), - ], - Alt( - Direction( - Left, - ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Direction( - Right, - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Direction( - Up, - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Direction( - Down, - ), - ): [ - MoveFocus( - Down, - ), - ], - Ctrl( - 'b', - ): [ - SwitchToMode( - Tmux, - ), - ], - Ctrl( - 'c', - ): [ - SwitchToMode( - Normal, - ), - ], - Ctrl( - 'g', - ): [ - SwitchToMode( - Locked, - ), - ], - Ctrl( - 'h', - ): [ - SwitchToMode( - Move, - ), - ], - Ctrl( - 'n', - ): [ - SwitchToMode( - Resize, - ), - ], - Ctrl( - 'o', - ): [ + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Session, ), ], - Ctrl( - 'p', - ): [ + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'p', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Pane, ), ], - Ctrl( - 'q', - ): [ + KeyWithModifier { + bare_key: Char( + 'q', + ), + key_modifiers: { + Ctrl, + }, + }: [ Quit, ], - Ctrl( - 's', - ): [ + KeyWithModifier { + bare_key: Char( + 's', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Scroll, ), ], - Ctrl( - 't', - ): [ + KeyWithModifier { + bare_key: Char( + 't', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Tab, ), ], - Esc: [ + KeyWithModifier { + bare_key: Esc, + key_modifiers: {}, + }: [ UndoRenameTab, SwitchToMode( Tab, ), ], - }, - RenamePane: { - Char( - '\n', - ): [ + KeyWithModifier { + bare_key: Enter, + key_modifiers: {}, + }: [ SwitchToMode( Normal, ), ], - Alt( - Char( + }, + RenamePane: { + KeyWithModifier { + bare_key: Left, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Down, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Up, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Right, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( '+', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Increase, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '-', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Decrease, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '=', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Increase, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '[', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ PreviousSwapLayout, ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( ']', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ NextSwapLayout, ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( + 'b', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Tmux, + ), + ], + KeyWithModifier { + bare_key: Char( + 'c', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Char( + 'g', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Locked, + ), + ], + KeyWithModifier { + bare_key: Char( 'h', ), - ): [ + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Move, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Alt, + }, + }: [ MoveFocusOrTab( Left, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'i', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveTab( Left, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'j', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveFocus( Down, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'k', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveFocus( Up, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'l', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveFocusOrTab( Right, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'n', ), - ): [ + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Resize, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Alt, + }, + }: [ NewPane( None, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'o', ), - ): [ - MoveTab( - Right, - ), - ], - Alt( - Direction( - Left, - ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Direction( - Right, - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Direction( - Up, - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Direction( - Down, - ), - ): [ - MoveFocus( - Down, - ), - ], - Ctrl( - 'b', - ): [ - SwitchToMode( - Tmux, - ), - ], - Ctrl( - 'c', - ): [ - SwitchToMode( - Normal, - ), - ], - Ctrl( - 'g', - ): [ - SwitchToMode( - Locked, - ), - ], - Ctrl( - 'h', - ): [ - SwitchToMode( - Move, - ), - ], - Ctrl( - 'n', - ): [ - SwitchToMode( - Resize, - ), - ], - Ctrl( - 'o', - ): [ + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Session, ), ], - Ctrl( - 'p', - ): [ + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'p', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Pane, ), ], - Ctrl( - 'q', - ): [ + KeyWithModifier { + bare_key: Char( + 'q', + ), + key_modifiers: { + Ctrl, + }, + }: [ Quit, ], - Ctrl( - 's', - ): [ + KeyWithModifier { + bare_key: Char( + 's', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Scroll, ), ], - Ctrl( - 't', - ): [ + KeyWithModifier { + bare_key: Char( + 't', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Tab, ), ], - Esc: [ + KeyWithModifier { + bare_key: Esc, + key_modifiers: {}, + }: [ UndoRenamePane, SwitchToMode( Pane, ), ], - }, - Session: { - Char( - '\n', - ): [ + KeyWithModifier { + bare_key: Enter, + key_modifiers: {}, + }: [ SwitchToMode( Normal, ), ], - Char( - 'd', - ): [ + }, + Session: { + KeyWithModifier { + bare_key: Left, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Down, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Up, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Right, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + '+', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Increase, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '-', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Decrease, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '=', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Increase, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '[', + ), + key_modifiers: { + Alt, + }, + }: [ + PreviousSwapLayout, + ], + KeyWithModifier { + bare_key: Char( + ']', + ), + key_modifiers: { + Alt, + }, + }: [ + NextSwapLayout, + ], + KeyWithModifier { + bare_key: Char( + 'b', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Tmux, + ), + ], + KeyWithModifier { + bare_key: Char( + 'd', + ), + key_modifiers: {}, + }: [ Detach, ], - Char( - 'w', - ): [ + KeyWithModifier { + bare_key: Char( + 'g', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Locked, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Move, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Char( + 'i', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Char( + 'j', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Char( + 'k', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Char( + 'l', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Resize, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Alt, + }, + }: [ + NewPane( + None, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'p', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Pane, + ), + ], + KeyWithModifier { + bare_key: Char( + 'q', + ), + key_modifiers: { + Ctrl, + }, + }: [ + Quit, + ], + KeyWithModifier { + bare_key: Char( + 's', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Scroll, + ), + ], + KeyWithModifier { + bare_key: Char( + 't', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Tab, + ), + ], + KeyWithModifier { + bare_key: Char( + 'w', + ), + key_modifiers: {}, + }: [ LaunchOrFocusPlugin( Alias( PluginAlias { @@ -2676,738 +4069,758 @@ Config { Normal, ), ], - Alt( - Char( - '+', - ), - ): [ - Resize( - Increase, - None, - ), - ], - Alt( - Char( - '-', - ), - ): [ - Resize( - Decrease, - None, - ), - ], - Alt( - Char( - '=', - ), - ): [ - Resize( - Increase, - None, - ), - ], - Alt( - Char( - '[', - ), - ): [ - PreviousSwapLayout, - ], - Alt( - Char( - ']', - ), - ): [ - NextSwapLayout, - ], - Alt( - Char( - 'h', - ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Char( - 'i', - ), - ): [ - MoveTab( - Left, - ), - ], - Alt( - Char( - 'j', - ), - ): [ - MoveFocus( - Down, - ), - ], - Alt( - Char( - 'k', - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Char( - 'l', - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Char( - 'n', - ), - ): [ - NewPane( - None, - None, - ), - ], - Alt( - Char( - 'o', - ), - ): [ - MoveTab( - Right, - ), - ], - Alt( - Direction( - Left, - ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Direction( - Right, - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Direction( - Up, - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Direction( - Down, - ), - ): [ - MoveFocus( - Down, - ), - ], - Ctrl( - 'b', - ): [ - SwitchToMode( - Tmux, - ), - ], - Ctrl( - 'g', - ): [ - SwitchToMode( - Locked, - ), - ], - Ctrl( - 'h', - ): [ - SwitchToMode( - Move, - ), - ], - Ctrl( - 'n', - ): [ - SwitchToMode( - Resize, - ), - ], - Ctrl( - 'o', - ): [ + KeyWithModifier { + bare_key: Esc, + key_modifiers: {}, + }: [ SwitchToMode( Normal, ), ], - Ctrl( - 'p', - ): [ - SwitchToMode( - Pane, - ), - ], - Ctrl( - 'q', - ): [ - Quit, - ], - Ctrl( - 's', - ): [ - SwitchToMode( - Scroll, - ), - ], - Ctrl( - 't', - ): [ - SwitchToMode( - Tab, - ), - ], - Esc: [ + KeyWithModifier { + bare_key: Enter, + key_modifiers: {}, + }: [ SwitchToMode( Normal, ), ], }, Move: { - Left: [ + KeyWithModifier { + bare_key: Left, + key_modifiers: {}, + }: [ MovePane( Some( Left, ), ), ], - Down: [ + KeyWithModifier { + bare_key: Left, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Down, + key_modifiers: {}, + }: [ MovePane( Some( Down, ), ), ], - Up: [ + KeyWithModifier { + bare_key: Down, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Up, + key_modifiers: {}, + }: [ MovePane( Some( Up, ), ), ], - Right: [ + KeyWithModifier { + bare_key: Up, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Right, + key_modifiers: {}, + }: [ MovePane( Some( Right, ), ), ], - Char( - '\n', - ): [ - SwitchToMode( - Normal, + KeyWithModifier { + bare_key: Right, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, ), ], - Char( - 'h', - ): [ - MovePane( - Some( - Left, - ), - ), - ], - Char( - 'j', - ): [ - MovePane( - Some( - Down, - ), - ), - ], - Char( - 'k', - ): [ - MovePane( - Some( - Up, - ), - ), - ], - Char( - 'l', - ): [ - MovePane( - Some( - Right, - ), - ), - ], - Char( - 'n', - ): [ - MovePane( - None, - ), - ], - Char( - 'p', - ): [ - MovePaneBackwards, - ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '+', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Increase, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '-', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Decrease, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '=', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Increase, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '[', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ PreviousSwapLayout, ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( ']', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ NextSwapLayout, ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( + 'b', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Tmux, + ), + ], + KeyWithModifier { + bare_key: Char( + 'g', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Locked, + ), + ], + KeyWithModifier { + bare_key: Char( 'h', ), - ): [ + key_modifiers: {}, + }: [ + MovePane( + Some( + Left, + ), + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Alt, + }, + }: [ MoveFocusOrTab( Left, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'i', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveTab( Left, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'j', ), - ): [ + key_modifiers: {}, + }: [ + MovePane( + Some( + Down, + ), + ), + ], + KeyWithModifier { + bare_key: Char( + 'j', + ), + key_modifiers: { + Alt, + }, + }: [ MoveFocus( Down, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'k', ), - ): [ + key_modifiers: {}, + }: [ + MovePane( + Some( + Up, + ), + ), + ], + KeyWithModifier { + bare_key: Char( + 'k', + ), + key_modifiers: { + Alt, + }, + }: [ MoveFocus( Up, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'l', ), - ): [ + key_modifiers: {}, + }: [ + MovePane( + Some( + Right, + ), + ), + ], + KeyWithModifier { + bare_key: Char( + 'l', + ), + key_modifiers: { + Alt, + }, + }: [ MoveFocusOrTab( Right, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'n', ), - ): [ + key_modifiers: {}, + }: [ + MovePane( + None, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Resize, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Alt, + }, + }: [ NewPane( None, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'o', ), - ): [ - MoveTab( - Right, - ), - ], - Alt( - Direction( - Left, - ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Direction( - Right, - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Direction( - Up, - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Direction( - Down, - ), - ): [ - MoveFocus( - Down, - ), - ], - Ctrl( - 'b', - ): [ - SwitchToMode( - Tmux, - ), - ], - Ctrl( - 'g', - ): [ - SwitchToMode( - Locked, - ), - ], - Ctrl( - 'h', - ): [ - SwitchToMode( - Normal, - ), - ], - Ctrl( - 'n', - ): [ - SwitchToMode( - Resize, - ), - ], - Ctrl( - 'o', - ): [ + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Session, ), ], - Ctrl( - 'p', - ): [ + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'p', + ), + key_modifiers: {}, + }: [ + MovePaneBackwards, + ], + KeyWithModifier { + bare_key: Char( + 'p', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Pane, ), ], - Ctrl( - 'q', - ): [ + KeyWithModifier { + bare_key: Char( + 'q', + ), + key_modifiers: { + Ctrl, + }, + }: [ Quit, ], - Ctrl( - 's', - ): [ + KeyWithModifier { + bare_key: Char( + 's', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Scroll, ), ], - Ctrl( - 't', - ): [ + KeyWithModifier { + bare_key: Char( + 't', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Tab, ), ], - BackTab: [ + KeyWithModifier { + bare_key: Tab, + key_modifiers: {}, + }: [ MovePane( None, ), ], - Esc: [ + KeyWithModifier { + bare_key: Esc, + key_modifiers: {}, + }: [ + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Enter, + key_modifiers: {}, + }: [ SwitchToMode( Normal, ), ], }, Prompt: { - Char( - '\n', - ): [ - SwitchToMode( - Normal, + KeyWithModifier { + bare_key: Left, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Down, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Up, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Right, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( '+', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Increase, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '-', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Decrease, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '=', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Increase, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '[', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ PreviousSwapLayout, ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( ']', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ NextSwapLayout, ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( + 'b', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Tmux, + ), + ], + KeyWithModifier { + bare_key: Char( + 'g', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Locked, + ), + ], + KeyWithModifier { + bare_key: Char( 'h', ), - ): [ + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Move, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Alt, + }, + }: [ MoveFocusOrTab( Left, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'i', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveTab( Left, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'j', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveFocus( Down, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'k', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveFocus( Up, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'l', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveFocusOrTab( Right, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'n', ), - ): [ + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Resize, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Alt, + }, + }: [ NewPane( None, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'o', ), - ): [ - MoveTab( - Right, - ), - ], - Alt( - Direction( - Left, - ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Direction( - Right, - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Direction( - Up, - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Direction( - Down, - ), - ): [ - MoveFocus( - Down, - ), - ], - Ctrl( - 'b', - ): [ - SwitchToMode( - Tmux, - ), - ], - Ctrl( - 'g', - ): [ - SwitchToMode( - Locked, - ), - ], - Ctrl( - 'h', - ): [ - SwitchToMode( - Move, - ), - ], - Ctrl( - 'n', - ): [ - SwitchToMode( - Resize, - ), - ], - Ctrl( - 'o', - ): [ + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Session, ), ], - Ctrl( - 'p', - ): [ + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'p', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Pane, ), ], - Ctrl( - 'q', - ): [ + KeyWithModifier { + bare_key: Char( + 'q', + ), + key_modifiers: { + Ctrl, + }, + }: [ Quit, ], - Ctrl( - 's', - ): [ + KeyWithModifier { + bare_key: Char( + 's', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Scroll, ), ], - Ctrl( - 't', - ): [ + KeyWithModifier { + bare_key: Char( + 't', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Tab, ), ], - Esc: [ + KeyWithModifier { + bare_key: Esc, + key_modifiers: {}, + }: [ + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Enter, + key_modifiers: {}, + }: [ SwitchToMode( Normal, ), ], }, Tmux: { - Left: [ + KeyWithModifier { + bare_key: Left, + key_modifiers: {}, + }: [ MoveFocus( Left, ), @@ -3415,7 +4828,20 @@ Config { Normal, ), ], - Down: [ + KeyWithModifier { + bare_key: Left, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Down, + key_modifiers: {}, + }: [ MoveFocus( Down, ), @@ -3423,7 +4849,20 @@ Config { Normal, ), ], - Up: [ + KeyWithModifier { + bare_key: Down, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Up, + key_modifiers: {}, + }: [ MoveFocus( Up, ), @@ -3431,7 +4870,20 @@ Config { Normal, ), ], - Right: [ + KeyWithModifier { + bare_key: Up, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Right, + key_modifiers: {}, + }: [ MoveFocus( Right, ), @@ -3439,21 +4891,30 @@ Config { Normal, ), ], - Char( - '\n', - ): [ - SwitchToMode( - Normal, + KeyWithModifier { + bare_key: Right, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, ), ], - Char( - ' ', - ): [ + KeyWithModifier { + bare_key: Char( + ' ', + ), + key_modifiers: {}, + }: [ NextSwapLayout, ], - Char( - '"', - ): [ + KeyWithModifier { + bare_key: Char( + '"', + ), + key_modifiers: {}, + }: [ NewPane( Some( Down, @@ -3464,9 +4925,12 @@ Config { Normal, ), ], - Char( - '%', - ): [ + KeyWithModifier { + bare_key: Char( + '%', + ), + key_modifiers: {}, + }: [ NewPane( Some( Right, @@ -3477,23 +4941,110 @@ Config { Normal, ), ], - Char( - ',', - ): [ + KeyWithModifier { + bare_key: Char( + '+', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Increase, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + ',', + ), + key_modifiers: {}, + }: [ SwitchToMode( RenameTab, ), ], - Char( - '[', - ): [ + KeyWithModifier { + bare_key: Char( + '-', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Decrease, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '=', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Increase, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '[', + ), + key_modifiers: {}, + }: [ SwitchToMode( Scroll, ), ], - Char( - 'c', - ): [ + KeyWithModifier { + bare_key: Char( + '[', + ), + key_modifiers: { + Alt, + }, + }: [ + PreviousSwapLayout, + ], + KeyWithModifier { + bare_key: Char( + ']', + ), + key_modifiers: { + Alt, + }, + }: [ + NextSwapLayout, + ], + KeyWithModifier { + bare_key: Char( + 'b', + ), + key_modifiers: { + Ctrl, + }, + }: [ + Write( + None, + [ + 2, + ], + false, + ), + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Char( + 'c', + ), + key_modifiers: {}, + }: [ NewTab( None, [], @@ -3505,14 +5056,32 @@ Config { Normal, ), ], - Char( - 'd', - ): [ + KeyWithModifier { + bare_key: Char( + 'd', + ), + key_modifiers: {}, + }: [ Detach, ], - Char( - 'h', - ): [ + KeyWithModifier { + bare_key: Char( + 'g', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Locked, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: {}, + }: [ MoveFocus( Left, ), @@ -3520,9 +5089,48 @@ Config { Normal, ), ], - Char( - 'j', - ): [ + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Move, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Char( + 'i', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Char( + 'j', + ), + key_modifiers: {}, + }: [ MoveFocus( Down, ), @@ -3530,9 +5138,24 @@ Config { Normal, ), ], - Char( - 'k', - ): [ + KeyWithModifier { + bare_key: Char( + 'j', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Char( + 'k', + ), + key_modifiers: {}, + }: [ MoveFocus( Up, ), @@ -3540,9 +5163,24 @@ Config { Normal, ), ], - Char( - 'l', - ): [ + KeyWithModifier { + bare_key: Char( + 'k', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Char( + 'l', + ), + key_modifiers: {}, + }: [ MoveFocus( Right, ), @@ -3550,254 +5188,177 @@ Config { Normal, ), ], - Char( - 'n', - ): [ + KeyWithModifier { + bare_key: Char( + 'l', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: {}, + }: [ GoToNextTab, SwitchToMode( Normal, ), ], - Char( - 'o', - ): [ - FocusNextPane, - ], - Char( - 'p', - ): [ - GoToPreviousTab, - SwitchToMode( - Normal, - ), - ], - Char( - 'x', - ): [ - CloseFocus, - SwitchToMode( - Normal, - ), - ], - Char( - 'z', - ): [ - ToggleFocusFullscreen, - SwitchToMode( - Normal, - ), - ], - Alt( - Char( - '+', - ), - ): [ - Resize( - Increase, - None, - ), - ], - Alt( - Char( - '-', - ), - ): [ - Resize( - Decrease, - None, - ), - ], - Alt( - Char( - '=', - ), - ): [ - Resize( - Increase, - None, - ), - ], - Alt( - Char( - '[', - ), - ): [ - PreviousSwapLayout, - ], - Alt( - Char( - ']', - ), - ): [ - NextSwapLayout, - ], - Alt( - Char( - 'h', - ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Char( - 'i', - ), - ): [ - MoveTab( - Left, - ), - ], - Alt( - Char( - 'j', - ), - ): [ - MoveFocus( - Down, - ), - ], - Alt( - Char( - 'k', - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Char( - 'l', - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'n', ), - ): [ + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Resize, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Alt, + }, + }: [ NewPane( None, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'o', ), - ): [ - MoveTab( - Right, - ), + key_modifiers: {}, + }: [ + FocusNextPane, ], - Alt( - Direction( - Left, + KeyWithModifier { + bare_key: Char( + 'o', ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Direction( - Right, - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Direction( - Up, - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Direction( - Down, - ), - ): [ - MoveFocus( - Down, - ), - ], - Ctrl( - 'b', - ): [ - Write( - [ - 2, - ], - ), - SwitchToMode( - Normal, - ), - ], - Ctrl( - 'g', - ): [ - SwitchToMode( - Locked, - ), - ], - Ctrl( - 'h', - ): [ - SwitchToMode( - Move, - ), - ], - Ctrl( - 'n', - ): [ - SwitchToMode( - Resize, - ), - ], - Ctrl( - 'o', - ): [ + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Session, ), ], - Ctrl( - 'p', - ): [ + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'p', + ), + key_modifiers: {}, + }: [ + GoToPreviousTab, + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Char( + 'p', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Pane, ), ], - Ctrl( - 'q', - ): [ + KeyWithModifier { + bare_key: Char( + 'q', + ), + key_modifiers: { + Ctrl, + }, + }: [ Quit, ], - Ctrl( - 's', - ): [ + KeyWithModifier { + bare_key: Char( + 's', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Scroll, ), ], - Ctrl( - 't', - ): [ + KeyWithModifier { + bare_key: Char( + 't', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Tab, ), ], - Esc: [ + KeyWithModifier { + bare_key: Char( + 'x', + ), + key_modifiers: {}, + }: [ + CloseFocus, + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Char( + 'z', + ), + key_modifiers: {}, + }: [ + ToggleFocusFullscreen, + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Esc, + key_modifiers: {}, + }: [ + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Enter, + key_modifiers: {}, + }: [ SwitchToMode( Normal, ), @@ -3831,6 +5392,7 @@ Config { styled_underlines: None, serialization_interval: None, disable_session_metadata: None, + support_kitty_keyboard_protocol: None, }, themes: { "other-theme-from-config": Theme { diff --git a/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_ui_config_overrides_config_ui_config.snap b/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_ui_config_overrides_config_ui_config.snap index acae6310..808e9cfb 100644 --- a/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_ui_config_overrides_config_ui_config.snap +++ b/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_ui_config_overrides_config_ui_config.snap @@ -1,228 +1,321 @@ --- source: zellij-utils/src/setup.rs -assertion_line: 770 +assertion_line: 797 expression: "format!(\"{:#?}\", config)" --- Config { keybinds: { Normal: { - Alt( - Char( + KeyWithModifier { + bare_key: Left, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Down, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Up, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Right, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( '+', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Increase, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '-', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Decrease, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '=', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Increase, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '[', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ PreviousSwapLayout, ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( ']', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ NextSwapLayout, ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( + 'b', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Tmux, + ), + ], + KeyWithModifier { + bare_key: Char( + 'g', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Locked, + ), + ], + KeyWithModifier { + bare_key: Char( 'h', ), - ): [ + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Move, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Alt, + }, + }: [ MoveFocusOrTab( Left, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'i', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveTab( Left, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'j', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveFocus( Down, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'k', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveFocus( Up, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'l', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveFocusOrTab( Right, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'n', ), - ): [ + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Resize, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Alt, + }, + }: [ NewPane( None, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'o', ), - ): [ - MoveTab( - Right, - ), - ], - Alt( - Direction( - Left, - ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Direction( - Right, - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Direction( - Up, - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Direction( - Down, - ), - ): [ - MoveFocus( - Down, - ), - ], - Ctrl( - 'b', - ): [ - SwitchToMode( - Tmux, - ), - ], - Ctrl( - 'g', - ): [ - SwitchToMode( - Locked, - ), - ], - Ctrl( - 'h', - ): [ - SwitchToMode( - Move, - ), - ], - Ctrl( - 'n', - ): [ - SwitchToMode( - Resize, - ), - ], - Ctrl( - 'o', - ): [ + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Session, ), ], - Ctrl( - 'p', - ): [ + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'p', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Pane, ), ], - Ctrl( - 'q', - ): [ + KeyWithModifier { + bare_key: Char( + 'q', + ), + key_modifiers: { + Ctrl, + }, + }: [ Quit, ], - Ctrl( - 's', - ): [ + KeyWithModifier { + bare_key: Char( + 's', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Scroll, ), ], - Ctrl( - 't', - ): [ + KeyWithModifier { + bare_key: Char( + 't', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Tab, ), ], }, Locked: { - Ctrl( - 'g', - ): [ + KeyWithModifier { + bare_key: Char( + 'g', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Normal, ), ], }, Resize: { - Left: [ + KeyWithModifier { + bare_key: Left, + key_modifiers: {}, + }: [ Resize( Increase, Some( @@ -230,383 +323,633 @@ Config { ), ), ], - Down: [ - Resize( - Increase, - Some( - Down, - ), - ), - ], - Up: [ - Resize( - Increase, - Some( - Up, - ), - ), - ], - Right: [ - Resize( - Increase, - Some( - Right, - ), - ), - ], - Char( - '\n', - ): [ - SwitchToMode( - Normal, - ), - ], - Char( - '+', - ): [ - Resize( - Increase, - None, - ), - ], - Char( - '-', - ): [ - Resize( - Decrease, - None, - ), - ], - Char( - '=', - ): [ - Resize( - Increase, - None, - ), - ], - Char( - 'H', - ): [ - Resize( - Decrease, - Some( - Left, - ), - ), - ], - Char( - 'J', - ): [ - Resize( - Decrease, - Some( - Down, - ), - ), - ], - Char( - 'K', - ): [ - Resize( - Decrease, - Some( - Up, - ), - ), - ], - Char( - 'L', - ): [ - Resize( - Decrease, - Some( - Right, - ), - ), - ], - Char( - 'h', - ): [ - Resize( - Increase, - Some( - Left, - ), - ), - ], - Char( - 'j', - ): [ - Resize( - Increase, - Some( - Down, - ), - ), - ], - Char( - 'k', - ): [ - Resize( - Increase, - Some( - Up, - ), - ), - ], - Char( - 'l', - ): [ - Resize( - Increase, - Some( - Right, - ), - ), - ], - Alt( - Char( - '+', - ), - ): [ - Resize( - Increase, - None, - ), - ], - Alt( - Char( - '-', - ), - ): [ - Resize( - Decrease, - None, - ), - ], - Alt( - Char( - '=', - ), - ): [ - Resize( - Increase, - None, - ), - ], - Alt( - Char( - '[', - ), - ): [ - PreviousSwapLayout, - ], - Alt( - Char( - ']', - ), - ): [ - NextSwapLayout, - ], - Alt( - Char( - 'h', - ), - ): [ + KeyWithModifier { + bare_key: Left, + key_modifiers: { + Alt, + }, + }: [ MoveFocusOrTab( Left, ), ], - Alt( - Char( - 'i', - ), - ): [ - MoveTab( - Left, + KeyWithModifier { + bare_key: Down, + key_modifiers: {}, + }: [ + Resize( + Increase, + Some( + Down, + ), ), ], - Alt( - Char( - 'j', - ), - ): [ + KeyWithModifier { + bare_key: Down, + key_modifiers: { + Alt, + }, + }: [ MoveFocus( Down, ), ], - Alt( - Char( - 'k', + KeyWithModifier { + bare_key: Up, + key_modifiers: {}, + }: [ + Resize( + Increase, + Some( + Up, + ), ), - ): [ + ], + KeyWithModifier { + bare_key: Up, + key_modifiers: { + Alt, + }, + }: [ MoveFocus( Up, ), ], - Alt( - Char( - 'l', + KeyWithModifier { + bare_key: Right, + key_modifiers: {}, + }: [ + Resize( + Increase, + Some( + Right, + ), ), - ): [ + ], + KeyWithModifier { + bare_key: Right, + key_modifiers: { + Alt, + }, + }: [ MoveFocusOrTab( Right, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( + '+', + ), + key_modifiers: {}, + }: [ + Resize( + Increase, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '+', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Increase, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '-', + ), + key_modifiers: {}, + }: [ + Resize( + Decrease, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '-', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Decrease, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '=', + ), + key_modifiers: {}, + }: [ + Resize( + Increase, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '=', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Increase, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + 'H', + ), + key_modifiers: {}, + }: [ + Resize( + Decrease, + Some( + Left, + ), + ), + ], + KeyWithModifier { + bare_key: Char( + 'J', + ), + key_modifiers: {}, + }: [ + Resize( + Decrease, + Some( + Down, + ), + ), + ], + KeyWithModifier { + bare_key: Char( + 'K', + ), + key_modifiers: {}, + }: [ + Resize( + Decrease, + Some( + Up, + ), + ), + ], + KeyWithModifier { + bare_key: Char( + 'L', + ), + key_modifiers: {}, + }: [ + Resize( + Decrease, + Some( + Right, + ), + ), + ], + KeyWithModifier { + bare_key: Char( + '[', + ), + key_modifiers: { + Alt, + }, + }: [ + PreviousSwapLayout, + ], + KeyWithModifier { + bare_key: Char( + ']', + ), + key_modifiers: { + Alt, + }, + }: [ + NextSwapLayout, + ], + KeyWithModifier { + bare_key: Char( + 'b', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Tmux, + ), + ], + KeyWithModifier { + bare_key: Char( + 'g', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Locked, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: {}, + }: [ + Resize( + Increase, + Some( + Left, + ), + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Move, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Char( + 'i', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Char( + 'j', + ), + key_modifiers: {}, + }: [ + Resize( + Increase, + Some( + Down, + ), + ), + ], + KeyWithModifier { + bare_key: Char( + 'j', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Char( + 'k', + ), + key_modifiers: {}, + }: [ + Resize( + Increase, + Some( + Up, + ), + ), + ], + KeyWithModifier { + bare_key: Char( + 'k', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Char( + 'l', + ), + key_modifiers: {}, + }: [ + Resize( + Increase, + Some( + Right, + ), + ), + ], + KeyWithModifier { + bare_key: Char( + 'l', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( 'n', ), - ): [ + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Alt, + }, + }: [ NewPane( None, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'o', ), - ): [ - MoveTab( - Right, - ), - ], - Alt( - Direction( - Left, - ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Direction( - Right, - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Direction( - Up, - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Direction( - Down, - ), - ): [ - MoveFocus( - Down, - ), - ], - Ctrl( - 'b', - ): [ - SwitchToMode( - Tmux, - ), - ], - Ctrl( - 'g', - ): [ - SwitchToMode( - Locked, - ), - ], - Ctrl( - 'h', - ): [ - SwitchToMode( - Move, - ), - ], - Ctrl( - 'n', - ): [ - SwitchToMode( - Normal, - ), - ], - Ctrl( - 'o', - ): [ + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Session, ), ], - Ctrl( - 'p', - ): [ + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'p', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Pane, ), ], - Ctrl( - 'q', - ): [ + KeyWithModifier { + bare_key: Char( + 'q', + ), + key_modifiers: { + Ctrl, + }, + }: [ Quit, ], - Ctrl( - 's', - ): [ + KeyWithModifier { + bare_key: Char( + 's', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Scroll, ), ], - Ctrl( - 't', - ): [ + KeyWithModifier { + bare_key: Char( + 't', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Tab, ), ], - Esc: [ + KeyWithModifier { + bare_key: Esc, + key_modifiers: {}, + }: [ + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Enter, + key_modifiers: {}, + }: [ SwitchToMode( Normal, ), ], }, Pane: { - Left: [ + KeyWithModifier { + bare_key: Left, + key_modifiers: {}, + }: [ MoveFocus( Left, ), ], - Down: [ + KeyWithModifier { + bare_key: Left, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Down, + key_modifiers: {}, + }: [ MoveFocus( Down, ), ], - Up: [ + KeyWithModifier { + bare_key: Down, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Up, + key_modifiers: {}, + }: [ MoveFocus( Up, ), ], - Right: [ + KeyWithModifier { + bare_key: Up, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Right, + key_modifiers: {}, + }: [ MoveFocus( Right, ), ], - Char( - '\n', - ): [ - SwitchToMode( - Normal, + KeyWithModifier { + bare_key: Right, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, ), ], - Char( - 'c', - ): [ + KeyWithModifier { + bare_key: Char( + '+', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Increase, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '-', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Decrease, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '=', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Increase, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '[', + ), + key_modifiers: { + Alt, + }, + }: [ + PreviousSwapLayout, + ], + KeyWithModifier { + bare_key: Char( + ']', + ), + key_modifiers: { + Alt, + }, + }: [ + NextSwapLayout, + ], + KeyWithModifier { + bare_key: Char( + 'b', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Tmux, + ), + ], + KeyWithModifier { + bare_key: Char( + 'c', + ), + key_modifiers: {}, + }: [ SwitchToMode( RenamePane, ), @@ -616,9 +959,12 @@ Config { ], ), ], - Char( - 'd', - ): [ + KeyWithModifier { + bare_key: Char( + 'd', + ), + key_modifiers: {}, + }: [ NewPane( Some( Down, @@ -629,53 +975,158 @@ Config { Normal, ), ], - Char( - 'e', - ): [ + KeyWithModifier { + bare_key: Char( + 'e', + ), + key_modifiers: {}, + }: [ TogglePaneEmbedOrFloating, SwitchToMode( Normal, ), ], - Char( - 'f', - ): [ + KeyWithModifier { + bare_key: Char( + 'f', + ), + key_modifiers: {}, + }: [ ToggleFocusFullscreen, SwitchToMode( Normal, ), ], - Char( - 'h', - ): [ + KeyWithModifier { + bare_key: Char( + 'g', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Locked, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: {}, + }: [ MoveFocus( Left, ), ], - Char( - 'j', - ): [ + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Move, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Char( + 'i', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Char( + 'j', + ), + key_modifiers: {}, + }: [ MoveFocus( Down, ), ], - Char( - 'k', - ): [ + KeyWithModifier { + bare_key: Char( + 'j', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Char( + 'k', + ), + key_modifiers: {}, + }: [ MoveFocus( Up, ), ], - Char( - 'l', - ): [ + KeyWithModifier { + bare_key: Char( + 'k', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Char( + 'l', + ), + key_modifiers: {}, + }: [ MoveFocus( Right, ), ], - Char( - 'n', - ): [ + KeyWithModifier { + bare_key: Char( + 'l', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: {}, + }: [ NewPane( None, None, @@ -684,14 +1135,91 @@ Config { Normal, ), ], - Char( - 'p', - ): [ + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Resize, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Alt, + }, + }: [ + NewPane( + None, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Session, + ), + ], + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'p', + ), + key_modifiers: {}, + }: [ SwitchFocus, ], - Char( - 'r', - ): [ + KeyWithModifier { + bare_key: Char( + 'p', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Char( + 'q', + ), + key_modifiers: { + Ctrl, + }, + }: [ + Quit, + ], + KeyWithModifier { + bare_key: Char( + 'r', + ), + key_modifiers: {}, + }: [ NewPane( Some( Right, @@ -702,264 +1230,177 @@ Config { Normal, ), ], - Char( - 'w', - ): [ + KeyWithModifier { + bare_key: Char( + 's', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Scroll, + ), + ], + KeyWithModifier { + bare_key: Char( + 't', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Tab, + ), + ], + KeyWithModifier { + bare_key: Char( + 'w', + ), + key_modifiers: {}, + }: [ ToggleFloatingPanes, SwitchToMode( Normal, ), ], - Char( - 'x', - ): [ + KeyWithModifier { + bare_key: Char( + 'x', + ), + key_modifiers: {}, + }: [ CloseFocus, SwitchToMode( Normal, ), ], - Char( - 'z', - ): [ + KeyWithModifier { + bare_key: Char( + 'z', + ), + key_modifiers: {}, + }: [ TogglePaneFrames, SwitchToMode( Normal, ), ], - Alt( - Char( - '+', - ), - ): [ - Resize( - Increase, - None, - ), - ], - Alt( - Char( - '-', - ), - ): [ - Resize( - Decrease, - None, - ), - ], - Alt( - Char( - '=', - ), - ): [ - Resize( - Increase, - None, - ), - ], - Alt( - Char( - '[', - ), - ): [ - PreviousSwapLayout, - ], - Alt( - Char( - ']', - ), - ): [ - NextSwapLayout, - ], - Alt( - Char( - 'h', - ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Char( - 'i', - ), - ): [ - MoveTab( - Left, - ), - ], - Alt( - Char( - 'j', - ), - ): [ - MoveFocus( - Down, - ), - ], - Alt( - Char( - 'k', - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Char( - 'l', - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Char( - 'n', - ), - ): [ - NewPane( - None, - None, - ), - ], - Alt( - Char( - 'o', - ), - ): [ - MoveTab( - Right, - ), - ], - Alt( - Direction( - Left, - ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Direction( - Right, - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Direction( - Up, - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Direction( - Down, - ), - ): [ - MoveFocus( - Down, - ), - ], - Ctrl( - 'b', - ): [ - SwitchToMode( - Tmux, - ), - ], - Ctrl( - 'g', - ): [ - SwitchToMode( - Locked, - ), - ], - Ctrl( - 'h', - ): [ - SwitchToMode( - Move, - ), - ], - Ctrl( - 'n', - ): [ - SwitchToMode( - Resize, - ), - ], - Ctrl( - 'o', - ): [ - SwitchToMode( - Session, - ), - ], - Ctrl( - 'p', - ): [ + KeyWithModifier { + bare_key: Esc, + key_modifiers: {}, + }: [ SwitchToMode( Normal, ), ], - Ctrl( - 'q', - ): [ - Quit, - ], - Ctrl( - 's', - ): [ - SwitchToMode( - Scroll, - ), - ], - Ctrl( - 't', - ): [ - SwitchToMode( - Tab, - ), - ], - Esc: [ + KeyWithModifier { + bare_key: Enter, + key_modifiers: {}, + }: [ SwitchToMode( Normal, ), ], }, Tab: { - Left: [ + KeyWithModifier { + bare_key: Left, + key_modifiers: {}, + }: [ GoToPreviousTab, ], - Down: [ - GoToNextTab, - ], - Up: [ - GoToPreviousTab, - ], - Right: [ - GoToNextTab, - ], - Char( - '\n', - ): [ - SwitchToMode( - Normal, + KeyWithModifier { + bare_key: Left, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, ), ], - Char( - '1', - ): [ + KeyWithModifier { + bare_key: Down, + key_modifiers: {}, + }: [ + GoToNextTab, + ], + KeyWithModifier { + bare_key: Down, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Up, + key_modifiers: {}, + }: [ + GoToPreviousTab, + ], + KeyWithModifier { + bare_key: Up, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Right, + key_modifiers: {}, + }: [ + GoToNextTab, + ], + KeyWithModifier { + bare_key: Right, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + '+', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Increase, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '-', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Decrease, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '1', + ), + key_modifiers: {}, + }: [ GoToTab( 1, ), @@ -967,9 +1408,12 @@ Config { Normal, ), ], - Char( - '2', - ): [ + KeyWithModifier { + bare_key: Char( + '2', + ), + key_modifiers: {}, + }: [ GoToTab( 2, ), @@ -977,9 +1421,12 @@ Config { Normal, ), ], - Char( - '3', - ): [ + KeyWithModifier { + bare_key: Char( + '3', + ), + key_modifiers: {}, + }: [ GoToTab( 3, ), @@ -987,9 +1434,12 @@ Config { Normal, ), ], - Char( - '4', - ): [ + KeyWithModifier { + bare_key: Char( + '4', + ), + key_modifiers: {}, + }: [ GoToTab( 4, ), @@ -997,9 +1447,12 @@ Config { Normal, ), ], - Char( - '5', - ): [ + KeyWithModifier { + bare_key: Char( + '5', + ), + key_modifiers: {}, + }: [ GoToTab( 5, ), @@ -1007,9 +1460,12 @@ Config { Normal, ), ], - Char( - '6', - ): [ + KeyWithModifier { + bare_key: Char( + '6', + ), + key_modifiers: {}, + }: [ GoToTab( 6, ), @@ -1017,9 +1473,12 @@ Config { Normal, ), ], - Char( - '7', - ): [ + KeyWithModifier { + bare_key: Char( + '7', + ), + key_modifiers: {}, + }: [ GoToTab( 7, ), @@ -1027,9 +1486,12 @@ Config { Normal, ), ], - Char( - '8', - ): [ + KeyWithModifier { + bare_key: Char( + '8', + ), + key_modifiers: {}, + }: [ GoToTab( 8, ), @@ -1037,9 +1499,12 @@ Config { Normal, ), ], - Char( - '9', - ): [ + KeyWithModifier { + bare_key: Char( + '9', + ), + key_modifiers: {}, + }: [ GoToTab( 9, ), @@ -1047,53 +1512,206 @@ Config { Normal, ), ], - Char( - '[', - ): [ + KeyWithModifier { + bare_key: Char( + '=', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Increase, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '[', + ), + key_modifiers: {}, + }: [ BreakPaneLeft, SwitchToMode( Normal, ), ], - Char( - ']', - ): [ + KeyWithModifier { + bare_key: Char( + '[', + ), + key_modifiers: { + Alt, + }, + }: [ + PreviousSwapLayout, + ], + KeyWithModifier { + bare_key: Char( + ']', + ), + key_modifiers: {}, + }: [ BreakPaneRight, SwitchToMode( Normal, ), ], - Char( - 'b', - ): [ + KeyWithModifier { + bare_key: Char( + ']', + ), + key_modifiers: { + Alt, + }, + }: [ + NextSwapLayout, + ], + KeyWithModifier { + bare_key: Char( + 'b', + ), + key_modifiers: {}, + }: [ BreakPane, SwitchToMode( Normal, ), ], - Char( - 'h', - ): [ + KeyWithModifier { + bare_key: Char( + 'b', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Tmux, + ), + ], + KeyWithModifier { + bare_key: Char( + 'g', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Locked, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: {}, + }: [ GoToPreviousTab, ], - Char( - 'j', - ): [ + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Move, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Char( + 'i', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Char( + 'j', + ), + key_modifiers: {}, + }: [ GoToNextTab, ], - Char( - 'k', - ): [ + KeyWithModifier { + bare_key: Char( + 'j', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Char( + 'k', + ), + key_modifiers: {}, + }: [ GoToPreviousTab, ], - Char( - 'l', - ): [ + KeyWithModifier { + bare_key: Char( + 'k', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Char( + 'l', + ), + key_modifiers: {}, + }: [ GoToNextTab, ], - Char( - 'n', - ): [ + KeyWithModifier { + bare_key: Char( + 'l', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: {}, + }: [ NewTab( None, [], @@ -1105,9 +1723,83 @@ Config { Normal, ), ], - Char( - 'r', - ): [ + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Resize, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Alt, + }, + }: [ + NewPane( + None, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Session, + ), + ], + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'p', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Pane, + ), + ], + KeyWithModifier { + bare_key: Char( + 'q', + ), + key_modifiers: { + Ctrl, + }, + }: [ + Quit, + ], + KeyWithModifier { + bare_key: Char( + 'r', + ), + key_modifiers: {}, + }: [ SwitchToMode( RenameTab, ), @@ -1117,298 +1809,456 @@ Config { ], ), ], - Char( - 's', - ): [ + KeyWithModifier { + bare_key: Char( + 's', + ), + key_modifiers: {}, + }: [ ToggleActiveSyncTab, SwitchToMode( Normal, ), ], - Char( - 'x', - ): [ + KeyWithModifier { + bare_key: Char( + 's', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Scroll, + ), + ], + KeyWithModifier { + bare_key: Char( + 't', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Char( + 'x', + ), + key_modifiers: {}, + }: [ CloseTab, SwitchToMode( Normal, ), ], - Alt( - Char( - '+', - ), - ): [ - Resize( - Increase, - None, - ), + KeyWithModifier { + bare_key: Tab, + key_modifiers: {}, + }: [ + ToggleTab, ], - Alt( - Char( - '-', - ), - ): [ - Resize( - Decrease, - None, - ), - ], - Alt( - Char( - '=', - ), - ): [ - Resize( - Increase, - None, - ), - ], - Alt( - Char( - '[', - ), - ): [ - PreviousSwapLayout, - ], - Alt( - Char( - ']', - ), - ): [ - NextSwapLayout, - ], - Alt( - Char( - 'h', - ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Char( - 'i', - ), - ): [ - MoveTab( - Left, - ), - ], - Alt( - Char( - 'j', - ), - ): [ - MoveFocus( - Down, - ), - ], - Alt( - Char( - 'k', - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Char( - 'l', - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Char( - 'n', - ), - ): [ - NewPane( - None, - None, - ), - ], - Alt( - Char( - 'o', - ), - ): [ - MoveTab( - Right, - ), - ], - Alt( - Direction( - Left, - ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Direction( - Right, - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Direction( - Up, - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Direction( - Down, - ), - ): [ - MoveFocus( - Down, - ), - ], - Ctrl( - 'b', - ): [ - SwitchToMode( - Tmux, - ), - ], - Ctrl( - 'g', - ): [ - SwitchToMode( - Locked, - ), - ], - Ctrl( - 'h', - ): [ - SwitchToMode( - Move, - ), - ], - Ctrl( - 'n', - ): [ - SwitchToMode( - Resize, - ), - ], - Ctrl( - 'o', - ): [ - SwitchToMode( - Session, - ), - ], - Ctrl( - 'p', - ): [ - SwitchToMode( - Pane, - ), - ], - Ctrl( - 'q', - ): [ - Quit, - ], - Ctrl( - 's', - ): [ - SwitchToMode( - Scroll, - ), - ], - Ctrl( - 't', - ): [ + KeyWithModifier { + bare_key: Esc, + key_modifiers: {}, + }: [ SwitchToMode( Normal, ), ], - BackTab: [ - ToggleTab, - ], - Esc: [ + KeyWithModifier { + bare_key: Enter, + key_modifiers: {}, + }: [ SwitchToMode( Normal, ), ], }, Scroll: { - PageDown: [ + KeyWithModifier { + bare_key: PageDown, + key_modifiers: {}, + }: [ PageScrollDown, ], - PageUp: [ + KeyWithModifier { + bare_key: PageUp, + key_modifiers: {}, + }: [ PageScrollUp, ], - Left: [ + KeyWithModifier { + bare_key: Left, + key_modifiers: {}, + }: [ PageScrollUp, ], - Down: [ + KeyWithModifier { + bare_key: Left, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Down, + key_modifiers: {}, + }: [ ScrollDown, ], - Up: [ + KeyWithModifier { + bare_key: Down, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Up, + key_modifiers: {}, + }: [ ScrollUp, ], - Right: [ + KeyWithModifier { + bare_key: Up, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Right, + key_modifiers: {}, + }: [ PageScrollDown, ], - Char( - '\n', - ): [ + KeyWithModifier { + bare_key: Right, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + '+', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Increase, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '-', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Decrease, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '=', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Increase, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '[', + ), + key_modifiers: { + Alt, + }, + }: [ + PreviousSwapLayout, + ], + KeyWithModifier { + bare_key: Char( + ']', + ), + key_modifiers: { + Alt, + }, + }: [ + NextSwapLayout, + ], + KeyWithModifier { + bare_key: Char( + 'b', + ), + key_modifiers: { + Ctrl, + }, + }: [ + PageScrollUp, + ], + KeyWithModifier { + bare_key: Char( + 'c', + ), + key_modifiers: { + Ctrl, + }, + }: [ + ScrollToBottom, SwitchToMode( Normal, ), ], - Char( - 'd', - ): [ + KeyWithModifier { + bare_key: Char( + 'd', + ), + key_modifiers: {}, + }: [ HalfPageScrollDown, ], - Char( - 'e', - ): [ + KeyWithModifier { + bare_key: Char( + 'e', + ), + key_modifiers: {}, + }: [ EditScrollback, SwitchToMode( Normal, ), ], - Char( - 'h', - ): [ - PageScrollUp, - ], - Char( - 'j', - ): [ - ScrollDown, - ], - Char( - 'k', - ): [ - ScrollUp, - ], - Char( - 'l', - ): [ + KeyWithModifier { + bare_key: Char( + 'f', + ), + key_modifiers: { + Ctrl, + }, + }: [ PageScrollDown, ], - Char( - 's', - ): [ + KeyWithModifier { + bare_key: Char( + 'g', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Locked, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: {}, + }: [ + PageScrollUp, + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Move, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Char( + 'i', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Char( + 'j', + ), + key_modifiers: {}, + }: [ + ScrollDown, + ], + KeyWithModifier { + bare_key: Char( + 'j', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Char( + 'k', + ), + key_modifiers: {}, + }: [ + ScrollUp, + ], + KeyWithModifier { + bare_key: Char( + 'k', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Char( + 'l', + ), + key_modifiers: {}, + }: [ + PageScrollDown, + ], + KeyWithModifier { + bare_key: Char( + 'l', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Resize, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Alt, + }, + }: [ + NewPane( + None, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Session, + ), + ], + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'p', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Pane, + ), + ], + KeyWithModifier { + bare_key: Char( + 'q', + ), + key_modifiers: { + Ctrl, + }, + }: [ + Quit, + ], + KeyWithModifier { + bare_key: Char( + 's', + ), + key_modifiers: {}, + }: [ SwitchToMode( EnterSearch, ), @@ -1418,1242 +2268,1785 @@ Config { ], ), ], - Char( - 'u', - ): [ - HalfPageScrollUp, - ], - Alt( - Char( - '+', + KeyWithModifier { + bare_key: Char( + 's', ), - ): [ - Resize( - Increase, - None, - ), - ], - Alt( - Char( - '-', - ), - ): [ - Resize( - Decrease, - None, - ), - ], - Alt( - Char( - '=', - ), - ): [ - Resize( - Increase, - None, - ), - ], - Alt( - Char( - '[', - ), - ): [ - PreviousSwapLayout, - ], - Alt( - Char( - ']', - ), - ): [ - NextSwapLayout, - ], - Alt( - Char( - 'h', - ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Char( - 'i', - ), - ): [ - MoveTab( - Left, - ), - ], - Alt( - Char( - 'j', - ), - ): [ - MoveFocus( - Down, - ), - ], - Alt( - Char( - 'k', - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Char( - 'l', - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Char( - 'n', - ), - ): [ - NewPane( - None, - None, - ), - ], - Alt( - Char( - 'o', - ), - ): [ - MoveTab( - Right, - ), - ], - Alt( - Direction( - Left, - ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Direction( - Right, - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Direction( - Up, - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Direction( - Down, - ), - ): [ - MoveFocus( - Down, - ), - ], - Ctrl( - 'b', - ): [ - PageScrollUp, - ], - Ctrl( - 'c', - ): [ - ScrollToBottom, + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Normal, ), ], - Ctrl( - 'f', - ): [ - PageScrollDown, - ], - Ctrl( - 'g', - ): [ - SwitchToMode( - Locked, + KeyWithModifier { + bare_key: Char( + 't', ), - ], - Ctrl( - 'h', - ): [ - SwitchToMode( - Move, - ), - ], - Ctrl( - 'n', - ): [ - SwitchToMode( - Resize, - ), - ], - Ctrl( - 'o', - ): [ - SwitchToMode( - Session, - ), - ], - Ctrl( - 'p', - ): [ - SwitchToMode( - Pane, - ), - ], - Ctrl( - 'q', - ): [ - Quit, - ], - Ctrl( - 's', - ): [ - SwitchToMode( - Normal, - ), - ], - Ctrl( - 't', - ): [ + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Tab, ), ], - Esc: [ + KeyWithModifier { + bare_key: Char( + 'u', + ), + key_modifiers: {}, + }: [ + HalfPageScrollUp, + ], + KeyWithModifier { + bare_key: Esc, + key_modifiers: {}, + }: [ + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Enter, + key_modifiers: {}, + }: [ SwitchToMode( Normal, ), ], }, EnterSearch: { - Char( - '\n', - ): [ - SwitchToMode( - Search, + KeyWithModifier { + bare_key: Left, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Down, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Up, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Right, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( '+', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Increase, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '-', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Decrease, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '=', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Increase, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '[', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ PreviousSwapLayout, ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( ']', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ NextSwapLayout, ], - Alt( - Char( - 'h', + KeyWithModifier { + bare_key: Char( + 'b', ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Char( - 'i', - ), - ): [ - MoveTab( - Left, - ), - ], - Alt( - Char( - 'j', - ), - ): [ - MoveFocus( - Down, - ), - ], - Alt( - Char( - 'k', - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Char( - 'l', - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Char( - 'n', - ), - ): [ - NewPane( - None, - None, - ), - ], - Alt( - Char( - 'o', - ), - ): [ - MoveTab( - Right, - ), - ], - Alt( - Direction( - Left, - ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Direction( - Right, - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Direction( - Up, - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Direction( - Down, - ), - ): [ - MoveFocus( - Down, - ), - ], - Ctrl( - 'b', - ): [ + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Tmux, ), ], - Ctrl( - 'c', - ): [ + KeyWithModifier { + bare_key: Char( + 'c', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Scroll, ), ], - Ctrl( - 'g', - ): [ + KeyWithModifier { + bare_key: Char( + 'g', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Locked, ), ], - Ctrl( - 'h', - ): [ + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Move, ), ], - Ctrl( - 'n', - ): [ - SwitchToMode( - Resize, - ), - ], - Ctrl( - 'o', - ): [ - SwitchToMode( - Session, - ), - ], - Ctrl( - 'p', - ): [ - SwitchToMode( - Pane, - ), - ], - Ctrl( - 'q', - ): [ - Quit, - ], - Ctrl( - 's', - ): [ - SwitchToMode( - Scroll, - ), - ], - Ctrl( - 't', - ): [ - SwitchToMode( - Tab, - ), - ], - Esc: [ - SwitchToMode( - Scroll, - ), - ], - }, - Search: { - PageDown: [ - PageScrollDown, - ], - PageUp: [ - PageScrollUp, - ], - Left: [ - PageScrollUp, - ], - Down: [ - ScrollDown, - ], - Up: [ - ScrollUp, - ], - Right: [ - PageScrollDown, - ], - Char( - '\n', - ): [ - SwitchToMode( - Normal, - ), - ], - Char( - 'c', - ): [ - SearchToggleOption( - CaseSensitivity, - ), - ], - Char( - 'd', - ): [ - HalfPageScrollDown, - ], - Char( - 'h', - ): [ - PageScrollUp, - ], - Char( - 'j', - ): [ - ScrollDown, - ], - Char( - 'k', - ): [ - ScrollUp, - ], - Char( - 'l', - ): [ - PageScrollDown, - ], - Char( - 'n', - ): [ - Search( - Down, - ), - ], - Char( - 'o', - ): [ - SearchToggleOption( - WholeWord, - ), - ], - Char( - 'p', - ): [ - Search( - Up, - ), - ], - Char( - 'u', - ): [ - HalfPageScrollUp, - ], - Char( - 'w', - ): [ - SearchToggleOption( - Wrap, - ), - ], - Alt( - Char( - '+', - ), - ): [ - Resize( - Increase, - None, - ), - ], - Alt( - Char( - '-', - ), - ): [ - Resize( - Decrease, - None, - ), - ], - Alt( - Char( - '=', - ), - ): [ - Resize( - Increase, - None, - ), - ], - Alt( - Char( - '[', - ), - ): [ - PreviousSwapLayout, - ], - Alt( - Char( - ']', - ), - ): [ - NextSwapLayout, - ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'h', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveFocusOrTab( Left, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'i', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveTab( Left, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'j', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveFocus( Down, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'k', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveFocus( Up, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'l', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveFocusOrTab( Right, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'n', ), - ): [ + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Resize, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Alt, + }, + }: [ NewPane( None, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'o', ), - ): [ + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Session, + ), + ], + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Alt, + }, + }: [ MoveTab( Right, ), ], - Alt( - Direction( - Left, + KeyWithModifier { + bare_key: Char( + 'p', ), - ): [ - MoveFocusOrTab( - Left, + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Pane, ), ], - Alt( - Direction( - Right, + KeyWithModifier { + bare_key: Char( + 'q', ), - ): [ - MoveFocusOrTab( - Right, + key_modifiers: { + Ctrl, + }, + }: [ + Quit, + ], + KeyWithModifier { + bare_key: Char( + 's', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Scroll, ), ], - Alt( - Direction( - Up, + KeyWithModifier { + bare_key: Char( + 't', ), - ): [ - MoveFocus( - Up, + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Tab, ), ], - Alt( - Direction( - Down, - ), - ): [ - MoveFocus( - Down, + KeyWithModifier { + bare_key: Esc, + key_modifiers: {}, + }: [ + SwitchToMode( + Scroll, ), ], - Ctrl( - 'b', - ): [ + KeyWithModifier { + bare_key: Enter, + key_modifiers: {}, + }: [ + SwitchToMode( + Search, + ), + ], + }, + Search: { + KeyWithModifier { + bare_key: PageDown, + key_modifiers: {}, + }: [ + PageScrollDown, + ], + KeyWithModifier { + bare_key: PageUp, + key_modifiers: {}, + }: [ PageScrollUp, ], - Ctrl( - 'c', - ): [ + KeyWithModifier { + bare_key: Left, + key_modifiers: {}, + }: [ + PageScrollUp, + ], + KeyWithModifier { + bare_key: Left, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Down, + key_modifiers: {}, + }: [ + ScrollDown, + ], + KeyWithModifier { + bare_key: Down, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Up, + key_modifiers: {}, + }: [ + ScrollUp, + ], + KeyWithModifier { + bare_key: Up, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Right, + key_modifiers: {}, + }: [ + PageScrollDown, + ], + KeyWithModifier { + bare_key: Right, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + '+', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Increase, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '-', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Decrease, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '=', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Increase, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '[', + ), + key_modifiers: { + Alt, + }, + }: [ + PreviousSwapLayout, + ], + KeyWithModifier { + bare_key: Char( + ']', + ), + key_modifiers: { + Alt, + }, + }: [ + NextSwapLayout, + ], + KeyWithModifier { + bare_key: Char( + 'b', + ), + key_modifiers: { + Ctrl, + }, + }: [ + PageScrollUp, + ], + KeyWithModifier { + bare_key: Char( + 'c', + ), + key_modifiers: {}, + }: [ + SearchToggleOption( + CaseSensitivity, + ), + ], + KeyWithModifier { + bare_key: Char( + 'c', + ), + key_modifiers: { + Ctrl, + }, + }: [ ScrollToBottom, SwitchToMode( Normal, ), ], - Ctrl( - 'f', - ): [ + KeyWithModifier { + bare_key: Char( + 'd', + ), + key_modifiers: {}, + }: [ + HalfPageScrollDown, + ], + KeyWithModifier { + bare_key: Char( + 'f', + ), + key_modifiers: { + Ctrl, + }, + }: [ PageScrollDown, ], - Ctrl( - 'g', - ): [ + KeyWithModifier { + bare_key: Char( + 'g', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Locked, ), ], - Ctrl( - 'h', - ): [ + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: {}, + }: [ + PageScrollUp, + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Move, ), ], - Ctrl( - 'n', - ): [ + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Char( + 'i', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Char( + 'j', + ), + key_modifiers: {}, + }: [ + ScrollDown, + ], + KeyWithModifier { + bare_key: Char( + 'j', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Char( + 'k', + ), + key_modifiers: {}, + }: [ + ScrollUp, + ], + KeyWithModifier { + bare_key: Char( + 'k', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Char( + 'l', + ), + key_modifiers: {}, + }: [ + PageScrollDown, + ], + KeyWithModifier { + bare_key: Char( + 'l', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: {}, + }: [ + Search( + Down, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Resize, ), ], - Ctrl( - 'o', - ): [ + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Alt, + }, + }: [ + NewPane( + None, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: {}, + }: [ + SearchToggleOption( + WholeWord, + ), + ], + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Session, ), ], - Ctrl( - 'p', - ): [ + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'p', + ), + key_modifiers: {}, + }: [ + Search( + Up, + ), + ], + KeyWithModifier { + bare_key: Char( + 'p', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Pane, ), ], - Ctrl( - 'q', - ): [ + KeyWithModifier { + bare_key: Char( + 'q', + ), + key_modifiers: { + Ctrl, + }, + }: [ Quit, ], - Ctrl( - 's', - ): [ + KeyWithModifier { + bare_key: Char( + 's', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Normal, ), ], - Ctrl( - 't', - ): [ + KeyWithModifier { + bare_key: Char( + 't', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Tab, ), ], - Esc: [ + KeyWithModifier { + bare_key: Char( + 'u', + ), + key_modifiers: {}, + }: [ + HalfPageScrollUp, + ], + KeyWithModifier { + bare_key: Char( + 'w', + ), + key_modifiers: {}, + }: [ + SearchToggleOption( + Wrap, + ), + ], + KeyWithModifier { + bare_key: Esc, + key_modifiers: {}, + }: [ + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Enter, + key_modifiers: {}, + }: [ SwitchToMode( Normal, ), ], }, RenameTab: { - Char( - '\n', - ): [ - SwitchToMode( - Normal, + KeyWithModifier { + bare_key: Left, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Down, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Up, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Right, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( '+', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Increase, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '-', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Decrease, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '=', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Increase, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '[', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ PreviousSwapLayout, ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( ']', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ NextSwapLayout, ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( + 'b', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Tmux, + ), + ], + KeyWithModifier { + bare_key: Char( + 'c', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Char( + 'g', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Locked, + ), + ], + KeyWithModifier { + bare_key: Char( 'h', ), - ): [ + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Move, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Alt, + }, + }: [ MoveFocusOrTab( Left, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'i', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveTab( Left, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'j', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveFocus( Down, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'k', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveFocus( Up, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'l', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveFocusOrTab( Right, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'n', ), - ): [ + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Resize, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Alt, + }, + }: [ NewPane( None, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'o', ), - ): [ - MoveTab( - Right, - ), - ], - Alt( - Direction( - Left, - ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Direction( - Right, - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Direction( - Up, - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Direction( - Down, - ), - ): [ - MoveFocus( - Down, - ), - ], - Ctrl( - 'b', - ): [ - SwitchToMode( - Tmux, - ), - ], - Ctrl( - 'c', - ): [ - SwitchToMode( - Normal, - ), - ], - Ctrl( - 'g', - ): [ - SwitchToMode( - Locked, - ), - ], - Ctrl( - 'h', - ): [ - SwitchToMode( - Move, - ), - ], - Ctrl( - 'n', - ): [ - SwitchToMode( - Resize, - ), - ], - Ctrl( - 'o', - ): [ + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Session, ), ], - Ctrl( - 'p', - ): [ + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'p', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Pane, ), ], - Ctrl( - 'q', - ): [ + KeyWithModifier { + bare_key: Char( + 'q', + ), + key_modifiers: { + Ctrl, + }, + }: [ Quit, ], - Ctrl( - 's', - ): [ + KeyWithModifier { + bare_key: Char( + 's', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Scroll, ), ], - Ctrl( - 't', - ): [ + KeyWithModifier { + bare_key: Char( + 't', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Tab, ), ], - Esc: [ + KeyWithModifier { + bare_key: Esc, + key_modifiers: {}, + }: [ UndoRenameTab, SwitchToMode( Tab, ), ], - }, - RenamePane: { - Char( - '\n', - ): [ + KeyWithModifier { + bare_key: Enter, + key_modifiers: {}, + }: [ SwitchToMode( Normal, ), ], - Alt( - Char( + }, + RenamePane: { + KeyWithModifier { + bare_key: Left, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Down, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Up, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Right, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( '+', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Increase, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '-', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Decrease, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '=', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Increase, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '[', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ PreviousSwapLayout, ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( ']', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ NextSwapLayout, ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( + 'b', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Tmux, + ), + ], + KeyWithModifier { + bare_key: Char( + 'c', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Char( + 'g', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Locked, + ), + ], + KeyWithModifier { + bare_key: Char( 'h', ), - ): [ + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Move, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Alt, + }, + }: [ MoveFocusOrTab( Left, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'i', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveTab( Left, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'j', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveFocus( Down, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'k', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveFocus( Up, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'l', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveFocusOrTab( Right, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'n', ), - ): [ + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Resize, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Alt, + }, + }: [ NewPane( None, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'o', ), - ): [ - MoveTab( - Right, - ), - ], - Alt( - Direction( - Left, - ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Direction( - Right, - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Direction( - Up, - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Direction( - Down, - ), - ): [ - MoveFocus( - Down, - ), - ], - Ctrl( - 'b', - ): [ - SwitchToMode( - Tmux, - ), - ], - Ctrl( - 'c', - ): [ - SwitchToMode( - Normal, - ), - ], - Ctrl( - 'g', - ): [ - SwitchToMode( - Locked, - ), - ], - Ctrl( - 'h', - ): [ - SwitchToMode( - Move, - ), - ], - Ctrl( - 'n', - ): [ - SwitchToMode( - Resize, - ), - ], - Ctrl( - 'o', - ): [ + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Session, ), ], - Ctrl( - 'p', - ): [ + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'p', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Pane, ), ], - Ctrl( - 'q', - ): [ + KeyWithModifier { + bare_key: Char( + 'q', + ), + key_modifiers: { + Ctrl, + }, + }: [ Quit, ], - Ctrl( - 's', - ): [ + KeyWithModifier { + bare_key: Char( + 's', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Scroll, ), ], - Ctrl( - 't', - ): [ + KeyWithModifier { + bare_key: Char( + 't', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Tab, ), ], - Esc: [ + KeyWithModifier { + bare_key: Esc, + key_modifiers: {}, + }: [ UndoRenamePane, SwitchToMode( Pane, ), ], - }, - Session: { - Char( - '\n', - ): [ + KeyWithModifier { + bare_key: Enter, + key_modifiers: {}, + }: [ SwitchToMode( Normal, ), ], - Char( - 'd', - ): [ + }, + Session: { + KeyWithModifier { + bare_key: Left, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Down, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Up, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Right, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + '+', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Increase, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '-', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Decrease, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '=', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Increase, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '[', + ), + key_modifiers: { + Alt, + }, + }: [ + PreviousSwapLayout, + ], + KeyWithModifier { + bare_key: Char( + ']', + ), + key_modifiers: { + Alt, + }, + }: [ + NextSwapLayout, + ], + KeyWithModifier { + bare_key: Char( + 'b', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Tmux, + ), + ], + KeyWithModifier { + bare_key: Char( + 'd', + ), + key_modifiers: {}, + }: [ Detach, ], - Char( - 'w', - ): [ + KeyWithModifier { + bare_key: Char( + 'g', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Locked, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Move, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Char( + 'i', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Char( + 'j', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Char( + 'k', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Char( + 'l', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Resize, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Alt, + }, + }: [ + NewPane( + None, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'p', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Pane, + ), + ], + KeyWithModifier { + bare_key: Char( + 'q', + ), + key_modifiers: { + Ctrl, + }, + }: [ + Quit, + ], + KeyWithModifier { + bare_key: Char( + 's', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Scroll, + ), + ], + KeyWithModifier { + bare_key: Char( + 't', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Tab, + ), + ], + KeyWithModifier { + bare_key: Char( + 'w', + ), + key_modifiers: {}, + }: [ LaunchOrFocusPlugin( Alias( PluginAlias { @@ -2676,738 +4069,758 @@ Config { Normal, ), ], - Alt( - Char( - '+', - ), - ): [ - Resize( - Increase, - None, - ), - ], - Alt( - Char( - '-', - ), - ): [ - Resize( - Decrease, - None, - ), - ], - Alt( - Char( - '=', - ), - ): [ - Resize( - Increase, - None, - ), - ], - Alt( - Char( - '[', - ), - ): [ - PreviousSwapLayout, - ], - Alt( - Char( - ']', - ), - ): [ - NextSwapLayout, - ], - Alt( - Char( - 'h', - ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Char( - 'i', - ), - ): [ - MoveTab( - Left, - ), - ], - Alt( - Char( - 'j', - ), - ): [ - MoveFocus( - Down, - ), - ], - Alt( - Char( - 'k', - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Char( - 'l', - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Char( - 'n', - ), - ): [ - NewPane( - None, - None, - ), - ], - Alt( - Char( - 'o', - ), - ): [ - MoveTab( - Right, - ), - ], - Alt( - Direction( - Left, - ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Direction( - Right, - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Direction( - Up, - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Direction( - Down, - ), - ): [ - MoveFocus( - Down, - ), - ], - Ctrl( - 'b', - ): [ - SwitchToMode( - Tmux, - ), - ], - Ctrl( - 'g', - ): [ - SwitchToMode( - Locked, - ), - ], - Ctrl( - 'h', - ): [ - SwitchToMode( - Move, - ), - ], - Ctrl( - 'n', - ): [ - SwitchToMode( - Resize, - ), - ], - Ctrl( - 'o', - ): [ + KeyWithModifier { + bare_key: Esc, + key_modifiers: {}, + }: [ SwitchToMode( Normal, ), ], - Ctrl( - 'p', - ): [ - SwitchToMode( - Pane, - ), - ], - Ctrl( - 'q', - ): [ - Quit, - ], - Ctrl( - 's', - ): [ - SwitchToMode( - Scroll, - ), - ], - Ctrl( - 't', - ): [ - SwitchToMode( - Tab, - ), - ], - Esc: [ + KeyWithModifier { + bare_key: Enter, + key_modifiers: {}, + }: [ SwitchToMode( Normal, ), ], }, Move: { - Left: [ + KeyWithModifier { + bare_key: Left, + key_modifiers: {}, + }: [ MovePane( Some( Left, ), ), ], - Down: [ + KeyWithModifier { + bare_key: Left, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Down, + key_modifiers: {}, + }: [ MovePane( Some( Down, ), ), ], - Up: [ + KeyWithModifier { + bare_key: Down, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Up, + key_modifiers: {}, + }: [ MovePane( Some( Up, ), ), ], - Right: [ + KeyWithModifier { + bare_key: Up, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Right, + key_modifiers: {}, + }: [ MovePane( Some( Right, ), ), ], - Char( - '\n', - ): [ - SwitchToMode( - Normal, + KeyWithModifier { + bare_key: Right, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, ), ], - Char( - 'h', - ): [ - MovePane( - Some( - Left, - ), - ), - ], - Char( - 'j', - ): [ - MovePane( - Some( - Down, - ), - ), - ], - Char( - 'k', - ): [ - MovePane( - Some( - Up, - ), - ), - ], - Char( - 'l', - ): [ - MovePane( - Some( - Right, - ), - ), - ], - Char( - 'n', - ): [ - MovePane( - None, - ), - ], - Char( - 'p', - ): [ - MovePaneBackwards, - ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '+', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Increase, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '-', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Decrease, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '=', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Increase, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '[', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ PreviousSwapLayout, ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( ']', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ NextSwapLayout, ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( + 'b', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Tmux, + ), + ], + KeyWithModifier { + bare_key: Char( + 'g', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Locked, + ), + ], + KeyWithModifier { + bare_key: Char( 'h', ), - ): [ + key_modifiers: {}, + }: [ + MovePane( + Some( + Left, + ), + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Alt, + }, + }: [ MoveFocusOrTab( Left, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'i', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveTab( Left, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'j', ), - ): [ + key_modifiers: {}, + }: [ + MovePane( + Some( + Down, + ), + ), + ], + KeyWithModifier { + bare_key: Char( + 'j', + ), + key_modifiers: { + Alt, + }, + }: [ MoveFocus( Down, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'k', ), - ): [ + key_modifiers: {}, + }: [ + MovePane( + Some( + Up, + ), + ), + ], + KeyWithModifier { + bare_key: Char( + 'k', + ), + key_modifiers: { + Alt, + }, + }: [ MoveFocus( Up, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'l', ), - ): [ + key_modifiers: {}, + }: [ + MovePane( + Some( + Right, + ), + ), + ], + KeyWithModifier { + bare_key: Char( + 'l', + ), + key_modifiers: { + Alt, + }, + }: [ MoveFocusOrTab( Right, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'n', ), - ): [ + key_modifiers: {}, + }: [ + MovePane( + None, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Resize, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Alt, + }, + }: [ NewPane( None, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'o', ), - ): [ - MoveTab( - Right, - ), - ], - Alt( - Direction( - Left, - ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Direction( - Right, - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Direction( - Up, - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Direction( - Down, - ), - ): [ - MoveFocus( - Down, - ), - ], - Ctrl( - 'b', - ): [ - SwitchToMode( - Tmux, - ), - ], - Ctrl( - 'g', - ): [ - SwitchToMode( - Locked, - ), - ], - Ctrl( - 'h', - ): [ - SwitchToMode( - Normal, - ), - ], - Ctrl( - 'n', - ): [ - SwitchToMode( - Resize, - ), - ], - Ctrl( - 'o', - ): [ + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Session, ), ], - Ctrl( - 'p', - ): [ + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'p', + ), + key_modifiers: {}, + }: [ + MovePaneBackwards, + ], + KeyWithModifier { + bare_key: Char( + 'p', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Pane, ), ], - Ctrl( - 'q', - ): [ + KeyWithModifier { + bare_key: Char( + 'q', + ), + key_modifiers: { + Ctrl, + }, + }: [ Quit, ], - Ctrl( - 's', - ): [ + KeyWithModifier { + bare_key: Char( + 's', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Scroll, ), ], - Ctrl( - 't', - ): [ + KeyWithModifier { + bare_key: Char( + 't', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Tab, ), ], - BackTab: [ + KeyWithModifier { + bare_key: Tab, + key_modifiers: {}, + }: [ MovePane( None, ), ], - Esc: [ + KeyWithModifier { + bare_key: Esc, + key_modifiers: {}, + }: [ + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Enter, + key_modifiers: {}, + }: [ SwitchToMode( Normal, ), ], }, Prompt: { - Char( - '\n', - ): [ - SwitchToMode( - Normal, + KeyWithModifier { + bare_key: Left, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Down, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Up, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Right, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( '+', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Increase, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '-', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Decrease, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '=', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ Resize( Increase, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( '[', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ PreviousSwapLayout, ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( ']', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ NextSwapLayout, ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( + 'b', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Tmux, + ), + ], + KeyWithModifier { + bare_key: Char( + 'g', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Locked, + ), + ], + KeyWithModifier { + bare_key: Char( 'h', ), - ): [ + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Move, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Alt, + }, + }: [ MoveFocusOrTab( Left, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'i', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveTab( Left, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'j', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveFocus( Down, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'k', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveFocus( Up, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'l', ), - ): [ + key_modifiers: { + Alt, + }, + }: [ MoveFocusOrTab( Right, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'n', ), - ): [ + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Resize, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Alt, + }, + }: [ NewPane( None, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'o', ), - ): [ - MoveTab( - Right, - ), - ], - Alt( - Direction( - Left, - ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Direction( - Right, - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Direction( - Up, - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Direction( - Down, - ), - ): [ - MoveFocus( - Down, - ), - ], - Ctrl( - 'b', - ): [ - SwitchToMode( - Tmux, - ), - ], - Ctrl( - 'g', - ): [ - SwitchToMode( - Locked, - ), - ], - Ctrl( - 'h', - ): [ - SwitchToMode( - Move, - ), - ], - Ctrl( - 'n', - ): [ - SwitchToMode( - Resize, - ), - ], - Ctrl( - 'o', - ): [ + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Session, ), ], - Ctrl( - 'p', - ): [ + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'p', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Pane, ), ], - Ctrl( - 'q', - ): [ + KeyWithModifier { + bare_key: Char( + 'q', + ), + key_modifiers: { + Ctrl, + }, + }: [ Quit, ], - Ctrl( - 's', - ): [ + KeyWithModifier { + bare_key: Char( + 's', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Scroll, ), ], - Ctrl( - 't', - ): [ + KeyWithModifier { + bare_key: Char( + 't', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Tab, ), ], - Esc: [ + KeyWithModifier { + bare_key: Esc, + key_modifiers: {}, + }: [ + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Enter, + key_modifiers: {}, + }: [ SwitchToMode( Normal, ), ], }, Tmux: { - Left: [ + KeyWithModifier { + bare_key: Left, + key_modifiers: {}, + }: [ MoveFocus( Left, ), @@ -3415,7 +4828,20 @@ Config { Normal, ), ], - Down: [ + KeyWithModifier { + bare_key: Left, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Down, + key_modifiers: {}, + }: [ MoveFocus( Down, ), @@ -3423,7 +4849,20 @@ Config { Normal, ), ], - Up: [ + KeyWithModifier { + bare_key: Down, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Up, + key_modifiers: {}, + }: [ MoveFocus( Up, ), @@ -3431,7 +4870,20 @@ Config { Normal, ), ], - Right: [ + KeyWithModifier { + bare_key: Up, + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Right, + key_modifiers: {}, + }: [ MoveFocus( Right, ), @@ -3439,21 +4891,30 @@ Config { Normal, ), ], - Char( - '\n', - ): [ - SwitchToMode( - Normal, + KeyWithModifier { + bare_key: Right, + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, ), ], - Char( - ' ', - ): [ + KeyWithModifier { + bare_key: Char( + ' ', + ), + key_modifiers: {}, + }: [ NextSwapLayout, ], - Char( - '"', - ): [ + KeyWithModifier { + bare_key: Char( + '"', + ), + key_modifiers: {}, + }: [ NewPane( Some( Down, @@ -3464,9 +4925,12 @@ Config { Normal, ), ], - Char( - '%', - ): [ + KeyWithModifier { + bare_key: Char( + '%', + ), + key_modifiers: {}, + }: [ NewPane( Some( Right, @@ -3477,23 +4941,110 @@ Config { Normal, ), ], - Char( - ',', - ): [ + KeyWithModifier { + bare_key: Char( + '+', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Increase, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + ',', + ), + key_modifiers: {}, + }: [ SwitchToMode( RenameTab, ), ], - Char( - '[', - ): [ + KeyWithModifier { + bare_key: Char( + '-', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Decrease, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '=', + ), + key_modifiers: { + Alt, + }, + }: [ + Resize( + Increase, + None, + ), + ], + KeyWithModifier { + bare_key: Char( + '[', + ), + key_modifiers: {}, + }: [ SwitchToMode( Scroll, ), ], - Char( - 'c', - ): [ + KeyWithModifier { + bare_key: Char( + '[', + ), + key_modifiers: { + Alt, + }, + }: [ + PreviousSwapLayout, + ], + KeyWithModifier { + bare_key: Char( + ']', + ), + key_modifiers: { + Alt, + }, + }: [ + NextSwapLayout, + ], + KeyWithModifier { + bare_key: Char( + 'b', + ), + key_modifiers: { + Ctrl, + }, + }: [ + Write( + None, + [ + 2, + ], + false, + ), + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Char( + 'c', + ), + key_modifiers: {}, + }: [ NewTab( None, [], @@ -3505,14 +5056,32 @@ Config { Normal, ), ], - Char( - 'd', - ): [ + KeyWithModifier { + bare_key: Char( + 'd', + ), + key_modifiers: {}, + }: [ Detach, ], - Char( - 'h', - ): [ + KeyWithModifier { + bare_key: Char( + 'g', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Locked, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: {}, + }: [ MoveFocus( Left, ), @@ -3520,9 +5089,48 @@ Config { Normal, ), ], - Char( - 'j', - ): [ + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Move, + ), + ], + KeyWithModifier { + bare_key: Char( + 'h', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Char( + 'i', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Left, + ), + ], + KeyWithModifier { + bare_key: Char( + 'j', + ), + key_modifiers: {}, + }: [ MoveFocus( Down, ), @@ -3530,9 +5138,24 @@ Config { Normal, ), ], - Char( - 'k', - ): [ + KeyWithModifier { + bare_key: Char( + 'j', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Down, + ), + ], + KeyWithModifier { + bare_key: Char( + 'k', + ), + key_modifiers: {}, + }: [ MoveFocus( Up, ), @@ -3540,9 +5163,24 @@ Config { Normal, ), ], - Char( - 'l', - ): [ + KeyWithModifier { + bare_key: Char( + 'k', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocus( + Up, + ), + ], + KeyWithModifier { + bare_key: Char( + 'l', + ), + key_modifiers: {}, + }: [ MoveFocus( Right, ), @@ -3550,254 +5188,177 @@ Config { Normal, ), ], - Char( - 'n', - ): [ + KeyWithModifier { + bare_key: Char( + 'l', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveFocusOrTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: {}, + }: [ GoToNextTab, SwitchToMode( Normal, ), ], - Char( - 'o', - ): [ - FocusNextPane, - ], - Char( - 'p', - ): [ - GoToPreviousTab, - SwitchToMode( - Normal, - ), - ], - Char( - 'x', - ): [ - CloseFocus, - SwitchToMode( - Normal, - ), - ], - Char( - 'z', - ): [ - ToggleFocusFullscreen, - SwitchToMode( - Normal, - ), - ], - Alt( - Char( - '+', - ), - ): [ - Resize( - Increase, - None, - ), - ], - Alt( - Char( - '-', - ), - ): [ - Resize( - Decrease, - None, - ), - ], - Alt( - Char( - '=', - ), - ): [ - Resize( - Increase, - None, - ), - ], - Alt( - Char( - '[', - ), - ): [ - PreviousSwapLayout, - ], - Alt( - Char( - ']', - ), - ): [ - NextSwapLayout, - ], - Alt( - Char( - 'h', - ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Char( - 'i', - ), - ): [ - MoveTab( - Left, - ), - ], - Alt( - Char( - 'j', - ), - ): [ - MoveFocus( - Down, - ), - ], - Alt( - Char( - 'k', - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Char( - 'l', - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'n', ), - ): [ + key_modifiers: { + Ctrl, + }, + }: [ + SwitchToMode( + Resize, + ), + ], + KeyWithModifier { + bare_key: Char( + 'n', + ), + key_modifiers: { + Alt, + }, + }: [ NewPane( None, None, ), ], - Alt( - Char( + KeyWithModifier { + bare_key: Char( 'o', ), - ): [ - MoveTab( - Right, - ), + key_modifiers: {}, + }: [ + FocusNextPane, ], - Alt( - Direction( - Left, + KeyWithModifier { + bare_key: Char( + 'o', ), - ): [ - MoveFocusOrTab( - Left, - ), - ], - Alt( - Direction( - Right, - ), - ): [ - MoveFocusOrTab( - Right, - ), - ], - Alt( - Direction( - Up, - ), - ): [ - MoveFocus( - Up, - ), - ], - Alt( - Direction( - Down, - ), - ): [ - MoveFocus( - Down, - ), - ], - Ctrl( - 'b', - ): [ - Write( - [ - 2, - ], - ), - SwitchToMode( - Normal, - ), - ], - Ctrl( - 'g', - ): [ - SwitchToMode( - Locked, - ), - ], - Ctrl( - 'h', - ): [ - SwitchToMode( - Move, - ), - ], - Ctrl( - 'n', - ): [ - SwitchToMode( - Resize, - ), - ], - Ctrl( - 'o', - ): [ + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Session, ), ], - Ctrl( - 'p', - ): [ + KeyWithModifier { + bare_key: Char( + 'o', + ), + key_modifiers: { + Alt, + }, + }: [ + MoveTab( + Right, + ), + ], + KeyWithModifier { + bare_key: Char( + 'p', + ), + key_modifiers: {}, + }: [ + GoToPreviousTab, + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Char( + 'p', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Pane, ), ], - Ctrl( - 'q', - ): [ + KeyWithModifier { + bare_key: Char( + 'q', + ), + key_modifiers: { + Ctrl, + }, + }: [ Quit, ], - Ctrl( - 's', - ): [ + KeyWithModifier { + bare_key: Char( + 's', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Scroll, ), ], - Ctrl( - 't', - ): [ + KeyWithModifier { + bare_key: Char( + 't', + ), + key_modifiers: { + Ctrl, + }, + }: [ SwitchToMode( Tab, ), ], - Esc: [ + KeyWithModifier { + bare_key: Char( + 'x', + ), + key_modifiers: {}, + }: [ + CloseFocus, + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Char( + 'z', + ), + key_modifiers: {}, + }: [ + ToggleFocusFullscreen, + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Esc, + key_modifiers: {}, + }: [ + SwitchToMode( + Normal, + ), + ], + KeyWithModifier { + bare_key: Enter, + key_modifiers: {}, + }: [ SwitchToMode( Normal, ), @@ -3831,6 +5392,7 @@ Config { styled_underlines: None, serialization_interval: None, disable_session_metadata: None, + support_kitty_keyboard_protocol: None, }, themes: {}, plugins: PluginAliases {