mirror of
https://github.com/zellij-org/zellij.git
synced 2024-11-29 04:15:06 +03:00
style(fmt): rustfmt
This commit is contained in:
parent
6207734b6b
commit
2133f3aeab
@ -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();
|
||||
},
|
||||
|
@ -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)?;
|
||||
},
|
||||
}
|
||||
|
@ -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(),
|
||||
|
@ -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")
|
||||
}
|
||||
|
@ -690,9 +690,7 @@ impl Action {
|
||||
skip_cache,
|
||||
}])
|
||||
},
|
||||
CliAction::ListClients => {
|
||||
Ok(vec![Action::ListClients])
|
||||
}
|
||||
CliAction::ListClients => Ok(vec![Action::ListClients]),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user