diff options
author | Aram Drevekenin <aram@poor.dev> | 2024-04-30 14:54:42 +0200 |
---|---|---|
committer | Aram Drevekenin <aram@poor.dev> | 2024-04-30 14:54:42 +0200 |
commit | 2133f3aeab7c9519018be9d763865b9dbe0252e2 (patch) | |
tree | 216050770c518e3be7507e0d08d659c41cf47de7 | |
parent | 6207734b6b54cba14c8aac77d10bf3517f0157cb (diff) |
style(fmt): rustfmtlist-clients
-rw-r--r-- | zellij-server/src/pty.rs | 8 | ||||
-rw-r--r-- | zellij-server/src/route.rs | 5 | ||||
-rw-r--r-- | zellij-server/src/screen.rs | 30 | ||||
-rw-r--r-- | zellij-server/src/session_layout_metadata.rs | 57 | ||||
-rw-r--r-- | zellij-utils/src/input/actions.rs | 4 |
5 files changed, 74 insertions, 30 deletions
diff --git a/zellij-server/src/pty.rs b/zellij-server/src/pty.rs index 74ea1cf0d..f8bd61d22 100644 --- a/zellij-server/src/pty.rs +++ b/zellij-server/src/pty.rs @@ -639,7 +639,13 @@ pub(crate) fn pty_thread_main(mut pty: Pty, layout: Box<Layout>) -> Result<()> { pty.populate_session_layout_metadata(&mut session_layout_metadata); pty.bus .senders - .send_to_server(ServerInstruction::Log(vec![format!("{}", session_layout_metadata.list_clients_metadata())], client_id)) + .send_to_server(ServerInstruction::Log( + vec![format!( + "{}", + session_layout_metadata.list_clients_metadata() + )], + client_id, + )) .with_context(err_context) .non_fatal(); }, diff --git a/zellij-server/src/route.rs b/zellij-server/src/route.rs index 394d214d0..fc50fd2c5 100644 --- a/zellij-server/src/route.rs +++ b/zellij-server/src/route.rs @@ -932,7 +932,10 @@ pub(crate) fn route_action( _ => None, }; senders - .send_to_screen(ScreenInstruction::ListClientsMetadata(default_shell, client_id)) + .send_to_screen(ScreenInstruction::ListClientsMetadata( + default_shell, + client_id, + )) .with_context(err_context)?; }, } diff --git a/zellij-server/src/screen.rs b/zellij-server/src/screen.rs index d2b2848d0..75d345626 100644 --- a/zellij-server/src/screen.rs +++ b/zellij-server/src/screen.rs @@ -2168,12 +2168,20 @@ impl Screen { suppressed_panes.insert(*triggering_pane_id, p); } - let all_connected_clients: Vec<ClientId> = - self.connected_clients.borrow().iter().copied().filter(|c| self.active_tab_indices.get(&c) == Some(&tab_index)).collect(); + let all_connected_clients: Vec<ClientId> = self + .connected_clients + .borrow() + .iter() + .copied() + .filter(|c| self.active_tab_indices.get(&c) == Some(&tab_index)) + .collect(); let mut active_pane_ids: HashMap<ClientId, Option<PaneId>> = HashMap::new(); for connected_client_id in &all_connected_clients { - active_pane_ids.insert(*connected_client_id, tab.get_active_pane_id(*connected_client_id)); + active_pane_ids.insert( + *connected_client_id, + tab.get_active_pane_id(*connected_client_id), + ); } let tiled_panes: Vec<PaneLayoutMetadata> = tab @@ -2192,7 +2200,12 @@ impl Screen { } }) .map(|(pane_id, p)| { - let focused_clients: Vec<ClientId> = active_pane_ids.iter().filter_map(|(c_id, p_id)| p_id.and_then(|p_id| if p_id == pane_id { Some(*c_id) } else { None })).collect(); + let focused_clients: Vec<ClientId> = active_pane_ids + .iter() + .filter_map(|(c_id, p_id)| { + p_id.and_then(|p_id| if p_id == pane_id { Some(*c_id) } else { None }) + }) + .collect(); PaneLayoutMetadata::new( pane_id, p.position_and_size(), @@ -2205,7 +2218,7 @@ impl Screen { } else { None }, - focused_clients + focused_clients, ) }) .collect(); @@ -2225,7 +2238,12 @@ impl Screen { } }) .map(|(pane_id, p)| { - let focused_clients: Vec<ClientId> = active_pane_ids.iter().filter_map(|(c_id, p_id)| p_id.and_then(|p_id| if p_id == pane_id { Some(*c_id) } else { None })).collect(); + let focused_clients: Vec<ClientId> = active_pane_ids + .iter() + .filter_map(|(c_id, p_id)| { + p_id.and_then(|p_id| if p_id == pane_id { Some(*c_id) } else { None }) + }) + .collect(); PaneLayoutMetadata::new( pane_id, p.position_and_size(), diff --git a/zellij-server/src/session_layout_metadata.rs b/zellij-server/src/session_layout_metadata.rs index 7c2716454..0ca25804e 100644 --- a/zellij-server/src/session_layout_metadata.rs +++ b/zellij-server/src/session_layout_metadata.rs @@ -1,13 +1,16 @@ -use crate::ClientId; use crate::panes::PaneId; -use std::collections::{HashMap, BTreeMap}; +use crate::ClientId; +use std::collections::{BTreeMap, HashMap}; use std::path::PathBuf; use zellij_utils::common_path::common_path_all; use zellij_utils::pane_size::PaneGeom; use zellij_utils::{ input::command::RunCommand, input::layout::{Layout, Run, RunPlugin, RunPluginOrAlias}, - session_serialization::{GlobalLayoutManifest, PaneLayoutManifest, TabLayoutManifest, extract_command_and_args, extract_plugin_and_config, extract_edit_and_line_number}, + session_serialization::{ + extract_command_and_args, extract_edit_and_line_number, extract_plugin_and_config, + GlobalLayoutManifest, PaneLayoutManifest, TabLayoutManifest, + }, }; #[derive(Default, Debug, Clone)] @@ -58,16 +61,22 @@ impl SessionLayoutMetadata { pub fn list_clients_metadata(&self) -> String { let mut clients_metadata: BTreeMap<ClientId, ClientMetadata> = BTreeMap::new(); for tab in &self.tabs { - let panes = if tab.hide_floating_panes { &tab.tiled_panes } else { &tab.floating_panes }; + let panes = if tab.hide_floating_panes { + &tab.tiled_panes + } else { + &tab.floating_panes + }; for pane in panes { for focused_client in &pane.focused_clients { - clients_metadata.insert(*focused_client, ClientMetadata { - pane_id: pane.id.clone(), - command: pane.run.clone(), - }); + clients_metadata.insert( + *focused_client, + ClientMetadata { + pane_id: pane.id.clone(), + command: pane.run.clone(), + }, + ); } } - } ClientMetadata::render_many(clients_metadata, &self.default_editor) @@ -311,7 +320,7 @@ impl PaneLayoutMetadata { struct ClientMetadata { pane_id: PaneId, - command: Option<Run> + command: Option<Run>, } impl ClientMetadata { pub fn stringify_pane_id(&self) -> String { @@ -325,30 +334,40 @@ impl ClientMetadata { Some(Run::Command(..)) => { let (command, args) = extract_command_and_args(&self.command); command.map(|c| format!("{} {}", c, args.join(" "))) - } + }, Some(Run::EditFile(..)) => { let (file_to_edit, _line_number) = extract_edit_and_line_number(&self.command); - editor - .as_ref() - .and_then(|editor| file_to_edit + editor.as_ref().and_then(|editor| { + file_to_edit .map(|file_to_edit| format!("{} {}", editor.display(), file_to_edit)) - ) - } + }) + }, Some(Run::Plugin(..)) => { let (plugin, _plugin_config) = extract_plugin_and_config(&self.command); plugin.map(|p| format!("{}", p)) - } + }, _ => None, }; stringified.unwrap_or("N/A".to_owned()) } - pub fn render_many(clients_metadata: BTreeMap<ClientId, ClientMetadata>, default_editor: &Option<PathBuf>) -> String { + pub fn render_many( + clients_metadata: BTreeMap<ClientId, ClientMetadata>, + default_editor: &Option<PathBuf>, + ) -> String { let mut lines = vec![]; lines.push(String::from("CLIENT_ID ZELLIJ_PANE_ID RUNNING_COMMAND")); for (client_id, client_metadata) in clients_metadata.iter() { // 9 - CLIENT_ID, 14 - ZELLIJ_PANE_ID, 15 - RUNNING_COMMAND - lines.push(format!("{} {} {}", format!("{0: <9}", client_id), format!("{0: <14}", client_metadata.stringify_pane_id()), format!("{0: <15}", client_metadata.stringify_command(default_editor)))); + lines.push(format!( + "{} {} {}", + format!("{0: <9}", client_id), + format!("{0: <14}", client_metadata.stringify_pane_id()), + format!( + "{0: <15}", + client_metadata.stringify_command(default_editor) + ) + )); } lines.join("\n") } diff --git a/zellij-utils/src/input/actions.rs b/zellij-utils/src/input/actions.rs index c988bcbae..e36ca763b 100644 --- a/zellij-utils/src/input/actions.rs +++ b/zellij-utils/src/input/actions.rs @@ -690,9 +690,7 @@ impl Action { skip_cache, }]) }, - CliAction::ListClients => { - Ok(vec![Action::ListClients]) - } + CliAction::ListClients => Ok(vec![Action::ListClients]), } } } |