mirror of
https://github.com/wez/wezterm.git
synced 2024-11-27 12:23:46 +03:00
pass config into Mux
This commit is contained in:
parent
ea8fa17f6e
commit
0d51fd0e7d
@ -110,13 +110,13 @@ fn run_terminal_gui(config: Arc<config::Config>, opts: Opt) -> Result<(), Error>
|
||||
None
|
||||
};
|
||||
|
||||
let mux = Rc::new(mux::Mux::default());
|
||||
let mux = Rc::new(mux::Mux::new(&config));
|
||||
Mux::set_mux(&mux);
|
||||
|
||||
let front_end = opts.front_end.unwrap_or(config.front_end);
|
||||
let gui = front_end.try_new(&mux)?;
|
||||
|
||||
spawn_window(&mux, &*gui, cmd, &config, &fontconfig)?;
|
||||
spawn_window(&mux, &*gui, cmd, &fontconfig)?;
|
||||
gui.run_forever()
|
||||
}
|
||||
|
||||
@ -167,11 +167,10 @@ fn spawn_window(
|
||||
mux: &Rc<Mux>,
|
||||
gui: &FrontEnd,
|
||||
cmd: Option<Vec<&std::ffi::OsStr>>,
|
||||
config: &Arc<config::Config>,
|
||||
fontconfig: &Rc<FontConfiguration>,
|
||||
) -> Result<(), Error> {
|
||||
let tab = spawn_tab(config, cmd)?;
|
||||
let tab = spawn_tab(mux.config(), cmd)?;
|
||||
mux.add_tab(gui.gui_executor(), &tab)?;
|
||||
|
||||
gui.spawn_new_window(config, &fontconfig, &tab)
|
||||
gui.spawn_new_window(mux.config(), &fontconfig, &tab)
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
use crate::config::Config;
|
||||
use crate::ExitStatus;
|
||||
use failure::Error;
|
||||
use promise::{Executor, Future};
|
||||
@ -5,6 +6,7 @@ use std::cell::{Ref, RefCell, RefMut};
|
||||
use std::collections::HashMap;
|
||||
use std::io::Read;
|
||||
use std::rc::Rc;
|
||||
use std::sync::Arc;
|
||||
use std::thread;
|
||||
use term::TerminalHost;
|
||||
use termwiz::hyperlink::Hyperlink;
|
||||
@ -16,10 +18,10 @@ pub mod window;
|
||||
use crate::mux::tab::{Tab, TabId};
|
||||
use crate::mux::window::{Window, WindowId};
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Mux {
|
||||
tabs: RefCell<HashMap<TabId, Rc<Tab>>>,
|
||||
windows: RefCell<HashMap<WindowId, Window>>,
|
||||
config: Arc<Config>,
|
||||
}
|
||||
|
||||
fn read_from_tab_pty(executor: Box<Executor>, tab_id: TabId, mut reader: Box<std::io::Read>) {
|
||||
@ -96,6 +98,18 @@ thread_local! {
|
||||
}
|
||||
|
||||
impl Mux {
|
||||
pub fn new(config: &Arc<Config>) -> Self {
|
||||
Self {
|
||||
tabs: RefCell::new(HashMap::new()),
|
||||
windows: RefCell::new(HashMap::new()),
|
||||
config: Arc::clone(config),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn config(&self) -> &Arc<Config> {
|
||||
&self.config
|
||||
}
|
||||
|
||||
pub fn set_mux(mux: &Rc<Mux>) {
|
||||
MUX.with(|m| {
|
||||
*m.borrow_mut() = Some(Rc::clone(mux));
|
||||
|
Loading…
Reference in New Issue
Block a user