From 3c7eeac2dac2c8bbe2c63e2b4d1575bf44412e93 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Wed, 13 Mar 2019 12:01:05 -0700 Subject: [PATCH] stub out muxserver frontend --- src/frontend/mod.rs | 14 +++++++------ src/frontend/muxserver/mod.rs | 37 +++++++++++++++++++++++++++++++++++ src/main.rs | 11 +---------- src/server/listener.rs | 11 ----------- 4 files changed, 46 insertions(+), 27 deletions(-) create mode 100644 src/frontend/muxserver/mod.rs diff --git a/src/frontend/mod.rs b/src/frontend/mod.rs index 9a38182a4..1d9495cf2 100644 --- a/src/frontend/mod.rs +++ b/src/frontend/mod.rs @@ -7,9 +7,9 @@ use promise::Executor; use std::rc::Rc; use std::sync::Arc; -pub mod guicommon; - pub mod glium; +pub mod guicommon; +pub mod muxserver; #[cfg(all(unix, not(feature = "force-glutin"), not(target_os = "macos")))] pub mod xwindows; @@ -17,6 +17,7 @@ pub mod xwindows; pub enum FrontEndSelection { Glutin, X11, + MuxServer, } impl Default for FrontEndSelection { @@ -33,19 +34,19 @@ impl Default for FrontEndSelection { impl FrontEndSelection { pub fn try_new(self, mux: &Rc) -> Result, Error> { - let system = match self { + match self { FrontEndSelection::Glutin => glium::glutinloop::GlutinFrontEnd::try_new(mux), #[cfg(all(unix, not(target_os = "macos")))] FrontEndSelection::X11 => xwindows::x11loop::X11FrontEnd::try_new(mux), #[cfg(not(all(unix, not(target_os = "macos"))))] FrontEndSelection::X11 => bail!("X11 not compiled in"), - }; - system + FrontEndSelection::MuxServer => muxserver::MuxServerFrontEnd::try_new(mux), + } } // TODO: find or build a proc macro for this pub fn variants() -> Vec<&'static str> { - vec!["Glutin", "X11"] + vec!["Glutin", "X11", "MuxServer"] } } @@ -55,6 +56,7 @@ impl std::str::FromStr for FrontEndSelection { match s.to_lowercase().as_ref() { "glutin" => Ok(FrontEndSelection::Glutin), "x11" => Ok(FrontEndSelection::X11), + "muxserver" => Ok(FrontEndSelection::MuxServer), _ => Err(format_err!( "{} is not a valid FrontEndSelection variant, possible values are {:?}", s, diff --git a/src/frontend/muxserver/mod.rs b/src/frontend/muxserver/mod.rs new file mode 100644 index 000000000..66dfcba08 --- /dev/null +++ b/src/frontend/muxserver/mod.rs @@ -0,0 +1,37 @@ +//! Implements the multiplexer server frontend +use crate::config::Config; +use crate::font::FontConfiguration; +use crate::frontend::FrontEnd; +use crate::mux::tab::Tab; +use crate::mux::Mux; +use failure::Error; +use promise::Executor; +use std::rc::Rc; +use std::sync::Arc; + +pub struct MuxServerFrontEnd {} + +impl MuxServerFrontEnd { + pub fn try_new(_mux: &Rc) -> Result, Error> { + Ok(Rc::new(Self {})) + } +} + +impl FrontEnd for MuxServerFrontEnd { + fn gui_executor(&self) -> Box { + unimplemented!(); + } + + fn run_forever(&self) -> Result<(), Error> { + unimplemented!(); + } + + fn spawn_new_window( + &self, + _config: &Arc, + _fontconfig: &Rc, + _tab: &Rc, + ) -> Result<(), Error> { + unimplemented!(); + } +} diff --git a/src/main.rs b/src/main.rs index 357458f32..92339300d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -96,11 +96,6 @@ struct Opt { /// as if it were a login shell. #[structopt(parse(from_os_str))] prog: Vec, - - /// Rather than running the terminal, run as the - /// multiplexer server. - #[structopt(long = "start-mux-server")] - start_mux_server: bool, } fn run_terminal_gui(config: Arc, opts: Opt) -> Result<(), Error> { @@ -134,11 +129,7 @@ fn main() -> Result<(), Error> { }); println!("Using configuration: {:#?}\nopts: {:#?}", config, opts); - if opts.start_mux_server { - server::listener::run_mux_server(config) - } else { - run_terminal_gui(config, opts) - } + run_terminal_gui(config, opts) } fn spawn_tab( diff --git a/src/server/listener.rs b/src/server/listener.rs index 2d8561889..b4cdee2c1 100644 --- a/src/server/listener.rs +++ b/src/server/listener.rs @@ -1,10 +1,6 @@ -use crate::config::Config; -use crate::mux::Mux; use crate::server::{UnixListener, UnixStream}; use failure::Error; use std::io::{Read, Write}; -use std::rc::Rc; -use std::sync::Arc; pub trait SocketLike: Read + Write + Send {} @@ -38,10 +34,3 @@ impl Listener { } pub struct ClientSession {} - -pub fn run_mux_server(config: Arc) -> Result<(), Error> { - let mux = Rc::new(Mux::default()); - Mux::set_mux(&mux); - - Ok(()) -}