Add SwitchToWorkspace keyassignment action

This action causes the active workspace for the gui to change.

If the name is omitted a random name will be generated.
If the workspace doesn't exist, it will be be created.
The optional spawn parameter can be used to launch a specific
program into the new workspace; if omitted, the default prog
will be used.

The gui only supports a single active workspace. Switching workspaces
will repurpose existing gui windows and re-assign them to windows
in the new workspace, adjusting their size to fit those windows,
spawning new windows or closing unused windows as required.

The gui now exits when there are no panes in the active workspace,
rather than no panes at all.

refs: #1531
This commit is contained in:
Wez Furlong committed 2022-01-15 13:53:34 -07:00
1 parent 626a022dd5
commit 6d288696c8
21 files changed
+328 -43

No files matched your search

+2 -1
View File
@@ -405,7 +405,7 @@ macro_rules! pdu {
/// The overall version of the codec.
/// This must be bumped when backwards incompatible changes
/// are made to the types and protocol.
pub const CODEC_VERSION: usize = 16;
pub const CODEC_VERSION: usize = 17;
// Defines the Pdu enum.
// Each struct has an explicit identifying number.
@@ -592,6 +592,7 @@ pub struct SpawnV2 {
pub command: Option<CommandBuilder>,
pub command_dir: Option<String>,
pub size: PtySize,
pub workspace: String,
}
#[derive(Deserialize, Serialize, PartialEq, Debug)]
+5
View File
@@ -264,6 +264,11 @@ pub enum KeyAssignment {
QuickSelectArgs(QuickSelectArguments),
Multiple(Vec<KeyAssignment>),
SwitchToWorkspace {
name: Option<String>,
spawn: Option<SpawnCommand>,
},
}
impl_lua_conversion!(KeyAssignment);
+58 -6
View File
@@ -53,6 +53,7 @@ pub enum MuxNotification {
WindowRemoved(WindowId),
WindowInvalidated(WindowId),
WindowWorkspaceChanged(WindowId),
ActiveWorkspaceChanged(Arc<ClientId>),
Alert {
pane_id: PaneId,
alert: wezterm_term::Alert,
@@ -73,6 +74,7 @@ pub struct Mux {
banner: RefCell<Option<String>>,
clients: RefCell<HashMap<ClientId, ClientInfo>>,
identity: RefCell<Option<Arc<ClientId>>>,
num_panes_by_workspace: RefCell<HashMap<String, usize>>,
}
const BUFSIZE: usize = 1024 * 1024;
@@ -328,9 +330,21 @@ impl Mux {
banner: RefCell::new(None),
clients: RefCell::new(HashMap::new()),
identity: RefCell::new(None),
num_panes_by_workspace: RefCell::new(HashMap::new()),
}
}
fn recompute_pane_count(&self) {
let mut count = HashMap::new();
for window in self.windows.borrow().values() {
let workspace = window.get_workspace();
for tab in window.iter() {
*count.entry(workspace.to_string()).or_insert(0) += tab.count_panes();
}
}
*self.num_panes_by_workspace.borrow_mut() = count;
}
pub fn client_had_input(&self, client_id: &ClientId) {
if let Some(info) = self.clients.borrow_mut().get_mut(client_id) {
info.update_last_input();
@@ -396,12 +410,22 @@ impl Mux {
.unwrap_or_else(|| DEFAULT_WORKSPACE.to_string())
}
/// Returns the effective active workspace name for a given client
pub fn active_workspace_for_client(&self, ident: &Arc<ClientId>) -> String {
self.clients
.borrow()
.get(&ident)
.and_then(|info| info.active_workspace.clone())
.unwrap_or_else(|| DEFAULT_WORKSPACE.to_string())
}
/// Assigns the active workspace name for the current identity
pub fn set_active_workspace(&self, workspace: &str) {
if let Some(ident) = self.identity.borrow().clone() {
let mut clients = self.clients.borrow_mut();
if let Some(info) = clients.get_mut(&ident) {
info.active_workspace.replace(workspace.to_string());
self.notify(MuxNotification::ActiveWorkspaceChanged(ident));
}
}
}
@@ -420,6 +444,11 @@ impl Mux {
std::mem::replace(&mut *self.identity.borrow_mut(), id)
}
/// Returns the active identity
pub fn active_identity(&self) -> Option<Arc<ClientId>> {
self.identity.borrow().clone()
}
pub fn unregister_client(&self, client_id: &ClientId) {
self.clients.borrow_mut().remove(client_id);
}
@@ -512,12 +541,14 @@ impl Mux {
let banner = self.banner.borrow().clone();
thread::spawn(move || read_from_pane_pty(pane_id, banner, reader));
}
self.recompute_pane_count();
self.notify(MuxNotification::PaneAdded(pane_id));
Ok(())
}
pub fn add_tab_no_panes(&self, tab: &Rc<Tab>) {
self.tabs.borrow_mut().insert(tab.tab_id(), Rc::clone(tab));
self.recompute_pane_count();
}
pub fn add_tab_and_active_pane(&self, tab: &Rc<Tab>) -> Result<(), Error> {
@@ -530,9 +561,10 @@ impl Mux {
fn remove_pane_internal(&self, pane_id: PaneId) {
log::debug!("removing pane {}", pane_id);
if let Some(pane) = self.panes.borrow_mut().remove(&pane_id) {
if let Some(pane) = self.panes.borrow_mut().remove(&pane_id).clone() {
log::debug!("killing pane {}", pane_id);
pane.kill();
self.recompute_pane_count();
self.notify(MuxNotification::PaneRemoved(pane_id));
}
}
@@ -555,6 +587,7 @@ impl Mux {
for pane_id in pane_ids {
self.remove_pane_internal(pane_id);
}
self.recompute_pane_count();
Some(tab)
}
@@ -572,6 +605,7 @@ impl Mux {
}
self.notify(MuxNotification::WindowRemoved(window_id));
}
self.recompute_pane_count();
}
pub fn remove_pane(&self, pane_id: PaneId) {
@@ -665,8 +699,8 @@ impl Mux {
window.get_active().map(Rc::clone)
}
pub fn new_empty_window(&self) -> MuxWindowBuilder {
let window = Window::new();
pub fn new_empty_window(&self, workspace: Option<String>) -> MuxWindowBuilder {
let window = Window::new(workspace);
let window_id = window.window_id();
self.windows.borrow_mut().insert(window_id, window);
MuxWindowBuilder {
@@ -699,6 +733,20 @@ impl Mux {
self.panes.borrow().is_empty()
}
pub fn is_workspace_empty(&self, workspace: &str) -> bool {
*self
.num_panes_by_workspace
.borrow()
.get(workspace)
.unwrap_or(&0)
== 0
}
pub fn is_active_workspace_empty(&self) -> bool {
let workspace = self.active_workspace();
self.is_workspace_empty(&workspace)
}
pub fn iter_panes(&self) -> Vec<Rc<dyn Pane>> {
self.panes
.borrow()
@@ -708,7 +756,8 @@ impl Mux {
}
pub fn iter_windows_in_workspace(&self, workspace: &str) -> Vec<WindowId> {
self.windows
let mut windows: Vec<WindowId> = self
.windows
.borrow()
.iter()
.filter_map(|(k, w)| {
@@ -719,7 +768,9 @@ impl Mux {
}
})
.cloned()
.collect()
.collect();
windows.sort();
windows
}
pub fn iter_windows(&self) -> Vec<WindowId> {
@@ -888,6 +939,7 @@ impl Mux {
command_dir: Option<String>,
size: PtySize,
current_pane_id: Option<PaneId>,
workspace_for_new_window: String,
) -> anyhow::Result<(Rc<Tab>, Rc<dyn Pane>, WindowId)> {
let domain = self
.resolve_spawn_tab_domain(current_pane_id, &domain)
@@ -913,7 +965,7 @@ impl Mux {
(window_id, size)
} else {
term_config = None;
window_builder = self.new_empty_window();
window_builder = self.new_empty_window(Some(workspace_for_new_window));
(*window_builder, size)
};
+5 -5
View File
@@ -197,10 +197,10 @@ fn build_from_pane_tree<F>(
tree: bintree::Tree<PaneEntry, SplitDirectionAndSize>,
active: &mut Option<Rc<dyn Pane>>,
zoomed: &mut Option<Rc<dyn Pane>>,
make_pane: &F,
make_pane: &mut F,
) -> Tree
where
F: Fn(PaneEntry) -> Rc<dyn Pane>,
F: FnMut(PaneEntry) -> Rc<dyn Pane>,
{
match tree {
bintree::Tree::Empty => Tree::Empty,
@@ -429,16 +429,16 @@ impl Tab {
/// PaneEntry, or to create a new Pane from that entry.
/// make_pane is expected to add the pane to the mux if it creates
/// a new pane, otherwise the pane won't poll/update in the GUI.
pub fn sync_with_pane_tree<F>(&self, size: PtySize, root: PaneNode, make_pane: F)
pub fn sync_with_pane_tree<F>(&self, size: PtySize, root: PaneNode, mut make_pane: F)
where
F: Fn(PaneEntry) -> Rc<dyn Pane>,
F: FnMut(PaneEntry) -> Rc<dyn Pane>,
{
let mut active = None;
let mut zoomed = None;
log::debug!("sync_with_pane_tree with size {:?}", size);
let t = build_from_pane_tree(root.into_tree(), &mut active, &mut zoomed, &make_pane);
let t = build_from_pane_tree(root.into_tree(), &mut active, &mut zoomed, &mut make_pane);
let mut cursor = t.cursor();
*self.active.borrow_mut() = 0;
+1 -1
View File
@@ -481,7 +481,7 @@ pub async fn run<
let domain: Arc<dyn Domain> = Arc::new(TermWizTerminalDomain::new());
mux.add_domain(&domain);
let window_id = mux.new_empty_window();
let window_id = mux.new_empty_window(None);
let pane = TermWizTerminalPane::new(domain.domain_id(), size, input_tx, render_rx);
let pane: Rc<dyn Pane> = Rc::new(pane);
+6 -4
View File
@@ -17,16 +17,18 @@ pub struct Window {
}
impl Window {
pub fn new() -> Self {
pub fn new(workspace: Option<String>) -> Self {
Self {
id: WIN_ID.fetch_add(1, ::std::sync::atomic::Ordering::Relaxed),
tabs: vec![],
active: 0,
last_active: None,
clipboard: None,
workspace: Mux::get()
.expect("Window::new to be called on mux thread")
.active_workspace(),
workspace: workspace.unwrap_or_else(|| {
Mux::get()
.expect("Window::new to be called on mux thread")
.active_workspace()
}),
}
}
+10 -1
View File
@@ -196,6 +196,9 @@ fn mux_notify_client_domain(local_domain_id: DomainId, notif: MuxNotification) -
None => return false,
};
match notif {
MuxNotification::ActiveWorkspaceChanged(_client_id) => {
// TODO: advice remote host of interesting workspaces
}
MuxNotification::WindowWorkspaceChanged(window_id) => {
if let Some(remote_window_id) = domain.local_to_remote_window_id(window_id) {
if let Some(workspace) = mux
@@ -334,7 +337,9 @@ impl ClientDomain {
}
log::debug!("tree: {:#?}", tabroot);
let mut workspace = None;
tab.sync_with_pane_tree(root_size, tabroot, |entry| {
workspace.replace(entry.workspace.clone());
if let Some(pane_id) = inner.remote_to_local_pane_id(entry.pane_id) {
match mux.get_pane(pane_id) {
Some(pane) => pane,
@@ -380,7 +385,7 @@ impl ClientDomain {
window.push(&tab);
}
} else {
let local_window_id = mux.new_empty_window();
let local_window_id = mux.new_empty_window(workspace.take());
inner.record_remote_to_local_window_mapping(remote_window_id, *local_window_id);
mux.add_tab_to_window(&tab, *local_window_id)?;
}
@@ -445,6 +450,9 @@ impl Domain for ClientDomain {
let inner = self
.inner()
.ok_or_else(|| anyhow!("domain is not attached"))?;
let workspace = Mux::get().unwrap().active_workspace();
let result = inner
.client
.spawn_v2(SpawnV2 {
@@ -453,6 +461,7 @@ impl Domain for ClientDomain {
size,
command,
command_dir,
workspace,
})
.await?;
+150 -11
View File
@@ -1,3 +1,4 @@
use crate::termwindow::TermWindowNotif;
use crate::TermWindow;
use ::window::*;
use anyhow::Error;
@@ -10,6 +11,8 @@ use wezterm_toast_notification::*;
pub struct GuiFrontEnd {
connection: Rc<Connection>,
switching_workspaces: RefCell<bool>,
known_windows: RefCell<Vec<Window>>,
}
impl Drop for GuiFrontEnd {
@@ -21,26 +24,49 @@ impl Drop for GuiFrontEnd {
impl GuiFrontEnd {
pub fn try_new() -> anyhow::Result<Rc<GuiFrontEnd>> {
let connection = Connection::init()?;
let front_end = Rc::new(GuiFrontEnd { connection });
let mux = Mux::get().expect("mux started and running on main thread");
let client_id = mux.active_identity().expect("to have set my own id");
let front_end = Rc::new(GuiFrontEnd {
connection,
switching_workspaces: RefCell::new(false),
known_windows: RefCell::new(vec![]),
});
let fe = Rc::downgrade(&front_end);
mux.subscribe(move |n| {
if let Some(_fe) = fe.upgrade() {
match n {
MuxNotification::WindowCreated(mux_window_id) => {
promise::spawn::spawn(async move {
if let Err(err) = TermWindow::new_window(mux_window_id).await {
log::error!("Failed to create window: {:#}", err);
let mux = Mux::get().expect("subscribe to trigger on main thread");
mux.kill_window(mux_window_id);
if !is_switching_workspace() {
let mux = Mux::get().expect("mux started and running on main thread");
let window = mux.get_window(mux_window_id).expect("new window notif to have valid window");
if window.get_workspace() == mux.active_workspace_for_client(&client_id) {
promise::spawn::spawn(async move {
if let Err(err) = TermWindow::new_window(mux_window_id).await {
log::error!("Failed to create window: {:#}", err);
let mux = Mux::get().expect("subscribe to trigger on main thread");
mux.kill_window(mux_window_id);
}
anyhow::Result::<()>::Ok(())
})
.detach();
}
anyhow::Result::<()>::Ok(())
})
.detach();
}
}
MuxNotification::WindowWorkspaceChanged(_) => {}
MuxNotification::WindowWorkspaceChanged(_) | MuxNotification::ActiveWorkspaceChanged(_) => {}
MuxNotification::WindowRemoved(_) => {}
MuxNotification::PaneRemoved(_) => {}
MuxNotification::PaneRemoved(_) => {
if mux::activity::Activity::count() == 0 {
let mux = Mux::get().expect("mux started and running on main thread");
let workspace = mux.active_workspace_for_client(&client_id);
if mux.is_workspace_empty(&workspace) {
log::trace!("Mux workspace is empty, terminate gui");
Connection::get().unwrap().terminate_message_loop();
}
}
}
MuxNotification::WindowInvalidated(_) => {}
MuxNotification::PaneOutput(_) => {}
MuxNotification::PaneAdded(_) => {}
@@ -88,12 +114,125 @@ impl GuiFrontEnd {
pub fn run_forever(&self) -> anyhow::Result<()> {
self.connection.run_message_loop()
}
pub fn switch_workspace(&self, workspace: &str) {
let mux = Mux::get().expect("mux started and running on main thread");
let mut mux_windows = mux.iter_windows_in_workspace(&workspace).into_iter();
// First, repurpose existing windows.
// Note that both iter_windows_in_workspace and self.known_windows have a
// deterministic iteration order, so switching back and forth should result
// in a consistent mux <-> gui window mapping.
{
let mut known_windows = self.known_windows.borrow_mut();
let mut windows = vec![];
for window in known_windows.drain(..) {
if let Some(mux_window_id) = mux_windows.next() {
window.notify(TermWindowNotif::SwitchToMuxWindow(mux_window_id));
windows.push(window);
} else {
// We have more windows than are in the new workspace;
// we no longer need this one!
window.close();
}
}
*known_windows = windows;
}
// then spawn any new windows that are needed
promise::spawn::spawn(async move {
while let Some(mux_window_id) = mux_windows.next() {
if let Err(err) = TermWindow::new_window(mux_window_id).await {
log::error!("Failed to create window: {:#}", err);
let mux = Mux::get().expect("switching_workspaces to trigger on main thread");
mux.kill_window(mux_window_id);
}
}
FRONT_END.with(|f| {
f.borrow_mut()
.as_mut()
.map(|f| *f.switching_workspaces.borrow_mut() = false)
});
})
.detach();
}
pub fn record_known_window(&self, window: Window) {
self.known_windows.borrow_mut().push(window);
}
pub fn forget_known_window(&self, window: Window) {
self.known_windows.borrow_mut().retain(|w| *w != window);
}
}
thread_local! {
static FRONT_END: RefCell<Option<Rc<GuiFrontEnd>>> = RefCell::new(None);
}
pub fn record_known_window(window: Window) {
FRONT_END.with(|f| {
f.borrow_mut()
.as_mut()
.map(|f| f.record_known_window(window))
});
}
pub fn forget_known_window(window: Window) {
FRONT_END.with(|f| {
f.borrow_mut()
.as_mut()
.map(|f| f.forget_known_window(window))
});
}
pub fn is_switching_workspace() -> bool {
FRONT_END
.with(|f| {
f.borrow()
.as_ref()
.map(|f| *f.switching_workspaces.borrow())
})
.unwrap_or(false)
}
pub fn switch_workspace(new_name: &str) {
FRONT_END.with(|f| {
f.borrow_mut()
.as_mut()
.map(|f| f.switch_workspace(new_name))
});
}
pub struct WorkspaceSwitcher {
new_name: String,
}
impl WorkspaceSwitcher {
pub fn new(new_name: &str) -> Self {
FRONT_END.with(|f| {
f.borrow_mut()
.as_mut()
.map(|f| *f.switching_workspaces.borrow_mut() = true)
});
Self {
new_name: new_name.to_string(),
}
}
pub fn do_switch(self) {
// Drop is invoked, which will complete the switch
}
}
impl Drop for WorkspaceSwitcher {
fn drop(&mut self) {
switch_workspace(&self.new_name);
}
}
pub fn shutdown() {
FRONT_END.with(|f| drop(f.borrow_mut().take()));
}
+4 -3
View File
@@ -173,7 +173,7 @@ fn run_serial(config: config::ConfigHandle, opts: &SerialCommand) -> anyhow::Res
block_on(domain.attach())?; // FIXME: blocking
{
let window_id = mux.new_empty_window();
let window_id = mux.new_empty_window(None);
// FIXME: blocking
let _tab = block_on(domain.spawn(config.initial_size(), None, None, *window_id))?;
}
@@ -289,7 +289,7 @@ async fn spawn_tab_in_default_domain_if_mux_is_empty(
true
});
let window_id = mux.new_empty_window();
let window_id = mux.new_empty_window(None);
let _tab = domain
.spawn(config.initial_size(), cmd, None, *window_id)
.await?;
@@ -451,6 +451,7 @@ impl Publish {
command,
command_dir: None,
size: config.initial_size(),
workspace: mux::DEFAULT_WORKSPACE.to_string(), // FIXME: command line option
})
.await
}));
@@ -522,7 +523,7 @@ fn setup_mux(
let client_id = Arc::new(mux::client::ClientId::new());
mux.register_client(client_id.clone());
mux.replace_identity(Some(client_id));
mux.set_active_workspace(mux::DEFAULT_WORKSPACE);
mux.set_active_workspace(mux::DEFAULT_WORKSPACE); // FIXME: command line option
crate::update::load_last_release_info_and_set_banner();
update_mux_domains(config)?;
+61
View File
@@ -108,6 +108,7 @@ pub enum TermWindowNotif {
MuxNotification(MuxNotification),
EmitStatusUpdate,
Apply(Box<dyn FnOnce(&mut TermWindow) + Send + Sync>),
SwitchToMuxWindow(MuxWindowId),
}
#[derive(Clone, Debug, PartialEq, Eq)]
@@ -772,6 +773,7 @@ impl TermWindow {
}
crate::update::start_update_checker();
crate::frontend::record_known_window(window);
Ok(())
}
@@ -979,6 +981,19 @@ impl TermWindow {
TermWindowNotif::Apply(func) => {
func(self);
}
TermWindowNotif::SwitchToMuxWindow(mux_window_id) => {
self.mux_window_id = mux_window_id;
self.pane_state.borrow_mut().clear();
self.tab_state.borrow_mut().clear();
self.current_highlight.take();
self.invalidate_fancy_tab_bar();
let mux = Mux::get().expect("to be main thread with mux running");
if let Some(tab) = mux.get_active_tab_for_window(mux_window_id) {
self.set_window_size(tab.get_size(), window)?;
}
window.invalidate();
}
}
Ok(())
@@ -2075,6 +2090,44 @@ impl TermWindow {
};
tab.toggle_zoom();
}
SwitchToWorkspace { name, spawn } => {
let mux = Mux::get().unwrap();
let name = name
.as_ref()
.map(|name| name.to_string())
.unwrap_or_else(|| mux.generate_workspace_name());
let switcher = crate::frontend::WorkspaceSwitcher::new(&name);
mux.set_active_workspace(&name);
if mux.iter_windows_in_workspace(&name).is_empty() {
let spawn = spawn.as_ref().map(|s| s.clone()).unwrap_or_default();
let size = self.config.initial_size();
let term_config = Arc::new(TermConfig::with_config(self.config.clone()));
let src_window_id = self.mux_window_id;
let clipboard = ClipboardHelper {
window: self.window.as_ref().unwrap().clone(),
};
promise::spawn::spawn(async move {
if let Err(err) = Self::spawn_command_internal(
spawn,
SpawnWhere::NewWindow,
size,
src_window_id,
clipboard,
term_config,
)
.await
{
log::error!("Failed to spawn: {:#}", err);
}
switcher.do_switch();
})
.detach();
} else {
switcher.do_switch();
}
}
};
Ok(())
}
@@ -2479,3 +2532,11 @@ impl TermWindow {
self.update_title();
}
}
impl Drop for TermWindow {
fn drop(&mut self) {
if let Some(window) = self.window.take() {
crate::frontend::forget_known_window(window);
}
}
}
+6 -2
View File
@@ -374,9 +374,8 @@ impl super::TermWindow {
self.adjust_font_scale(1.0, window);
}
pub fn reset_font_and_window_size(&mut self, window: &Window) -> anyhow::Result<()> {
pub fn set_window_size(&mut self, size: PtySize, window: &Window) -> anyhow::Result<()> {
let config = &self.config;
let size = config.initial_size();
let fontconfig = Rc::new(FontConfiguration::new(
Some(config.clone()),
self.dimensions.dpi,
@@ -434,6 +433,11 @@ impl super::TermWindow {
Ok(())
}
pub fn reset_font_and_window_size(&mut self, window: &Window) -> anyhow::Result<()> {
let size = self.config.initial_size();
self.set_window_size(size, window)
}
pub fn effective_right_padding(&self, config: &ConfigHandle) -> u16 {
effective_right_padding(
config,
+5 -3
View File
@@ -16,7 +16,7 @@ pub enum SpawnWhere {
}
impl super::TermWindow {
pub fn spawn_command(&mut self, spawn: &SpawnCommand, spawn_where: SpawnWhere) {
pub fn spawn_command(&self, spawn: &SpawnCommand, spawn_where: SpawnWhere) {
let size = if spawn_where == SpawnWhere::NewWindow {
self.config.initial_size()
} else {
@@ -36,7 +36,7 @@ impl super::TermWindow {
)
}
pub fn spawn_command_impl(
fn spawn_command_impl(
spawn: &SpawnCommand,
spawn_where: SpawnWhere,
size: PtySize,
@@ -63,7 +63,7 @@ impl super::TermWindow {
.detach();
}
async fn spawn_command_internal(
pub async fn spawn_command_internal(
spawn: SpawnCommand,
spawn_where: SpawnWhere,
size: PtySize,
@@ -107,6 +107,7 @@ impl super::TermWindow {
let clipboard: Arc<dyn wezterm_term::Clipboard> = Arc::new(clipboard);
let downloader: Arc<dyn wezterm_term::DownloadHandler> =
Arc::new(crate::download::Downloader::new());
let workspace = mux.active_workspace().clone();
match spawn_where {
SpawnWhere::SplitPane(direction) => {
@@ -146,6 +147,7 @@ impl super::TermWindow {
cwd,
size,
current_pane_id,
workspace,
)
.await
.context("spawn_tab_or_window")?;
+1
View File
@@ -115,6 +115,7 @@ where
stream.flush().await.context("flushing PDU to client")?;
}
}
Ok(Item::Notif(MuxNotification::ActiveWorkspaceChanged(_))) => {}
Ok(Item::Notif(MuxNotification::Empty)) => {}
Err(err) => {
log::error!("process_async Err {}", err);
@@ -759,6 +759,7 @@ async fn domain_spawn_v2(
spawn.command_dir,
spawn.size,
None, // optional current pane_id
spawn.workspace,
)
.await?;
+1 -1
View File
@@ -198,7 +198,7 @@ async fn async_run(cmd: Option<CommandBuilder>) -> anyhow::Result<()> {
domain.attach().await?;
let config = config::configuration();
let window_id = mux.new_empty_window();
let window_id = mux.new_empty_window(None);
let _tab = mux
.default_domain()
.spawn(config.initial_size(), cmd, None, *window_id)
+7
View File
@@ -182,6 +182,9 @@ Outputs the pane-id for the newly created pane on success"
#[structopt(long = "cwd", parse(from_os_str))]
cwd: Option<OsString>,
#[structopt(long = "workspace")]
workspace: Option<String>,
/// Instead of executing your shell, run PROG.
/// For example: `wezterm start -- bash -l` will spawn bash
/// as if it were a login shell.
@@ -568,6 +571,7 @@ async fn run_cli_async(config: config::ConfigHandle, cli: CliCommand) -> anyhow:
domain_name,
window_id,
new_window,
workspace,
} => {
let window_id = if new_window {
None
@@ -611,6 +615,8 @@ async fn run_cli_async(config: config::ConfigHandle, cli: CliCommand) -> anyhow:
}
};
let workspace = workspace.unwrap_or_else(|| Mux::get().unwrap().active_workspace());
let spawned = client
.spawn_v2(codec::SpawnV2 {
domain: domain_name.map_or(SpawnTabDomain::DefaultDomain, |name| {
@@ -625,6 +631,7 @@ async fn run_cli_async(config: config::ConfigHandle, cli: CliCommand) -> anyhow:
},
command_dir: canon_cwd(cwd)?,
size: config::configuration().initial_size(),
workspace,
})
.await?;
+1 -1
View File
@@ -367,7 +367,7 @@ fn function_key_to_keycode(function_key: char) -> KeyCode {
}
}
#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq)]
pub struct Window {
id: usize,
ns_window: *mut Object,
+1 -1
View File
@@ -223,7 +223,7 @@ impl PendingEvent {
}
}
#[derive(Clone, Debug)]
#[derive(Clone, Debug, PartialEq)]
pub struct WaylandWindow(usize);
impl WaylandWindow {
+1 -1
View File
@@ -68,7 +68,7 @@ pub(crate) struct WindowInner {
config: ConfigHandle,
}
#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq)]
pub struct Window(HWindow);
fn rect_width(r: &RECT) -> i32 {
+1 -1
View File
@@ -740,7 +740,7 @@ impl XWindowInner {
}
/// A Window!
#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq)]
pub struct XWindow(xcb::xproto::Window);
impl XWindow {
+1 -1
View File
@@ -22,7 +22,7 @@ pub enum Connection {
Wayland(Rc<WaylandConnection>),
}
#[derive(Clone)]
#[derive(Clone, PartialEq)]
pub enum Window {
X11(XWindow),
#[cfg(feature = "wayland")]