mirror of
https://github.com/wez/wezterm.git
synced 2024-12-23 05:12:40 +03:00
mux: rename Mux::get() -> try_get(), add "infallible" Mux::get()
This allows removing a bunch of unwrap/expect calls. However, my primary motive was to replace the cases where we used Mux::get() == None to indicate that we were not on the main thread. A separate API has been added to test for that explicitly rather than implicitly.
This commit is contained in:
parent
478cc59be3
commit
02eb0b4294
@ -22,8 +22,7 @@ pub use tab::MuxTab;
|
||||
pub use window::MuxWindow;
|
||||
|
||||
fn get_mux() -> mlua::Result<Arc<Mux>> {
|
||||
Mux::get()
|
||||
.ok_or_else(|| mlua::Error::external("cannot get Mux: not running on the mux thread?"))
|
||||
Mux::try_get().ok_or_else(|| mlua::Error::external("cannot get Mux!?"))
|
||||
}
|
||||
|
||||
pub fn register(lua: &Lua) -> anyhow::Result<()> {
|
||||
|
@ -186,7 +186,7 @@ impl UserData for MuxPane {
|
||||
let mux = get_mux()?;
|
||||
let pane = this.resolve(&mux)?;
|
||||
let mut name = None;
|
||||
if let Some(mux) = Mux::get() {
|
||||
if let Some(mux) = Mux::try_get() {
|
||||
let domain_id = pane.domain_id();
|
||||
name = mux
|
||||
.get_domain(domain_id)
|
||||
|
@ -28,7 +28,7 @@ impl Drop for Activity {
|
||||
COUNT.fetch_sub(1, Ordering::SeqCst);
|
||||
|
||||
promise::spawn::spawn_into_main_thread(async move {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
mux.prune_dead_windows();
|
||||
})
|
||||
.detach();
|
||||
|
@ -61,7 +61,7 @@ pub trait Domain: Downcast + Send + Sync {
|
||||
let tab = Arc::new(Tab::new(&size));
|
||||
tab.assign_pane(&pane);
|
||||
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
mux.add_tab_and_active_pane(&tab)?;
|
||||
mux.add_tab_to_window(&tab, window)?;
|
||||
|
||||
@ -75,7 +75,7 @@ pub trait Domain: Downcast + Send + Sync {
|
||||
pane_id: PaneId,
|
||||
split_request: SplitRequest,
|
||||
) -> anyhow::Result<Arc<dyn Pane>> {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
let tab = match mux.get_tab(tab) {
|
||||
Some(t) => t,
|
||||
None => anyhow::bail!("Invalid tab id {}", tab),
|
||||
@ -521,7 +521,7 @@ impl Domain for LocalDomain {
|
||||
command_description,
|
||||
));
|
||||
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
mux.add_pane(&pane)?;
|
||||
|
||||
Ok(pane)
|
||||
|
@ -93,6 +93,7 @@ pub struct Mux {
|
||||
clients: RwLock<HashMap<ClientId, ClientInfo>>,
|
||||
identity: RwLock<Option<Arc<ClientId>>>,
|
||||
num_panes_by_workspace: RwLock<HashMap<String, usize>>,
|
||||
main_thread_id: std::thread::ThreadId,
|
||||
}
|
||||
|
||||
const BUFSIZE: usize = 1024 * 1024;
|
||||
@ -292,7 +293,7 @@ fn read_from_pane_pty(
|
||||
// We don't know if we can unilaterally close
|
||||
// this pane right now, so don't!
|
||||
promise::spawn::spawn_into_main_thread(async move {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
log::trace!("checking for dead windows after EOF on pane {}", pane_id);
|
||||
mux.prune_dead_windows();
|
||||
})
|
||||
@ -300,7 +301,7 @@ fn read_from_pane_pty(
|
||||
}
|
||||
ExitBehavior::Close => {
|
||||
promise::spawn::spawn_into_main_thread(async move {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
mux.remove_pane(pane_id);
|
||||
})
|
||||
.detach();
|
||||
@ -328,7 +329,8 @@ impl MuxWindowBuilder {
|
||||
self.notified = true;
|
||||
let activity = self.activity.take().unwrap();
|
||||
let window_id = self.window_id;
|
||||
if let Some(mux) = Mux::get() {
|
||||
let mux = Mux::get();
|
||||
if mux.is_main_thread() {
|
||||
// If we're already on the mux thread, just send the notification
|
||||
// immediately.
|
||||
// This is super important for Wayland; if we push it to the
|
||||
@ -337,7 +339,7 @@ impl MuxWindowBuilder {
|
||||
mux.notify(MuxNotification::WindowCreated(window_id));
|
||||
} else {
|
||||
promise::spawn::spawn_into_main_thread(async move {
|
||||
if let Some(mux) = Mux::get() {
|
||||
if let Some(mux) = Mux::try_get() {
|
||||
mux.notify(MuxNotification::WindowCreated(window_id));
|
||||
drop(activity);
|
||||
}
|
||||
@ -386,9 +388,14 @@ impl Mux {
|
||||
clients: RwLock::new(HashMap::new()),
|
||||
identity: RwLock::new(None),
|
||||
num_panes_by_workspace: RwLock::new(HashMap::new()),
|
||||
main_thread_id: std::thread::current().id(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_main_thread(&self) -> bool {
|
||||
std::thread::current().id() == self.main_thread_id
|
||||
}
|
||||
|
||||
fn recompute_pane_count(&self) {
|
||||
let mut count = HashMap::new();
|
||||
for window in self.windows.read().values() {
|
||||
@ -555,16 +562,18 @@ impl Mux {
|
||||
}
|
||||
|
||||
pub fn notify_from_any_thread(notification: MuxNotification) {
|
||||
if let Some(mux) = Mux::get() {
|
||||
mux.notify(notification)
|
||||
} else {
|
||||
promise::spawn::spawn_into_main_thread(async {
|
||||
if let Some(mux) = Mux::get() {
|
||||
mux.notify(notification);
|
||||
}
|
||||
})
|
||||
.detach();
|
||||
if let Some(mux) = Mux::try_get() {
|
||||
if mux.is_main_thread() {
|
||||
mux.notify(notification);
|
||||
return;
|
||||
}
|
||||
}
|
||||
promise::spawn::spawn_into_main_thread(async {
|
||||
if let Some(mux) = Mux::try_get() {
|
||||
mux.notify(notification);
|
||||
}
|
||||
})
|
||||
.detach();
|
||||
}
|
||||
|
||||
pub fn default_domain(&self) -> Arc<dyn Domain> {
|
||||
@ -603,7 +612,11 @@ impl Mux {
|
||||
MUX.lock().take();
|
||||
}
|
||||
|
||||
pub fn get() -> Option<Arc<Mux>> {
|
||||
pub fn get() -> Arc<Mux> {
|
||||
Self::try_get().unwrap()
|
||||
}
|
||||
|
||||
pub fn try_get() -> Option<Arc<Mux>> {
|
||||
MUX.lock().as_ref().map(Arc::clone)
|
||||
}
|
||||
|
||||
@ -1184,7 +1197,7 @@ pub struct IdentityHolder {
|
||||
|
||||
impl Drop for IdentityHolder {
|
||||
fn drop(&mut self) {
|
||||
if let Some(mux) = Mux::get() {
|
||||
if let Some(mux) = Mux::try_get() {
|
||||
mux.replace_identity(self.prior.take());
|
||||
}
|
||||
}
|
||||
@ -1221,7 +1234,7 @@ impl Clipboard for MuxClipboard {
|
||||
clipboard: Option<String>,
|
||||
) -> anyhow::Result<()> {
|
||||
let mux =
|
||||
Mux::get().ok_or_else(|| anyhow::anyhow!("MuxClipboard::set_contents: no Mux?"))?;
|
||||
Mux::try_get().ok_or_else(|| anyhow::anyhow!("MuxClipboard::set_contents: no Mux?"))?;
|
||||
mux.notify(MuxNotification::AssignClipboard {
|
||||
pane_id: self.pane_id,
|
||||
selection,
|
||||
@ -1235,7 +1248,7 @@ struct MuxDownloader {}
|
||||
|
||||
impl wezterm_term::DownloadHandler for MuxDownloader {
|
||||
fn save_to_downloads(&self, name: Option<String>, data: Vec<u8>) {
|
||||
if let Some(mux) = Mux::get() {
|
||||
if let Some(mux) = Mux::try_get() {
|
||||
mux.notify(MuxNotification::SaveToDownloads {
|
||||
name,
|
||||
data: Arc::new(data),
|
||||
|
@ -275,12 +275,12 @@ impl Pane for LocalPane {
|
||||
}
|
||||
|
||||
fn mouse_event(&self, event: MouseEvent) -> Result<(), Error> {
|
||||
Mux::get().unwrap().record_input_for_current_identity();
|
||||
Mux::get().record_input_for_current_identity();
|
||||
self.terminal.lock().mouse_event(event)
|
||||
}
|
||||
|
||||
fn key_down(&self, key: KeyCode, mods: KeyModifiers) -> Result<(), Error> {
|
||||
Mux::get().unwrap().record_input_for_current_identity();
|
||||
Mux::get().record_input_for_current_identity();
|
||||
if self.tmux_domain.lock().is_some() {
|
||||
log::error!("key: {:?}", key);
|
||||
if key == KeyCode::Char('q') {
|
||||
@ -293,7 +293,7 @@ impl Pane for LocalPane {
|
||||
}
|
||||
|
||||
fn key_up(&self, key: KeyCode, mods: KeyModifiers) -> Result<(), Error> {
|
||||
Mux::get().unwrap().record_input_for_current_identity();
|
||||
Mux::get().record_input_for_current_identity();
|
||||
self.terminal.lock().key_up(key, mods)
|
||||
}
|
||||
|
||||
@ -309,7 +309,7 @@ impl Pane for LocalPane {
|
||||
}
|
||||
|
||||
fn writer(&self) -> MappedMutexGuard<dyn std::io::Write> {
|
||||
Mux::get().unwrap().record_input_for_current_identity();
|
||||
Mux::get().record_input_for_current_identity();
|
||||
MutexGuard::map(self.writer.lock(), |writer| {
|
||||
let w: &mut dyn std::io::Write = writer;
|
||||
w
|
||||
@ -321,7 +321,7 @@ impl Pane for LocalPane {
|
||||
}
|
||||
|
||||
fn send_paste(&self, text: &str) -> Result<(), Error> {
|
||||
Mux::get().unwrap().record_input_for_current_identity();
|
||||
Mux::get().record_input_for_current_identity();
|
||||
if self.tmux_domain.lock().is_some() {
|
||||
Ok(())
|
||||
} else {
|
||||
@ -686,7 +686,7 @@ pub(crate) fn emit_output_for_pane(pane_id: PaneId, message: &str) {
|
||||
parser.parse(message.as_bytes(), |action| actions.push(action));
|
||||
|
||||
promise::spawn::spawn_into_main_thread(async move {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
if let Some(pane) = mux.get_pane(pane_id) {
|
||||
pane.perform_actions(actions);
|
||||
mux.notify(MuxNotification::PaneOutput(pane_id));
|
||||
@ -711,7 +711,7 @@ impl wezterm_term::DeviceControlHandler for LocalPaneDCSHandler {
|
||||
let tmux_domain = Arc::clone(&domain.inner);
|
||||
|
||||
let domain: Arc<dyn Domain> = Arc::new(domain);
|
||||
let mux = Mux::get().expect("to be called on main thread");
|
||||
let mux = Mux::get();
|
||||
mux.add_domain(&domain);
|
||||
|
||||
if let Some(pane) = mux.get_pane(self.pane_id) {
|
||||
@ -735,7 +735,7 @@ impl wezterm_term::DeviceControlHandler for LocalPaneDCSHandler {
|
||||
}
|
||||
DeviceControlMode::Exit => {
|
||||
if let Some(tmux) = self.tmux_domain.take() {
|
||||
let mux = Mux::get().expect("to be called on main thread");
|
||||
let mux = Mux::get();
|
||||
if let Some(pane) = mux.get_pane(self.pane_id) {
|
||||
let pane = pane.downcast_ref::<LocalPane>().unwrap();
|
||||
pane.tmux_domain.lock().take();
|
||||
@ -772,27 +772,26 @@ impl AlertHandler for LocalPaneNotifHandler {
|
||||
fn alert(&mut self, alert: Alert) {
|
||||
let pane_id = self.pane_id;
|
||||
promise::spawn::spawn_into_main_thread(async move {
|
||||
if let Some(mux) = Mux::get() {
|
||||
match &alert {
|
||||
Alert::WindowTitleChanged(title) => {
|
||||
if let Some((_domain, window_id, _tab_id)) = mux.resolve_pane_id(pane_id) {
|
||||
if let Some(mut window) = mux.get_window_mut(window_id) {
|
||||
window.set_title(title);
|
||||
}
|
||||
let mux = Mux::get();
|
||||
match &alert {
|
||||
Alert::WindowTitleChanged(title) => {
|
||||
if let Some((_domain, window_id, _tab_id)) = mux.resolve_pane_id(pane_id) {
|
||||
if let Some(mut window) = mux.get_window_mut(window_id) {
|
||||
window.set_title(title);
|
||||
}
|
||||
}
|
||||
Alert::TabTitleChanged(title) => {
|
||||
if let Some((_domain, _window_id, tab_id)) = mux.resolve_pane_id(pane_id) {
|
||||
if let Some(tab) = mux.get_tab(tab_id) {
|
||||
tab.set_title(title.as_deref().unwrap_or(""));
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
mux.notify(MuxNotification::Alert { pane_id, alert });
|
||||
Alert::TabTitleChanged(title) => {
|
||||
if let Some((_domain, _window_id, tab_id)) = mux.resolve_pane_id(pane_id) {
|
||||
if let Some(tab) = mux.get_tab(tab_id) {
|
||||
tab.set_title(title.as_deref().unwrap_or(""));
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
mux.notify(MuxNotification::Alert { pane_id, alert });
|
||||
})
|
||||
.detach();
|
||||
}
|
||||
@ -822,7 +821,7 @@ fn split_child(
|
||||
let status = process.wait();
|
||||
tx.try_send(status).ok();
|
||||
promise::spawn::spawn_into_main_thread(async move {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
mux.prune_dead_windows();
|
||||
})
|
||||
.detach();
|
||||
|
@ -108,7 +108,7 @@ struct Paste {
|
||||
|
||||
fn paste_next_chunk(paste: &Arc<Mutex<Paste>>) {
|
||||
let mut locked = paste.lock();
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
let pane = mux.get_pane(locked.pane_id).unwrap();
|
||||
|
||||
let remain = locked.text.len() - locked.offset;
|
||||
|
@ -685,7 +685,7 @@ impl Domain for RemoteSshDomain {
|
||||
self.id,
|
||||
"RemoteSshDomain".to_string(),
|
||||
));
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
mux.add_pane(&pane)?;
|
||||
|
||||
Ok(pane)
|
||||
@ -766,7 +766,7 @@ impl WrappedSshChild {
|
||||
promise::spawn::spawn_into_main_thread(async move {
|
||||
if let Ok(status) = child.async_wait().await {
|
||||
tx.send(status).await.ok();
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
mux.prune_dead_windows();
|
||||
}
|
||||
})
|
||||
|
@ -790,7 +790,7 @@ impl TabInner {
|
||||
}
|
||||
|
||||
fn codec_pane_tree(&mut self) -> PaneNode {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
let tab_id = self.id;
|
||||
let window_id = match mux.window_containing_tab(tab_id) {
|
||||
Some(w) => w,
|
||||
@ -1636,7 +1636,7 @@ impl TabInner {
|
||||
if !dead_panes.is_empty() && kill {
|
||||
let to_kill: Vec<_> = dead_panes.iter().map(|p| p.pane_id()).collect();
|
||||
promise::spawn::spawn_into_main_thread(async move {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
for pane_id in to_kill.into_iter() {
|
||||
mux.remove_pane(pane_id);
|
||||
}
|
||||
|
@ -465,7 +465,7 @@ pub fn allocate(
|
||||
// Add the tab to the mux so that the output is processed
|
||||
let pane: Arc<dyn Pane> = Arc::new(pane);
|
||||
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
mux.add_pane(&pane).expect("to be able to add pane to mux");
|
||||
|
||||
(tw_term, pane)
|
||||
@ -515,7 +515,7 @@ pub async fn run<
|
||||
window_id: Option<WindowId>,
|
||||
term_config: Option<Arc<dyn TerminalConfiguration + Send + Sync>>,
|
||||
) -> anyhow::Result<(PaneId, WindowId)> {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
|
||||
// TODO: make a singleton
|
||||
let domain: Arc<dyn Domain> = Arc::new(TermWizTerminalDomain::new());
|
||||
@ -562,7 +562,7 @@ pub async fn run<
|
||||
// be shown in succession, we don't want to leave lingering dead windows
|
||||
// on the screen so let's ask the mux to kill off our window now.
|
||||
promise::spawn::spawn_into_main_thread(async move {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
if should_close_window {
|
||||
mux.kill_window(window_id);
|
||||
} else if let Some(pane) = mux.get_pane(pane_id) {
|
||||
|
@ -140,7 +140,7 @@ impl TmuxDomainState {
|
||||
if let Some(first) = cmd_queue.front() {
|
||||
let cmd = first.get_command();
|
||||
log::info!("sending cmd {:?}", cmd);
|
||||
let mux = Mux::get().expect("to be called on main thread");
|
||||
let mux = Mux::get();
|
||||
if let Some(pane) = mux.get_pane(self.pane_id) {
|
||||
let mut writer = pane.writer();
|
||||
let _ = write!(writer, "{}", cmd);
|
||||
@ -152,7 +152,7 @@ impl TmuxDomainState {
|
||||
/// schedule a `send_next_command` into main thread
|
||||
pub fn schedule_send_next_command(domain_id: usize) {
|
||||
promise::spawn::spawn_into_main_thread(async move {
|
||||
let mux = Mux::get().expect("to be called on main thread");
|
||||
let mux = Mux::get();
|
||||
if let Some(domain) = mux.get_domain(domain_id) {
|
||||
if let Some(tmux_domain) = domain.downcast_ref::<TmuxDomain>() {
|
||||
tmux_domain.send_next_command();
|
||||
@ -165,7 +165,7 @@ impl TmuxDomainState {
|
||||
/// create a standalone window for tmux tabs
|
||||
pub fn create_gui_window(&self) {
|
||||
if self.gui_window.lock().is_none() {
|
||||
let mux = Mux::get().expect("should be call at main thread");
|
||||
let mux = Mux::get();
|
||||
let window_builder = mux.new_empty_window(None /* TODO: pass session here */);
|
||||
log::info!("Tmux create window id {}", window_builder.window_id);
|
||||
{
|
||||
|
@ -129,7 +129,7 @@ impl TmuxDomainState {
|
||||
master_pane: ref_pane,
|
||||
};
|
||||
let writer = WriterWrapper::new(pane_pty.take_writer()?);
|
||||
let mux = Mux::get().expect("should be called at main thread");
|
||||
let mux = Mux::get();
|
||||
let size = TerminalSize {
|
||||
rows: pane.pane_height as usize,
|
||||
cols: pane.pane_width as usize,
|
||||
@ -259,7 +259,7 @@ impl TmuxCommand for ListAllPanes {
|
||||
}
|
||||
|
||||
log::info!("panes in domain_id {}: {:?}", domain_id, items);
|
||||
let mux = Mux::get().expect("to be called on main thread");
|
||||
let mux = Mux::get();
|
||||
if let Some(domain) = mux.get_domain(domain_id) {
|
||||
if let Some(tmux_domain) = domain.downcast_ref::<TmuxDomain>() {
|
||||
return tmux_domain.inner.sync_pane_state(&items);
|
||||
@ -299,7 +299,7 @@ impl TmuxCommand for CapturePane {
|
||||
}
|
||||
|
||||
fn process_result(&self, domain_id: DomainId, result: &Guarded) -> anyhow::Result<()> {
|
||||
let mux = Mux::get().expect("to be called on main thread");
|
||||
let mux = Mux::get();
|
||||
let domain = match mux.get_domain(domain_id) {
|
||||
Some(d) => d,
|
||||
None => anyhow::bail!("Tmux domain lost"),
|
||||
|
@ -22,11 +22,7 @@ impl Window {
|
||||
active: 0,
|
||||
last_active: None,
|
||||
title: String::new(),
|
||||
workspace: workspace.unwrap_or_else(|| {
|
||||
Mux::get()
|
||||
.expect("Window::new to be called on mux thread")
|
||||
.active_workspace()
|
||||
}),
|
||||
workspace: workspace.unwrap_or_else(|| Mux::get().active_workspace()),
|
||||
}
|
||||
}
|
||||
|
||||
@ -47,9 +43,7 @@ impl Window {
|
||||
return;
|
||||
}
|
||||
self.workspace = workspace.to_string();
|
||||
if let Some(mux) = Mux::get() {
|
||||
mux.notify(MuxNotification::WindowWorkspaceChanged(self.id));
|
||||
}
|
||||
Mux::get().notify(MuxNotification::WindowWorkspaceChanged(self.id));
|
||||
}
|
||||
|
||||
pub fn window_id(&self) -> WindowId {
|
||||
@ -63,7 +57,7 @@ impl Window {
|
||||
}
|
||||
|
||||
fn invalidate(&self) {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
mux.notify(MuxNotification::WindowInvalidated(self.id));
|
||||
}
|
||||
|
||||
|
@ -121,7 +121,7 @@ async fn process_unilateral_inner_async(
|
||||
local_domain_id: DomainId,
|
||||
decoded: DecodedPdu,
|
||||
) -> anyhow::Result<()> {
|
||||
let mux = match Mux::get() {
|
||||
let mux = match Mux::try_get() {
|
||||
Some(mux) => mux,
|
||||
None => {
|
||||
// This can happen for some client scenarios; it is ok to ignore it.
|
||||
@ -196,7 +196,7 @@ fn process_unilateral(
|
||||
let window_id = *window_id;
|
||||
let workspace = workspace.to_string();
|
||||
promise::spawn::spawn_into_main_thread(async move {
|
||||
let mux = Mux::get().ok_or_else(|| anyhow!("no more mux"))?;
|
||||
let mux = Mux::try_get().ok_or_else(|| anyhow!("no more mux"))?;
|
||||
let client_domain = mux
|
||||
.get_domain(local_domain_id)
|
||||
.ok_or_else(|| anyhow!("no such domain {}", local_domain_id))?;
|
||||
@ -989,7 +989,7 @@ impl Client {
|
||||
}
|
||||
|
||||
async fn detach(local_domain_id: DomainId) -> anyhow::Result<()> {
|
||||
if let Some(mux) = Mux::get() {
|
||||
if let Some(mux) = Mux::try_get() {
|
||||
let client_domain = mux
|
||||
.get_domain(local_domain_id)
|
||||
.ok_or_else(|| anyhow!("no such domain {}", local_domain_id))?;
|
||||
|
@ -36,7 +36,7 @@ impl ClientInner {
|
||||
}
|
||||
|
||||
pub(crate) fn expire_stale_mappings(&self) {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
|
||||
self.remote_to_local_pane
|
||||
.lock()
|
||||
@ -117,7 +117,7 @@ impl ClientInner {
|
||||
return Some(*id);
|
||||
}
|
||||
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
|
||||
for pane in mux.iter_panes() {
|
||||
if pane.domain_id() != self.local_domain_id {
|
||||
@ -264,7 +264,7 @@ async fn update_remote_workspace(
|
||||
}
|
||||
|
||||
fn mux_notify_client_domain(local_domain_id: DomainId, notif: MuxNotification) -> bool {
|
||||
let mux = Mux::get().expect("called by mux");
|
||||
let mux = Mux::get();
|
||||
let domain = match mux.get_domain(local_domain_id) {
|
||||
Some(domain) => domain,
|
||||
None => return false,
|
||||
@ -281,7 +281,7 @@ fn mux_notify_client_domain(local_domain_id: DomainId, notif: MuxNotification) -
|
||||
// immediately; defer the bulk of this work.
|
||||
// <https://github.com/wez/wezterm/issues/2638>
|
||||
promise::spawn::spawn_into_main_thread(async move {
|
||||
let mux = Mux::get().expect("called by mux");
|
||||
let mux = Mux::get();
|
||||
let domain = match mux.get_domain(local_domain_id) {
|
||||
Some(domain) => domain,
|
||||
None => return,
|
||||
@ -322,9 +322,7 @@ impl ClientDomain {
|
||||
pub fn new(config: ClientDomainConfig) -> Self {
|
||||
let local_domain_id = alloc_domain_id();
|
||||
let label = config.label();
|
||||
Mux::get()
|
||||
.expect("created on main thread")
|
||||
.subscribe(move |notif| mux_notify_client_domain(local_domain_id, notif));
|
||||
Mux::get().subscribe(move |notif| mux_notify_client_domain(local_domain_id, notif));
|
||||
Self {
|
||||
config,
|
||||
label,
|
||||
@ -344,7 +342,7 @@ impl ClientDomain {
|
||||
pub fn perform_detach(&self) {
|
||||
log::info!("detached domain {}", self.local_domain_id);
|
||||
self.inner.lock().unwrap().take();
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
mux.domain_was_detached(self.local_domain_id);
|
||||
}
|
||||
|
||||
@ -364,7 +362,7 @@ impl ClientDomain {
|
||||
}
|
||||
|
||||
pub fn get_client_inner_for_domain(domain_id: DomainId) -> anyhow::Result<Arc<ClientInner>> {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
let domain = mux
|
||||
.get_domain(domain_id)
|
||||
.ok_or_else(|| anyhow!("invalid domain id {}", domain_id))?;
|
||||
@ -406,7 +404,7 @@ impl ClientDomain {
|
||||
panes: ListPanesResponse,
|
||||
mut primary_window_id: Option<WindowId>,
|
||||
) -> anyhow::Result<()> {
|
||||
let mux = Mux::get().expect("to be called on main thread");
|
||||
let mux = Mux::get();
|
||||
log::debug!(
|
||||
"domain {}: ListPanes result {:#?}",
|
||||
inner.local_domain_id,
|
||||
@ -547,7 +545,7 @@ impl ClientDomain {
|
||||
panes: ListPanesResponse,
|
||||
primary_window_id: Option<WindowId>,
|
||||
) -> anyhow::Result<()> {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
let domain = mux
|
||||
.get_domain(domain_id)
|
||||
.ok_or_else(|| anyhow!("invalid domain id {}", domain_id))?;
|
||||
@ -605,7 +603,7 @@ impl Domain for ClientDomain {
|
||||
.inner()
|
||||
.ok_or_else(|| anyhow!("domain is not attached"))?;
|
||||
|
||||
let workspace = Mux::get().unwrap().active_workspace();
|
||||
let workspace = Mux::get().active_workspace();
|
||||
|
||||
let result = inner
|
||||
.client
|
||||
@ -633,7 +631,7 @@ impl Domain for ClientDomain {
|
||||
inner.remove_old_tab_mapping(result.tab_id);
|
||||
inner.record_remote_to_local_tab_mapping(result.tab_id, tab.tab_id());
|
||||
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
mux.add_tab_and_active_pane(&tab)?;
|
||||
mux.add_tab_to_window(&tab, window)?;
|
||||
|
||||
@ -651,7 +649,7 @@ impl Domain for ClientDomain {
|
||||
.inner()
|
||||
.ok_or_else(|| anyhow!("domain is not attached"))?;
|
||||
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
|
||||
let tab = mux
|
||||
.get_tab(tab_id)
|
||||
@ -770,7 +768,7 @@ impl Domain for ClientDomain {
|
||||
}
|
||||
|
||||
fn local_window_is_closing(&self, window_id: WindowId) {
|
||||
let mux = Mux::get().expect("to be called by mux on mux thread");
|
||||
let mux = Mux::get();
|
||||
let window = match mux.get_window(window_id) {
|
||||
Some(w) => w,
|
||||
None => return,
|
||||
|
@ -142,14 +142,14 @@ impl ClientPane {
|
||||
},
|
||||
Pdu::SetPalette(SetPalette { palette, .. }) => {
|
||||
*self.palette.lock() = palette;
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
mux.notify(MuxNotification::Alert {
|
||||
pane_id: self.local_pane_id,
|
||||
alert: Alert::PaletteChanged,
|
||||
});
|
||||
}
|
||||
Pdu::NotifyAlert(NotifyAlert { alert, .. }) => {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
match &alert {
|
||||
Alert::SetUserVar { name, value } => {
|
||||
self.user_vars.lock().insert(name.clone(), value.clone());
|
||||
@ -164,7 +164,7 @@ impl ClientPane {
|
||||
Pdu::PaneRemoved(PaneRemoved { pane_id }) => {
|
||||
log::trace!("remote pane {} has been removed", pane_id);
|
||||
self.renderable.lock().inner.borrow_mut().dead = true;
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
mux.prune_dead_windows();
|
||||
|
||||
self.client.expire_stale_mappings();
|
||||
@ -428,7 +428,7 @@ impl Pane for ClientPane {
|
||||
let mut send_kill = true;
|
||||
|
||||
{
|
||||
let mux = Mux::get().expect("called on main thread");
|
||||
let mux = Mux::get();
|
||||
if let Some(client_domain) = mux.get_domain(local_domain_id) {
|
||||
if client_domain.state() == mux::domain::DomainState::Detached {
|
||||
send_kill = false;
|
||||
@ -451,7 +451,7 @@ impl Pane for ClientPane {
|
||||
// effects of killing the pane.
|
||||
// <https://github.com/wez/wezterm/issues/1752#issuecomment-1088269363>
|
||||
smol::Timer::after(std::time::Duration::from_millis(200)).await;
|
||||
let mux = Mux::get().expect("called on main thread");
|
||||
let mux = Mux::get();
|
||||
let client_domain = mux
|
||||
.get_domain(local_domain_id)
|
||||
.ok_or_else(|| anyhow::anyhow!("no such domain {}", local_domain_id))?;
|
||||
|
@ -368,9 +368,7 @@ impl RenderableInner {
|
||||
"apply_changes_to_surface: Generate PaneOutput event for local={}",
|
||||
self.local_pane_id
|
||||
);
|
||||
Mux::get()
|
||||
.unwrap()
|
||||
.notify(mux::MuxNotification::PaneOutput(self.local_pane_id));
|
||||
Mux::get().notify(mux::MuxNotification::PaneOutput(self.local_pane_id));
|
||||
|
||||
let mut to_fetch = RangeSet::new();
|
||||
log::trace!("dirty as of seq {} -> {:?}", delta.seqno, dirty);
|
||||
@ -535,7 +533,7 @@ impl RenderableInner {
|
||||
to_fetch: RangeSet<StableRowIndex>,
|
||||
now: Instant,
|
||||
) -> anyhow::Result<()> {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
let pane = mux
|
||||
.get_pane(local_pane_id)
|
||||
.ok_or_else(|| anyhow!("no such tab {}", local_pane_id))?;
|
||||
@ -616,7 +614,7 @@ impl RenderableInner {
|
||||
Err(_) => client.client.is_reconnectable,
|
||||
};
|
||||
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
let tab = mux
|
||||
.get_pane(local_pane_id)
|
||||
.ok_or_else(|| anyhow!("no such tab {}", local_pane_id))?;
|
||||
|
@ -34,7 +34,7 @@ impl GuiFrontEnd {
|
||||
let connection = Connection::init()?;
|
||||
connection.set_event_handler(Self::app_event_handler);
|
||||
|
||||
let mux = Mux::get().expect("mux started and running on main thread");
|
||||
let mux = Mux::get();
|
||||
let client_id = mux.active_identity().expect("to have set my own id");
|
||||
|
||||
let front_end = Rc::new(GuiFrontEnd {
|
||||
@ -172,7 +172,7 @@ impl GuiFrontEnd {
|
||||
.collect(),
|
||||
);
|
||||
|
||||
let mux = Mux::get().expect("mux started");
|
||||
let mux = Mux::get();
|
||||
let window_id = None;
|
||||
let pane_id = None;
|
||||
let cwd = None;
|
||||
@ -211,7 +211,7 @@ impl GuiFrontEnd {
|
||||
|
||||
pub fn reconcile_workspace(&self) -> Future<()> {
|
||||
let mut promise = Promise::new();
|
||||
let mux = Mux::get().expect("mux started and running on main thread");
|
||||
let mux = Mux::get();
|
||||
let workspace = mux.active_workspace_for_client(&self.client_id);
|
||||
|
||||
if mux.is_workspace_empty(&workspace) {
|
||||
@ -291,7 +291,7 @@ impl GuiFrontEnd {
|
||||
log::trace!("Creating TermWindow for mux_window_id={}", mux_window_id);
|
||||
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");
|
||||
let mux = Mux::get();
|
||||
mux.kill_window(mux_window_id);
|
||||
front_end()
|
||||
.spawned_mux_window
|
||||
@ -316,7 +316,7 @@ impl GuiFrontEnd {
|
||||
}
|
||||
|
||||
pub fn switch_workspace(&self, workspace: &str) {
|
||||
let mux = Mux::get().expect("mux started and running on main thread");
|
||||
let mux = Mux::get();
|
||||
mux.set_active_workspace_for_client(&self.client_id, workspace);
|
||||
*self.switching_workspaces.borrow_mut() = false;
|
||||
self.reconcile_workspace();
|
||||
|
@ -159,7 +159,7 @@ async fn async_run_ssh(opts: SshCommand) -> anyhow::Result<()> {
|
||||
};
|
||||
|
||||
let domain: Arc<dyn Domain> = Arc::new(mux::ssh::RemoteSshDomain::with_ssh_domain(&dom)?);
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
mux.add_domain(&domain);
|
||||
mux.set_default_domain(&domain);
|
||||
|
||||
@ -243,7 +243,7 @@ async fn async_run_with_domain_as_default(
|
||||
domain: Arc<dyn Domain>,
|
||||
cmd: Option<CommandBuilder>,
|
||||
) -> anyhow::Result<()> {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
crate::update::load_last_release_info_and_set_banner();
|
||||
|
||||
// Allow spawning local commands into new tabs/panes
|
||||
@ -276,7 +276,6 @@ async fn async_run_mux_client(opts: ConnectCommand) -> anyhow::Result<()> {
|
||||
}
|
||||
|
||||
let domain = Mux::get()
|
||||
.unwrap()
|
||||
.get_domain_by_name(&opts.domain_name)
|
||||
.ok_or_else(|| {
|
||||
anyhow!(
|
||||
@ -315,7 +314,7 @@ async fn spawn_tab_in_default_domain_if_mux_is_empty(
|
||||
cmd: Option<CommandBuilder>,
|
||||
is_connecting: bool,
|
||||
) -> anyhow::Result<()> {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
|
||||
let domain = mux.default_domain();
|
||||
|
||||
@ -373,7 +372,7 @@ async fn spawn_tab_in_default_domain_if_mux_is_empty(
|
||||
}
|
||||
|
||||
fn update_mux_domains(config: &ConfigHandle) -> anyhow::Result<()> {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
|
||||
for client_config in client_domains(&config) {
|
||||
if mux.get_domain_by_name(client_config.name()).is_some() {
|
||||
@ -425,7 +424,7 @@ fn update_mux_domains(config: &ConfigHandle) -> anyhow::Result<()> {
|
||||
}
|
||||
|
||||
async fn connect_to_auto_connect_domains() -> anyhow::Result<()> {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
let domains = mux.iter_domains();
|
||||
for dom in domains {
|
||||
if let Some(dom) = dom.downcast_ref::<ClientDomain>() {
|
||||
|
@ -175,7 +175,7 @@ pub fn confirm_close_pane(
|
||||
) -> anyhow::Result<()> {
|
||||
if run_confirmation_app("🛑 Really kill this pane?", &mut term)? {
|
||||
promise::spawn::spawn_into_main_thread(async move {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
let tab = match mux.get_active_tab_for_window(mux_window_id) {
|
||||
Some(tab) => tab,
|
||||
None => return,
|
||||
@ -200,7 +200,7 @@ pub fn confirm_close_tab(
|
||||
&mut term,
|
||||
)? {
|
||||
promise::spawn::spawn_into_main_thread(async move {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
mux.remove_tab(tab_id);
|
||||
})
|
||||
.detach();
|
||||
@ -221,7 +221,7 @@ pub fn confirm_close_window(
|
||||
&mut term,
|
||||
)? {
|
||||
promise::spawn::spawn_into_main_thread(async move {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
mux.kill_window(mux_window_id);
|
||||
})
|
||||
.detach();
|
||||
|
@ -116,7 +116,6 @@ impl CopyOverlay {
|
||||
cursor.visibility = CursorVisibility::Visible;
|
||||
|
||||
let (_domain, _window, tab_id) = mux::Mux::get()
|
||||
.expect("called on main thread")
|
||||
.resolve_pane_id(pane.pane_id())
|
||||
.ok_or_else(|| anyhow::anyhow!("no tab contains the current pane"))?;
|
||||
|
||||
|
@ -69,7 +69,7 @@ impl LauncherArgs {
|
||||
pane_id: PaneId,
|
||||
domain_id_of_current_tab: DomainId,
|
||||
) -> Self {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
|
||||
let active_workspace = mux.active_workspace();
|
||||
|
||||
|
@ -867,7 +867,7 @@ impl QuickSelectRenderable {
|
||||
let action = self.args.action.clone();
|
||||
self.window
|
||||
.notify(TermWindowNotif::Apply(Box::new(move |term_window| {
|
||||
let mux = mux::Mux::get().unwrap();
|
||||
let mux = mux::Mux::get();
|
||||
if let Some(pane) = mux.get_pane(pane_id) {
|
||||
{
|
||||
let mut selection = term_window.selection(pane_id);
|
||||
|
@ -264,8 +264,8 @@ impl UserData for GuiWin {
|
||||
Ok(result)
|
||||
});
|
||||
methods.add_method("active_workspace", |_, _, _: ()| {
|
||||
let mux = Mux::get()
|
||||
.ok_or_else(|| anyhow::anyhow!("must be called on main thread"))
|
||||
let mux = Mux::try_get()
|
||||
.ok_or_else(|| anyhow::anyhow!("no mux?"))
|
||||
.map_err(luaerr)?;
|
||||
Ok(mux.active_workspace().to_string())
|
||||
});
|
||||
@ -291,8 +291,7 @@ impl UserData for GuiWin {
|
||||
pane_id: PaneId,
|
||||
term_window: &mut TermWindow,
|
||||
) -> anyhow::Result<String> {
|
||||
let mux = Mux::get()
|
||||
.ok_or_else(|| anyhow::anyhow!("not called on main thread"))?;
|
||||
let mux = Mux::try_get().ok_or_else(|| anyhow::anyhow!("no mux"))?;
|
||||
let pane = mux
|
||||
.get_pane(pane_id)
|
||||
.ok_or_else(|| anyhow::anyhow!("invalid pane {pane_id}"))?;
|
||||
|
@ -45,7 +45,7 @@ impl TermWindow {
|
||||
.as_ref()
|
||||
.map(|overlay| overlay.pane.clone())
|
||||
.or_else(|| {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
mux.get_pane(pane_id)
|
||||
})
|
||||
{
|
||||
|
@ -219,7 +219,7 @@ impl UserData for TabInformation {
|
||||
}
|
||||
});
|
||||
fields.add_field_method_get("panes", |_, this| {
|
||||
let mux = Mux::get().expect("event to run on main thread");
|
||||
let mux = Mux::get();
|
||||
let mut panes = vec![];
|
||||
if let Some(tab) = mux.get_tab(this.tab_id) {
|
||||
panes = tab
|
||||
@ -232,14 +232,14 @@ impl UserData for TabInformation {
|
||||
});
|
||||
fields.add_field_method_get("window_id", |_, this| Ok(this.window_id));
|
||||
fields.add_field_method_get("tab_title", |_, this| {
|
||||
let mux = Mux::get().expect("event to run on main thread");
|
||||
let mux = Mux::get();
|
||||
let tab = mux
|
||||
.get_tab(this.tab_id)
|
||||
.ok_or_else(|| mlua::Error::external(format!("tab {} not found", this.tab_id)))?;
|
||||
Ok(tab.get_title())
|
||||
});
|
||||
fields.add_field_method_get("window_title", |_, this| {
|
||||
let mux = Mux::get().expect("event to run on main thread");
|
||||
let mux = Mux::get();
|
||||
let window = mux.get_window(this.window_id).ok_or_else(|| {
|
||||
mlua::Error::external(format!("window {} not found", this.window_id))
|
||||
})?;
|
||||
@ -283,7 +283,7 @@ impl UserData for PaneInformation {
|
||||
fields.add_field_method_get("user_vars", |_, this| Ok(this.user_vars.clone()));
|
||||
fields.add_field_method_get("foreground_process_name", |_, this| {
|
||||
let mut name = None;
|
||||
if let Some(mux) = Mux::get() {
|
||||
if let Some(mux) = Mux::try_get() {
|
||||
if let Some(pane) = mux.get_pane(this.pane_id) {
|
||||
name = pane.get_foreground_process_name();
|
||||
}
|
||||
@ -295,7 +295,7 @@ impl UserData for PaneInformation {
|
||||
});
|
||||
fields.add_field_method_get("current_working_dir", |_, this| {
|
||||
let mut name = None;
|
||||
if let Some(mux) = Mux::get() {
|
||||
if let Some(mux) = Mux::try_get() {
|
||||
if let Some(pane) = mux.get_pane(this.pane_id) {
|
||||
name = pane.get_current_working_dir().map(|u| u.to_string());
|
||||
}
|
||||
@ -307,7 +307,7 @@ impl UserData for PaneInformation {
|
||||
});
|
||||
fields.add_field_method_get("domain_name", |_, this| {
|
||||
let mut name = None;
|
||||
if let Some(mux) = Mux::get() {
|
||||
if let Some(mux) = Mux::try_get() {
|
||||
if let Some(pane) = mux.get_pane(this.pane_id) {
|
||||
let domain_id = pane.domain_id();
|
||||
name = mux
|
||||
@ -457,7 +457,7 @@ impl TermWindow {
|
||||
}
|
||||
|
||||
fn close_requested(&mut self, window: &Window) {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
match self.config.window_close_confirmation {
|
||||
WindowCloseConfirmation::NeverPrompt => {
|
||||
// Immediately kill the tabs and allow the window to close
|
||||
@ -565,7 +565,7 @@ impl TermWindow {
|
||||
let dpi = config.dpi.unwrap_or_else(|| ::window::default_dpi()) as usize;
|
||||
let fontconfig = Rc::new(FontConfiguration::new(Some(config.clone()), dpi)?);
|
||||
|
||||
let mux = Mux::get().expect("to be main thread with mux running");
|
||||
let mux = Mux::get();
|
||||
let size = match mux.get_active_tab_for_window(mux_window_id) {
|
||||
Some(tab) => tab.get_size(),
|
||||
None => {
|
||||
@ -1002,7 +1002,7 @@ impl TermWindow {
|
||||
pane_id,
|
||||
assignment,
|
||||
} => {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
let pane = mux
|
||||
.get_pane(pane_id)
|
||||
.ok_or_else(|| anyhow!("pane id {} is not valid", pane_id))?;
|
||||
@ -1106,7 +1106,7 @@ impl TermWindow {
|
||||
window_id: _,
|
||||
tab_id,
|
||||
} => {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
let mut size = self.terminal_size;
|
||||
if let Some(tab) = mux.get_tab(tab_id) {
|
||||
// If we attached to a remote domain and loaded in
|
||||
@ -1154,7 +1154,7 @@ impl TermWindow {
|
||||
self.emit_status_event();
|
||||
}
|
||||
TermWindowNotif::GetSelectionForPane { pane_id, tx } => {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
let pane = mux
|
||||
.get_pane(pane_id)
|
||||
.ok_or_else(|| anyhow!("pane id {} is not valid", pane_id))?;
|
||||
@ -1175,7 +1175,7 @@ impl TermWindow {
|
||||
self.invalidate_fancy_tab_bar();
|
||||
self.invalidate_modal();
|
||||
|
||||
let mux = Mux::get().expect("to be main thread with mux running");
|
||||
let mux = Mux::get();
|
||||
if let Some(window) = mux.get_window(self.mux_window_id) {
|
||||
for tab in window.iter() {
|
||||
tab.resize(self.terminal_size);
|
||||
@ -1238,7 +1238,7 @@ impl TermWindow {
|
||||
}
|
||||
|
||||
fn is_pane_visible(&mut self, pane_id: PaneId) -> bool {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
let tab = match mux.get_active_tab_for_window(self.mux_window_id) {
|
||||
Some(tab) => tab,
|
||||
None => return false,
|
||||
@ -1296,7 +1296,7 @@ impl TermWindow {
|
||||
// signal for that case, so we just check window validity
|
||||
// here and propagate to the window event handler that
|
||||
// will then do the check with full context.
|
||||
let mux = Mux::get().expect("mux is calling us");
|
||||
let mux = Mux::get();
|
||||
if mux.get_window(mux_window_id).is_none() {
|
||||
// Something inconsistent: cancel subscription
|
||||
log::debug!(
|
||||
@ -1311,7 +1311,7 @@ impl TermWindow {
|
||||
MuxNotification::PaneAdded(_pane_id) => {
|
||||
// If some other client spawns a pane inside this window, this
|
||||
// gives us an opportunity to attach it to the clipboard.
|
||||
let mux = Mux::get().expect("mux is calling us");
|
||||
let mux = Mux::get();
|
||||
return mux.get_window(mux_window_id).is_some();
|
||||
}
|
||||
MuxNotification::TabAddedToWindow { window_id, .. }
|
||||
@ -1342,7 +1342,7 @@ impl TermWindow {
|
||||
fn subscribe_to_pane_updates(&self) {
|
||||
let window = self.window.clone().expect("window to be valid on startup");
|
||||
let mux_window_id = Arc::clone(&self.mux_window_id_for_subscriptions);
|
||||
let mux = Mux::get().expect("mux started and running on main thread");
|
||||
let mux = Mux::get();
|
||||
let dead = Arc::new(AtomicBool::new(false));
|
||||
mux.subscribe(move |n| {
|
||||
let mux_window_id = *mux_window_id.lock().unwrap();
|
||||
@ -1364,7 +1364,7 @@ impl TermWindow {
|
||||
fn schedule_window_event(&mut self, name: &str, pane_id: Option<PaneId>) {
|
||||
let window = GuiWin::new(self);
|
||||
let pane = match pane_id {
|
||||
Some(pane_id) => Mux::get().expect("on main thread").get_pane(pane_id),
|
||||
Some(pane_id) => Mux::get().get_pane(pane_id),
|
||||
None => None,
|
||||
};
|
||||
let pane = match pane {
|
||||
@ -1547,7 +1547,7 @@ impl TermWindow {
|
||||
&self.render_metrics,
|
||||
);
|
||||
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
let window = match mux.get_window(self.mux_window_id) {
|
||||
Some(window) => window,
|
||||
_ => return,
|
||||
@ -1687,7 +1687,7 @@ impl TermWindow {
|
||||
|
||||
fn emit_user_var_event(&mut self, pane_id: PaneId, name: String, value: String) {
|
||||
let window = GuiWin::new(self);
|
||||
let pane = match Mux::get().expect("on main thread").get_pane(pane_id) {
|
||||
let pane = match Mux::get().get_pane(pane_id) {
|
||||
Some(pane) => mux_lua::MuxPane(pane.pane_id()),
|
||||
None => return,
|
||||
};
|
||||
@ -1730,7 +1730,7 @@ impl TermWindow {
|
||||
}
|
||||
|
||||
fn update_title_impl(&mut self) {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
let window = match mux.get_window(self.mux_window_id) {
|
||||
Some(window) => window,
|
||||
_ => return,
|
||||
@ -1923,7 +1923,7 @@ impl TermWindow {
|
||||
}
|
||||
|
||||
fn activate_tab(&mut self, tab_idx: isize) -> anyhow::Result<()> {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
let mut window = mux
|
||||
.get_window_mut(self.mux_window_id)
|
||||
.ok_or_else(|| anyhow!("no such window"))?;
|
||||
@ -1952,7 +1952,7 @@ impl TermWindow {
|
||||
}
|
||||
|
||||
fn activate_tab_relative(&mut self, delta: isize, wrap: bool) -> anyhow::Result<()> {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
let window = mux
|
||||
.get_window(self.mux_window_id)
|
||||
.ok_or_else(|| anyhow!("no such window"))?;
|
||||
@ -1979,7 +1979,7 @@ impl TermWindow {
|
||||
}
|
||||
|
||||
fn activate_last_tab(&mut self) -> anyhow::Result<()> {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
let window = mux
|
||||
.get_window(self.mux_window_id)
|
||||
.ok_or_else(|| anyhow!("no such window"))?;
|
||||
@ -1993,7 +1993,7 @@ impl TermWindow {
|
||||
}
|
||||
|
||||
fn move_tab(&mut self, tab_idx: usize) -> anyhow::Result<()> {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
let mut window = mux
|
||||
.get_window_mut(self.mux_window_id)
|
||||
.ok_or_else(|| anyhow!("no such window"))?;
|
||||
@ -2017,7 +2017,7 @@ impl TermWindow {
|
||||
}
|
||||
|
||||
fn show_debug_overlay(&mut self) {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
let tab = match mux.get_active_tab_for_window(self.mux_window_id) {
|
||||
Some(tab) => tab,
|
||||
None => return,
|
||||
@ -2053,7 +2053,7 @@ impl TermWindow {
|
||||
let mux_window_id = self.mux_window_id;
|
||||
let window = self.window.as_ref().unwrap().clone();
|
||||
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
let tab = match mux.get_active_tab_for_window(self.mux_window_id) {
|
||||
Some(tab) => tab,
|
||||
None => return,
|
||||
@ -2084,7 +2084,7 @@ impl TermWindow {
|
||||
|
||||
let win = window.clone();
|
||||
win.notify(TermWindowNotif::Apply(Box::new(move |term_window| {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
if let Some(tab) = mux.get_tab(tab_id) {
|
||||
let window = window.clone();
|
||||
let (overlay, future) =
|
||||
@ -2204,7 +2204,7 @@ impl TermWindow {
|
||||
}
|
||||
|
||||
fn move_tab_relative(&mut self, delta: isize) -> anyhow::Result<()> {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
let window = mux
|
||||
.get_window(self.mux_window_id)
|
||||
.ok_or_else(|| anyhow!("no such window"))?;
|
||||
@ -2415,7 +2415,7 @@ impl TermWindow {
|
||||
con.hide_application();
|
||||
}
|
||||
QuitApplication => {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
let config = &self.config;
|
||||
|
||||
match config.window_close_confirmation {
|
||||
@ -2565,7 +2565,7 @@ impl TermWindow {
|
||||
}
|
||||
}
|
||||
AdjustPaneSize(direction, amount) => {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
let tab = match mux.get_active_tab_for_window(self.mux_window_id) {
|
||||
Some(tab) => tab,
|
||||
None => return Ok(PerformAssignmentResult::Handled),
|
||||
@ -2578,7 +2578,7 @@ impl TermWindow {
|
||||
}
|
||||
}
|
||||
ActivatePaneByIndex(index) => {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
let tab = match mux.get_active_tab_for_window(self.mux_window_id) {
|
||||
Some(tab) => tab,
|
||||
None => return Ok(PerformAssignmentResult::Handled),
|
||||
@ -2594,7 +2594,7 @@ impl TermWindow {
|
||||
}
|
||||
}
|
||||
ActivatePaneDirection(direction) => {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
let tab = match mux.get_active_tab_for_window(self.mux_window_id) {
|
||||
Some(tab) => tab,
|
||||
None => return Ok(PerformAssignmentResult::Handled),
|
||||
@ -2607,7 +2607,7 @@ impl TermWindow {
|
||||
}
|
||||
}
|
||||
TogglePaneZoomState => {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
let tab = match mux.get_active_tab_for_window(self.mux_window_id) {
|
||||
Some(tab) => tab,
|
||||
None => return Ok(PerformAssignmentResult::Handled),
|
||||
@ -2615,7 +2615,7 @@ impl TermWindow {
|
||||
tab.toggle_zoom();
|
||||
}
|
||||
SetPaneZoomState(zoomed) => {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
let tab = match mux.get_active_tab_for_window(self.mux_window_id) {
|
||||
Some(tab) => tab,
|
||||
None => return Ok(PerformAssignmentResult::Handled),
|
||||
@ -2623,7 +2623,7 @@ impl TermWindow {
|
||||
tab.set_zoomed(*zoomed);
|
||||
}
|
||||
SwitchWorkspaceRelative(delta) => {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
let workspace = mux.active_workspace();
|
||||
let workspaces = mux.iter_workspaces();
|
||||
let idx = workspaces.iter().position(|w| *w == workspace).unwrap_or(0);
|
||||
@ -2640,7 +2640,7 @@ impl TermWindow {
|
||||
}
|
||||
SwitchToWorkspace { name, spawn } => {
|
||||
let activity = crate::Activity::new();
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
let name = name
|
||||
.as_ref()
|
||||
.map(|name| name.to_string())
|
||||
@ -2675,9 +2675,7 @@ impl TermWindow {
|
||||
}
|
||||
}
|
||||
DetachDomain(domain) => {
|
||||
let domain = Mux::get()
|
||||
.expect("running on GUI thread")
|
||||
.resolve_spawn_tab_domain(Some(pane.pane_id()), domain)?;
|
||||
let domain = Mux::get().resolve_spawn_tab_domain(Some(pane.pane_id()), domain)?;
|
||||
domain.detach()?;
|
||||
}
|
||||
AttachDomain(domain) => {
|
||||
@ -2686,7 +2684,7 @@ impl TermWindow {
|
||||
let dpi = self.dimensions.dpi as u32;
|
||||
|
||||
promise::spawn::spawn(async move {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
let domain = mux
|
||||
.get_domain_by_name(&domain)
|
||||
.ok_or_else(|| anyhow!("{} is not a valid domain name", domain))?;
|
||||
@ -2712,7 +2710,7 @@ impl TermWindow {
|
||||
// NOP here; handled by the overlay directly
|
||||
}
|
||||
RotatePanes(direction) => {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
let tab = match mux.get_active_tab_for_window(self.mux_window_id) {
|
||||
Some(tab) => tab,
|
||||
None => return Ok(PerformAssignmentResult::Handled),
|
||||
@ -2819,7 +2817,7 @@ impl TermWindow {
|
||||
}
|
||||
fn close_current_pane(&mut self, confirm: bool) {
|
||||
let mux_window_id = self.mux_window_id;
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
let tab = match mux.get_active_tab_for_window(mux_window_id) {
|
||||
Some(tab) => tab,
|
||||
None => return,
|
||||
@ -2843,7 +2841,7 @@ impl TermWindow {
|
||||
}
|
||||
|
||||
fn close_specific_tab(&mut self, tab_idx: usize, confirm: bool) {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
let mux_window_id = self.mux_window_id;
|
||||
let mux_window = match mux.get_window(mux_window_id) {
|
||||
Some(w) => w,
|
||||
@ -2874,7 +2872,7 @@ impl TermWindow {
|
||||
}
|
||||
|
||||
fn close_current_tab(&mut self, confirm: bool) {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
let tab = match mux.get_active_tab_for_window(self.mux_window_id) {
|
||||
Some(tab) => tab,
|
||||
None => return,
|
||||
@ -2907,7 +2905,7 @@ impl TermWindow {
|
||||
|
||||
/// Resize overlays to match their corresponding tab/pane dimensions
|
||||
pub fn resize_overlays(&self) {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
for (_, state) in self.tab_state.borrow().iter() {
|
||||
if let Some(overlay) = state.overlay.as_ref().map(|o| &o.pane) {
|
||||
overlay.resize(self.terminal_size).ok();
|
||||
@ -2989,7 +2987,7 @@ impl TermWindow {
|
||||
}
|
||||
|
||||
fn get_active_pane_no_overlay(&self) -> Option<Arc<dyn Pane>> {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
mux.get_active_tab_for_window(self.mux_window_id)
|
||||
.and_then(|tab| tab.get_active_pane())
|
||||
}
|
||||
@ -3001,7 +2999,7 @@ impl TermWindow {
|
||||
/// an active overlay (such as search or copy mode) then that will
|
||||
/// be returned.
|
||||
pub fn get_active_pane_or_overlay(&self) -> Option<Arc<dyn Pane>> {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
let tab = match mux.get_active_tab_for_window(self.mux_window_id) {
|
||||
Some(tab) => tab,
|
||||
None => return None,
|
||||
@ -3028,7 +3026,7 @@ impl TermWindow {
|
||||
}
|
||||
|
||||
fn get_splits(&mut self) -> Vec<PositionedSplit> {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
let tab = match mux.get_active_tab_for_window(self.mux_window_id) {
|
||||
Some(tab) => tab,
|
||||
None => return vec![],
|
||||
@ -3062,7 +3060,7 @@ impl TermWindow {
|
||||
}
|
||||
|
||||
fn get_tab_information(&mut self) -> Vec<TabInformation> {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
let window = match mux.get_window(self.mux_window_id) {
|
||||
Some(window) => window,
|
||||
_ => return vec![],
|
||||
@ -3130,7 +3128,7 @@ impl TermWindow {
|
||||
}
|
||||
|
||||
fn get_panes_to_render(&mut self) -> Vec<PositionedPane> {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
let tab = match mux.get_active_tab_for_window(self.mux_window_id) {
|
||||
Some(tab) => tab,
|
||||
None => return vec![],
|
||||
@ -3153,7 +3151,7 @@ impl TermWindow {
|
||||
}
|
||||
}
|
||||
if let Some(overlay) = self.tab_state(tab_id).overlay.take() {
|
||||
Mux::get().unwrap().remove_pane(overlay.pane.pane_id());
|
||||
Mux::get().remove_pane(overlay.pane.pane_id());
|
||||
}
|
||||
if let Some(window) = self.window.as_ref() {
|
||||
window.invalidate();
|
||||
@ -3171,7 +3169,7 @@ impl TermWindow {
|
||||
// pane id. Take care to avoid killing ourselves off
|
||||
// when closing the CopyOverlay
|
||||
if pane_id != overlay.pane.pane_id() {
|
||||
Mux::get().unwrap().remove_pane(overlay.pane.pane_id());
|
||||
Mux::get().remove_pane(overlay.pane.pane_id());
|
||||
}
|
||||
}
|
||||
if let Some(window) = self.window.as_ref() {
|
||||
|
@ -249,7 +249,7 @@ impl super::TermWindow {
|
||||
y: i64,
|
||||
context: &dyn WindowOps,
|
||||
) {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
let tab = match mux.get_active_tab_for_window(self.mux_window_id) {
|
||||
Some(tab) => tab,
|
||||
None => return,
|
||||
@ -564,7 +564,7 @@ impl super::TermWindow {
|
||||
// We're over a pane that isn't active
|
||||
match &event.kind {
|
||||
WMEK::Press(_) => {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
mux.get_active_tab_for_window(self.mux_window_id)
|
||||
.map(|tab| tab.set_active_idx(pos.index));
|
||||
|
||||
@ -573,7 +573,7 @@ impl super::TermWindow {
|
||||
}
|
||||
WMEK::Move => {
|
||||
if self.config.pane_focus_follows_mouse {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
mux.get_active_tab_for_window(self.mux_window_id)
|
||||
.map(|tab| tab.set_active_idx(pos.index));
|
||||
|
||||
|
@ -144,7 +144,7 @@ impl PaneSelector {
|
||||
pane_index: usize,
|
||||
term_window: &mut TermWindow,
|
||||
) -> anyhow::Result<()> {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
let tab = match mux.get_active_tab_for_window(term_window.mux_window_id) {
|
||||
Some(tab) => tab,
|
||||
None => return Ok(()),
|
||||
|
@ -2329,9 +2329,7 @@ impl super::TermWindow {
|
||||
self.update_text_cursor(&pos);
|
||||
if focused {
|
||||
pos.pane.advise_focus();
|
||||
mux::Mux::get()
|
||||
.expect("called on mux thread")
|
||||
.record_focus_for_current_identity(pos.pane.pane_id());
|
||||
mux::Mux::get().record_focus_for_current_identity(pos.pane.pane_id());
|
||||
}
|
||||
}
|
||||
self.paint_pane_opengl(&pos, num_panes, &mut layers)?;
|
||||
|
@ -261,7 +261,7 @@ impl super::TermWindow {
|
||||
|
||||
self.terminal_size = size;
|
||||
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
if let Some(window) = mux.get_window(self.mux_window_id) {
|
||||
for tab in window.iter() {
|
||||
tab.resize(size);
|
||||
|
@ -56,7 +56,7 @@ impl super::TermWindow {
|
||||
src_window_id: MuxWindowId,
|
||||
term_config: Arc<TermConfig>,
|
||||
) -> anyhow::Result<()> {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
let activity = Activity::new();
|
||||
|
||||
let current_pane_id = if let Some(tab) = mux.get_active_tab_for_window(src_window_id) {
|
||||
|
@ -283,7 +283,7 @@ pub fn load_last_release_info_and_set_banner() {
|
||||
}
|
||||
|
||||
fn set_banner_from_release_info(latest: &Release) {
|
||||
let mux = crate::Mux::get().unwrap();
|
||||
let mux = crate::Mux::get();
|
||||
let url = format!(
|
||||
"https://wezfurlong.org/wezterm/changelog.html#{}",
|
||||
latest.tag_name
|
||||
|
@ -57,7 +57,7 @@ where
|
||||
let mut handler = SessionHandler::new(pdu_sender);
|
||||
|
||||
{
|
||||
let mux = Mux::get().expect("to be running on gui thread");
|
||||
let mux = Mux::get();
|
||||
let tx = item_tx.clone();
|
||||
mux.subscribe(move |n| tx.try_send(Item::Notif(n)).is_ok());
|
||||
}
|
||||
@ -145,7 +145,7 @@ where
|
||||
Ok(Item::Notif(MuxNotification::WindowInvalidated(_window_id))) => {}
|
||||
Ok(Item::Notif(MuxNotification::WindowWorkspaceChanged(window_id))) => {
|
||||
let workspace = {
|
||||
let mux = Mux::get().expect("to be running on gui thread");
|
||||
let mux = Mux::get();
|
||||
mux.get_window(window_id)
|
||||
.map(|w| w.get_workspace().to_string())
|
||||
};
|
||||
|
@ -199,7 +199,7 @@ pub struct SessionHandler {
|
||||
impl Drop for SessionHandler {
|
||||
fn drop(&mut self) {
|
||||
if let Some(client_id) = self.client_id.take() {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
mux.unregister_client(&client_id);
|
||||
}
|
||||
}
|
||||
@ -226,7 +226,7 @@ impl SessionHandler {
|
||||
let sender = self.to_write_tx.clone();
|
||||
let per_pane = self.per_pane(pane_id);
|
||||
spawn_into_main_thread(async move {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
let pane = mux
|
||||
.get_pane(pane_id)
|
||||
.ok_or_else(|| anyhow!("no such pane {}", pane_id))?;
|
||||
@ -242,7 +242,7 @@ impl SessionHandler {
|
||||
let serial = decoded.serial;
|
||||
|
||||
if let Some(client_id) = &self.client_id {
|
||||
Mux::get().unwrap().client_had_input(client_id);
|
||||
Mux::get().client_had_input(client_id);
|
||||
}
|
||||
|
||||
let send_response = move |result: anyhow::Result<Pdu>| {
|
||||
@ -273,7 +273,7 @@ impl SessionHandler {
|
||||
spawn_into_main_thread(async move {
|
||||
catch(
|
||||
move || {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
let mut window = mux
|
||||
.get_window_mut(window_id)
|
||||
.ok_or_else(|| anyhow!("window {} is invalid", window_id))?;
|
||||
@ -289,7 +289,7 @@ impl SessionHandler {
|
||||
let client_id = Arc::new(client_id);
|
||||
self.client_id.replace(client_id.clone());
|
||||
spawn_into_main_thread(async move {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
mux.register_client(client_id);
|
||||
})
|
||||
.detach();
|
||||
@ -298,7 +298,7 @@ impl SessionHandler {
|
||||
Pdu::SetFocusedPane(SetFocusedPane { pane_id }) => {
|
||||
let client_id = self.client_id.clone();
|
||||
spawn_into_main_thread(async move {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
let _identity = mux.with_identity(client_id);
|
||||
mux.record_focus_for_current_identity(pane_id);
|
||||
})
|
||||
@ -309,7 +309,7 @@ impl SessionHandler {
|
||||
spawn_into_main_thread(async move {
|
||||
catch(
|
||||
move || {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
let clients = mux.iter_clients();
|
||||
Ok(Pdu::GetClientListResponse(GetClientListResponse {
|
||||
clients,
|
||||
@ -324,7 +324,7 @@ impl SessionHandler {
|
||||
spawn_into_main_thread(async move {
|
||||
catch(
|
||||
move || {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
let mut tabs = vec![];
|
||||
for window_id in mux.iter_windows().into_iter() {
|
||||
let window = mux.get_window(window_id).unwrap();
|
||||
@ -347,7 +347,7 @@ impl SessionHandler {
|
||||
spawn_into_main_thread(async move {
|
||||
catch(
|
||||
move || {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
let pane = mux
|
||||
.get_pane(pane_id)
|
||||
.ok_or_else(|| anyhow!("no such pane {}", pane_id))?;
|
||||
@ -366,7 +366,7 @@ impl SessionHandler {
|
||||
spawn_into_main_thread(async move {
|
||||
catch(
|
||||
move || {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
let pane = mux
|
||||
.get_pane(pane_id)
|
||||
.ok_or_else(|| anyhow!("no such pane {}", pane_id))?;
|
||||
@ -386,7 +386,7 @@ impl SessionHandler {
|
||||
spawn_into_main_thread(async move {
|
||||
catch(
|
||||
move || {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
let pane = mux
|
||||
.get_pane(pane_id)
|
||||
.ok_or_else(|| anyhow!("no such pane {}", pane_id))?;
|
||||
@ -414,7 +414,7 @@ impl SessionHandler {
|
||||
range: std::ops::Range<StableRowIndex>,
|
||||
limit: Option<u32>,
|
||||
) -> anyhow::Result<Pdu> {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
let pane = mux
|
||||
.get_pane(pane_id)
|
||||
.ok_or_else(|| anyhow!("no such pane {}", pane_id))?;
|
||||
@ -442,7 +442,7 @@ impl SessionHandler {
|
||||
spawn_into_main_thread(async move {
|
||||
catch(
|
||||
move || {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
let pane = mux
|
||||
.get_pane(pane_id)
|
||||
.ok_or_else(|| anyhow!("no such pane {}", pane_id))?;
|
||||
@ -463,7 +463,7 @@ impl SessionHandler {
|
||||
spawn_into_main_thread(async move {
|
||||
catch(
|
||||
move || {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
let (_domain_id, _window_id, tab_id) = mux
|
||||
.resolve_pane_id(pane_id)
|
||||
.ok_or_else(|| anyhow!("no such pane {}", pane_id))?;
|
||||
@ -487,7 +487,7 @@ impl SessionHandler {
|
||||
spawn_into_main_thread(async move {
|
||||
catch(
|
||||
move || {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
let pane = mux
|
||||
.get_pane(pane_id)
|
||||
.ok_or_else(|| anyhow!("no such pane {}", pane_id))?;
|
||||
@ -514,7 +514,7 @@ impl SessionHandler {
|
||||
spawn_into_main_thread(async move {
|
||||
catch(
|
||||
move || {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
let pane = mux
|
||||
.get_pane(pane_id)
|
||||
.ok_or_else(|| anyhow!("no such pane {}", pane_id))?;
|
||||
@ -544,7 +544,7 @@ impl SessionHandler {
|
||||
spawn_into_main_thread(async move {
|
||||
catch(
|
||||
move || {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
let pane = mux
|
||||
.get_pane(pane_id)
|
||||
.ok_or_else(|| anyhow!("no such pane {}", pane_id))?;
|
||||
@ -588,7 +588,7 @@ impl SessionHandler {
|
||||
spawn_into_main_thread(async move {
|
||||
catch(
|
||||
move || {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
let is_alive = match mux.get_pane(pane_id) {
|
||||
Some(pane) => {
|
||||
maybe_push_pane_changes(&pane, sender, per_pane)?;
|
||||
@ -611,7 +611,7 @@ impl SessionHandler {
|
||||
spawn_into_main_thread(async move {
|
||||
catch(
|
||||
move || {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
let pane = mux
|
||||
.get_pane(pane_id)
|
||||
.ok_or_else(|| anyhow!("no such pane {}", pane_id))?;
|
||||
@ -645,7 +645,7 @@ impl SessionHandler {
|
||||
spawn_into_main_thread(async move {
|
||||
catch(
|
||||
move || {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
let mut data = None;
|
||||
|
||||
let pane = mux
|
||||
@ -755,7 +755,7 @@ where
|
||||
}
|
||||
|
||||
async fn split_pane(split: SplitPane, client_id: Option<Arc<ClientId>>) -> anyhow::Result<Pdu> {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
let _identity = mux.with_identity(client_id);
|
||||
|
||||
let (_pane_domain_id, window_id, tab_id) = mux
|
||||
@ -784,7 +784,7 @@ async fn split_pane(split: SplitPane, client_id: Option<Arc<ClientId>>) -> anyho
|
||||
}
|
||||
|
||||
async fn domain_spawn_v2(spawn: SpawnV2, client_id: Option<Arc<ClientId>>) -> anyhow::Result<Pdu> {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
let _identity = mux.with_identity(client_id);
|
||||
|
||||
let (tab, pane, window_id) = mux
|
||||
@ -822,7 +822,7 @@ async fn move_pane(
|
||||
request: MovePaneToNewTab,
|
||||
client_id: Option<Arc<ClientId>>,
|
||||
) -> anyhow::Result<Pdu> {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
let _identity = mux.with_identity(client_id);
|
||||
|
||||
let (tab, window_id) = mux
|
||||
|
@ -210,7 +210,7 @@ async fn trigger_mux_startup(lua: Option<Rc<mlua::Lua>>) -> anyhow::Result<()> {
|
||||
}
|
||||
|
||||
async fn async_run(cmd: Option<CommandBuilder>) -> anyhow::Result<()> {
|
||||
let mux = Mux::get().unwrap();
|
||||
let mux = Mux::get();
|
||||
|
||||
let domain = mux.default_domain();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user