1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-23 23:21:08 +03:00

wezterm: export WEZTERM_PANE=<pane_id>

When spawning processes, export the local pane_id.

refs: https://github.com/wez/wezterm/issues/230
This commit is contained in:
Wez Furlong 2020-09-27 20:04:41 -07:00
parent 242adbbcfe
commit 23c777aadd
3 changed files with 33 additions and 8 deletions

View File

@ -1,6 +1,6 @@
use crate::mux::domain::DomainId;
use crate::mux::renderable::Renderable;
use crate::mux::tab::{alloc_pane_id, Pane, PaneId};
use crate::mux::tab::{Pane, PaneId};
use crate::mux::tab::{Pattern, SearchResult};
use anyhow::Error;
use async_trait::async_trait;
@ -223,12 +223,12 @@ impl Pane for LocalPane {
impl LocalPane {
pub fn new(
pane_id: PaneId,
terminal: Terminal,
process: Box<dyn Child>,
pty: Box<dyn MasterPty>,
domain_id: DomainId,
) -> Self {
let pane_id = alloc_pane_id();
Self {
pane_id,
terminal: RefCell::new(terminal),

View File

@ -7,7 +7,7 @@
use crate::config::configuration;
use crate::localtab::LocalPane;
use crate::mux::tab::{Pane, PaneId, SplitDirection, Tab, TabId};
use crate::mux::tab::{alloc_pane_id, Pane, PaneId, SplitDirection, Tab, TabId};
use crate::mux::window::WindowId;
use crate::mux::Mux;
use anyhow::{bail, Error};
@ -130,6 +130,9 @@ impl Domain for LocalDomain {
}
}
let pair = self.pty_system.openpty(size)?;
let pane_id = alloc_pane_id();
cmd.env("WEZTERM_PANE", pane_id.to_string());
let child = pair.slave.spawn_command(cmd)?;
info!("spawned: {:?}", child);
@ -147,7 +150,13 @@ impl Domain for LocalDomain {
);
let mux = Mux::get().unwrap();
let pane: Rc<dyn Pane> = Rc::new(LocalPane::new(terminal, child, pair.master, self.id));
let pane: Rc<dyn Pane> = Rc::new(LocalPane::new(
pane_id,
terminal,
child,
pair.master,
self.id,
));
let tab = Rc::new(Tab::new(&size));
tab.assign_pane(&pane);
@ -204,6 +213,8 @@ impl Domain for LocalDomain {
}
}
let pair = self.pty_system.openpty(split_size.second)?;
let pane_id = alloc_pane_id();
cmd.env("WEZTERM_PANE", pane_id.to_string());
let child = pair.slave.spawn_command(cmd)?;
info!("spawned: {:?}", child);
@ -220,7 +231,13 @@ impl Domain for LocalDomain {
Box::new(writer),
);
let pane: Rc<dyn Pane> = Rc::new(LocalPane::new(terminal, child, pair.master, self.id));
let pane: Rc<dyn Pane> = Rc::new(LocalPane::new(
pane_id,
terminal,
child,
pair.master,
self.id,
));
tab.split_and_insert(pane_index, direction, Rc::clone(&pane))?;

View File

@ -1,7 +1,7 @@
use crate::connui::ConnectionUI;
use crate::localtab::LocalPane;
use crate::mux::domain::{alloc_domain_id, Domain, DomainId, DomainState};
use crate::mux::tab::{Pane, PaneId, SplitDirection, Tab, TabId};
use crate::mux::tab::{alloc_pane_id, Pane, PaneId, SplitDirection, Tab, TabId};
use crate::mux::window::WindowId;
use crate::mux::Mux;
use anyhow::{anyhow, bail, Context, Error};
@ -242,11 +242,13 @@ impl Domain for RemoteSshDomain {
_command_dir: Option<String>,
window: WindowId,
) -> Result<Rc<Tab>, Error> {
let cmd = match command {
let mut cmd = match command {
Some(c) => c,
None => CommandBuilder::new_default_prog(),
};
let pair = self.pty_system.openpty(size)?;
let pane_id = alloc_pane_id();
cmd.env("WEZTERM_PANE", pane_id.to_string());
let child = pair.slave.spawn_command(cmd)?;
log::info!("spawned: {:?}", child);
@ -264,7 +266,13 @@ impl Domain for RemoteSshDomain {
);
let mux = Mux::get().unwrap();
let pane: Rc<dyn Pane> = Rc::new(LocalPane::new(terminal, child, pair.master, self.id));
let pane: Rc<dyn Pane> = Rc::new(LocalPane::new(
pane_id,
terminal,
child,
pair.master,
self.id,
));
let tab = Rc::new(Tab::new(&size));
tab.assign_pane(&pane);