mirror of
https://github.com/wez/wezterm.git
synced 2024-11-24 07:46:59 +03:00
parent
6ba9d7f72e
commit
aa52555fb8
@ -32,6 +32,7 @@ bitflags::bitflags! {
|
||||
const LAUNCH_MENU_ITEMS = 4;
|
||||
const DOMAINS = 8;
|
||||
const KEY_ASSIGNMENTS = 16;
|
||||
const WORKSPACES = 32;
|
||||
}
|
||||
}
|
||||
|
||||
@ -69,6 +70,8 @@ pub struct LauncherArgs {
|
||||
pane_id: PaneId,
|
||||
domain_id_of_current_tab: DomainId,
|
||||
title: String,
|
||||
active_workspace: String,
|
||||
workspaces: Vec<String>,
|
||||
}
|
||||
|
||||
impl LauncherArgs {
|
||||
@ -82,6 +85,14 @@ impl LauncherArgs {
|
||||
) -> Self {
|
||||
let mux = Mux::get().unwrap();
|
||||
|
||||
let active_workspace = mux.active_workspace();
|
||||
|
||||
let workspaces = if flags.contains(LauncherFlags::WORKSPACES) {
|
||||
mux.iter_workspaces()
|
||||
} else {
|
||||
vec![]
|
||||
};
|
||||
|
||||
let tabs = if flags.contains(LauncherFlags::TABS) {
|
||||
// Ideally we'd resolve the tabs on the fly once we've started the
|
||||
// overlay, but since the overlay runs in a different thread, accessing
|
||||
@ -152,6 +163,8 @@ impl LauncherArgs {
|
||||
pane_id,
|
||||
domain_id_of_current_tab,
|
||||
title: title.to_string(),
|
||||
workspaces,
|
||||
active_workspace,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -254,6 +267,27 @@ impl LauncherState {
|
||||
self.entries.push(entry);
|
||||
}
|
||||
|
||||
if args.flags.contains(LauncherFlags::WORKSPACES) {
|
||||
for ws in &args.workspaces {
|
||||
if *ws != args.active_workspace {
|
||||
self.entries.push(Entry {
|
||||
label: format!("Switch to workspace: `{}`", ws),
|
||||
kind: EntryKind::KeyAssignment(KeyAssignment::SwitchToWorkspace {
|
||||
name: Some(ws.clone()),
|
||||
spawn: None,
|
||||
}),
|
||||
});
|
||||
}
|
||||
}
|
||||
self.entries.push(Entry {
|
||||
label: "Create new Workspace".to_string(),
|
||||
kind: EntryKind::KeyAssignment(KeyAssignment::SwitchToWorkspace {
|
||||
name: None,
|
||||
spawn: None,
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
for tab in &args.tabs {
|
||||
self.entries.push(Entry {
|
||||
label: format!("{}. {} panes", tab.title, tab.pane_count),
|
||||
|
@ -1685,6 +1685,7 @@ impl TermWindow {
|
||||
self.show_launcher_impl(
|
||||
"Launcher",
|
||||
LauncherFlags::LAUNCH_MENU_ITEMS
|
||||
| LauncherFlags::WORKSPACES
|
||||
| LauncherFlags::DOMAINS
|
||||
| LauncherFlags::KEY_ASSIGNMENTS,
|
||||
);
|
||||
@ -2091,6 +2092,7 @@ impl TermWindow {
|
||||
tab.toggle_zoom();
|
||||
}
|
||||
SwitchToWorkspace { name, spawn } => {
|
||||
let activity = crate::Activity::new();
|
||||
let mux = Mux::get().unwrap();
|
||||
let name = name
|
||||
.as_ref()
|
||||
@ -2122,6 +2124,7 @@ impl TermWindow {
|
||||
log::error!("Failed to spawn: {:#}", err);
|
||||
}
|
||||
switcher.do_switch();
|
||||
drop(activity);
|
||||
})
|
||||
.detach();
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user