diff --git a/base91/src/lib.rs b/base91/src/lib.rs index 6fc6dc665..e9857214e 100644 --- a/base91/src/lib.rs +++ b/base91/src/lib.rs @@ -63,14 +63,14 @@ const DECTAB: [u8; 256] = [ /// maintains up to 2 bytes of pending data; the Drop impl will implicitly flush on /// your behalf, but will mask any error that may occur during the flush. pub struct Base91Encoder<'a> { - writer: &'a mut Write, + writer: &'a mut dyn Write, accumulator: u64, bits: u32, } impl<'a> Base91Encoder<'a> { /// Construct a Base91Encoder that writes encoded data to the supplied writer - pub fn new(writer: &'a mut Write) -> Self { + pub fn new(writer: &'a mut dyn Write) -> Self { Self { writer, accumulator: 0, @@ -149,14 +149,14 @@ pub fn encode(buf: &[u8]) -> Vec { /// maintains up to 1 byte of pending data; the Drop impl will implicitly flush on /// your behalf, but will mask any error that may occur during the flush. pub struct Base91Decoder<'a> { - writer: &'a mut Write, + writer: &'a mut dyn Write, accumulator: u64, bits: u32, value: Option, } impl<'a> Base91Decoder<'a> { - pub fn new(writer: &'a mut Write) -> Self { + pub fn new(writer: &'a mut dyn Write) -> Self { Self { writer, accumulator: 0, diff --git a/promise/src/lib.rs b/promise/src/lib.rs index 1bffccffb..6b8574d82 100644 --- a/promise/src/lib.rs +++ b/promise/src/lib.rs @@ -6,14 +6,14 @@ pub type SpawnFunc = Box; pub trait Executor: Send { fn execute(&self, f: SpawnFunc); - fn clone_executor(&self) -> Box; + fn clone_executor(&self) -> Box; } -impl Executor for Box { +impl Executor for Box { fn execute(&self, f: SpawnFunc) { Executor::execute(&**self, f) } - fn clone_executor(&self) -> Box { + fn clone_executor(&self) -> Box { Executor::clone_executor(&**self) } } @@ -33,7 +33,7 @@ impl Executor for RayonExecutor { fn execute(&self, f: SpawnFunc) { rayon::spawn(f); } - fn clone_executor(&self) -> Box { + fn clone_executor(&self) -> Box { Box::new(RayonExecutor::new()) } } diff --git a/pty/src/lib.rs b/pty/src/lib.rs index f1c8733b3..d4008590b 100644 --- a/pty/src/lib.rs +++ b/pty/src/lib.rs @@ -85,7 +85,7 @@ pub trait MasterPty: std::io::Write { fn get_size(&self) -> Result; /// Obtain a readable handle; output from the slave(s) is readable /// via this stream. - fn try_clone_reader(&self) -> Result, Error>; + fn try_clone_reader(&self) -> Result, Error>; } /// Represents a child process spawned into the pty. @@ -107,7 +107,7 @@ pub trait Child: std::fmt::Debug { /// Can be used to spawn processes into the pty. pub trait SlavePty { /// Spawns the command specified by the provided CommandBuilder - fn spawn_command(&self, cmd: CommandBuilder) -> Result, Error>; + fn spawn_command(&self, cmd: CommandBuilder) -> Result, Error>; } /// Represents the exit status of a child process. @@ -146,7 +146,7 @@ pub trait PtySystem { /// Create a new Pty instance with the window size set to the specified /// dimensions. Returns a (master, slave) Pty pair. The master side /// is used to drive the slave side. - fn openpty(&self, size: PtySize) -> Result<(Box, Box), Error>; + fn openpty(&self, size: PtySize) -> Result<(Box, Box), Error>; } impl Child for std::process::Child { @@ -188,7 +188,7 @@ impl PtySystemSelection { /// Construct an instance of PtySystem described by the enum value. /// Windows specific enum variants result in an error. #[cfg(unix)] - pub fn get(&self) -> Result, Error> { + pub fn get(&self) -> Result, Error> { match self { PtySystemSelection::Unix => Ok(Box::new(unix::UnixPtySystem {})), _ => bail!("{:?} not available on unix", self), diff --git a/pty/src/unix.rs b/pty/src/unix.rs index 1a70d4f15..23b02be75 100644 --- a/pty/src/unix.rs +++ b/pty/src/unix.rs @@ -13,7 +13,7 @@ use std::ptr; pub struct UnixPtySystem {} impl PtySystem for UnixPtySystem { - fn openpty(&self, size: PtySize) -> Result<(Box, Box), Error> { + fn openpty(&self, size: PtySize) -> Result<(Box, Box), Error> { let mut master: RawFd = -1; let mut slave: RawFd = -1; @@ -128,15 +128,15 @@ fn set_nonblocking(fd: RawFd) -> Result<(), Error> { } impl SlavePty for UnixSlavePty { - fn spawn_command(&self, builder: CommandBuilder) -> Result, Error> { + fn spawn_command(&self, builder: CommandBuilder) -> Result, Error> { let mut cmd = builder.as_command(); - cmd.stdin(self.as_stdio()?) - .stdout(self.as_stdio()?) - .stderr(self.as_stdio()?) - .before_exec(move || { - // Clean up a few things before we exec the program - unsafe { + unsafe { + cmd.stdin(self.as_stdio()?) + .stdout(self.as_stdio()?) + .stderr(self.as_stdio()?) + .pre_exec(move || { + // Clean up a few things before we exec the program // Clear out any potentially problematic signal // dispositions that we might have inherited for signo in &[ @@ -170,8 +170,8 @@ impl SlavePty for UnixSlavePty { } } Ok(()) - } - }); + }) + }; let mut child = cmd.spawn()?; @@ -232,7 +232,7 @@ impl MasterPty for UnixMasterPty { }) } - fn try_clone_reader(&self) -> Result, Error> { + fn try_clone_reader(&self) -> Result, Error> { let fd = self.fd.try_clone()?; Ok(Box::new(fd)) } diff --git a/src/font/fontconfigandfreetype.rs b/src/font/fontconfigandfreetype.rs index 86c6a8436..a9d964ee8 100644 --- a/src/font/fontconfigandfreetype.rs +++ b/src/font/fontconfigandfreetype.rs @@ -24,7 +24,7 @@ impl FontSystem for FontConfigAndFreeType { config: &Config, style: &TextStyle, font_scale: f64, - ) -> Result, Error> { + ) -> Result, Error> { let fonts = style.font_with_fallback(); let mut pattern = if !fonts.is_empty() { let mut pattern = FontPattern::new()?; @@ -72,7 +72,7 @@ impl Drop for NamedFontImpl { } impl NamedFont for NamedFontImpl { - fn get_fallback(&mut self, idx: FallbackIdx) -> Result<&Font, Error> { + fn get_fallback(&mut self, idx: FallbackIdx) -> Result<&dyn Font, Error> { Ok(self.get_font(idx)?) } fn shape(&mut self, s: &str) -> Result, Error> { diff --git a/src/font/mod.rs b/src/font/mod.rs index bed530fd9..277887e7e 100644 --- a/src/font/mod.rs +++ b/src/font/mod.rs @@ -31,13 +31,13 @@ pub mod fontloader_and_freetype; use super::config::{Config, TextStyle}; use term::CellAttributes; -type FontPtr = Rc>>; +type FontPtr = Rc>>; /// Matches and loads fonts for a given input style pub struct FontConfiguration { config: Arc, fonts: RefCell>, - system: Rc, + system: Rc, metrics: RefCell>, dpi_scale: RefCell, font_scale: RefCell, @@ -69,7 +69,7 @@ thread_local! { } impl FontSystemSelection { - fn new_font_system(self) -> Rc { + fn new_font_system(self) -> Rc { match self { FontSystemSelection::FontConfigAndFreeType => { #[cfg(all(unix, any(feature = "fontconfig", not(target_os = "macos"))))] @@ -142,7 +142,7 @@ impl FontConfiguration { /// Given a text style, load (with caching) the font that best /// matches according to the fontconfig pattern. - pub fn cached_font(&self, style: &TextStyle) -> Result>>, Error> { + pub fn cached_font(&self, style: &TextStyle) -> Result>>, Error> { let mut fonts = self.fonts.borrow_mut(); if let Some(entry) = fonts.get(style) { @@ -167,7 +167,7 @@ impl FontConfiguration { } /// Returns the baseline font specified in the configuration - pub fn default_font(&self) -> Result>>, Error> { + pub fn default_font(&self) -> Result>>, Error> { self.cached_font(&self.config.font) } @@ -234,7 +234,7 @@ impl FontConfiguration { #[allow(dead_code)] pub fn shape_with_harfbuzz( - font: &mut NamedFont, + font: &mut dyn NamedFont, font_idx: system::FallbackIdx, s: &str, ) -> Result, Error> { diff --git a/src/font/system.rs b/src/font/system.rs index b368b5cc6..cdd64e390 100644 --- a/src/font/system.rs +++ b/src/font/system.rs @@ -73,7 +73,7 @@ pub type FallbackIdx = usize; /// zero as the best/most preferred font. pub trait NamedFont { /// Get a reference to a numbered fallback Font instance - fn get_fallback(&mut self, idx: FallbackIdx) -> Result<&Font, Error>; + fn get_fallback(&mut self, idx: FallbackIdx) -> Result<&dyn Font, Error>; /// Shape text and return a vector of GlyphInfo fn shape(&mut self, text: &str) -> Result, Error>; @@ -88,7 +88,7 @@ pub trait FontSystem { config: &Config, style: &TextStyle, font_scale: f64, - ) -> Result, Error>; + ) -> Result, Error>; } /// Describes the key font metrics that we use in rendering diff --git a/src/frontend/glium/glutinloop.rs b/src/frontend/glium/glutinloop.rs index f30fb3522..eed659601 100644 --- a/src/frontend/glium/glutinloop.rs +++ b/src/frontend/glium/glutinloop.rs @@ -71,7 +71,7 @@ impl Executor for GlutinGuiExecutor { fn execute(&self, f: SpawnFunc) { self.tx.send(f).expect("GlutinExecutor execute failed"); } - fn clone_executor(&self) -> Box { + fn clone_executor(&self) -> Box { Box::new(GlutinGuiExecutor { tx: Arc::clone(&self.tx), }) @@ -109,7 +109,7 @@ thread_local! { } impl GlutinFrontEnd { - pub fn try_new(mux: &Rc) -> Result, Error> { + pub fn try_new(mux: &Rc) -> Result, Error> { let event_loop = Rc::new(GuiEventLoop::new(mux)?); GLUTIN_EVENT_LOOP.with(|f| *f.borrow_mut() = Some(Rc::clone(&event_loop))); Ok(Rc::new(Self { event_loop })) @@ -117,7 +117,7 @@ impl GlutinFrontEnd { } impl FrontEnd for GlutinFrontEnd { - fn gui_executor(&self) -> Box { + fn gui_executor(&self) -> Box { self.event_loop.gui_executor() } @@ -146,7 +146,7 @@ impl FrontEnd for GlutinFrontEnd { &self, config: &Arc, fontconfig: &Rc, - tab: &Rc, + tab: &Rc, ) -> Result<(), Error> { let window = GliumTerminalWindow::new(&self.event_loop, fontconfig, config, tab)?; @@ -198,13 +198,13 @@ impl GuiEventLoop { self.gui_thread_sends.borrow_mut().push_back(func); } - fn gui_executor(&self) -> Box { + fn gui_executor(&self) -> Box { Box::new(GlutinGuiExecutor { tx: self.gui_tx.clone(), }) } - pub fn with_window Result<(), Error>>( + pub fn with_window Result<(), Error>>( &self, window_id: WindowId, func: F, diff --git a/src/frontend/glium/window.rs b/src/frontend/glium/window.rs index 3b7d2e1cb..2649050a5 100644 --- a/src/frontend/glium/window.rs +++ b/src/frontend/glium/window.rs @@ -33,7 +33,7 @@ struct Host { } impl HostHelper for Host { - fn with_window Result<(), Error>>( + fn with_window Result<(), Error>>( &self, func: F, ) { @@ -194,7 +194,7 @@ impl GliumTerminalWindow { event_loop: &Rc, fonts: &Rc, config: &Arc, - tab: &Rc, + tab: &Rc, ) -> Result { let (physical_rows, physical_cols) = tab.renderer().physical_dimensions(); diff --git a/src/frontend/guicommon/host.rs b/src/frontend/guicommon/host.rs index af9cbb486..39c7823ad 100644 --- a/src/frontend/guicommon/host.rs +++ b/src/frontend/guicommon/host.rs @@ -36,7 +36,7 @@ pub enum KeyAssignment { } pub trait HostHelper { - fn with_window Result<(), Error>>( + fn with_window Result<(), Error>>( &self, func: F, ); @@ -214,7 +214,7 @@ impl HostImpl { pub fn perform_key_assignment( &mut self, - tab: &Tab, + tab: &dyn Tab, assignment: &KeyAssignment, ) -> Fallible<()> { use KeyAssignment::*; @@ -252,7 +252,7 @@ impl HostImpl { pub fn process_gui_shortcuts( &mut self, - tab: &Tab, + tab: &dyn Tab, mods: KeyModifiers, key: KeyCode, ) -> Result { @@ -341,18 +341,18 @@ impl DerefMut for HostImpl { /// `TabHost` instances are short lived and borrow references to /// other state. pub struct TabHost<'a, H: HostHelper> { - writer: &'a mut std::io::Write, + writer: &'a mut dyn std::io::Write, host: &'a mut HostImpl, } impl<'a, H: HostHelper> TabHost<'a, H> { - pub fn new(writer: &'a mut std::io::Write, host: &'a mut HostImpl) -> Self { + pub fn new(writer: &'a mut dyn std::io::Write, host: &'a mut HostImpl) -> Self { Self { writer, host } } } impl<'a, H: HostHelper> term::TerminalHost for TabHost<'a, H> { - fn writer(&mut self) -> &mut std::io::Write { + fn writer(&mut self) -> &mut dyn std::io::Write { &mut self.writer } diff --git a/src/frontend/guicommon/localtab.rs b/src/frontend/guicommon/localtab.rs index 35803ac32..909cfba6e 100644 --- a/src/frontend/guicommon/localtab.rs +++ b/src/frontend/guicommon/localtab.rs @@ -9,8 +9,8 @@ use term::{KeyCode, KeyModifiers, MouseEvent, Terminal, TerminalHost}; pub struct LocalTab { tab_id: TabId, terminal: RefCell, - process: RefCell>, - pty: RefCell>, + process: RefCell>, + pty: RefCell>, } impl Tab for LocalTab { @@ -19,7 +19,7 @@ impl Tab for LocalTab { self.tab_id } - fn renderer(&self) -> RefMut { + fn renderer(&self) -> RefMut { RefMut::map(self.terminal.borrow_mut(), |t| &mut *t) } @@ -31,11 +31,11 @@ impl Tab for LocalTab { } } - fn advance_bytes(&self, buf: &[u8], host: &mut TerminalHost) { + fn advance_bytes(&self, buf: &[u8], host: &mut dyn TerminalHost) { self.terminal.borrow_mut().advance_bytes(buf, host) } - fn mouse_event(&self, event: MouseEvent, host: &mut TerminalHost) -> Result<(), Error> { + fn mouse_event(&self, event: MouseEvent, host: &mut dyn TerminalHost) -> Result<(), Error> { self.terminal.borrow_mut().mouse_event(event, host) } @@ -64,11 +64,11 @@ impl Tab for LocalTab { Ok(()) } - fn writer(&self) -> RefMut { + fn writer(&self) -> RefMut { self.pty.borrow_mut() } - fn reader(&self) -> Result, Error> { + fn reader(&self) -> Result, Error> { self.pty.borrow_mut().try_clone_reader() } @@ -88,7 +88,7 @@ impl Tab for LocalTab { } impl LocalTab { - pub fn new(terminal: Terminal, process: Box, pty: Box) -> Self { + pub fn new(terminal: Terminal, process: Box, pty: Box) -> Self { let tab_id = alloc_tab_id(); Self { tab_id, diff --git a/src/frontend/guicommon/window.rs b/src/frontend/guicommon/window.rs index 15e896289..352c62530 100644 --- a/src/frontend/guicommon/window.rs +++ b/src/frontend/guicommon/window.rs @@ -284,7 +284,7 @@ pub trait TerminalWindow { Some(window) => window, None => return true, }; - let dead_tabs: Vec> = window + let dead_tabs: Vec> = window .iter() .filter_map(|tab| { if tab.is_dead() { diff --git a/src/frontend/mod.rs b/src/frontend/mod.rs index 4458e1087..9cb5c40d9 100644 --- a/src/frontend/mod.rs +++ b/src/frontend/mod.rs @@ -37,13 +37,13 @@ impl Default for FrontEndSelection { } lazy_static! { - static ref EXECUTOR: Mutex>> = Mutex::new(None); + static ref EXECUTOR: Mutex>> = Mutex::new(None); } thread_local! { - static FRONT_END: RefCell>> = RefCell::new(None); + static FRONT_END: RefCell>> = RefCell::new(None); } -pub fn gui_executor() -> Option> { +pub fn gui_executor() -> Option> { let locked = EXECUTOR.lock().unwrap(); match locked.as_ref() { Some(exec) => Some(exec.clone_executor()), @@ -51,7 +51,7 @@ pub fn gui_executor() -> Option> { } } -pub fn front_end() -> Option> { +pub fn front_end() -> Option> { let mut res = None; FRONT_END.with(|f| { if let Some(me) = &*f.borrow() { @@ -62,7 +62,7 @@ pub fn front_end() -> Option> { } impl FrontEndSelection { - pub fn try_new(self, mux: &Rc) -> Result, Error> { + pub fn try_new(self, mux: &Rc) -> Result, Error> { let front_end = match self { FrontEndSelection::Glutin => glium::glutinloop::GlutinFrontEnd::try_new(mux), #[cfg(all(unix, not(target_os = "macos")))] @@ -111,8 +111,8 @@ pub trait FrontEnd { &self, config: &Arc, fontconfig: &Rc, - tab: &Rc, + tab: &Rc, ) -> Result<(), Error>; - fn gui_executor(&self) -> Box; + fn gui_executor(&self) -> Box; } diff --git a/src/frontend/muxserver/mod.rs b/src/frontend/muxserver/mod.rs index 77d968c24..e3cfd189f 100644 --- a/src/frontend/muxserver/mod.rs +++ b/src/frontend/muxserver/mod.rs @@ -22,7 +22,7 @@ impl Executor for MuxExecutor { fn execute(&self, f: SpawnFunc) { self.tx.send(f).expect("MuxExecutor execute failed"); } - fn clone_executor(&self) -> Box { + fn clone_executor(&self) -> Box { Box::new(MuxExecutor { tx: self.tx.clone(), }) @@ -36,7 +36,7 @@ pub struct MuxServerFrontEnd { impl MuxServerFrontEnd { #[cfg_attr(feature = "cargo-clippy", allow(clippy::new_ret_no_self))] - fn new(mux: &Rc, start_listener: bool) -> Result, Error> { + fn new(mux: &Rc, start_listener: bool) -> Result, Error> { let (tx, rx) = mpsc::sync_channel(4); if start_listener { @@ -45,17 +45,17 @@ impl MuxServerFrontEnd { Ok(Rc::new(Self { tx, rx })) } - pub fn try_new(mux: &Rc) -> Result, Error> { + pub fn try_new(mux: &Rc) -> Result, Error> { Self::new(mux, true) } - pub fn new_null(mux: &Rc) -> Result, Error> { + pub fn new_null(mux: &Rc) -> Result, Error> { Self::new(mux, false) } } impl FrontEnd for MuxServerFrontEnd { - fn gui_executor(&self) -> Box { + fn gui_executor(&self) -> Box { Box::new(MuxExecutor { tx: self.tx.clone(), }) @@ -79,7 +79,7 @@ impl FrontEnd for MuxServerFrontEnd { &self, _config: &Arc, _fontconfig: &Rc, - _tab: &Rc, + _tab: &Rc, ) -> Result<(), Error> { // The tab was already added to the mux, so we are a NOP Ok(()) diff --git a/src/frontend/xwindows/x11loop.rs b/src/frontend/xwindows/x11loop.rs index 6fd1b3836..5e8018f78 100644 --- a/src/frontend/xwindows/x11loop.rs +++ b/src/frontend/xwindows/x11loop.rs @@ -10,7 +10,6 @@ use failure::{bail, Error}; use log::debug; use mio::{Events, Poll, PollOpt, Ready, Token}; use mio_extras::channel::{channel, Receiver as GuiReceiver, Sender as GuiSender}; -use portable_pty::PtySize; use promise::{Executor, Future, SpawnFunc}; use std::cell::RefCell; use std::collections::HashMap; @@ -36,7 +35,7 @@ impl Executor for X11GuiExecutor { fn execute(&self, f: SpawnFunc) { self.tx.send(f).expect("X11GuiExecutor execute failed"); } - fn clone_executor(&self) -> Box { + fn clone_executor(&self) -> Box { Box::new(X11GuiExecutor { tx: self.tx.clone(), }) @@ -60,7 +59,7 @@ pub struct X11FrontEnd { event_loop: Rc, } impl X11FrontEnd { - pub fn try_new(mux: &Rc) -> Result, Error> { + pub fn try_new(mux: &Rc) -> Result, Error> { let event_loop = Rc::new(GuiEventLoop::new(mux)?); X11_EVENT_LOOP.with(|f| *f.borrow_mut() = Some(Rc::clone(&event_loop))); Ok(Rc::new(Self { event_loop })) @@ -72,7 +71,7 @@ thread_local! { } impl FrontEnd for X11FrontEnd { - fn gui_executor(&self) -> Box { + fn gui_executor(&self) -> Box { self.event_loop.gui_executor() } @@ -83,7 +82,7 @@ impl FrontEnd for X11FrontEnd { &self, config: &Arc, fontconfig: &Rc, - tab: &Rc, + tab: &Rc, ) -> Result<(), Error> { let window = X11TerminalWindow::new(&self.event_loop, fontconfig, config, tab)?; @@ -128,7 +127,7 @@ impl GuiEventLoop { res } - fn gui_executor(&self) -> Box { + fn gui_executor(&self) -> Box { Box::new(X11GuiExecutor { tx: self.gui_tx.clone(), }) @@ -183,7 +182,7 @@ impl GuiEventLoop { /// Run a function with access to the mutable version of the window with /// the specified window id - pub fn with_window Result<(), Error>>( + pub fn with_window Result<(), Error>>( &self, window_id: WindowId, func: F, @@ -205,17 +204,6 @@ impl GuiEventLoop { Ok(()) } - fn do_spawn_new_window( - &self, - config: &Arc, - fonts: &Rc, - ) -> Result<(), Error> { - let tab = self.mux.default_domain().spawn(PtySize::default(), None)?; - let events = Self::get().expect("to be called on gui thread"); - let window = X11TerminalWindow::new(&events, &fonts, &config, &tab)?; - events.add_window(window) - } - pub fn add_window(&self, window: X11TerminalWindow) -> Result<(), Error> { let window_id = window.window_id(); diff --git a/src/frontend/xwindows/xwin.rs b/src/frontend/xwindows/xwin.rs index c13685846..ee7bd53fc 100644 --- a/src/frontend/xwindows/xwin.rs +++ b/src/frontend/xwindows/xwin.rs @@ -25,7 +25,7 @@ struct Host { } impl HostHelper for Host { - fn with_window Result<(), Error>>( + fn with_window Result<(), Error>>( &self, func: F, ) { @@ -115,7 +115,7 @@ impl X11TerminalWindow { event_loop: &Rc, fonts: &Rc, config: &Arc, - tab: &Rc, + tab: &Rc, ) -> Result { let (physical_rows, physical_cols) = tab.renderer().physical_dimensions(); diff --git a/src/main.rs b/src/main.rs index 0e0090148..4a4c75592 100644 --- a/src/main.rs +++ b/src/main.rs @@ -125,7 +125,7 @@ fn run_terminal_gui(config: Arc, opts: &StartCommand) -> Result< None }; - let domain: Arc = Arc::new(LocalDomain::new(&config)?); + let domain: Arc = Arc::new(LocalDomain::new(&config)?); let mux = Rc::new(mux::Mux::new(&config, &domain)); Mux::set_mux(&mux); @@ -192,7 +192,7 @@ fn main() -> Result<(), Error> { fn spawn_window( mux: &Rc, - gui: &FrontEnd, + gui: &dyn FrontEnd, cmd: Option, fontconfig: &Rc, ) -> Result<(), Error> { diff --git a/src/mux/domain.rs b/src/mux/domain.rs index b2ca46a4a..0b701605c 100644 --- a/src/mux/domain.rs +++ b/src/mux/domain.rs @@ -18,11 +18,11 @@ use std::sync::Arc; pub trait Domain { /// Spawn a new command within this domain - fn spawn(&self, size: PtySize, command: Option) -> Result, Error>; + fn spawn(&self, size: PtySize, command: Option) -> Result, Error>; } pub struct LocalDomain { - pty_system: Box, + pty_system: Box, config: Arc, } @@ -35,7 +35,7 @@ impl LocalDomain { } impl Domain for LocalDomain { - fn spawn(&self, size: PtySize, command: Option) -> Result, Error> { + fn spawn(&self, size: PtySize, command: Option) -> Result, Error> { let cmd = match command { Some(c) => c, None => self.config.build_prog(None)?, @@ -51,7 +51,7 @@ impl Domain for LocalDomain { self.config.hyperlink_rules.clone(), ); - let tab: Rc = Rc::new(LocalTab::new(terminal, child, master)); + let tab: Rc = Rc::new(LocalTab::new(terminal, child, master)); Mux::get().unwrap().add_tab(&tab)?; diff --git a/src/mux/mod.rs b/src/mux/mod.rs index 424fdbada..24dfc86c0 100644 --- a/src/mux/mod.rs +++ b/src/mux/mod.rs @@ -24,13 +24,13 @@ use crate::mux::window::{Window, WindowId}; use domain::Domain; pub struct Mux { - tabs: RefCell>>, + tabs: RefCell>>, windows: RefCell>, config: Arc, - default_domain: Arc, + default_domain: Arc, } -fn read_from_tab_pty(tab_id: TabId, mut reader: Box) { +fn read_from_tab_pty(tab_id: TabId, mut reader: Box) { let executor = gui_executor().expect("gui_executor was not registered yet!?"); const BUFSIZE: usize = 32 * 1024; let mut buf = [0; BUFSIZE]; @@ -73,11 +73,11 @@ fn read_from_tab_pty(tab_id: TabId, mut reader: Box) { /// As such it only really has Host::writer get called. /// The GUI driven flows provide their own impl of TerminalHost. struct Host<'a> { - writer: &'a mut std::io::Write, + writer: &'a mut dyn std::io::Write, } impl<'a> TerminalHost for Host<'a> { - fn writer(&mut self) -> &mut std::io::Write { + fn writer(&mut self) -> &mut dyn std::io::Write { &mut self.writer } @@ -105,7 +105,7 @@ thread_local! { } impl Mux { - pub fn new(config: &Arc, default_domain: &Arc) -> Self { + pub fn new(config: &Arc, default_domain: &Arc) -> Self { Self { tabs: RefCell::new(HashMap::new()), windows: RefCell::new(HashMap::new()), @@ -114,7 +114,7 @@ impl Mux { } } - pub fn default_domain(&self) -> &Arc { + pub fn default_domain(&self) -> &Arc { &self.default_domain } @@ -138,11 +138,11 @@ impl Mux { res } - pub fn get_tab(&self, tab_id: TabId) -> Option> { + pub fn get_tab(&self, tab_id: TabId) -> Option> { self.tabs.borrow().get(&tab_id).map(Rc::clone) } - pub fn add_tab(&self, tab: &Rc) -> Result<(), Error> { + pub fn add_tab(&self, tab: &Rc) -> Result<(), Error> { self.tabs.borrow_mut().insert(tab.tab_id(), Rc::clone(tab)); let reader = tab.reader()?; @@ -175,12 +175,12 @@ impl Mux { })) } - pub fn get_active_tab_for_window(&self, window_id: WindowId) -> Option> { + pub fn get_active_tab_for_window(&self, window_id: WindowId) -> Option> { let window = self.get_window(window_id)?; window.get_active().map(Rc::clone) } - pub fn add_new_window_with_tab(&self, tab: &Rc) -> Result { + pub fn add_new_window_with_tab(&self, tab: &Rc) -> Result { let window = Window::new(tab); let window_id = window.window_id(); self.windows.borrow_mut().insert(window_id, window); @@ -192,7 +192,7 @@ impl Mux { self.tabs.borrow().is_empty() } - pub fn iter_tabs(&self) -> Vec> { + pub fn iter_tabs(&self) -> Vec> { self.tabs .borrow() .iter() diff --git a/src/mux/tab.rs b/src/mux/tab.rs index 1db14a21c..95b2bd8ea 100644 --- a/src/mux/tab.rs +++ b/src/mux/tab.rs @@ -13,11 +13,11 @@ pub fn alloc_tab_id() -> TabId { pub trait Tab { fn tab_id(&self) -> TabId; - fn renderer(&self) -> RefMut; + fn renderer(&self) -> RefMut; fn get_title(&self) -> String; fn send_paste(&self, text: &str) -> Result<(), Error>; - fn reader(&self) -> Result, Error>; - fn writer(&self) -> RefMut; + fn reader(&self) -> Result, Error>; + fn writer(&self) -> RefMut; fn resize( &self, rows: u16, @@ -26,8 +26,8 @@ pub trait Tab { pixel_height: u16, ) -> Result<(), Error>; fn key_down(&self, key: KeyCode, mods: KeyModifiers) -> Result<(), Error>; - fn mouse_event(&self, event: MouseEvent, host: &mut TerminalHost) -> Result<(), Error>; - fn advance_bytes(&self, buf: &[u8], host: &mut TerminalHost); + fn mouse_event(&self, event: MouseEvent, host: &mut dyn TerminalHost) -> Result<(), Error>; + fn advance_bytes(&self, buf: &[u8], host: &mut dyn TerminalHost); fn is_dead(&self) -> bool; fn palette(&self) -> ColorPalette; } diff --git a/src/mux/window.rs b/src/mux/window.rs index af3d7a962..87cd599a0 100644 --- a/src/mux/window.rs +++ b/src/mux/window.rs @@ -6,12 +6,12 @@ pub type WindowId = usize; pub struct Window { id: WindowId, - tabs: Vec>, + tabs: Vec>, active: usize, } impl Window { - pub fn new(tab: &Rc) -> Self { + pub fn new(tab: &Rc) -> Self { Self { id: WIN_ID.fetch_add(1, ::std::sync::atomic::Ordering::Relaxed), tabs: vec![Rc::clone(tab)], @@ -23,7 +23,7 @@ impl Window { self.id } - pub fn push(&mut self, tab: &Rc) { + pub fn push(&mut self, tab: &Rc) { self.tabs.push(Rc::clone(tab)) } @@ -35,7 +35,7 @@ impl Window { self.tabs.len() } - pub fn get_by_idx(&self, idx: usize) -> Option<&Rc> { + pub fn get_by_idx(&self, idx: usize) -> Option<&Rc> { self.tabs.get(idx) } @@ -58,7 +58,7 @@ impl Window { } } - pub fn get_active(&self) -> Option<&Rc> { + pub fn get_active(&self) -> Option<&Rc> { self.get_by_idx(self.active) } @@ -76,7 +76,7 @@ impl Window { .make_all_lines_dirty(); } - pub fn iter(&self) -> impl Iterator> { + pub fn iter(&self) -> impl Iterator> { self.tabs.iter() } } diff --git a/src/opengl/render.rs b/src/opengl/render.rs index 255f2fcb9..586d3df03 100644 --- a/src/opengl/render.rs +++ b/src/opengl/render.rs @@ -653,7 +653,7 @@ impl Renderer { line: &Line, selection: Range, cursor: &CursorPosition, - terminal: &Renderable, + terminal: &dyn Renderable, palette: &ColorPalette, ) -> Result<(), Error> { let (_num_rows, num_cols) = terminal.physical_dimensions(); @@ -933,7 +933,7 @@ impl Renderer { pub fn paint( &mut self, target: &mut glium::Frame, - term: &mut Renderable, + term: &mut dyn Renderable, palette: &ColorPalette, ) -> Result<(), Error> { let background_color = palette.resolve_bg(term::color::ColorAttribute::Default); diff --git a/src/server/listener.rs b/src/server/listener.rs index a1f4366cf..19ab745e7 100644 --- a/src/server/listener.rs +++ b/src/server/listener.rs @@ -17,11 +17,11 @@ use std::thread; pub struct Listener { acceptor: UnixListener, - executor: Box, + executor: Box, } impl Listener { - pub fn new(acceptor: UnixListener, executor: Box) -> Self { + pub fn new(acceptor: UnixListener, executor: Box) -> Self { Self { acceptor, executor } } @@ -44,11 +44,11 @@ impl Listener { pub struct ClientSession { stream: UnixStream, - executor: Box, + executor: Box, } impl ClientSession { - fn new(stream: UnixStream, executor: Box) -> Self { + fn new(stream: UnixStream, executor: Box) -> Self { Self { stream, executor } } @@ -197,7 +197,7 @@ fn safely_create_sock_path(sock_path: &str) -> Result { .map_err(|e| format_err!("Failed to bind to {}: {}", sock_path.display(), e)) } -pub fn spawn_listener(config: &Arc, executor: Box) -> Result<(), Error> { +pub fn spawn_listener(config: &Arc, executor: Box) -> Result<(), Error> { let sock_path = config .mux_server_unix_domain_socket_path .as_ref()