From 67d2673cae60954e8287c2a1f58a21a56e066afb Mon Sep 17 00:00:00 2001 From: a-kenji Date: Fri, 10 Jun 2022 20:03:13 +0200 Subject: [PATCH] add(style): add trailing comma in match blocks (#1483) This makes it easier to distinguish from normal blocks --- .rustfmt.toml | 1 + default-plugins/compact-bar/src/main.rs | 16 +- default-plugins/status-bar/src/first_line.rs | 8 +- default-plugins/status-bar/src/main.rs | 18 +- default-plugins/status-bar/src/second_line.rs | 8 +- default-plugins/status-bar/src/tip/cache.rs | 6 +- default-plugins/strider/src/main.rs | 20 +- default-plugins/strider/src/state.rs | 2 +- default-plugins/tab-bar/src/main.rs | 16 +- src/commands.rs | 32 +-- src/sessions.rs | 26 +-- src/tests/e2e/remote_runner.rs | 6 +- zellij-client/src/input_handler.rs | 46 ++--- zellij-client/src/lib.rs | 22 +- zellij-client/src/os_input_output.rs | 10 +- zellij-client/src/stdin_ansi_parser.rs | 18 +- zellij-server/src/lib.rs | 24 +-- zellij-server/src/os_input_output.rs | 8 +- zellij-server/src/output/mod.rs | 6 +- zellij-server/src/panes/floating_panes/mod.rs | 28 +-- zellij-server/src/panes/grid.rs | 192 +++++++++--------- zellij-server/src/panes/link_handler.rs | 4 +- zellij-server/src/panes/plugin_pane.rs | 6 +- zellij-server/src/panes/terminal_character.rs | 112 +++++----- zellij-server/src/panes/terminal_pane.rs | 26 +-- zellij-server/src/panes/tiled_panes/mod.rs | 20 +- .../src/panes/tiled_panes/tiled_pane_grid.rs | 4 +- zellij-server/src/pty.rs | 38 ++-- zellij-server/src/pty_writer.rs | 4 +- zellij-server/src/route.rs | 134 ++++++------ zellij-server/src/screen.rs | 176 ++++++++-------- zellij-server/src/tab/clipboard.rs | 4 +- zellij-server/src/tab/mod.rs | 28 +-- zellij-server/src/ui/boundaries.rs | 68 +++---- zellij-server/src/ui/pane_boundaries_frame.rs | 14 +- zellij-server/src/ui/pane_contents_and_ui.rs | 2 +- zellij-server/src/wasm_vm.rs | 16 +- zellij-utils/src/input/config.rs | 4 +- zellij-utils/src/input/keybinds.rs | 12 +- zellij-utils/src/input/layout.rs | 22 +- zellij-utils/src/input/mod.rs | 10 +- zellij-utils/src/input/plugins.rs | 4 +- zellij-utils/src/ipc.rs | 2 +- zellij-utils/src/setup.rs | 28 +-- zellij-utils/src/shared.rs | 2 +- 45 files changed, 627 insertions(+), 626 deletions(-) create mode 100644 .rustfmt.toml diff --git a/.rustfmt.toml b/.rustfmt.toml new file mode 100644 index 000000000..8c795ae5d --- /dev/null +++ b/.rustfmt.toml @@ -0,0 +1 @@ +match_block_trailing_comma = true diff --git a/default-plugins/compact-bar/src/main.rs b/default-plugins/compact-bar/src/main.rs index 3e875a269..cf85d5d9b 100644 --- a/default-plugins/compact-bar/src/main.rs +++ b/default-plugins/compact-bar/src/main.rs @@ -49,23 +49,23 @@ impl ZellijPlugin for State { } else { eprintln!("Could not find active tab."); } - } + }, Event::Mouse(me) => match me { Mouse::LeftClick(_, col) => { self.mouse_click_pos = col; self.should_render = true; - } + }, Mouse::ScrollUp(_) => { switch_tab_to(min(self.active_tab_idx + 1, self.tabs.len()) as u32); - } + }, Mouse::ScrollDown(_) => { switch_tab_to(max(self.active_tab_idx.saturating_sub(1), 1) as u32); - } - _ => {} + }, + _ => {}, }, _ => { eprintln!("Got unrecognized event: {:?}", event); - } + }, } } @@ -130,10 +130,10 @@ impl ZellijPlugin for State { match background { PaletteColor::Rgb((r, g, b)) => { println!("{}\u{1b}[48;2;{};{};{}m\u{1b}[0K", s, r, g, b); - } + }, PaletteColor::EightBit(color) => { println!("{}\u{1b}[48;5;{}m\u{1b}[0K", s, color); - } + }, } self.should_render = false; } diff --git a/default-plugins/status-bar/src/first_line.rs b/default-plugins/status-bar/src/first_line.rs index dc7b95ecc..a4fa91b86 100644 --- a/default-plugins/status-bar/src/first_line.rs +++ b/default-plugins/status-bar/src/first_line.rs @@ -261,16 +261,16 @@ fn single_letter_ctrl_key( match key.mode { CtrlKeyMode::Unselected => { unselected_mode_shortcut_single_letter(letter_shortcut, palette, separator) - } + }, CtrlKeyMode::UnselectedAlternate => { unselected_alternate_mode_shortcut_single_letter(letter_shortcut, palette, separator) - } + }, CtrlKeyMode::Selected => { selected_mode_shortcut_single_letter(letter_shortcut, palette, separator) - } + }, CtrlKeyMode::Disabled => { disabled_mode_shortcut(&format!(" {}", letter_shortcut), palette, separator) - } + }, } } diff --git a/default-plugins/status-bar/src/main.rs b/default-plugins/status-bar/src/main.rs index 4a53fed8a..23ee3de76 100644 --- a/default-plugins/status-bar/src/main.rs +++ b/default-plugins/status-bar/src/main.rs @@ -237,21 +237,21 @@ impl ZellijPlugin for State { match event { Event::ModeUpdate(mode_info) => { self.mode_info = mode_info; - } + }, Event::TabUpdate(tabs) => { self.tabs = tabs; - } + }, Event::CopyToClipboard(copy_destination) => { self.text_copy_destination = Some(copy_destination); - } + }, Event::SystemClipboardFailure => { self.display_system_clipboard_failure = true; - } + }, Event::InputReceived => { self.text_copy_destination = None; self.display_system_clipboard_failure = false; - } - _ => {} + }, + _ => {}, } } @@ -284,10 +284,10 @@ impl ZellijPlugin for State { match background { PaletteColor::Rgb((r, g, b)) => { println!("{}\u{1b}[48;2;{};{};{}m\u{1b}[0K", first_line, r, g, b); - } + }, PaletteColor::EightBit(color) => { println!("{}\u{1b}[48;5;{}m\u{1b}[0K", first_line, color); - } + }, } println!("\u{1b}[m{}\u{1b}[0K", second_line); } @@ -319,7 +319,7 @@ impl State { InputMode::Normal => floating_panes_are_visible(&self.mode_info.style.colors), InputMode::Locked => { locked_floating_panes_are_visible(&self.mode_info.style.colors) - } + }, _ => keybinds(&self.mode_info, &self.tip_name, cols), } } else { diff --git a/default-plugins/status-bar/src/second_line.rs b/default-plugins/status-bar/src/second_line.rs index 9b6540336..56a71e4b5 100644 --- a/default-plugins/status-bar/src/second_line.rs +++ b/default-plugins/status-bar/src/second_line.rs @@ -224,7 +224,7 @@ fn shortened_shortcut_list(help: &ModeInfo, tip: TipFn) -> LinePart { InputMode::Tmux => short_tmux_mode_indication(help), InputMode::RenamePane => { shortened_shortcut_list_nonstandard_mode(select_pane_shortcut)(help) - } + }, _ => shortened_shortcut_list_nonstandard_mode(confirm_pane_selection)(help), } } @@ -279,7 +279,7 @@ fn best_effort_shortcut_list(help: &ModeInfo, tip: TipFn, max_len: usize) -> Lin } else { LinePart::default() } - } + }, InputMode::Locked => { let line_part = locked_interface_indication(help.style.colors); if line_part.len <= max_len { @@ -287,11 +287,11 @@ fn best_effort_shortcut_list(help: &ModeInfo, tip: TipFn, max_len: usize) -> Lin } else { LinePart::default() } - } + }, InputMode::Tmux => best_effort_tmux_shortcut_list(help, max_len), InputMode::RenamePane => { best_effort_shortcut_list_nonstandard_mode(select_pane_shortcut)(help, max_len) - } + }, _ => best_effort_shortcut_list_nonstandard_mode(confirm_pane_selection)(help, max_len), } } diff --git a/default-plugins/status-bar/src/tip/cache.rs b/default-plugins/status-bar/src/tip/cache.rs index dece82437..e62e658d9 100644 --- a/default-plugins/status-bar/src/tip/cache.rs +++ b/default-plugins/status-bar/src/tip/cache.rs @@ -47,7 +47,7 @@ impl LocalCache { }); } Err(LocalCacheError::Serde(err)) - } + }, } } @@ -64,7 +64,7 @@ impl LocalCache { let metadata = LocalCache::from_json(&json_cache)?; Ok(LocalCache { path, metadata }) - } + }, Err(e) => Err(LocalCacheError::IoPath(e, path)), } } @@ -77,7 +77,7 @@ impl LocalCache { file.write_all(json_cache.as_bytes()) .map_err(LocalCacheError::Io)?; Ok(()) - } + }, Err(e) => Err(LocalCacheError::Serde(e)), } } diff --git a/default-plugins/strider/src/main.rs b/default-plugins/strider/src/main.rs index 4ce0b0434..22ca1c614 100644 --- a/default-plugins/strider/src/main.rs +++ b/default-plugins/strider/src/main.rs @@ -24,15 +24,15 @@ impl ZellijPlugin for State { Event::Key(key) => match key { Key::Up | Key::Char('k') => { *self.selected_mut() = self.selected().saturating_sub(1); - } + }, Key::Down | Key::Char('j') => { let next = self.selected().saturating_add(1); *self.selected_mut() = min(self.files.len().saturating_sub(1), next); - } + }, Key::Right | Key::Char('\n') | Key::Char('l') if !self.files.is_empty() => { self.traverse_dir_or_open_file(); self.ev_history.clear(); - } + }, Key::Left | Key::Char('h') => { if self.path.components().count() > 2 { // don't descend into /host @@ -42,11 +42,11 @@ impl ZellijPlugin for State { self.path.pop(); refresh_directory(self); } - } + }, Key::Char('.') => { self.toggle_hidden_files(); refresh_directory(self); - } + }, _ => (), }, @@ -54,10 +54,10 @@ impl ZellijPlugin for State { Mouse::ScrollDown(_) => { let next = self.selected().saturating_add(1); *self.selected_mut() = min(self.files.len().saturating_sub(1), next); - } + }, Mouse::ScrollUp(_) => { *self.selected_mut() = self.selected().saturating_sub(1); - } + }, Mouse::Release(line, _) => { if line < 0 { return; @@ -75,12 +75,12 @@ impl ZellijPlugin for State { if should_select && self.scroll() + (line as usize) < self.files.len() { *self.selected_mut() = self.scroll() + (line as usize); } - } - _ => {} + }, + _ => {}, }, _ => { dbg!("Unknown event {:?}", event); - } + }, } } diff --git a/default-plugins/strider/src/state.rs b/default-plugins/strider/src/state.rs index 81d44a61d..05ede0df7 100644 --- a/default-plugins/strider/src/state.rs +++ b/default-plugins/strider/src/state.rs @@ -39,7 +39,7 @@ impl State { FsEntry::Dir(p, _) => { self.path = p; refresh_directory(self); - } + }, FsEntry::File(p, _) => open_file(p.strip_prefix(ROOT).unwrap()), } } diff --git a/default-plugins/tab-bar/src/main.rs b/default-plugins/tab-bar/src/main.rs index a6647fcef..b11ab87c2 100644 --- a/default-plugins/tab-bar/src/main.rs +++ b/default-plugins/tab-bar/src/main.rs @@ -49,23 +49,23 @@ impl ZellijPlugin for State { } else { eprintln!("Could not find active tab."); } - } + }, Event::Mouse(me) => match me { Mouse::LeftClick(_, col) => { self.mouse_click_pos = col; self.should_render = true; - } + }, Mouse::ScrollUp(_) => { switch_tab_to(min(self.active_tab_idx + 1, self.tabs.len()) as u32); - } + }, Mouse::ScrollDown(_) => { switch_tab_to(max(self.active_tab_idx.saturating_sub(1), 1) as u32); - } - _ => {} + }, + _ => {}, }, _ => { eprintln!("Got unrecognized event: {:?}", event); - } + }, } } @@ -129,10 +129,10 @@ impl ZellijPlugin for State { match background { PaletteColor::Rgb((r, g, b)) => { println!("{}\u{1b}[48;2;{};{};{}m\u{1b}[0K", s, r, g, b); - } + }, PaletteColor::EightBit(color) => { println!("{}\u{1b}[48;5;{}m\u{1b}[0K", s, color); - } + }, } self.should_render = false; } diff --git a/src/commands.rs b/src/commands.rs index a2311dc77..f92ba8b43 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -27,7 +27,7 @@ pub(crate) fn kill_all_sessions(yes: bool) { Ok(sessions) if sessions.is_empty() => { eprintln!("No active zellij sessions found."); process::exit(1); - } + }, Ok(sessions) => { if !yes { println!("WARNING: this action will kill all sessions."); @@ -44,11 +44,11 @@ pub(crate) fn kill_all_sessions(yes: bool) { kill_session_impl(session); } process::exit(0); - } + }, Err(e) => { eprintln!("Error occurred: {:?}", e); process::exit(1); - } + }, } } @@ -58,11 +58,11 @@ pub(crate) fn kill_session(target_session: &Option) { assert_session(target_session); kill_session_impl(target_session); process::exit(0); - } + }, None => { println!("Please specify the session name to kill."); process::exit(1); - } + }, } } @@ -74,7 +74,7 @@ fn get_os_input( Err(e) => { eprintln!("failed to open terminal:\n{}", e); process::exit(1); - } + }, } } @@ -108,7 +108,7 @@ fn find_indexed_session( ); print_sessions_with_index(sessions); process::exit(1); - } + }, } } @@ -122,12 +122,12 @@ fn attach_with_session_index(config_options: Options, index: usize, create: bool eprintln!("No active zellij sessions found."); process::exit(1); } - } + }, Ok(sessions) => find_indexed_session(sessions, config_options, index, create), Err(e) => { eprintln!("Error occurred: {:?}", e); process::exit(1); - } + }, } } @@ -143,11 +143,11 @@ fn attach_with_session_name( } else { ClientInfo::Attach(session_name.unwrap(), config_options) } - } + }, Some(prefix) => match match_session_name(prefix).unwrap() { SessionNameMatch::UniquePrefix(s) | SessionNameMatch::Exact(s) => { ClientInfo::Attach(s, config_options) - } + }, SessionNameMatch::AmbiguousPrefix(sessions) => { println!( "Ambiguous selection: multiple sessions names start with '{}':", @@ -155,24 +155,24 @@ fn attach_with_session_name( ); print_sessions(sessions); process::exit(1); - } + }, SessionNameMatch::None => { eprintln!("No session with the name '{}' found!", prefix); process::exit(1); - } + }, }, None => match get_active_session() { ActiveSession::None if create => create_new_client(), ActiveSession::None => { eprintln!("No active zellij sessions found."); process::exit(1); - } + }, ActiveSession::One(session_name) => ClientInfo::Attach(session_name, config_options), ActiveSession::Many => { println!("Please specify the session to attach to, either by using the full name or a unique prefix.\nThe following sessions are active:"); print_sessions(get_sessions().unwrap()); process::exit(1); - } + }, }, } } @@ -183,7 +183,7 @@ pub(crate) fn start_client(opts: CliArgs) { Err(e) => { eprintln!("{}", e); process::exit(1); - } + }, }; let os_input = get_os_input(get_client_os_input); diff --git a/src/sessions.rs b/src/sessions.rs index f7644b63d..38f783977 100644 --- a/src/sessions.rs +++ b/src/sessions.rs @@ -21,7 +21,7 @@ pub(crate) fn get_sessions() -> Result, io::ErrorKind> { } }); Ok(sessions) - } + }, Err(err) if io::ErrorKind::NotFound != err.kind() => Err(err.kind()), Err(_) => Ok(Vec::with_capacity(0)), } @@ -43,7 +43,7 @@ pub(crate) fn get_sessions_sorted_by_mtime() -> anyhow::Result> { let sessions = sessions_with_mtime.iter().map(|x| x.0.clone()).collect(); Ok(sessions) - } + }, Err(err) if io::ErrorKind::NotFound != err.kind() => Err(err.into()), Err(_) => Ok(Vec::with_capacity(0)), } @@ -59,14 +59,14 @@ fn assert_socket(name: &str) -> bool { match receiver.recv() { Some((instruction, _)) => { matches!(instruction, ServerToClientMsg::Connected) - } + }, None => false, } - } + }, Err(e) if e.kind() == io::ErrorKind::ConnectionRefused => { drop(fs::remove_file(path)); false - } + }, Err(_) => false, } } @@ -109,7 +109,7 @@ pub(crate) fn get_active_session() -> ActiveSession { Err(e) => { eprintln!("Error occurred: {:?}", e); process::exit(1); - } + }, } } @@ -118,11 +118,11 @@ pub(crate) fn kill_session(name: &str) { match LocalSocketStream::connect(path) { Ok(stream) => { IpcSenderWithContext::new(stream).send(ClientToServerMsg::KillSession); - } + }, Err(e) => { eprintln!("Error occurred: {:?}", e); process::exit(1); - } + }, }; } @@ -131,15 +131,15 @@ pub(crate) fn list_sessions() { Ok(sessions) if !sessions.is_empty() => { print_sessions(sessions); 0 - } + }, Ok(_) => { eprintln!("No active zellij sessions found."); 1 - } + }, Err(e) => { eprintln!("Error occurred: {:?}", e); 1 - } + }, }; process::exit(exit_code); } @@ -192,10 +192,10 @@ pub(crate) fn assert_session(name: &str) { println!(" help: Did you mean `{}`?", sugg); } } - } + }, Err(e) => { eprintln!("Error occurred: {:?}", e); - } + }, }; process::exit(1); } diff --git a/src/tests/e2e/remote_runner.rs b/src/tests/e2e/remote_runner.rs index ad15de228..eb9b33152 100644 --- a/src/tests/e2e/remote_runner.rs +++ b/src/tests/e2e/remote_runner.rs @@ -201,7 +201,7 @@ fn read_from_channel( terminal_output.cursor_coordinates().unwrap_or((0, 0)); *last_snapshot = current_snapshot; should_sleep = true; - } + }, Ok(count) => { for byte in buf.iter().take(count) { vte_parser.advance(&mut terminal_output.grid, *byte); @@ -212,7 +212,7 @@ fn read_from_channel( terminal_output.grid.cursor_coordinates().unwrap_or((0, 0)); *last_snapshot = current_snapshot; should_sleep = true; - } + }, Err(e) => { if e.kind() == std::io::ErrorKind::WouldBlock { let current_snapshot = take_snapshot(&mut terminal_output); @@ -226,7 +226,7 @@ fn read_from_channel( } else { break; } - } + }, } } } diff --git a/zellij-client/src/input_handler.rs b/zellij-client/src/input_handler.rs index 6b89a3f9c..6e3c71e1d 100644 --- a/zellij-client/src/input_handler.rs +++ b/zellij-client/src/input_handler.rs @@ -100,12 +100,12 @@ impl InputHandler { } else { self.handle_key(&key, raw_bytes); } - } + }, InputEvent::Mouse(mouse_event) => { let mouse_event = zellij_utils::input::mouse::MouseEvent::from(mouse_event); self.handle_mouse_event(&mouse_event); - } + }, InputEvent::Paste(pasted_text) => { if self.mode == InputMode::Normal || self.mode == InputMode::Locked { self.dispatch_action(Action::Write(bracketed_paste_start.clone())); @@ -114,13 +114,13 @@ impl InputHandler { )); self.dispatch_action(Action::Write(bracketed_paste_end.clone())); } - } - _ => {} + }, + _ => {}, } - } + }, Ok((InputInstruction::SwitchToMode(input_mode), _error_context)) => { self.mode = input_mode; - } + }, Ok((InputInstruction::PossiblePixelRatioChange, _error_context)) => { let _ = self .os_input @@ -128,7 +128,7 @@ impl InputHandler { .write(get_cell_pixel_info.as_bytes()) .unwrap(); ansi_stdin_parser.increment_expected_ansi_instructions(4); - } + }, Err(err) => panic!("Encountered read error: {:?}", err), } } @@ -150,25 +150,25 @@ impl InputHandler { Some(AnsiStdinInstructionOrKeys::PixelDimensions(pixel_dimensions)) => { self.os_input .send_to_server(ClientToServerMsg::TerminalPixelDimensions(pixel_dimensions)); - } + }, Some(AnsiStdinInstructionOrKeys::BackgroundColor(background_color_instruction)) => { self.os_input .send_to_server(ClientToServerMsg::BackgroundColor( background_color_instruction, )); - } + }, Some(AnsiStdinInstructionOrKeys::ForegroundColor(foreground_color_instruction)) => { self.os_input .send_to_server(ClientToServerMsg::ForegroundColor( foreground_color_instruction, )); - } + }, Some(AnsiStdinInstructionOrKeys::Keys(keys)) => { for (key, raw_bytes) in keys { self.handle_key(&key, raw_bytes); } - } - None => {} + }, + None => {}, } } fn handle_mouse_event(&mut self, mouse_event: &MouseEvent) { @@ -176,10 +176,10 @@ impl InputHandler { MouseEvent::Press(button, point) => match button { MouseButton::WheelUp => { self.dispatch_action(Action::ScrollUpAt(point)); - } + }, MouseButton::WheelDown => { self.dispatch_action(Action::ScrollDownAt(point)); - } + }, MouseButton::Left => { if self.holding_mouse { self.dispatch_action(Action::MouseHold(point)); @@ -187,7 +187,7 @@ impl InputHandler { self.dispatch_action(Action::LeftClick(point)); } self.holding_mouse = true; - } + }, MouseButton::Right => { if self.holding_mouse { self.dispatch_action(Action::MouseHold(point)); @@ -195,17 +195,17 @@ impl InputHandler { self.dispatch_action(Action::RightClick(point)); } self.holding_mouse = true; - } - _ => {} + }, + _ => {}, }, MouseEvent::Release(point) => { self.dispatch_action(Action::MouseRelease(point)); self.holding_mouse = false; - } + }, MouseEvent::Hold(point) => { self.dispatch_action(Action::MouseHold(point)); self.holding_mouse = true; - } + }, } } @@ -224,20 +224,20 @@ impl InputHandler { let mut should_break = false; match action { - Action::NoOp => {} + Action::NoOp => {}, Action::Quit | Action::Detach => { self.os_input .send_to_server(ClientToServerMsg::Action(action)); self.exit(); should_break = true; - } + }, Action::SwitchToMode(mode) => { // this is an optimistic update, we should get a SwitchMode instruction from the // server later that atomically changes the mode as well self.mode = mode; self.os_input .send_to_server(ClientToServerMsg::Action(action)); - } + }, Action::CloseFocus | Action::NewPane(_) | Action::ToggleFloatingPanes @@ -254,7 +254,7 @@ impl InputHandler { .send_to_server(ClientToServerMsg::Action(action)); self.command_is_executing .wait_until_input_thread_is_unblocked(); - } + }, _ => self .os_input .send_to_server(ClientToServerMsg::Action(action)), diff --git a/zellij-client/src/lib.rs b/zellij-client/src/lib.rs index 4d7c3978c..2d7764961 100644 --- a/zellij-client/src/lib.rs +++ b/zellij-client/src/lib.rs @@ -49,7 +49,7 @@ impl From for ClientInstruction { ServerToClientMsg::UnblockInputThread => ClientInstruction::UnblockInputThread, ServerToClientMsg::SwitchToMode(input_mode) => { ClientInstruction::SwitchToMode(input_mode) - } + }, ServerToClientMsg::Connected => ClientInstruction::Connected, } } @@ -160,7 +160,7 @@ pub fn start_client( envs::set_session_name(name); ClientToServerMsg::AttachClient(client_attributes, config_options) - } + }, ClientInfo::New(name) => { envs::set_session_name(name); @@ -173,7 +173,7 @@ pub fn start_client( Box::new(layout.unwrap()), Some(config.plugins.clone()), ) - } + }, }; os_input.connect_to_server(&*ZELLIJ_IPC_PIPE); @@ -283,13 +283,13 @@ pub fn start_client( if should_break { break; } - } + }, None => { send_client_instructions .send(ClientInstruction::UnblockInputThread) .unwrap(); log::error!("Received empty message from server"); - } + }, } } }) @@ -329,27 +329,27 @@ pub fn start_client( } exit_msg = reason.to_string(); break; - } + }, ClientInstruction::Error(backtrace) => { let _ = os_input.send_to_server(ClientToServerMsg::Action(Action::Quit)); handle_error(backtrace); - } + }, ClientInstruction::Render(output) => { let mut stdout = os_input.get_stdout_writer(); stdout .write_all(output.as_bytes()) .expect("cannot write to stdout"); stdout.flush().expect("could not flush"); - } + }, ClientInstruction::UnblockInputThread => { command_is_executing.unblock_input_thread(); - } + }, ClientInstruction::SwitchToMode(input_mode) => { send_input_instructions .send(InputInstruction::SwitchToMode(input_mode)) .unwrap(); - } - _ => {} + }, + _ => {}, } } diff --git a/zellij-client/src/os_input_output.rs b/zellij-client/src/os_input_output.rs index f3e916c48..2be1a90af 100644 --- a/zellij-client/src/os_input_output.rs +++ b/zellij-client/src/os_input_output.rs @@ -27,7 +27,7 @@ fn into_raw_mode(pid: RawFd) { let mut tio = termios::tcgetattr(pid).expect("could not get terminal attribute"); termios::cfmakeraw(&mut tio); match termios::tcsetattr(pid, termios::SetArg::TCSANOW, &tio) { - Ok(_) => {} + Ok(_) => {}, Err(e) => panic!("error {:?}", e), }; } @@ -161,11 +161,11 @@ impl ClientOsApi for ClientOsInputOutput { } sigwinch_cb_timestamp = time::Instant::now(); sigwinch_cb(); - } + }, SIGTERM | SIGINT | SIGQUIT | SIGHUP => { quit_cb(); break; - } + }, _ => unreachable!(), } } @@ -177,10 +177,10 @@ impl ClientOsApi for ClientOsInputOutput { Ok(sock) => { socket = sock; break; - } + }, Err(_) => { std::thread::sleep(std::time::Duration::from_millis(50)); - } + }, } } let sender = IpcSenderWithContext::new(socket); diff --git a/zellij-client/src/stdin_ansi_parser.rs b/zellij-client/src/stdin_ansi_parser.rs index 31e6ccbb3..cf20e1f06 100644 --- a/zellij-client/src/stdin_ansi_parser.rs +++ b/zellij-client/src/stdin_ansi_parser.rs @@ -43,13 +43,13 @@ impl StdinAnsiParser { self.decrement_expected_ansi_instructions(1); self.current_buffer.clear(); Some(pixel_instruction) - } + }, Err(_) => { self.expected_ansi_instructions = 0; Some(AnsiStdinInstructionOrKeys::Keys( self.current_buffer.drain(..).collect(), )) - } + }, } } else if let Key::Alt(CharOrArrow::Char('\\')) | Key::Ctrl('g') = key { match AnsiStdinInstructionOrKeys::color_sequence_from_keys(&self.current_buffer) { @@ -57,13 +57,13 @@ impl StdinAnsiParser { self.decrement_expected_ansi_instructions(1); self.current_buffer.clear(); Some(color_instruction) - } + }, Err(_) => { self.expected_ansi_instructions = 0; Some(AnsiStdinInstructionOrKeys::Keys( self.current_buffer.drain(..).collect(), )) - } + }, } } else if self.key_is_valid(key) { self.current_buffer.push((key, raw_bytes)); @@ -84,7 +84,7 @@ impl StdinAnsiParser { // if they spam ESC they need to be able to get back to normal mode and not "us // waiting for ansi instructions" mode !self.current_buffer.iter().any(|(key, _)| *key == Key::Esc) - } + }, Key::Char(';') | Key::Char('[') | Key::Char(']') @@ -102,7 +102,7 @@ impl StdinAnsiParser { } else { false } - } + }, _ => false, } } @@ -153,7 +153,7 @@ impl AnsiStdinInstructionOrKeys { }), }, )) - } + }, Ok(6) => { // character cell size Ok(AnsiStdinInstructionOrKeys::PixelDimensions( @@ -165,7 +165,7 @@ impl AnsiStdinInstructionOrKeys { text_area_size: None, }, )) - } + }, _ => Err("invalid sequence"), } } else { @@ -182,7 +182,7 @@ impl AnsiStdinInstructionOrKeys { let key_string = keys.iter().fold(String::new(), |mut acc, (key, _)| { match key { Key::Char(c) => acc.push(*c), - _ => {} + _ => {}, }; acc }); diff --git a/zellij-server/src/lib.rs b/zellij-server/src/lib.rs index 0a587d7c6..2841c932e 100644 --- a/zellij-server/src/lib.rs +++ b/zellij-server/src/lib.rs @@ -260,10 +260,10 @@ pub fn start_server(mut os_input: Box, socket_path: PathBuf) { }) .unwrap(), ); - } + }, Err(err) => { panic!("err {:?}", err); - } + }, } } } @@ -351,7 +351,7 @@ pub fn start_server(mut os_input: Box, socket_path: PathBuf) { .senders .send_to_plugin(PluginInstruction::AddClient(client_id)) .unwrap(); - } + }, ServerInstruction::AttachClient(attrs, options, client_id) => { let rlock = session_data.read().unwrap(); let session_data = rlock.as_ref().unwrap(); @@ -392,12 +392,12 @@ pub fn start_server(mut os_input: Box, socket_path: PathBuf) { )) .unwrap(); os_input.send_to_client(client_id, ServerToClientMsg::SwitchToMode(mode)); - } + }, ServerInstruction::UnblockInputThread => { for client_id in session_state.read().unwrap().clients.keys() { os_input.send_to_client(*client_id, ServerToClientMsg::UnblockInputThread); } - } + }, ServerInstruction::ClientExit(client_id) => { os_input.send_to_client(client_id, ServerToClientMsg::Exit(ExitReason::Normal)); remove_client!(client_id, os_input, session_state); @@ -431,7 +431,7 @@ pub fn start_server(mut os_input: Box, socket_path: PathBuf) { *session_data.write().unwrap() = None; break; } - } + }, ServerInstruction::RemoveClient(client_id) => { remove_client!(client_id, os_input, session_state); if let Some(min_size) = session_state.read().unwrap().min_client_terminal_size() { @@ -460,7 +460,7 @@ pub fn start_server(mut os_input: Box, socket_path: PathBuf) { .senders .send_to_plugin(PluginInstruction::RemoveClient(client_id)) .unwrap(); - } + }, ServerInstruction::KillSession => { let client_ids = session_state.read().unwrap().client_ids(); for client_id in client_ids { @@ -468,7 +468,7 @@ pub fn start_server(mut os_input: Box, socket_path: PathBuf) { remove_client!(client_id, os_input, session_state); } break; - } + }, ServerInstruction::DetachSession(client_id) => { os_input.send_to_client(client_id, ServerToClientMsg::Exit(ExitReason::Normal)); remove_client!(client_id, os_input, session_state); @@ -498,7 +498,7 @@ pub fn start_server(mut os_input: Box, socket_path: PathBuf) { .senders .send_to_plugin(PluginInstruction::RemoveClient(client_id)) .unwrap(); - } + }, ServerInstruction::Render(serialized_output) => { let client_ids = session_state.read().unwrap().client_ids(); // If `Some(_)`- unwrap it and forward it to the clients to render. @@ -518,7 +518,7 @@ pub fn start_server(mut os_input: Box, socket_path: PathBuf) { } break; } - } + }, ServerInstruction::Error(backtrace) => { let client_ids = session_state.read().unwrap().client_ids(); for client_id in client_ids { @@ -529,11 +529,11 @@ pub fn start_server(mut os_input: Box, socket_path: PathBuf) { remove_client!(client_id, os_input, session_state); } break; - } + }, ServerInstruction::ConnStatus(client_id) => { os_input.send_to_client(client_id, ServerToClientMsg::Connected); remove_client!(client_id, os_input, session_state); - } + }, } } diff --git a/zellij-server/src/os_input_output.rs b/zellij-server/src/os_input_output.rs index 0a3e00d54..d800da492 100644 --- a/zellij-server/src/os_input_output.rs +++ b/zellij-server/src/os_input_output.rs @@ -73,10 +73,10 @@ fn handle_command_exit(mut child: Child) { // and exit this function // TODO: handle errors? break 'handle_exit; - } + }, Ok(None) => { ::std::thread::sleep(::std::time::Duration::from_millis(10)); - } + }, Err(e) => panic!("error attempting to wait: {}", e), } @@ -157,7 +157,7 @@ fn handle_terminal( Some(failover_cmd) => handle_terminal(failover_cmd, None, orig_termios, quit_cb), None => { panic!("failed to start pty{:?}", e); - } + }, }, } } @@ -217,7 +217,7 @@ pub fn spawn_terminal( args, cwd: None, } - } + }, TerminalAction::RunCommand(command) => command, }; let failover_cmd = if let Some(failover_cmd_args) = failover_cmd_args { diff --git a/zellij-server/src/output/mod.rs b/zellij-server/src/output/mod.rs index 07d27d1bb..6d8010016 100644 --- a/zellij-server/src/output/mod.rs +++ b/zellij-server/src/output/mod.rs @@ -311,10 +311,10 @@ impl FloatingPanesStack { } } visible_chunks.push(c_chunk); - } + }, None => { break 'chunk_loop; - } + }, } } visible_chunks @@ -565,7 +565,7 @@ impl OutputBuffer { Some(row) => self.extract_characters_from_row(row, viewport_width), None => { vec![EMPTY_TERMINAL_CHARACTER; viewport_width] - } + }, } } } diff --git a/zellij-server/src/panes/floating_panes/mod.rs b/zellij-server/src/panes/floating_panes/mod.rs index f8bd46bc3..8434ae39e 100644 --- a/zellij-server/src/panes/floating_panes/mod.rs +++ b/zellij-server/src/panes/floating_panes/mod.rs @@ -486,7 +486,7 @@ impl FloatingPanes { self.set_force_render(); return true; - } + }, None => Some(active_pane_id), } } else { @@ -500,12 +500,12 @@ impl FloatingPanes { } self.set_pane_active_at(updated_active_pane); self.set_force_render(); - } + }, None => { // TODO: can this happen? self.active_panes.clear(); self.z_indices.clear(); - } + }, } false } @@ -557,7 +557,7 @@ impl FloatingPanes { self.set_pane_active_at(p); self.set_force_render(); return true; - } + }, None => Some(active_pane_id), } } else { @@ -571,12 +571,12 @@ impl FloatingPanes { } self.set_pane_active_at(updated_active_pane); self.set_force_render(); - } + }, None => { // TODO: can this happen? self.active_panes.clear(); self.z_indices.clear(); - } + }, } false } @@ -627,7 +627,7 @@ impl FloatingPanes { self.set_force_render(); self.set_pane_active_at(p); return true; - } + }, None => Some(active_pane_id), } } else { @@ -641,12 +641,12 @@ impl FloatingPanes { } self.set_pane_active_at(updated_active_pane); self.set_force_render(); - } + }, None => { // TODO: can this happen? self.active_panes.clear(); self.z_indices.clear(); - } + }, } false } @@ -697,7 +697,7 @@ impl FloatingPanes { self.set_force_render(); return true; - } + }, None => Some(active_pane_id), } } else { @@ -711,12 +711,12 @@ impl FloatingPanes { } self.set_pane_active_at(updated_active_pane); self.set_force_render(); - } + }, None => { // TODO: can this happen? self.active_panes.clear(); self.z_indices.clear(); - } + }, } false } @@ -789,10 +789,10 @@ impl FloatingPanes { Some(next_active_pane) => { self.active_panes.insert(client_id, next_active_pane); self.focus_pane(next_active_pane, client_id); - } + }, None => { self.defocus_pane(pane_id, client_id); - } + }, } } } diff --git a/zellij-server/src/panes/grid.rs b/zellij-server/src/panes/grid.rs index ef8d2e43c..870d743c1 100644 --- a/zellij-server/src/panes/grid.rs +++ b/zellij-server/src/panes/grid.rs @@ -45,7 +45,7 @@ fn get_top_non_canonical_rows(rows: &mut Vec) -> Vec { match index_of_last_non_canonical_row { Some(index_of_last_non_canonical_row) => { rows.drain(..=index_of_last_non_canonical_row).collect() - } + }, None => vec![], } } @@ -61,7 +61,7 @@ fn get_lines_above_bottom_canonical_row_and_wraps(rows: &mut VecDeque) -> V match index_of_last_non_canonical_row { Some(index_of_last_non_canonical_row) => { rows.drain(index_of_last_non_canonical_row..).collect() - } + }, None => vec![], } } @@ -77,7 +77,7 @@ fn get_viewport_bottom_canonical_row_and_wraps(viewport: &mut Vec) -> Vec { viewport.drain(index_of_last_non_canonical_row..).collect() - } + }, None => vec![], } } @@ -134,7 +134,7 @@ fn transfer_rows_from_lines_above_to_viewport( // no more lines at lines_above, the line we popped was probably empty break; } - } + }, None => break, // no more rows } } @@ -407,10 +407,10 @@ impl Grid { match next_tabstop { Some(tabstop) => { self.cursor.x = tabstop; - } + }, None => { self.cursor.x = self.width.saturating_sub(1); - } + }, } let mut empty_character = EMPTY_TERMINAL_CHARACTER; empty_character.styles = styles; @@ -427,10 +427,10 @@ impl Grid { match previous_tabstop { Some(tabstop) => { self.cursor.x = tabstop; - } + }, None => { self.cursor.x = 0; - } + }, } } pub fn cursor_shape(&self) -> CursorShape { @@ -627,14 +627,14 @@ impl Grid { match viewport_canonical_lines.last_mut() { Some(last_line) => { last_line.append(&mut row.columns); - } + }, None => { // the state is corrupted somehow // this is a bug and I'm not yet sure why it happens // usually it fixes itself and is a result of some race // TODO: investigate why this happens and solve it return; - } + }, } } } @@ -701,7 +701,7 @@ impl Grid { ); let rows_pulled = self.viewport.len() - current_viewport_row_count; new_cursor_y += rows_pulled; - } + }, Ordering::Greater => { let row_count_to_transfer = current_viewport_row_count - self.height; if row_count_to_transfer > new_cursor_y { @@ -715,8 +715,8 @@ impl Grid { row_count_to_transfer, new_columns, ); - } - Ordering::Equal => {} + }, + Ordering::Equal => {}, } self.cursor.y = new_cursor_y; self.cursor.x = new_cursor_x; @@ -753,7 +753,7 @@ impl Grid { self.saved_cursor_position .as_mut() .map(|saved_cursor_position| saved_cursor_position.y += rows_pulled); - } + }, Ordering::Greater => { let row_count_to_transfer = current_viewport_row_count - new_rows; if row_count_to_transfer > self.cursor.y { @@ -780,8 +780,8 @@ impl Grid { // in alternate screen, no scroll buffer, so just remove lines self.viewport.drain(0..row_count_to_transfer); } - } - Ordering::Equal => {} + }, + Ordering::Equal => {}, } } self.height = new_rows; @@ -1001,7 +1001,7 @@ impl Grid { row.add_character_at(terminal_character, self.cursor.x); } self.output_buffer.update_line(self.cursor.y); - } + }, None => { // pad lines until cursor if they do not exist for _ in self.viewport.len()..self.cursor.y { @@ -1013,7 +1013,7 @@ impl Grid { .canonical(), ); self.output_buffer.update_line(self.cursor.y); - } + }, } } pub fn add_character(&mut self, terminal_character: TerminalCharacter) { @@ -1147,13 +1147,13 @@ impl Grid { } self.pad_lines_until(self.cursor.y, pad_character); self.pad_current_line_until(self.cursor.x, pad_character); - } + }, None => { self.cursor.x = std::cmp::min(self.width - 1, x); self.cursor.y = std::cmp::min(self.height - 1, y); self.pad_lines_until(self.cursor.y, pad_character); self.pad_current_line_until(self.cursor.x, pad_character); - } + }, } } pub fn move_cursor_up(&mut self, count: usize) { @@ -1517,32 +1517,32 @@ impl Perform for Grid { match byte { 7 => { self.ring_bell = true; - } + }, 8 => { // backspace self.move_cursor_back(1); - } + }, 9 => { // tab self.advance_to_next_tabstop(self.cursor.pending_styles); - } + }, 10 | 11 | 12 => { // 0a, newline // 0b, vertical tabulation // 0c, form feed self.add_newline(); - } + }, 13 => { // 0d, carriage return self.move_cursor_to_beginning_of_line(); - } + }, 14 => { self.set_active_charset(CharsetIndex::G1); - } + }, 15 => { self.set_active_charset(CharsetIndex::G0); - } - _ => {} + }, + _ => {}, } } @@ -1578,7 +1578,7 @@ impl Perform for Grid { .to_owned(); self.set_title(title); } - } + }, // Set color index. b"4" => { @@ -1593,7 +1593,7 @@ impl Perform for Grid { return; } } - } + }, // define hyperlink b"8" => { @@ -1602,7 +1602,7 @@ impl Perform for Grid { } self.cursor.pending_styles.link_anchor = self.link_handler.borrow_mut().dispatch_osc8(params); - } + }, // Get/set Foreground (b"10") or background (b"11") colors b"10" | b"11" => { @@ -1626,14 +1626,14 @@ impl Perform for Grid { // dynamic_code, color.r, color.g, color.b, terminator dynamic_code, r, g, b, terminator ) - } + }, _ => { format!( "\u{1b}]{};rgb:{1:02x}{1:02x}/{2:02x}{2:02x}/{3:02x}{3:02x}{4}", // dynamic_code, color.r, color.g, color.b, terminator dynamic_code, 0, 0, 0, terminator ) - } + }, }; self.pending_messages_to_pty .push(color_response_message.as_bytes().to_vec()); @@ -1642,11 +1642,11 @@ impl Perform for Grid { } } } - } + }, b"12" => { // get/set cursor color currently unimplemented - } + }, // Set cursor style. b"50" => { @@ -1664,7 +1664,7 @@ impl Perform for Grid { self.cursor.change_shape(cursor_shape); } } - } + }, // Set clipboard. b"52" => { @@ -1676,12 +1676,12 @@ impl Perform for Grid { match params[2] { b"?" => { // TBD: paste from own clipboard - currently unsupported - } + }, _base64 => { // TBD: copy to own clipboard - currently unsupported - } + }, } - } + }, // Reset color index. b"104" => { @@ -1712,24 +1712,24 @@ impl Perform for Grid { // TBD - reset color index - currently unimplemented } } - } + }, // Reset foreground color. b"110" => { // TBD - reset foreground color - currently unimplemented - } + }, // Reset background color. b"111" => { // TBD - reset background color - currently unimplemented - } + }, // Reset text cursor color. b"112" => { // TBD - reset text cursor color - currently unimplemented - } + }, - _ => {} + _ => {}, } } @@ -1809,7 +1809,7 @@ impl Perform for Grid { match params_iter.next().map(|param| param[0]) { Some(2004) => { self.bracketed_paste_mode = false; - } + }, Some(1049) => { // leave alternate buffer if let Some(( @@ -1826,31 +1826,31 @@ impl Perform for Grid { self.clear_viewport_before_rendering = true; self.force_change_size(self.height, self.width); // the alternative_viewport might have been of a different size... self.mark_for_rerender(); - } + }, Some(25) => { self.hide_cursor(); self.mark_for_rerender(); - } + }, Some(1) => { self.cursor_key_mode = false; - } + }, Some(3) => { // DECCOLM - only side effects self.scroll_region = None; self.clear_all(EMPTY_TERMINAL_CHARACTER); self.cursor.x = 0; self.cursor.y = 0; - } + }, Some(6) => { self.erasure_mode = false; - } + }, Some(7) => { self.disable_linewrap = true; - } + }, Some(1006) => { self.mouse_mode = false; - } - _ => {} + }, + _ => {}, }; } else if let Some(4) = params_iter.next().map(|param| param[0]) { self.insert_mode = false; @@ -1866,10 +1866,10 @@ impl Perform for Grid { Some(25) => { self.show_cursor(); self.mark_for_rerender(); - } + }, Some(2004) => { self.bracketed_paste_mode = true; - } + }, Some(1049) => { // enter alternate buffer let current_lines_above = std::mem::replace( @@ -1886,27 +1886,27 @@ impl Perform for Grid { self.clear_viewport_before_rendering = true; self.scrollback_buffer_lines = self.recalculate_scrollback_buffer_count(); self.output_buffer.update_all_lines(); // make sure the screen gets cleared in the next render - } + }, Some(1) => { self.cursor_key_mode = true; - } + }, Some(3) => { // DECCOLM - only side effects self.scroll_region = None; self.clear_all(EMPTY_TERMINAL_CHARACTER); self.cursor.x = 0; self.cursor.y = 0; - } + }, Some(6) => { self.erasure_mode = true; - } + }, Some(7) => { self.disable_linewrap = false; - } + }, Some(1006) => { self.mouse_mode = true; - } - _ => {} + }, + _ => {}, }; } else if let Some(4) = params_iter.next().map(|param| param[0]) { self.insert_mode = true; @@ -2039,14 +2039,14 @@ impl Perform for Grid { let terminal_capabilities = "\u{1b}[?6c"; self.pending_messages_to_pty .push(terminal_capabilities.as_bytes().to_vec()); - } + }, Some(b'>') => { // secondary device attributes let version = version_number(VERSION); let text = format!("\u{1b}[>0;{};1c", version); self.pending_messages_to_pty.push(text.as_bytes().to_vec()); - } - _ => {} + }, + _ => {}, } } else if c == 'n' { // DSR - device status report @@ -2057,15 +2057,15 @@ impl Perform for Grid { let all_good = "\u{1b}[0n"; self.pending_messages_to_pty .push(all_good.as_bytes().to_vec()); - } + }, 6 => { // CPR - cursor position report let position_report = format!("\x1b[{};{}R", self.cursor.y + 1, self.cursor.x + 1); self.pending_messages_to_pty .push(position_report.as_bytes().to_vec()); - } - _ => {} + }, + _ => {}, } } else if c == 't' { match next_param_or(1) as usize { @@ -2079,7 +2079,7 @@ impl Perform for Grid { self.pending_messages_to_pty .push(text_area_pixel_size_report.as_bytes().to_vec()); } - } + }, 16 => { if let Some(character_cell_size) = *self.character_cell_size.borrow() { let character_cell_size_report = format!( @@ -2089,20 +2089,20 @@ impl Perform for Grid { self.pending_messages_to_pty .push(character_cell_size_report.as_bytes().to_vec()); } - } + }, 18 => { // report text area let text_area_report = format!("\x1b[8;{};{}t", self.height, self.width); self.pending_messages_to_pty .push(text_area_report.as_bytes().to_vec()); - } + }, 22 => { self.push_current_title_to_stack(); - } + }, 23 => { self.pop_title_from_stack(); - } - _ => {} + }, + _ => {}, } } else { log::warn!("Unhandled csi: {}->{:?}", c, params); @@ -2120,10 +2120,10 @@ impl Perform for Grid { _ => { // invalid, silently do nothing return; - } + }, }; self.configure_charset(StandardCharset::Ascii, charset_index); - } + }, (b'0', charset_index_symbol) => { let charset_index: CharsetIndex = match charset_index_symbol { Some(b'(') => CharsetIndex::G0, @@ -2133,47 +2133,47 @@ impl Perform for Grid { _ => { // invalid, silently do nothing return; - } + }, }; self.configure_charset( StandardCharset::SpecialCharacterAndLineDrawing, charset_index, ); - } + }, (b'D', None) => { self.add_newline(); - } + }, (b'E', None) => { self.add_newline(); self.move_cursor_to_beginning_of_line(); - } + }, (b'M', None) => { // TODO: if cursor is at the top, it should go down one self.move_cursor_up_with_scrolling(1); - } + }, (b'c', None) => { self.reset_terminal_state(); - } + }, (b'H', None) => { self.set_horizontal_tabstop(); - } + }, (b'7', None) => { self.save_cursor_position(); - } + }, (b'Z', None) => { let terminal_capabilities = "\u{1b}[?6c"; self.pending_messages_to_pty .push(terminal_capabilities.as_bytes().to_vec()); - } + }, (b'8', None) => { self.restore_cursor_position(); - } + }, (b'8', Some(b'#')) => { let mut fill_character = EMPTY_TERMINAL_CHARACTER; fill_character.character = 'E'; self.fill_viewport(fill_character); - } - _ => {} + }, + _ => {}, } } } @@ -2303,7 +2303,7 @@ impl Row { self.columns.push_back(terminal_character); // this is unwrapped because this always happens after self.width_cached() *self.width.as_mut().unwrap() += terminal_character.width; - } + }, Ordering::Less => { // adding the character after the end of the current line // we pad the line up to the character and then add it @@ -2312,7 +2312,7 @@ impl Row { .resize(x.saturating_sub(width_offset), EMPTY_TERMINAL_CHARACTER); self.columns.push_back(terminal_character); self.width = None; - } + }, Ordering::Greater => { // adding the character in the middle of the line // we replace the character at its position @@ -2335,7 +2335,7 @@ impl Row { .insert(position_to_remove, EMPTY_TERMINAL_CHARACTER); } } - } + }, Ordering::Less => { // the replaced character is wider than the current character // (eg. we added an English character in place of a wide emoji) @@ -2349,11 +2349,11 @@ impl Row { self.columns .insert(absolute_x_index + 1, EMPTY_TERMINAL_CHARACTER); } - } - _ => {} + }, + _ => {}, } self.width = None; - } + }, } } pub fn insert_character_at(&mut self, terminal_character: TerminalCharacter, x: usize) { @@ -2364,10 +2364,10 @@ impl Row { self.columns .resize(insert_position, EMPTY_TERMINAL_CHARACTER); self.columns.push_back(terminal_character); - } + }, Ordering::Greater => { self.columns.insert(insert_position, terminal_character); - } + }, } self.width = None; } diff --git a/zellij-server/src/panes/link_handler.rs b/zellij-server/src/panes/link_handler.rs index e6119a6c7..bfccd9471 100644 --- a/zellij-server/src/panes/link_handler.rs +++ b/zellij-server/src/panes/link_handler.rs @@ -71,7 +71,7 @@ impl LinkHandler { } output - } + }, LinkAnchor::End => Some(format!("\u{1b}]8;;{}", TERMINATOR)), }) .flatten() @@ -102,7 +102,7 @@ mod tests { let link = link_handler.links.get(&link_id).expect("link was not some"); assert_eq!(link.id, Some("test".to_string())); assert_eq!(link.uri, uri); - } + }, _ => panic!("pending link handler was not start"), } diff --git a/zellij-server/src/panes/plugin_pane.rs b/zellij-server/src/panes/plugin_pane.rs index 8b21c8333..a4f8cacd5 100644 --- a/zellij-server/src/panes/plugin_pane.rs +++ b/zellij-server/src/panes/plugin_pane.rs @@ -268,14 +268,14 @@ impl Pane for PluginPane { match name { "\0" => { self.pane_name = String::new(); - } + }, "\u{007F}" | "\u{0008}" => { //delete and backspace keys self.pane_name.pop(); - } + }, c => { self.pane_name.push_str(c); - } + }, } } fn pid(&self) -> PaneId { diff --git a/zellij-server/src/panes/terminal_character.rs b/zellij-server/src/panes/terminal_character.rs index 341f45c7c..19f4ee42a 100644 --- a/zellij-server/src/panes/terminal_character.rs +++ b/zellij-server/src/panes/terminal_character.rs @@ -297,13 +297,13 @@ impl CharacterStyles { [22] => { *self = self.bold(Some(AnsiCode::Reset)); *self = self.dim(Some(AnsiCode::Reset)); - } + }, [23] => *self = self.italic(Some(AnsiCode::Reset)), [24] => *self = self.underline(Some(AnsiCode::Reset)), [25] => { *self = self.blink_slow(Some(AnsiCode::Reset)); *self = self.blink_fast(Some(AnsiCode::Reset)); - } + }, [27] => *self = self.reverse(Some(AnsiCode::Reset)), [28] => *self = self.hidden(Some(AnsiCode::Reset)), [29] => *self = self.strike(Some(AnsiCode::Reset)), @@ -320,7 +320,7 @@ impl CharacterStyles { if let Some(ansi_code) = parse_sgr_color(&mut iter) { *self = self.foreground(Some(ansi_code)); } - } + }, [38, params @ ..] => { let rgb_start = if params.len() > 4 { 2 } else { 1 }; let rgb_iter = params[rgb_start..].iter().copied(); @@ -328,7 +328,7 @@ impl CharacterStyles { if let Some(ansi_code) = parse_sgr_color(&mut iter) { *self = self.foreground(Some(ansi_code)); } - } + }, [39] => *self = self.foreground(Some(AnsiCode::Reset)), [40] => *self = self.background(Some(AnsiCode::NamedColor(NamedColor::Black))), [41] => *self = self.background(Some(AnsiCode::NamedColor(NamedColor::Red))), @@ -343,7 +343,7 @@ impl CharacterStyles { if let Some(ansi_code) = parse_sgr_color(&mut iter) { *self = self.background(Some(ansi_code)); } - } + }, [48, params @ ..] => { let rgb_start = if params.len() > 4 { 2 } else { 1 }; let rgb_iter = params[rgb_start..].iter().copied(); @@ -351,52 +351,52 @@ impl CharacterStyles { if let Some(ansi_code) = parse_sgr_color(&mut iter) { *self = self.background(Some(ansi_code)); } - } + }, [49] => *self = self.background(Some(AnsiCode::Reset)), [90] => { *self = self.foreground(Some(AnsiCode::NamedColor(NamedColor::BrightBlack))) - } + }, [91] => *self = self.foreground(Some(AnsiCode::NamedColor(NamedColor::BrightRed))), [92] => { *self = self.foreground(Some(AnsiCode::NamedColor(NamedColor::BrightGreen))) - } + }, [93] => { *self = self.foreground(Some(AnsiCode::NamedColor(NamedColor::BrightYellow))) - } + }, [94] => *self = self.foreground(Some(AnsiCode::NamedColor(NamedColor::BrightBlue))), [95] => { *self = self.foreground(Some(AnsiCode::NamedColor(NamedColor::BrightMagenta))) - } + }, [96] => *self = self.foreground(Some(AnsiCode::NamedColor(NamedColor::BrightCyan))), [97] => { *self = self.foreground(Some(AnsiCode::NamedColor(NamedColor::BrightWhite))) - } + }, [100] => { *self = self.background(Some(AnsiCode::NamedColor(NamedColor::BrightBlack))) - } + }, [101] => *self = self.background(Some(AnsiCode::NamedColor(NamedColor::BrightRed))), [102] => { *self = self.background(Some(AnsiCode::NamedColor(NamedColor::BrightGreen))) - } + }, [103] => { *self = self.background(Some(AnsiCode::NamedColor(NamedColor::BrightYellow))) - } + }, [104] => { *self = self.background(Some(AnsiCode::NamedColor(NamedColor::BrightBlue))) - } + }, [105] => { *self = self.background(Some(AnsiCode::NamedColor(NamedColor::BrightMagenta))) - } + }, [106] => { *self = self.background(Some(AnsiCode::NamedColor(NamedColor::BrightCyan))) - } + }, [107] => { *self = self.background(Some(AnsiCode::NamedColor(NamedColor::BrightWhite))) - } + }, _ => { log::warn!("unhandled csi m code {:?}", param); return; - } + }, } } } @@ -423,102 +423,102 @@ impl Display for CharacterStyles { match ansi_code { AnsiCode::RgbCode((r, g, b)) => { write!(f, "\u{1b}[38;2;{};{};{}m", r, g, b)?; - } + }, AnsiCode::ColorIndex(color_index) => { write!(f, "\u{1b}[38;5;{}m", color_index)?; - } + }, AnsiCode::Reset => { write!(f, "\u{1b}[39m")?; - } + }, AnsiCode::NamedColor(named_color) => { write!(f, "\u{1b}[{}m", named_color.to_foreground_ansi_code())?; - } - _ => {} + }, + _ => {}, } }; if let Some(ansi_code) = self.background { match ansi_code { AnsiCode::RgbCode((r, g, b)) => { write!(f, "\u{1b}[48;2;{};{};{}m", r, g, b)?; - } + }, AnsiCode::ColorIndex(color_index) => { write!(f, "\u{1b}[48;5;{}m", color_index)?; - } + }, AnsiCode::Reset => { write!(f, "\u{1b}[49m")?; - } + }, AnsiCode::NamedColor(named_color) => { write!(f, "\u{1b}[{}m", named_color.to_background_ansi_code())?; - } - _ => {} + }, + _ => {}, } } if let Some(ansi_code) = self.strike { match ansi_code { AnsiCode::On => { write!(f, "\u{1b}[9m")?; - } + }, AnsiCode::Reset => { write!(f, "\u{1b}[29m")?; - } - _ => {} + }, + _ => {}, } } if let Some(ansi_code) = self.hidden { match ansi_code { AnsiCode::On => { write!(f, "\u{1b}[8m")?; - } + }, AnsiCode::Reset => { write!(f, "\u{1b}[28m")?; - } - _ => {} + }, + _ => {}, } } if let Some(ansi_code) = self.reverse { match ansi_code { AnsiCode::On => { write!(f, "\u{1b}[7m")?; - } + }, AnsiCode::Reset => { write!(f, "\u{1b}[27m")?; - } - _ => {} + }, + _ => {}, } } if let Some(ansi_code) = self.fast_blink { match ansi_code { AnsiCode::On => { write!(f, "\u{1b}[6m")?; - } + }, AnsiCode::Reset => { write!(f, "\u{1b}[25m")?; - } - _ => {} + }, + _ => {}, } } if let Some(ansi_code) = self.slow_blink { match ansi_code { AnsiCode::On => { write!(f, "\u{1b}[5m")?; - } + }, AnsiCode::Reset => { write!(f, "\u{1b}[25m")?; - } - _ => {} + }, + _ => {}, } } if let Some(ansi_code) = self.bold { match ansi_code { AnsiCode::On => { write!(f, "\u{1b}[1m")?; - } + }, AnsiCode::Reset => { write!(f, "\u{1b}[22m\u{1b}[24m")?; // TODO: this cancels bold + underline, if this behaviour is indeed correct, we // need to properly handle it in the struct methods etc like dim - } - _ => {} + }, + _ => {}, } } // notice the order is important here, bold must be before underline @@ -528,36 +528,36 @@ impl Display for CharacterStyles { match ansi_code { AnsiCode::On => { write!(f, "\u{1b}[4m")?; - } + }, AnsiCode::Reset => { write!(f, "\u{1b}[24m")?; - } - _ => {} + }, + _ => {}, } } if let Some(ansi_code) = self.dim { match ansi_code { AnsiCode::On => { write!(f, "\u{1b}[2m")?; - } + }, AnsiCode::Reset => { if let Some(AnsiCode::Reset) = self.bold { // we only reset dim if both dim and bold should be reset write!(f, "\u{1b}[22m")?; } - } - _ => {} + }, + _ => {}, } } if let Some(ansi_code) = self.italic { match ansi_code { AnsiCode::On => { write!(f, "\u{1b}[3m")?; - } + }, AnsiCode::Reset => { write!(f, "\u{1b}[23m")?; - } - _ => {} + }, + _ => {}, } }; Ok(()) diff --git a/zellij-server/src/panes/terminal_pane.rs b/zellij-server/src/panes/terminal_pane.rs index 4e57f462b..53b6d1384 100644 --- a/zellij-server/src/panes/terminal_pane.rs +++ b/zellij-server/src/panes/terminal_pane.rs @@ -123,7 +123,7 @@ impl Pane for TerminalPane { // some editors will not show this return "OD".as_bytes().to_vec(); } - } + }, [27, 91, 67] => { // right arrow if self.grid.cursor_key_mode { @@ -131,7 +131,7 @@ impl Pane for TerminalPane { // some editors will not show this return "OC".as_bytes().to_vec(); } - } + }, [27, 91, 65] => { // up arrow if self.grid.cursor_key_mode { @@ -139,20 +139,20 @@ impl Pane for TerminalPane { // some editors will not show this return "OA".as_bytes().to_vec(); } - } + }, [27, 91, 72] => { // home key if self.grid.cursor_key_mode { return vec![27, 79, 72]; // ESC O H } - } + }, [27, 91, 70] => { // end key if self.grid.cursor_key_mode { return vec![27, 79, 70]; // ESC O F } - } + }, [27, 91, 66] => { // down arrow if self.grid.cursor_key_mode { @@ -160,7 +160,7 @@ impl Pane for TerminalPane { // some editors will not show this return "OB".as_bytes().to_vec(); } - } + }, [27, 91, 50, 48, 48, 126] | [27, 91, 50, 48, 49, 126] => { if !self.grid.bracketed_paste_mode { // Zellij itself operates in bracketed paste mode, so the terminal sends these @@ -169,8 +169,8 @@ impl Pane for TerminalPane { // panes who do not work in this mode return vec![]; } - } - _ => {} + }, + _ => {}, }; input_bytes } @@ -281,7 +281,7 @@ impl Pane for TerminalPane { } else { None } - } + }, None => { if !self.borderless { let frame_output = frame.render(); @@ -290,7 +290,7 @@ impl Pane for TerminalPane { } else { None } - } + }, } } fn render_fake_cursor( @@ -333,14 +333,14 @@ impl Pane for TerminalPane { match name { "\0" => { self.pane_name = String::new(); - } + }, "\u{007F}" | "\u{0008}" => { //delete and backspace keys self.pane_name.pop(); - } + }, c => { self.pane_name.push_str(c); - } + }, } } fn pid(&self) -> PaneId { diff --git a/zellij-server/src/panes/tiled_panes/mod.rs b/zellij-server/src/panes/tiled_panes/mod.rs index 1f9582976..7a6d3dc41 100644 --- a/zellij-server/src/panes/tiled_panes/mod.rs +++ b/zellij-server/src/panes/tiled_panes/mod.rs @@ -219,7 +219,7 @@ impl TiledPanes { let result = match direction { Direction::Horizontal => { pane_grid.layout(direction, (*self.display_area.borrow()).cols) - } + }, Direction::Vertical => pane_grid.layout(direction, (*self.display_area.borrow()).rows), }; if let Err(e) = &result { @@ -632,10 +632,10 @@ impl TiledPanes { self.set_pane_active_at(p); true - } + }, None => false, } - } + }, None => false, } } @@ -673,10 +673,10 @@ impl TiledPanes { self.set_pane_active_at(p); true - } + }, None => false, } - } + }, None => false, } } @@ -714,10 +714,10 @@ impl TiledPanes { self.set_pane_active_at(p); true - } + }, None => false, } - } + }, None => false, } } @@ -755,10 +755,10 @@ impl TiledPanes { self.set_pane_active_at(p); true - } + }, None => false, } - } + }, None => false, } } @@ -952,7 +952,7 @@ impl TiledPanes { self.active_panes.insert(client_id, *next_active_pane); } } - } + }, None => self.active_panes.clear(), } } diff --git a/zellij-server/src/panes/tiled_panes/tiled_pane_grid.rs b/zellij-server/src/panes/tiled_panes/tiled_pane_grid.rs index 53a48f9ea..6bb90e9d3 100644 --- a/zellij-server/src/panes/tiled_panes/tiled_pane_grid.rs +++ b/zellij-server/src/panes/tiled_panes/tiled_pane_grid.rs @@ -1574,12 +1574,12 @@ impl<'a> TiledPaneGrid<'a> { for pane_id in panes { self.increase_pane_width(pane_id, width); } - } + }, Direction::Vertical => { for pane_id in panes { self.increase_pane_height(pane_id, height); } - } + }, }; } pub fn fill_space_over_pane(&mut self, id: PaneId) -> bool { diff --git a/zellij-server/src/pty.rs b/zellij-server/src/pty.rs index 6abcd6671..717973a94 100644 --- a/zellij-server/src/pty.rs +++ b/zellij-server/src/pty.rs @@ -96,7 +96,7 @@ pub(crate) fn pty_thread_main(mut pty: Pty, layout: Box) { client_or_tab_index, )) .unwrap(); - } + }, PtyInstruction::OpenInPlaceEditor(temp_file, line_number, client_id) => { match pty.spawn_terminal( Some(TerminalAction::OpenFile(temp_file, line_number)), @@ -110,12 +110,12 @@ pub(crate) fn pty_thread_main(mut pty: Pty, layout: Box) { client_id, )) .unwrap(); - } + }, Err(e) => { log::error!("Failed to open editor: {}", e); - } + }, } - } + }, PtyInstruction::SpawnTerminalVertically(terminal_action, client_id) => { let pid = pty .spawn_terminal(terminal_action, ClientOrTabIndex::ClientId(client_id)) @@ -127,7 +127,7 @@ pub(crate) fn pty_thread_main(mut pty: Pty, layout: Box) { client_id, )) .unwrap(); - } + }, PtyInstruction::SpawnTerminalHorizontally(terminal_action, client_id) => { let pid = pty .spawn_terminal(terminal_action, ClientOrTabIndex::ClientId(client_id)) @@ -139,16 +139,16 @@ pub(crate) fn pty_thread_main(mut pty: Pty, layout: Box) { client_id, )) .unwrap(); - } + }, PtyInstruction::UpdateActivePane(pane_id, client_id) => { pty.set_active_pane(pane_id, client_id); - } + }, PtyInstruction::GoToTab(tab_index, client_id) => { pty.bus .senders .send_to_screen(ScreenInstruction::GoToTab(tab_index, Some(client_id))) .unwrap(); - } + }, PtyInstruction::NewTab(terminal_action, tab_layout, client_id) => { let tab_name = tab_layout.as_ref().and_then(|layout| { if layout.name.is_empty() { @@ -178,21 +178,21 @@ pub(crate) fn pty_thread_main(mut pty: Pty, layout: Box) { )) .unwrap(); } - } + }, PtyInstruction::ClosePane(id) => { pty.close_pane(id); pty.bus .senders .send_to_server(ServerInstruction::UnblockInputThread) .unwrap(); - } + }, PtyInstruction::CloseTab(ids) => { pty.close_tab(ids); pty.bus .senders .send_to_server(ServerInstruction::UnblockInputThread) .unwrap(); - } + }, PtyInstruction::Exit => break, } } @@ -270,7 +270,7 @@ fn stream_terminal_bytes( // next read does not need a deadline as we just rendered everything render_deadline = None; last_render = Instant::now(); - } + }, ReadResult::Ok(n_bytes) => { let bytes = &buf[..n_bytes]; if debug { @@ -284,7 +284,7 @@ fn stream_terminal_bytes( // if we already have a render_deadline we keep it, otherwise we set it // to RENDER_PAUSE since the last time we rendered. render_deadline.get_or_insert(last_render + RENDER_PAUSE); - } + }, } } async_send_to_screen(senders.clone(), ScreenInstruction::Render).await; @@ -344,10 +344,10 @@ impl Pty { terminal_action.unwrap_or_else(|| self.get_default_terminal()); self.fill_cwd(&mut terminal_action, client_id); terminal_action - } + }, ClientOrTabIndex::TabIndex(_) => { terminal_action.unwrap_or_else(|| self.get_default_terminal()) - } + }, }; let quit_cb = Box::new({ let senders = self.bus.senders.clone(); @@ -400,7 +400,7 @@ impl Pty { .unwrap(); // TODO: handle error here self.id_to_child_pid.insert(pid_primary, child_fd); new_pane_pids.push(pid_primary); - } + }, None => { let (pid_primary, child_fd): (RawFd, RawFd) = self .bus @@ -411,9 +411,9 @@ impl Pty { .unwrap(); // TODO: handle error here self.id_to_child_pid.insert(pid_primary, child_fd); new_pane_pids.push(pid_primary); - } + }, // Investigate moving plugin loading to here. - Some(Run::Plugin(_)) => {} + Some(Run::Plugin(_)) => {}, } } self.bus @@ -447,7 +447,7 @@ impl Pty { .kill(Pid::from_raw(child_fd)) .unwrap(); }); - } + }, PaneId::Plugin(pid) => drop( self.bus .senders diff --git a/zellij-server/src/pty_writer.rs b/zellij-server/src/pty_writer.rs index 760b67a1f..f0aeaf42b 100644 --- a/zellij-server/src/pty_writer.rs +++ b/zellij-server/src/pty_writer.rs @@ -30,10 +30,10 @@ pub(crate) fn pty_writer_main(bus: Bus) { if let Err(e) = os_input.tcdrain(terminal_id) { log::error!("failed to drain terminal: {}", e); }; - } + }, PtyWriteInstruction::Exit => { break; - } + }, } } } diff --git a/zellij-server/src/route.rs b/zellij-server/src/route.rs index fd86e7f30..3057ec0e3 100644 --- a/zellij-server/src/route.rs +++ b/zellij-server/src/route.rs @@ -43,7 +43,7 @@ fn route_action( .senders .send_to_screen(ScreenInstruction::ToggleTab(client_id)) .unwrap(); - } + }, Action::Write(val) => { session .senders @@ -53,7 +53,7 @@ fn route_action( .senders .send_to_screen(ScreenInstruction::WriteCharacter(val, client_id)) .unwrap(); - } + }, Action::WriteChars(val) => { session .senders @@ -64,7 +64,7 @@ fn route_action( .senders .send_to_screen(ScreenInstruction::WriteCharacter(val, client_id)) .unwrap(); - } + }, Action::SwitchToMode(mode) => { let style = session.style; // TODO: use the palette from the client and remove it from the server os api @@ -89,7 +89,7 @@ fn route_action( .senders .send_to_screen(ScreenInstruction::Render) .unwrap(); - } + }, Action::Resize(direction) => { let screen_instr = match direction { ResizeDirection::Left => ScreenInstruction::ResizeLeft(client_id), @@ -100,25 +100,25 @@ fn route_action( ResizeDirection::Decrease => ScreenInstruction::ResizeDecrease(client_id), }; session.senders.send_to_screen(screen_instr).unwrap(); - } + }, Action::SwitchFocus => { session .senders .send_to_screen(ScreenInstruction::SwitchFocus(client_id)) .unwrap(); - } + }, Action::FocusNextPane => { session .senders .send_to_screen(ScreenInstruction::FocusNextPane(client_id)) .unwrap(); - } + }, Action::FocusPreviousPane => { session .senders .send_to_screen(ScreenInstruction::FocusPreviousPane(client_id)) .unwrap(); - } + }, Action::MoveFocus(direction) => { let screen_instr = match direction { Direction::Left => ScreenInstruction::MoveFocusLeft(client_id), @@ -127,7 +127,7 @@ fn route_action( Direction::Down => ScreenInstruction::MoveFocusDown(client_id), }; session.senders.send_to_screen(screen_instr).unwrap(); - } + }, Action::MoveFocusOrTab(direction) => { let screen_instr = match direction { Direction::Left => ScreenInstruction::MoveFocusLeftOrPreviousTab(client_id), @@ -135,7 +135,7 @@ fn route_action( _ => unreachable!(), }; session.senders.send_to_screen(screen_instr).unwrap(); - } + }, Action::MovePane(direction) => { let screen_instr = match direction { Some(Direction::Left) => ScreenInstruction::MovePaneLeft(client_id), @@ -145,85 +145,85 @@ fn route_action( None => ScreenInstruction::MovePane(client_id), }; session.senders.send_to_screen(screen_instr).unwrap(); - } + }, Action::DumpScreen(val) => { session .senders .send_to_screen(ScreenInstruction::DumpScreen(val, client_id)) .unwrap(); - } + }, Action::EditScrollback => { session .senders .send_to_screen(ScreenInstruction::EditScrollback(client_id)) .unwrap(); - } + }, Action::ScrollUp => { session .senders .send_to_screen(ScreenInstruction::ScrollUp(client_id)) .unwrap(); - } + }, Action::ScrollUpAt(point) => { session .senders .send_to_screen(ScreenInstruction::ScrollUpAt(point, client_id)) .unwrap(); - } + }, Action::ScrollDown => { session .senders .send_to_screen(ScreenInstruction::ScrollDown(client_id)) .unwrap(); - } + }, Action::ScrollDownAt(point) => { session .senders .send_to_screen(ScreenInstruction::ScrollDownAt(point, client_id)) .unwrap(); - } + }, Action::ScrollToBottom => { session .senders .send_to_screen(ScreenInstruction::ScrollToBottom(client_id)) .unwrap(); - } + }, Action::PageScrollUp => { session .senders .send_to_screen(ScreenInstruction::PageScrollUp(client_id)) .unwrap(); - } + }, Action::PageScrollDown => { session .senders .send_to_screen(ScreenInstruction::PageScrollDown(client_id)) .unwrap(); - } + }, Action::HalfPageScrollUp => { session .senders .send_to_screen(ScreenInstruction::HalfPageScrollUp(client_id)) .unwrap(); - } + }, Action::HalfPageScrollDown => { session .senders .send_to_screen(ScreenInstruction::HalfPageScrollDown(client_id)) .unwrap(); - } + }, Action::ToggleFocusFullscreen => { session .senders .send_to_screen(ScreenInstruction::ToggleActiveTerminalFullscreen(client_id)) .unwrap(); - } + }, Action::TogglePaneFrames => { session .senders .send_to_screen(ScreenInstruction::TogglePaneFrames) .unwrap(); - } + }, Action::NewPane(direction) => { let shell = session.default_shell.clone(); let pty_instr = match direction { @@ -232,18 +232,18 @@ fn route_action( Some(Direction::Up) => PtyInstruction::SpawnTerminalHorizontally(shell, client_id), Some(Direction::Down) => { PtyInstruction::SpawnTerminalHorizontally(shell, client_id) - } + }, // No direction specified - try to put it in the biggest available spot None => PtyInstruction::SpawnTerminal(shell, ClientOrTabIndex::ClientId(client_id)), }; session.senders.send_to_pty(pty_instr).unwrap(); - } + }, Action::TogglePaneEmbedOrFloating => { session .senders .send_to_screen(ScreenInstruction::TogglePaneEmbedOrFloating(client_id)) .unwrap(); - } + }, Action::ToggleFloatingPanes => { session .senders @@ -252,139 +252,139 @@ fn route_action( session.default_shell.clone(), )) .unwrap(); - } + }, Action::PaneNameInput(c) => { session .senders .send_to_screen(ScreenInstruction::UpdatePaneName(c, client_id)) .unwrap(); - } + }, Action::Run(command) => { let run_cmd = Some(TerminalAction::RunCommand(command.clone().into())); let pty_instr = match command.direction { Some(Direction::Left) => { PtyInstruction::SpawnTerminalVertically(run_cmd, client_id) - } + }, Some(Direction::Right) => { PtyInstruction::SpawnTerminalVertically(run_cmd, client_id) - } + }, Some(Direction::Up) => { PtyInstruction::SpawnTerminalHorizontally(run_cmd, client_id) - } + }, Some(Direction::Down) => { PtyInstruction::SpawnTerminalHorizontally(run_cmd, client_id) - } + }, // No direction specified - try to put it in the biggest available spot None => { PtyInstruction::SpawnTerminal(run_cmd, ClientOrTabIndex::ClientId(client_id)) - } + }, }; session.senders.send_to_pty(pty_instr).unwrap(); - } + }, Action::CloseFocus => { session .senders .send_to_screen(ScreenInstruction::CloseFocusedPane(client_id)) .unwrap(); - } + }, Action::NewTab(tab_layout) => { let shell = session.default_shell.clone(); session .senders .send_to_pty(PtyInstruction::NewTab(shell, tab_layout, client_id)) .unwrap(); - } + }, Action::GoToNextTab => { session .senders .send_to_screen(ScreenInstruction::SwitchTabNext(client_id)) .unwrap(); - } + }, Action::GoToPreviousTab => { session .senders .send_to_screen(ScreenInstruction::SwitchTabPrev(client_id)) .unwrap(); - } + }, Action::ToggleActiveSyncTab => { session .senders .send_to_screen(ScreenInstruction::ToggleActiveSyncTab(client_id)) .unwrap(); - } + }, Action::CloseTab => { session .senders .send_to_screen(ScreenInstruction::CloseTab(client_id)) .unwrap(); - } + }, Action::GoToTab(i) => { session .senders .send_to_screen(ScreenInstruction::GoToTab(i, Some(client_id))) .unwrap(); - } + }, Action::TabNameInput(c) => { session .senders .send_to_screen(ScreenInstruction::UpdateTabName(c, client_id)) .unwrap(); - } + }, Action::Quit => { to_server .send(ServerInstruction::ClientExit(client_id)) .unwrap(); should_break = true; - } + }, Action::Detach => { to_server .send(ServerInstruction::DetachSession(client_id)) .unwrap(); should_break = true; - } + }, Action::LeftClick(point) => { session .senders .send_to_screen(ScreenInstruction::LeftClick(point, client_id)) .unwrap(); - } + }, Action::RightClick(point) => { session .senders .send_to_screen(ScreenInstruction::RightClick(point, client_id)) .unwrap(); - } + }, Action::MouseRelease(point) => { session .senders .send_to_screen(ScreenInstruction::MouseRelease(point, client_id)) .unwrap(); - } + }, Action::MouseHold(point) => { session .senders .send_to_screen(ScreenInstruction::MouseHold(point, client_id)) .unwrap(); - } + }, Action::Copy => { session .senders .send_to_screen(ScreenInstruction::Copy(client_id)) .unwrap(); - } + }, Action::Confirm => { session .senders .send_to_screen(ScreenInstruction::ConfirmPrompt(client_id)) .unwrap(); - } + }, Action::Deny => { session .senders .send_to_screen(ScreenInstruction::DenyPrompt(client_id)) .unwrap(); - } + }, #[allow(clippy::single_match)] Action::SkipConfirm(action) => match *action { Action::Quit => { @@ -392,10 +392,10 @@ fn route_action( .send(ServerInstruction::ClientExit(client_id)) .unwrap(); should_break = true; - } - _ => {} + }, + _ => {}, }, - Action::NoOp => {} + Action::NoOp => {}, } should_break } @@ -433,7 +433,7 @@ pub(crate) fn route_thread_main( break; } } - } + }, ClientToServerMsg::TerminalResize(new_size) => { session_state .write() @@ -450,7 +450,7 @@ pub(crate) fn route_thread_main( .senders .send_to_screen(ScreenInstruction::TerminalResize(min_size)) .unwrap(); - } + }, ClientToServerMsg::TerminalPixelDimensions(pixel_dimensions) => { rlocked_sessions .as_ref() @@ -460,7 +460,7 @@ pub(crate) fn route_thread_main( pixel_dimensions, )) .unwrap(); - } + }, ClientToServerMsg::BackgroundColor(background_color_instruction) => { rlocked_sessions .as_ref() @@ -470,7 +470,7 @@ pub(crate) fn route_thread_main( background_color_instruction, )) .unwrap(); - } + }, ClientToServerMsg::ForegroundColor(foreground_color_instruction) => { rlocked_sessions .as_ref() @@ -480,7 +480,7 @@ pub(crate) fn route_thread_main( foreground_color_instruction, )) .unwrap(); - } + }, ClientToServerMsg::NewClient( client_attributes, cli_args, @@ -497,27 +497,27 @@ pub(crate) fn route_thread_main( plugin_config, ); to_server.send(new_client_instruction).unwrap(); - } + }, ClientToServerMsg::AttachClient(client_attributes, opts) => { let attach_client_instruction = ServerInstruction::AttachClient(client_attributes, opts, client_id); to_server.send(attach_client_instruction).unwrap(); - } + }, ClientToServerMsg::ClientExited => { // we don't unwrap this because we don't really care if there's an error here (eg. // if the main server thread exited before this router thread did) let _ = to_server.send(ServerInstruction::RemoveClient(client_id)); break; - } + }, ClientToServerMsg::KillSession => { to_server.send(ServerInstruction::KillSession).unwrap(); - } + }, ClientToServerMsg::ConnStatus => { let _ = to_server.send(ServerInstruction::ConnStatus(client_id)); break; - } + }, } - } + }, None => { log::error!("Received empty message from client"); os_input.send_to_client( @@ -527,7 +527,7 @@ pub(crate) fn route_thread_main( )), ); break; - } + }, } } } diff --git a/zellij-server/src/screen.rs b/zellij-server/src/screen.rs index 1723528de..add355401 100644 --- a/zellij-server/src/screen.rs +++ b/zellij-server/src/screen.rs @@ -120,7 +120,7 @@ impl From<&ScreenInstruction> for ScreenContext { ScreenInstruction::OpenInPlaceEditor(..) => ScreenContext::OpenInPlaceEditor, ScreenInstruction::TogglePaneEmbedOrFloating(..) => { ScreenContext::TogglePaneEmbedOrFloating - } + }, ScreenInstruction::ToggleFloatingPanes(..) => ScreenContext::ToggleFloatingPanes, ScreenInstruction::HorizontalSplit(..) => ScreenContext::HorizontalSplit, ScreenInstruction::VerticalSplit(..) => ScreenContext::VerticalSplit, @@ -137,13 +137,13 @@ impl From<&ScreenInstruction> for ScreenContext { ScreenInstruction::MoveFocusLeft(..) => ScreenContext::MoveFocusLeft, ScreenInstruction::MoveFocusLeftOrPreviousTab(..) => { ScreenContext::MoveFocusLeftOrPreviousTab - } + }, ScreenInstruction::MoveFocusDown(..) => ScreenContext::MoveFocusDown, ScreenInstruction::MoveFocusUp(..) => ScreenContext::MoveFocusUp, ScreenInstruction::MoveFocusRight(..) => ScreenContext::MoveFocusRight, ScreenInstruction::MoveFocusRightOrNextTab(..) => { ScreenContext::MoveFocusRightOrNextTab - } + }, ScreenInstruction::MovePane(..) => ScreenContext::MovePane, ScreenInstruction::MovePaneDown(..) => ScreenContext::MovePaneDown, ScreenInstruction::MovePaneUp(..) => ScreenContext::MovePaneUp, @@ -163,7 +163,7 @@ impl From<&ScreenInstruction> for ScreenContext { ScreenInstruction::CloseFocusedPane(..) => ScreenContext::CloseFocusedPane, ScreenInstruction::ToggleActiveTerminalFullscreen(..) => { ScreenContext::ToggleActiveTerminalFullscreen - } + }, ScreenInstruction::TogglePaneFrames => ScreenContext::TogglePaneFrames, ScreenInstruction::SetSelectable(..) => ScreenContext::SetSelectable, ScreenInstruction::ClosePane(..) => ScreenContext::ClosePane, @@ -177,13 +177,13 @@ impl From<&ScreenInstruction> for ScreenContext { ScreenInstruction::TerminalResize(..) => ScreenContext::TerminalResize, ScreenInstruction::TerminalPixelDimensions(..) => { ScreenContext::TerminalPixelDimensions - } + }, ScreenInstruction::TerminalBackgroundColor(..) => { ScreenContext::TerminalBackgroundColor - } + }, ScreenInstruction::TerminalForegroundColor(..) => { ScreenContext::TerminalForegroundColor - } + }, ScreenInstruction::ChangeMode(..) => ScreenContext::ChangeMode, ScreenInstruction::ToggleActiveSyncTab(..) => ScreenContext::ToggleActiveSyncTab, ScreenInstruction::ScrollUpAt(..) => ScreenContext::ScrollUpAt, @@ -359,10 +359,10 @@ impl Screen { let client_tab_history = self.tab_history.entry(client_id).or_insert_with(Vec::new); client_tab_history.retain(|&e| e != new_tab_index); client_tab_history.push(old_active_index); - } + }, None => { self.active_tab_indices.insert(client_id, new_tab_index); - } + }, } } /// A helper function to switch to a new tab at specified position. @@ -725,17 +725,17 @@ impl Screen { match s { "\0" => { active_tab.name = String::new(); - } + }, "\u{007F}" | "\u{0008}" => { // delete and backspace keys active_tab.name.pop(); - } + }, c => { // It only allows printable unicode if buf.iter().all(|u| matches!(u, 0x20..=0x7E)) { active_tab.name.push_str(c); } - } + }, } self.update_tabs(); } else { @@ -842,10 +842,10 @@ pub(crate) fn screen_thread_main( break; } } - } + }, ScreenInstruction::Render => { screen.render(); - } + }, ScreenInstruction::NewPane(pid, client_or_tab_index) => { match client_or_tab_index { ClientOrTabIndex::ClientId(client_id) => { @@ -854,14 +854,14 @@ pub(crate) fn screen_thread_main( } else { log::error!("Active tab not found for client id: {:?}", client_id); } - } + }, ClientOrTabIndex::TabIndex(tab_index) => { if let Some(active_tab) = screen.tabs.get_mut(&tab_index) { active_tab.new_pane(pid, None); } else { log::error!("Tab index not found: {:?}", tab_index); } - } + }, }; screen .bus @@ -871,7 +871,7 @@ pub(crate) fn screen_thread_main( screen.update_tabs(); screen.render(); - } + }, ScreenInstruction::OpenInPlaceEditor(pid, client_id) => { if let Some(active_tab) = screen.get_active_tab_mut(client_id) { active_tab.suppress_active_pane(pid, client_id); @@ -887,7 +887,7 @@ pub(crate) fn screen_thread_main( screen.update_tabs(); screen.render(); - } + }, ScreenInstruction::TogglePaneEmbedOrFloating(client_id) => { if let Some(active_tab) = screen.get_active_tab_mut(client_id) { active_tab.toggle_pane_embed_or_floating(client_id); @@ -901,7 +901,7 @@ pub(crate) fn screen_thread_main( .unwrap(); screen.update_tabs(); // update tabs so that the ui indication will be send to the plugins screen.render(); - } + }, ScreenInstruction::ToggleFloatingPanes(client_id, default_shell) => { if let Some(active_tab) = screen.get_active_tab_mut(client_id) { active_tab.toggle_floating_panes(client_id, default_shell); @@ -915,7 +915,7 @@ pub(crate) fn screen_thread_main( .unwrap(); screen.update_tabs(); // update tabs so that the ui indication will be send to the plugins screen.render(); - } + }, ScreenInstruction::HorizontalSplit(pid, client_id) => { if let Some(active_tab) = screen.get_active_tab_mut(client_id) { active_tab.horizontal_split(pid, client_id); @@ -930,7 +930,7 @@ pub(crate) fn screen_thread_main( screen.update_tabs(); screen.render(); - } + }, ScreenInstruction::VerticalSplit(pid, client_id) => { if let Some(active_tab) = screen.get_active_tab_mut(client_id) { active_tab.vertical_split(pid, client_id); @@ -945,7 +945,7 @@ pub(crate) fn screen_thread_main( screen.update_tabs(); screen.render(); - } + }, ScreenInstruction::WriteCharacter(bytes, client_id) => { if let Some(active_tab) = screen.get_active_tab_mut(client_id) { match active_tab.is_sync_panes_active() { @@ -955,7 +955,7 @@ pub(crate) fn screen_thread_main( } else { log::error!("Active tab not found for client id: {:?}", client_id); } - } + }, ScreenInstruction::ResizeLeft(client_id) => { if let Some(active_tab) = screen.get_active_tab_mut(client_id) { active_tab.resize_left(client_id); @@ -964,14 +964,14 @@ pub(crate) fn screen_thread_main( } screen.render(); - } + }, ScreenInstruction::ResizeRight(client_id) => { if let Some(active_tab) = screen.get_active_tab_mut(client_id) { active_tab.resize_right(client_id); } screen.render(); - } + }, ScreenInstruction::ResizeDown(client_id) => { if let Some(active_tab) = screen.get_active_tab_mut(client_id) { active_tab.resize_down(client_id); @@ -980,7 +980,7 @@ pub(crate) fn screen_thread_main( } screen.render(); - } + }, ScreenInstruction::ResizeUp(client_id) => { if let Some(active_tab) = screen.get_active_tab_mut(client_id) { active_tab.resize_up(client_id); @@ -989,7 +989,7 @@ pub(crate) fn screen_thread_main( } screen.render(); - } + }, ScreenInstruction::ResizeIncrease(client_id) => { if let Some(active_tab) = screen.get_active_tab_mut(client_id) { active_tab.resize_increase(client_id); @@ -998,7 +998,7 @@ pub(crate) fn screen_thread_main( } screen.render(); - } + }, ScreenInstruction::ResizeDecrease(client_id) => { if let Some(active_tab) = screen.get_active_tab_mut(client_id) { active_tab.resize_decrease(client_id); @@ -1007,7 +1007,7 @@ pub(crate) fn screen_thread_main( } screen.render(); - } + }, ScreenInstruction::SwitchFocus(client_id) => { if let Some(active_tab) = screen.get_active_tab_mut(client_id) { active_tab.focus_next_pane(client_id); @@ -1016,7 +1016,7 @@ pub(crate) fn screen_thread_main( } screen.render(); - } + }, ScreenInstruction::FocusNextPane(client_id) => { if let Some(active_tab) = screen.get_active_tab_mut(client_id) { active_tab.focus_next_pane(client_id); @@ -1025,7 +1025,7 @@ pub(crate) fn screen_thread_main( } screen.render(); - } + }, ScreenInstruction::FocusPreviousPane(client_id) => { if let Some(active_tab) = screen.get_active_tab_mut(client_id) { active_tab.focus_previous_pane(client_id); @@ -1034,7 +1034,7 @@ pub(crate) fn screen_thread_main( } screen.render(); - } + }, ScreenInstruction::MoveFocusLeft(client_id) => { if let Some(active_tab) = screen.get_active_tab_mut(client_id) { active_tab.move_focus_left(client_id); @@ -1043,7 +1043,7 @@ pub(crate) fn screen_thread_main( } screen.render(); - } + }, ScreenInstruction::MoveFocusLeftOrPreviousTab(client_id) => { screen.move_focus_left_or_previous_tab(client_id); screen @@ -1053,7 +1053,7 @@ pub(crate) fn screen_thread_main( .unwrap(); screen.render(); - } + }, ScreenInstruction::MoveFocusDown(client_id) => { if let Some(active_tab) = screen.get_active_tab_mut(client_id) { active_tab.move_focus_down(client_id); @@ -1062,7 +1062,7 @@ pub(crate) fn screen_thread_main( } screen.render(); - } + }, ScreenInstruction::MoveFocusRight(client_id) => { if let Some(active_tab) = screen.get_active_tab_mut(client_id) { active_tab.move_focus_right(client_id); @@ -1071,7 +1071,7 @@ pub(crate) fn screen_thread_main( } screen.render(); - } + }, ScreenInstruction::MoveFocusRightOrNextTab(client_id) => { screen.move_focus_right_or_next_tab(client_id); screen @@ -1081,7 +1081,7 @@ pub(crate) fn screen_thread_main( .unwrap(); screen.render(); - } + }, ScreenInstruction::MoveFocusUp(client_id) => { if let Some(active_tab) = screen.get_active_tab_mut(client_id) { active_tab.move_focus_up(client_id); @@ -1090,7 +1090,7 @@ pub(crate) fn screen_thread_main( } screen.render(); - } + }, ScreenInstruction::DumpScreen(file, client_id) => { if let Some(active_tab) = screen.get_active_tab_mut(client_id) { active_tab.dump_active_terminal_screen(Some(file.to_string()), client_id); @@ -1099,7 +1099,7 @@ pub(crate) fn screen_thread_main( } screen.render(); - } + }, ScreenInstruction::EditScrollback(client_id) => { if let Some(active_tab) = screen.get_active_tab_mut(client_id) { active_tab.edit_scrollback(client_id); @@ -1108,7 +1108,7 @@ pub(crate) fn screen_thread_main( } screen.render(); - } + }, ScreenInstruction::ScrollUp(client_id) => { if let Some(active_tab) = screen.get_active_tab_mut(client_id) { active_tab.scroll_active_terminal_up(client_id); @@ -1117,7 +1117,7 @@ pub(crate) fn screen_thread_main( } screen.render(); - } + }, ScreenInstruction::MovePane(client_id) => { if let Some(active_tab) = screen.get_active_tab_mut(client_id) { active_tab.move_active_pane(client_id); @@ -1126,7 +1126,7 @@ pub(crate) fn screen_thread_main( } screen.render(); - } + }, ScreenInstruction::MovePaneDown(client_id) => { if let Some(active_tab) = screen.get_active_tab_mut(client_id) { active_tab.move_active_pane_down(client_id); @@ -1135,7 +1135,7 @@ pub(crate) fn screen_thread_main( } screen.render(); - } + }, ScreenInstruction::MovePaneUp(client_id) => { if let Some(active_tab) = screen.get_active_tab_mut(client_id) { active_tab.move_active_pane_up(client_id); @@ -1144,7 +1144,7 @@ pub(crate) fn screen_thread_main( } screen.render(); - } + }, ScreenInstruction::MovePaneRight(client_id) => { if let Some(active_tab) = screen.get_active_tab_mut(client_id) { active_tab.move_active_pane_right(client_id); @@ -1153,7 +1153,7 @@ pub(crate) fn screen_thread_main( } screen.render(); - } + }, ScreenInstruction::MovePaneLeft(client_id) => { if let Some(active_tab) = screen.get_active_tab_mut(client_id) { active_tab.move_active_pane_left(client_id); @@ -1162,7 +1162,7 @@ pub(crate) fn screen_thread_main( } screen.render(); - } + }, ScreenInstruction::ScrollUpAt(point, client_id) => { if let Some(active_tab) = screen.get_active_tab_mut(client_id) { active_tab.scroll_terminal_up(&point, 3, client_id); @@ -1171,7 +1171,7 @@ pub(crate) fn screen_thread_main( } screen.render(); - } + }, ScreenInstruction::ScrollDown(client_id) => { if let Some(active_tab) = screen.get_active_tab_mut(client_id) { active_tab.scroll_active_terminal_down(client_id); @@ -1180,7 +1180,7 @@ pub(crate) fn screen_thread_main( } screen.render(); - } + }, ScreenInstruction::ScrollDownAt(point, client_id) => { if let Some(active_tab) = screen.get_active_tab_mut(client_id) { active_tab.scroll_terminal_down(&point, 3, client_id); @@ -1189,7 +1189,7 @@ pub(crate) fn screen_thread_main( } screen.render(); - } + }, ScreenInstruction::ScrollToBottom(client_id) => { if let Some(active_tab) = screen.get_active_tab_mut(client_id) { active_tab.scroll_active_terminal_to_bottom(client_id); @@ -1198,7 +1198,7 @@ pub(crate) fn screen_thread_main( } screen.render(); - } + }, ScreenInstruction::PageScrollUp(client_id) => { if let Some(active_tab) = screen.get_active_tab_mut(client_id) { active_tab.scroll_active_terminal_up_page(client_id); @@ -1207,7 +1207,7 @@ pub(crate) fn screen_thread_main( } screen.render(); - } + }, ScreenInstruction::PageScrollDown(client_id) => { if let Some(active_tab) = screen.get_active_tab_mut(client_id) { active_tab.scroll_active_terminal_down_page(client_id); @@ -1216,7 +1216,7 @@ pub(crate) fn screen_thread_main( } screen.render(); - } + }, ScreenInstruction::HalfPageScrollUp(client_id) => { if let Some(active_tab) = screen.get_active_tab_mut(client_id) { active_tab.scroll_active_terminal_up_half_page(client_id); @@ -1225,7 +1225,7 @@ pub(crate) fn screen_thread_main( } screen.render(); - } + }, ScreenInstruction::HalfPageScrollDown(client_id) => { if let Some(active_tab) = screen.get_active_tab_mut(client_id) { active_tab.scroll_active_terminal_down_half_page(client_id); @@ -1234,7 +1234,7 @@ pub(crate) fn screen_thread_main( } screen.render(); - } + }, ScreenInstruction::ClearScroll(client_id) => { if let Some(active_tab) = screen.get_active_tab_mut(client_id) { active_tab.clear_active_terminal_scroll(client_id); @@ -1243,7 +1243,7 @@ pub(crate) fn screen_thread_main( } screen.render(); - } + }, ScreenInstruction::CloseFocusedPane(client_id) => { if let Some(active_tab) = screen.get_active_tab_mut(client_id) { active_tab.close_focused_pane(client_id); @@ -1251,7 +1251,7 @@ pub(crate) fn screen_thread_main( log::error!("Active tab not found for client id: {:?}", client_id); } screen.update_tabs(); // update_tabs eventually calls render through the plugin thread - } + }, ScreenInstruction::SetSelectable(id, selectable, tab_index) => { screen.get_indexed_tab_mut(tab_index).map_or_else( || { @@ -1265,7 +1265,7 @@ pub(crate) fn screen_thread_main( ); screen.render(); - } + }, ScreenInstruction::ClosePane(id, client_id) => { match client_id { Some(client_id) => { @@ -1276,7 +1276,7 @@ pub(crate) fn screen_thread_main( log::error!("Active tab not found for client id: {:?}", client_id); None }); - } + }, None => { for tab in screen.tabs.values_mut() { if tab.get_all_pane_ids().contains(&id) { @@ -1284,10 +1284,10 @@ pub(crate) fn screen_thread_main( break; } } - } + }, } screen.update_tabs(); - } + }, ScreenInstruction::UpdatePaneName(c, client_id) => { if let Some(active_tab) = screen.get_active_tab_mut(client_id) { active_tab.update_active_pane_name(c, client_id); @@ -1296,7 +1296,7 @@ pub(crate) fn screen_thread_main( } screen.render(); - } + }, ScreenInstruction::ToggleActiveTerminalFullscreen(client_id) => { if let Some(active_tab) = screen.get_active_tab_mut(client_id) { active_tab.toggle_active_pane_fullscreen(client_id); @@ -1306,14 +1306,14 @@ pub(crate) fn screen_thread_main( screen.update_tabs(); screen.render(); - } + }, ScreenInstruction::TogglePaneFrames => { screen.draw_pane_frames = !screen.draw_pane_frames; for tab in screen.tabs.values_mut() { tab.set_pane_frames(screen.draw_pane_frames); } screen.render(); - } + }, ScreenInstruction::SwitchTabNext(client_id) => { screen.switch_tab_next(client_id); screen @@ -1323,7 +1323,7 @@ pub(crate) fn screen_thread_main( .unwrap(); screen.render(); - } + }, ScreenInstruction::SwitchTabPrev(client_id) => { screen.switch_tab_prev(client_id); screen @@ -1333,7 +1333,7 @@ pub(crate) fn screen_thread_main( .unwrap(); screen.render(); - } + }, ScreenInstruction::CloseTab(client_id) => { screen.close_tab(client_id); screen @@ -1343,7 +1343,7 @@ pub(crate) fn screen_thread_main( .unwrap(); screen.render(); - } + }, ScreenInstruction::NewTab(layout, new_pane_pids, client_id) => { screen.new_tab(layout, new_pane_pids, client_id); screen @@ -1353,7 +1353,7 @@ pub(crate) fn screen_thread_main( .unwrap(); screen.render(); - } + }, ScreenInstruction::GoToTab(tab_index, client_id) => { if let Some(client_id) = client_id.or_else(|| screen.active_tab_indices.keys().next().copied()) @@ -1367,31 +1367,31 @@ pub(crate) fn screen_thread_main( screen.render(); } - } + }, ScreenInstruction::UpdateTabName(c, client_id) => { screen.update_active_tab_name(c, client_id); screen.render(); - } + }, ScreenInstruction::TerminalResize(new_size) => { screen.resize_to_screen(new_size); screen.render(); - } + }, ScreenInstruction::TerminalPixelDimensions(pixel_dimensions) => { screen.update_pixel_dimensions(pixel_dimensions); - } + }, ScreenInstruction::TerminalBackgroundColor(background_color_instruction) => { screen.update_terminal_background_color(background_color_instruction); - } + }, ScreenInstruction::TerminalForegroundColor(background_color_instruction) => { screen.update_terminal_foreground_color(background_color_instruction); - } + }, ScreenInstruction::ChangeMode(mode_info, client_id) => { screen.change_mode(mode_info, client_id); screen.render(); - } + }, ScreenInstruction::ToggleActiveSyncTab(client_id) => { if let Some(active_tab) = screen.get_active_tab_mut(client_id) { active_tab.toggle_sync_panes_is_active(); @@ -1401,7 +1401,7 @@ pub(crate) fn screen_thread_main( screen.update_tabs(); screen.render(); - } + }, ScreenInstruction::LeftClick(point, client_id) => { if let Some(active_tab) = screen.get_active_tab_mut(client_id) { active_tab.handle_left_click(&point, client_id); @@ -1411,7 +1411,7 @@ pub(crate) fn screen_thread_main( screen.update_tabs(); screen.render(); - } + }, ScreenInstruction::RightClick(point, client_id) => { if let Some(active_tab) = screen.get_active_tab_mut(client_id) { active_tab.handle_right_click(&point, client_id); @@ -1421,7 +1421,7 @@ pub(crate) fn screen_thread_main( screen.update_tabs(); screen.render(); - } + }, ScreenInstruction::MouseRelease(point, client_id) => { if let Some(active_tab) = screen.get_active_tab_mut(client_id) { active_tab.handle_mouse_release(&point, client_id); @@ -1430,7 +1430,7 @@ pub(crate) fn screen_thread_main( } screen.render(); - } + }, ScreenInstruction::MouseHold(point, client_id) => { if let Some(active_tab) = screen.get_active_tab_mut(client_id) { active_tab.handle_mouse_hold(&point, client_id); @@ -1439,7 +1439,7 @@ pub(crate) fn screen_thread_main( } screen.render(); - } + }, ScreenInstruction::Copy(client_id) => { if let Some(active_tab) = screen.get_active_tab(client_id) { active_tab.copy_selection(client_id); @@ -1448,10 +1448,10 @@ pub(crate) fn screen_thread_main( } screen.render(); - } + }, ScreenInstruction::Exit => { break; - } + }, ScreenInstruction::ToggleTab(client_id) => { screen.toggle_tab(client_id); screen @@ -1461,18 +1461,18 @@ pub(crate) fn screen_thread_main( .unwrap(); screen.render(); - } + }, ScreenInstruction::AddClient(client_id) => { screen.add_client(client_id); screen.update_tabs(); screen.render(); - } + }, ScreenInstruction::RemoveClient(client_id) => { screen.remove_client(client_id); screen.render(); - } + }, ScreenInstruction::AddOverlay(overlay, _client_id) => { screen.get_active_overlays_mut().pop(); screen.get_active_overlays_mut().push(overlay); @@ -1481,7 +1481,7 @@ pub(crate) fn screen_thread_main( .senders .send_to_server(ServerInstruction::UnblockInputThread) .unwrap(); - } + }, ScreenInstruction::RemoveOverlay(_client_id) => { screen.get_active_overlays_mut().pop(); screen.render(); @@ -1490,7 +1490,7 @@ pub(crate) fn screen_thread_main( .senders .send_to_server(ServerInstruction::UnblockInputThread) .unwrap(); - } + }, ScreenInstruction::ConfirmPrompt(_client_id) => { let overlay = screen.get_active_overlays_mut().pop(); let instruction = overlay.and_then(|o| o.prompt_confirm()); @@ -1502,7 +1502,7 @@ pub(crate) fn screen_thread_main( .senders .send_to_server(ServerInstruction::UnblockInputThread) .unwrap(); - } + }, ScreenInstruction::DenyPrompt(_client_id) => { screen.get_active_overlays_mut().pop(); screen.render(); @@ -1511,7 +1511,7 @@ pub(crate) fn screen_thread_main( .senders .send_to_server(ServerInstruction::UnblockInputThread) .unwrap(); - } + }, } } } diff --git a/zellij-server/src/tab/clipboard.rs b/zellij-server/src/tab/clipboard.rs index 0eab13a96..b2202baf9 100644 --- a/zellij-server/src/tab/clipboard.rs +++ b/zellij-server/src/tab/clipboard.rs @@ -20,7 +20,7 @@ impl ClipboardProvider { match &self { ClipboardProvider::Command(command) => { command.set(content.to_string())?; - } + }, ClipboardProvider::Osc52(clipboard) => { let dest = match clipboard { #[cfg(not(target_os = "macos"))] @@ -33,7 +33,7 @@ impl ClipboardProvider { client_ids, &format!("\u{1b}]52;{};{}\u{1b}\\", dest, base64::encode(content)), ); - } + }, }; Ok(()) } diff --git a/zellij-server/src/tab/mod.rs b/zellij-server/src/tab/mod.rs index 7dd19c251..5d95ac769 100644 --- a/zellij-server/src/tab/mod.rs +++ b/zellij-server/src/tab/mod.rs @@ -474,11 +474,11 @@ impl Tab { match next_selectable_pane_id { Some(active_pane_id) => { self.tiled_panes.focus_pane(active_pane_id, client_id); - } + }, None => { // this is very likely a configuration error (layout with no selectable panes) self.tiled_panes.clear_active_panes(); - } + }, } } } @@ -628,7 +628,7 @@ impl Tab { self.floating_panes .focus_pane(first_floating_pane_id, client_id); } - } + }, None => { // there aren't any floating panes, we need to open a new one // @@ -645,7 +645,7 @@ impl Tab { ClientOrTabIndex::ClientId(client_id), ); self.senders.send_to_pty(instruction).unwrap(); - } + }, } self.floating_panes.set_force_render(); } @@ -729,15 +729,15 @@ impl Tab { .insert(PaneId::Terminal(pid), replaced_pane); let current_active_pane = self.get_active_pane(client_id).unwrap(); // this will be the newly replaced pane we just created resize_pty!(current_active_pane, self.os_api); - } + }, None => { log::error!("Could not find editor pane to replace - is no pane focused?") - } + }, } - } + }, PaneId::Plugin(_pid) => { // TBD, currently unsupported - } + }, } } pub fn horizontal_split(&mut self, pid: PaneId, client_id: ClientId) { @@ -944,14 +944,14 @@ impl Tab { active_terminal_id, )) .unwrap(); - } + }, PaneId::Plugin(pid) => { for key in parse_keys(&input_bytes) { self.senders .send_to_plugin(PluginInstruction::Update(Some(pid), None, Event::Key(key))) .unwrap() } - } + }, } } pub fn get_active_terminal_cursor_position( @@ -1087,11 +1087,11 @@ impl Tab { ); // goto row/col output.add_post_vte_instruction_to_client(client_id, show_cursor); output.add_post_vte_instruction_to_client(client_id, goto_cursor_position); - } + }, None => { let hide_cursor = "\u{1b}[?25l"; output.add_post_vte_instruction_to_client(client_id, hide_cursor); - } + }, } } } @@ -1847,11 +1847,11 @@ impl Tab { .send_to_server(ServerInstruction::Render(Some(serialized_output))) .unwrap(); Event::CopyToClipboard(self.clipboard_provider.as_copy_destination()) - } + }, Err(err) => { log::error!("could not write selection to clipboard: {}", err); Event::SystemClipboardFailure - } + }, }; self.senders .send_to_plugin(PluginInstruction::Update(None, None, clipboard_event)) diff --git a/zellij-server/src/ui/boundaries.rs b/zellij-server/src/ui/boundaries.rs index b78d631cf..a8aff7344 100644 --- a/zellij-server/src/ui/boundaries.rs +++ b/zellij-server/src/ui/boundaries.rs @@ -71,10 +71,10 @@ impl Display for BoundarySymbol { Some(color) => match color { PaletteColor::Rgb((r, g, b)) => { write!(f, "{}", RGB(r, g, b).paint(self.boundary_type)) - } + }, PaletteColor::EightBit(color) => { write!(f, "{}", Fixed(color).paint(self.boundary_type)) - } + }, }, None => write!(f, "{}", self.boundary_type), }, @@ -98,7 +98,7 @@ fn combine_symbols( invisible, color, }) - } + }, (TOP_RIGHT, TOP_RIGHT) => { // (┐, ┐) => Some(┐) let boundary_type = TOP_RIGHT; @@ -107,7 +107,7 @@ fn combine_symbols( invisible, color, }) - } + }, (TOP_RIGHT, VERTICAL) | (TOP_RIGHT, BOTTOM_RIGHT) | (TOP_RIGHT, VERTICAL_LEFT) => { // (┐, │) => Some(┤) // (┐, ┘) => Some(┤) @@ -118,7 +118,7 @@ fn combine_symbols( invisible, color, }) - } + }, (TOP_RIGHT, HORIZONTAL) | (TOP_RIGHT, TOP_LEFT) | (TOP_RIGHT, HORIZONTAL_DOWN) => { // (┐, ─) => Some(┬) // (┐, ┌) => Some(┬) @@ -129,7 +129,7 @@ fn combine_symbols( invisible, color, }) - } + }, (TOP_RIGHT, BOTTOM_LEFT) | (TOP_RIGHT, VERTICAL_RIGHT) | (TOP_RIGHT, HORIZONTAL_UP) => { // (┐, └) => Some(┼) // (┐, ├) => Some(┼) @@ -140,7 +140,7 @@ fn combine_symbols( invisible, color, }) - } + }, (HORIZONTAL, HORIZONTAL) => { // (─, ─) => Some(─) let boundary_type = HORIZONTAL; @@ -149,7 +149,7 @@ fn combine_symbols( invisible, color, }) - } + }, (HORIZONTAL, VERTICAL) | (HORIZONTAL, VERTICAL_LEFT) | (HORIZONTAL, VERTICAL_RIGHT) => { // (─, │) => Some(┼) // (─, ┤) => Some(┼) @@ -160,7 +160,7 @@ fn combine_symbols( invisible, color, }) - } + }, (HORIZONTAL, TOP_LEFT) | (HORIZONTAL, HORIZONTAL_DOWN) => { // (─, ┌) => Some(┬) // (─, ┬) => Some(┬) @@ -170,7 +170,7 @@ fn combine_symbols( invisible, color, }) - } + }, (HORIZONTAL, BOTTOM_RIGHT) | (HORIZONTAL, BOTTOM_LEFT) | (HORIZONTAL, HORIZONTAL_UP) => { // (─, ┘) => Some(┴) // (─, └) => Some(┴) @@ -181,7 +181,7 @@ fn combine_symbols( invisible, color, }) - } + }, (VERTICAL, VERTICAL) => { // (│, │) => Some(│) let boundary_type = VERTICAL; @@ -190,7 +190,7 @@ fn combine_symbols( invisible, color, }) - } + }, (VERTICAL, TOP_LEFT) | (VERTICAL, BOTTOM_LEFT) | (VERTICAL, VERTICAL_RIGHT) => { // (│, ┌) => Some(├) // (│, └) => Some(├) @@ -201,7 +201,7 @@ fn combine_symbols( invisible, color, }) - } + }, (VERTICAL, BOTTOM_RIGHT) | (VERTICAL, VERTICAL_LEFT) => { // (│, ┘) => Some(┤) // (│, ┤) => Some(┤) @@ -211,7 +211,7 @@ fn combine_symbols( invisible, color, }) - } + }, (VERTICAL, HORIZONTAL_DOWN) | (VERTICAL, HORIZONTAL_UP) => { // (│, ┬) => Some(┼) // (│, ┴) => Some(┼) @@ -221,7 +221,7 @@ fn combine_symbols( invisible, color, }) - } + }, (TOP_LEFT, TOP_LEFT) => { // (┌, ┌) => Some(┌) let boundary_type = TOP_LEFT; @@ -230,7 +230,7 @@ fn combine_symbols( invisible, color, }) - } + }, (TOP_LEFT, BOTTOM_RIGHT) | (TOP_LEFT, VERTICAL_LEFT) | (TOP_LEFT, HORIZONTAL_UP) => { // (┌, ┘) => Some(┼) // (┌, ┤) => Some(┼) @@ -241,7 +241,7 @@ fn combine_symbols( invisible, color, }) - } + }, (TOP_LEFT, BOTTOM_LEFT) | (TOP_LEFT, VERTICAL_RIGHT) => { // (┌, └) => Some(├) // (┌, ├) => Some(├) @@ -251,7 +251,7 @@ fn combine_symbols( invisible, color, }) - } + }, (TOP_LEFT, HORIZONTAL_DOWN) => { // (┌, ┬) => Some(┬) let boundary_type = HORIZONTAL_DOWN; @@ -260,7 +260,7 @@ fn combine_symbols( invisible, color, }) - } + }, (BOTTOM_RIGHT, BOTTOM_RIGHT) => { // (┘, ┘) => Some(┘) let boundary_type = BOTTOM_RIGHT; @@ -269,7 +269,7 @@ fn combine_symbols( invisible, color, }) - } + }, (BOTTOM_RIGHT, BOTTOM_LEFT) | (BOTTOM_RIGHT, HORIZONTAL_UP) => { // (┘, └) => Some(┴) // (┘, ┴) => Some(┴) @@ -279,7 +279,7 @@ fn combine_symbols( invisible, color, }) - } + }, (BOTTOM_RIGHT, VERTICAL_LEFT) => { // (┘, ┤) => Some(┤) let boundary_type = VERTICAL_LEFT; @@ -288,7 +288,7 @@ fn combine_symbols( invisible, color, }) - } + }, (BOTTOM_RIGHT, VERTICAL_RIGHT) | (BOTTOM_RIGHT, HORIZONTAL_DOWN) => { // (┘, ├) => Some(┼) // (┘, ┬) => Some(┼) @@ -298,7 +298,7 @@ fn combine_symbols( invisible, color, }) - } + }, (BOTTOM_LEFT, BOTTOM_LEFT) => { // (└, └) => Some(└) let boundary_type = BOTTOM_LEFT; @@ -307,7 +307,7 @@ fn combine_symbols( invisible, color, }) - } + }, (BOTTOM_LEFT, VERTICAL_LEFT) | (BOTTOM_LEFT, HORIZONTAL_DOWN) => { // (└, ┤) => Some(┼) // (└, ┬) => Some(┼) @@ -317,7 +317,7 @@ fn combine_symbols( invisible, color, }) - } + }, (BOTTOM_LEFT, VERTICAL_RIGHT) => { // (└, ├) => Some(├) let boundary_type = VERTICAL_RIGHT; @@ -326,7 +326,7 @@ fn combine_symbols( invisible, color, }) - } + }, (BOTTOM_LEFT, HORIZONTAL_UP) => { // (└, ┴) => Some(┴) let boundary_type = HORIZONTAL_UP; @@ -335,7 +335,7 @@ fn combine_symbols( invisible, color, }) - } + }, (VERTICAL_LEFT, VERTICAL_LEFT) => { // (┤, ┤) => Some(┤) let boundary_type = VERTICAL_LEFT; @@ -344,7 +344,7 @@ fn combine_symbols( invisible, color, }) - } + }, (VERTICAL_LEFT, VERTICAL_RIGHT) | (VERTICAL_LEFT, HORIZONTAL_DOWN) | (VERTICAL_LEFT, HORIZONTAL_UP) => { @@ -357,7 +357,7 @@ fn combine_symbols( invisible, color, }) - } + }, (VERTICAL_RIGHT, VERTICAL_RIGHT) => { // (├, ├) => Some(├) let boundary_type = VERTICAL_RIGHT; @@ -366,7 +366,7 @@ fn combine_symbols( invisible, color, }) - } + }, (VERTICAL_RIGHT, HORIZONTAL_DOWN) | (VERTICAL_RIGHT, HORIZONTAL_UP) => { // (├, ┬) => Some(┼) // (├, ┴) => Some(┼) @@ -376,7 +376,7 @@ fn combine_symbols( invisible, color, }) - } + }, (HORIZONTAL_DOWN, HORIZONTAL_DOWN) => { // (┬, ┬) => Some(┬) let boundary_type = HORIZONTAL_DOWN; @@ -385,7 +385,7 @@ fn combine_symbols( invisible, color, }) - } + }, (HORIZONTAL_DOWN, HORIZONTAL_UP) => { // (┬, ┴) => Some(┼) let boundary_type = CROSS; @@ -394,7 +394,7 @@ fn combine_symbols( invisible, color, }) - } + }, (HORIZONTAL_UP, HORIZONTAL_UP) => { // (┴, ┴) => Some(┴) let boundary_type = HORIZONTAL_UP; @@ -403,7 +403,7 @@ fn combine_symbols( invisible, color, }) - } + }, (_, _) => combine_symbols(next_symbol, current_symbol), } } diff --git a/zellij-server/src/ui/pane_boundaries_frame.rs b/zellij-server/src/ui/pane_boundaries_frame.rs index 905c3b87b..40d0cd6fb 100644 --- a/zellij-server/src/ui/pane_boundaries_frame.rs +++ b/zellij-server/src/ui/pane_boundaries_frame.rs @@ -18,12 +18,12 @@ fn foreground_color(characters: &str, color: Option) -> Vec { let mut styles = CharacterStyles::new(); styles.reset_all(); styles.bold(Some(AnsiCode::On)) - } + }, }; let terminal_character = TerminalCharacter { character, @@ -45,12 +45,12 @@ fn background_color(characters: &str, color: Option) -> Vec { let mut styles = CharacterStyles::new(); styles.reset_all(); styles - } + }, }; let terminal_character = TerminalCharacter { character, @@ -566,7 +566,7 @@ impl PaneFrame { ), (Some((left_side, left_side_len)), None) => { self.left_and_middle_title_line(left_side, &left_side_len, middle, middle_len) - } + }, _ => self.middle_only_title_line(middle, middle_len), } } @@ -580,10 +580,10 @@ impl PaneFrame { match (left_side, right_side) { (Some((left_side, left_side_len)), Some((right_side, right_side_len))) => { self.two_part_title_line(left_side, &left_side_len, right_side, &right_side_len) - } + }, (Some((left_side, left_side_len)), None) => { self.left_only_title_line(left_side, &left_side_len) - } + }, _ => self.empty_title_line(), } } diff --git a/zellij-server/src/ui/pane_contents_and_ui.rs b/zellij-server/src/ui/pane_contents_and_ui.rs index 4a39da8ff..e9702a3d1 100644 --- a/zellij-server/src/ui/pane_contents_and_ui.rs +++ b/zellij-server/src/ui/pane_contents_and_ui.rs @@ -202,7 +202,7 @@ impl<'a> PaneContentsAndUi<'a> { let colors = client_id_to_colors(client_id, self.style.colors); colors.map(|colors| colors.0) } - } + }, _ => Some(self.style.colors.orange), } } else { diff --git a/zellij-server/src/wasm_vm.rs b/zellij-server/src/wasm_vm.rs index 4ae8bd9cf..4e08e6c49 100644 --- a/zellij-server/src/wasm_vm.rs +++ b/zellij-server/src/wasm_vm.rs @@ -128,7 +128,7 @@ pub(crate) fn wasm_thread_main( } pid_tx.send(plugin_id).unwrap(); plugin_id += 1; - } + }, PluginInstruction::Update(pid, cid, event) => { for (&(plugin_id, client_id), (instance, plugin_env)) in &plugin_map { let subs = plugin_env.subscriptions.lock().unwrap(); @@ -146,7 +146,7 @@ pub(crate) fn wasm_thread_main( } } drop(bus.senders.send_to_screen(ScreenInstruction::Render)); - } + }, PluginInstruction::Render(buf_tx, pid, cid, rows, cols) => { if rows == 0 || cols == 0 { buf_tx.send(String::new()).unwrap(); @@ -160,7 +160,7 @@ pub(crate) fn wasm_thread_main( buf_tx.send(wasi_read_string(&plugin_env.wasi_env)).unwrap(); } - } + }, PluginInstruction::Unload(pid) => { info!("Bye from plugin {}", &pid); // TODO: remove plugin's own data directory @@ -170,7 +170,7 @@ pub(crate) fn wasm_thread_main( drop(plugin_map.remove(&(plugin_id, client_id))); } } - } + }, PluginInstruction::AddClient(client_id) => { connected_clients.push(client_id); @@ -203,10 +203,10 @@ pub(crate) fn wasm_thread_main( plugin_id += 1; } } - } + }, PluginInstruction::RemoveClient(client_id) => { connected_clients.retain(|c| c != &client_id); - } + }, PluginInstruction::Exit => break, } } @@ -366,13 +366,13 @@ fn host_set_selectable(plugin_env: &PluginEnv, selectable: i32) { tab_index, )) .unwrap() - } + }, _ => { debug!( "{} - Calling method 'host_set_selectable' does nothing for headless plugins", plugin_env.plugin.location ) - } + }, } } diff --git a/zellij-utils/src/input/config.rs b/zellij-utils/src/input/config.rs index 811f5d54c..4b9f4100b 100644 --- a/zellij-utils/src/input/config.rs +++ b/zellij-utils/src/input/config.rs @@ -131,7 +131,7 @@ impl Config { return Ok(Config::default()); } return Err(ConfigError::Serde(e)); - } + }, Ok(config) => config, }; @@ -149,7 +149,7 @@ impl Config { file.read_to_string(&mut yaml_config) .map_err(|e| ConfigError::IoPath(e, path.to_path_buf()))?; Ok(Config::from_yaml(&yaml_config)?) - } + }, Err(e) => Err(ConfigError::IoPath(e, path.into())), } } diff --git a/zellij-utils/src/input/keybinds.rs b/zellij-utils/src/input/keybinds.rs index 4838fdf64..83177793a 100644 --- a/zellij-utils/src/input/keybinds.rs +++ b/zellij-utils/src/input/keybinds.rs @@ -113,12 +113,12 @@ impl Keybinds { match keybind { KeyActionUnbind::Unbind(unbind) => { unbind_config.insert(mode, unbind.unbind.clone()); - } + }, KeyActionUnbind::KeyAction(key_action_from_yaml) => { keybind_config .0 .insert(mode, ModeKeybinds::from(key_action_from_yaml.clone())); - } + }, } } } @@ -145,19 +145,19 @@ impl Keybinds { for mode in InputMode::iter() { if let Some(unbind) = unbind.get(&mode) { match unbind { - Unbind::All(true) => {} + Unbind::All(true) => {}, Unbind::Keys(keys) => { if let Some(defaults) = self.0.get(&mode) { keybinds .0 .insert(mode, defaults.clone().unbind_keys(keys.to_vec())); } - } + }, Unbind::All(false) => { if let Some(defaults) = self.0.get(&mode) { keybinds.0.insert(mode, defaults.clone()); } - } + }, } } else if let Some(defaults) = self.0.get(&mode) { keybinds.0.insert(mode, defaults.clone()); @@ -210,7 +210,7 @@ impl Keybinds { match *mode { InputMode::Normal | InputMode::Locked => { mode_keybind_or_action(Action::Write(raw_bytes)) - } + }, InputMode::RenameTab => mode_keybind_or_action(Action::TabNameInput(raw_bytes)), InputMode::RenamePane => mode_keybind_or_action(Action::PaneNameInput(raw_bytes)), _ => mode_keybind_or_action(Action::NoOp), diff --git a/zellij-utils/src/input/layout.rs b/zellij-utils/src/input/layout.rs index 4c1131254..b7eff7bda 100644 --- a/zellij-utils/src/input/layout.rs +++ b/zellij-utils/src/input/layout.rs @@ -201,7 +201,7 @@ impl LayoutFromYamlIntermediate { return Ok(LayoutFromYamlIntermediate::default()); } return Err(ConfigError::Serde(e)); - } + }, Ok(config) => config, }; @@ -211,7 +211,7 @@ impl LayoutFromYamlIntermediate { tab.check()?; } Ok(layout) - } + }, None => Ok(LayoutFromYamlIntermediate::default()), } } @@ -225,7 +225,7 @@ impl LayoutFromYamlIntermediate { return Ok(LayoutFromYamlIntermediate::default()); } return Err(ConfigError::Serde(e)); - } + }, Ok(config) => config, }; Ok(layout) @@ -276,7 +276,7 @@ impl LayoutFromYamlIntermediate { } else { LayoutFromYamlIntermediate::from_default_assets(layout) } - } + }, None => LayoutFromYamlIntermediate::from_default_assets(layout), } } @@ -341,7 +341,7 @@ impl LayoutFromYaml { return Ok(LayoutFromYaml::default()); } return Err(ConfigError::Serde(e)); - } + }, Ok(config) => config, }; @@ -351,7 +351,7 @@ impl LayoutFromYaml { tab.check()?; } Ok(layout) - } + }, None => Ok(LayoutFromYaml::default()), } } @@ -362,7 +362,7 @@ impl LayoutFromYaml { match layout_dir { Some(dir) => { Self::new(&dir.join(layout)).or_else(|_| Self::from_default_assets(layout)) - } + }, None => Self::from_default_assets(layout), } } @@ -518,8 +518,8 @@ impl Layout { match part.run { Some(Run::Command(_)) | None => { total_panes += part.total_terminal_panes(); - } - Some(Run::Plugin(_)) => {} + }, + Some(Run::Plugin(_)) => {}, } } total_panes @@ -624,7 +624,7 @@ fn split_space(space_to_split: &PaneGeom, layout: &Layout) -> Vec<(Layout, PaneG panic!("Implicit sizing within fixed-size panes is not supported"); }; Dimension::percent(free_percent / flex_parts as f64) - } + }, }; inherited_dimension.set_inner( layout @@ -682,7 +682,7 @@ impl TryFrom for RunPluginLocation { Err(_) => Err(PluginsConfigError::InvalidPluginLocation(path.to_owned())), }) .map(Self::File) - } + }, _ => Err(PluginsConfigError::InvalidUrl(url)), } } diff --git a/zellij-utils/src/input/mod.rs b/zellij-utils/src/input/mod.rs index 0d51f4f5d..ed88b62d1 100644 --- a/zellij-utils/src/input/mod.rs +++ b/zellij-utils/src/input/mod.rs @@ -118,7 +118,7 @@ pub fn cast_termwiz_key(event: KeyEvent, raw_bytes: &[u8]) -> Key { } else { Key::Char(c) } - } + }, KeyCode::Backspace => Key::Backspace, KeyCode::LeftArrow | KeyCode::ApplicationLeftArrow => { if modifiers.contains(Modifiers::ALT) { @@ -126,14 +126,14 @@ pub fn cast_termwiz_key(event: KeyEvent, raw_bytes: &[u8]) -> Key { } else { Key::Left } - } + }, KeyCode::RightArrow | KeyCode::ApplicationRightArrow => { if modifiers.contains(Modifiers::ALT) { Key::Alt(CharOrArrow::Direction(Direction::Right)) } else { Key::Right } - } + }, KeyCode::UpArrow | KeyCode::ApplicationUpArrow => { if modifiers.contains(Modifiers::ALT) { //Key::AltPlusUpArrow @@ -141,14 +141,14 @@ pub fn cast_termwiz_key(event: KeyEvent, raw_bytes: &[u8]) -> Key { } else { Key::Up } - } + }, KeyCode::DownArrow | KeyCode::ApplicationDownArrow => { if modifiers.contains(Modifiers::ALT) { Key::Alt(CharOrArrow::Direction(Direction::Down)) } else { Key::Down } - } + }, KeyCode::Home => Key::Home, KeyCode::End => Key::End, KeyCode::PageUp => Key::PageUp, diff --git a/zellij-utils/src/input/plugins.rs b/zellij-utils/src/input/plugins.rs index 5d169849c..fba3c531c 100644 --- a/zellij-utils/src/input/plugins.rs +++ b/zellij-utils/src/input/plugins.rs @@ -146,8 +146,8 @@ impl PluginConfig { match self.run { PluginType::Pane(..) => { self.run = PluginType::Pane(Some(tab_index)); - } - PluginType::Headless => {} + }, + PluginType::Headless => {}, } } } diff --git a/zellij-utils/src/ipc.rs b/zellij-utils/src/ipc.rs index ea6b4039c..a07a67851 100644 --- a/zellij-utils/src/ipc.rs +++ b/zellij-utils/src/ipc.rs @@ -193,7 +193,7 @@ where Err(e) => { warn!("Error in IpcReceiver.recv(): {:?}", e); None - } + }, } } diff --git a/zellij-utils/src/setup.rs b/zellij-utils/src/setup.rs index f5d149616..ab0509832 100644 --- a/zellij-utils/src/setup.rs +++ b/zellij-utils/src/setup.rs @@ -218,7 +218,7 @@ impl Setup { Ok(config) => config, Err(e) => { return Err(e); - } + }, } } else { Config::default() @@ -241,7 +241,7 @@ impl Setup { Some(Ok(layout)) => Some(layout), Some(Err(e)) => { return Err(e); - } + }, }; if let Some(Command::Setup(ref setup)) = &opts.command { @@ -431,20 +431,20 @@ impl Setup { _ => { eprintln!("Unsupported shell: {}", shell); std::process::exit(1); - } + }, }; let mut out = std::io::stdout(); clap_complete::generate(shell, &mut CliArgs::command(), "zellij", &mut out); // add shell dependent extra completion match shell { - Shell::Bash => {} - Shell::Elvish => {} + Shell::Bash => {}, + Shell::Elvish => {}, Shell::Fish => { let _ = out.write_all(FISH_EXTRA_COMPLETION); - } - Shell::PowerShell => {} - Shell::Zsh => {} - _ => {} + }, + Shell::PowerShell => {}, + Shell::Zsh => {}, + _ => {}, }; } @@ -454,21 +454,21 @@ impl Setup { _ => { eprintln!("Unsupported shell: {}", shell); std::process::exit(1); - } + }, }; let mut out = std::io::stdout(); match shell { Shell::Bash => { let _ = out.write_all(BASH_AUTO_START_SCRIPT); - } + }, Shell::Fish => { let _ = out.write_all(FISH_AUTO_START_SCRIPT); - } + }, Shell::Zsh => { let _ = out.write_all(ZSH_AUTO_START_SCRIPT); - } - _ => {} + }, + _ => {}, } } } diff --git a/zellij-utils/src/shared.rs b/zellij-utils/src/shared.rs index 0f9756823..6df753daf 100644 --- a/zellij-utils/src/shared.rs +++ b/zellij-utils/src/shared.rs @@ -112,7 +112,7 @@ pub fn detect_theme_hue(bg: PaletteColor) -> ThemeHue { true => ThemeHue::Light, false => ThemeHue::Dark, } - } + }, _ => ThemeHue::Dark, } }