mirror of
https://github.com/wez/wezterm.git
synced 2024-11-22 22:42:48 +03:00
register mux as a gui thread local variable
This commit is contained in:
parent
aa6cfb00dd
commit
12e93fce57
@ -125,6 +125,7 @@ fn main() -> Result<(), Error> {
|
||||
};
|
||||
|
||||
let mux = Rc::new(mux::Mux::default());
|
||||
Mux::set_mux(&mux);
|
||||
|
||||
let gui_system = opts.gui_system.unwrap_or(config.gui_system);
|
||||
let gui = gui_system.try_new(&mux)?;
|
||||
|
@ -101,11 +101,31 @@ impl<'a> TerminalHost for Host<'a> {
|
||||
fn set_title(&mut self, _title: &str) {}
|
||||
}
|
||||
|
||||
thread_local! {
|
||||
static MUX: RefCell<Option<Rc<Mux>>> = RefCell::new(None);
|
||||
}
|
||||
|
||||
impl Mux {
|
||||
pub fn set_spawner(&self, spawner: Spawner) {
|
||||
*self.spawner.borrow_mut() = Some(spawner);
|
||||
}
|
||||
|
||||
pub fn set_mux(mux: &Rc<Mux>) {
|
||||
MUX.with(|m| {
|
||||
*m.borrow_mut() = Some(Rc::clone(mux));
|
||||
});
|
||||
}
|
||||
|
||||
pub fn get() -> Option<Rc<Mux>> {
|
||||
let mut res = None;
|
||||
MUX.with(|m| {
|
||||
if let Some(mux) = &*m.borrow() {
|
||||
res = Some(Rc::clone(mux));
|
||||
}
|
||||
});
|
||||
res
|
||||
}
|
||||
|
||||
pub fn get_tab(&self, tab_id: TabId) -> Option<Rc<Tab>> {
|
||||
self.tabs.borrow().get(&tab_id).map(Rc::clone)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user