1
1
mirror of https://github.com/wez/wezterm.git synced 2024-10-28 09:22:19 +03:00

launcher: show some domain details

Show the type of mux connection and the destination host alongside
the convenient name from the user's config.
This commit is contained in:
Wez Furlong 2020-03-03 08:25:11 -08:00
parent 0bf67d7b69
commit 58310627be
5 changed files with 37 additions and 5 deletions

View File

@ -57,7 +57,7 @@ pub fn launcher(
for (domain_id, domain_state, domain_name) in &domains {
let entry = if *domain_state == DomainState::Attached {
Entry::Spawn {
label: format!("New Tab (domain `{}`)", domain_name),
label: format!("New Tab ({})", domain_name),
command: SpawnCommand {
domain: SpawnTabDomain::Domain(*domain_id),
..SpawnCommand::default()
@ -66,7 +66,7 @@ pub fn launcher(
}
} else {
Entry::Attach {
label: format!("Attach domain `{}`", domain_name),
label: format!("Attach {}", domain_name),
domain: *domain_id,
}
};

View File

@ -1080,7 +1080,16 @@ impl TermWindow {
domains.retain(|dom| dom.spawnable());
let domains: Vec<(DomainId, DomainState, String)> = domains
.iter()
.map(|dom| (dom.domain_id(), dom.state(), dom.domain_name().to_owned()))
.map(|dom| {
let name = dom.domain_name();
let label = dom.domain_label();
let label = if name == label || label == "" {
format!("domain `{}`", name)
} else {
format!("domain `{}` - {}", name, label)
};
(dom.domain_id(), dom.state(), label)
})
.collect();
let domain_id_of_current_tab = tab.domain_id();

View File

@ -53,9 +53,15 @@ pub trait Domain: Downcast {
/// a handle on the domain later.
fn domain_id(&self) -> DomainId;
/// Returns the name of the domain
/// Returns the name of the domain.
/// Should be a short identifier.
fn domain_name(&self) -> &str;
/// Returns a label describing the domain.
fn domain_label(&self) -> &str {
self.domain_name()
}
/// Re-attach to any tabs that might be pre-existing in this domain
async fn attach(&self) -> anyhow::Result<()>;

View File

@ -99,6 +99,16 @@ impl ClientDomainConfig {
}
}
pub fn label(&self) -> String {
match self {
ClientDomainConfig::Unix(unix) => format!("unix mux {}", unix.socket_path().display()),
ClientDomainConfig::Tls(tls) => format!("TLS mux {}", tls.remote_address),
ClientDomainConfig::Ssh(ssh) => {
format!("SSH mux {}@{}", ssh.username, ssh.remote_address)
}
}
}
pub fn connect_automatically(&self) -> bool {
match self {
ClientDomainConfig::Unix(unix) => unix.connect_automatically,
@ -127,6 +137,7 @@ impl ClientInner {
pub struct ClientDomain {
config: ClientDomainConfig,
label: String,
inner: RefCell<Option<Arc<ClientInner>>>,
local_domain_id: DomainId,
}
@ -134,8 +145,10 @@ pub struct ClientDomain {
impl ClientDomain {
pub fn new(config: ClientDomainConfig) -> Self {
let local_domain_id = alloc_domain_id();
let label = config.label();
Self {
config,
label,
inner: RefCell::new(None),
local_domain_id,
}
@ -283,6 +296,10 @@ impl Domain for ClientDomain {
self.config.name()
}
fn domain_label(&self) -> &str {
&self.label
}
async fn spawn(
&self,
size: PtySize,

View File

@ -233,7 +233,7 @@ impl RemoteSshDomain {
Self {
pty_system,
id,
name: name.to_string(),
name: format!("SSH to {}", name),
}
}
}