diff options
author | Christian Duerr <chrisduerr@users.noreply.github.com> | 2019-03-30 16:48:36 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-30 16:48:36 +0000 |
commit | cfd025b5289bc305470a96657868c982a2b13bc2 (patch) | |
tree | 093b9105c881e28b909e031c46d2054016b643b3 /src/tty/windows | |
parent | 91aa683bcd060b2ac2f621a388a6448f564d0537 (diff) | |
download | alacritty-cfd025b5289bc305470a96657868c982a2b13bc2.tar.gz alacritty-cfd025b5289bc305470a96657868c982a2b13bc2.zip |
Add rustfmt style guidev0.3.0-rc1
Diffstat (limited to 'src/tty/windows')
-rw-r--r-- | src/tty/windows/conpty.rs | 15 | ||||
-rw-r--r-- | src/tty/windows/mod.rs | 66 | ||||
-rw-r--r-- | src/tty/windows/winpty.rs | 42 |
3 files changed, 31 insertions, 92 deletions
diff --git a/src/tty/windows/conpty.rs b/src/tty/windows/conpty.rs index 6c74df7f..7383118f 100644 --- a/src/tty/windows/conpty.rs +++ b/src/tty/windows/conpty.rs @@ -214,10 +214,7 @@ pub fn new<'a>( cmdline.insert(0, initial_command.program().into()); // Warning, here be borrow hell - let cwd = options - .working_dir - .as_ref() - .map(|dir| canonicalize(dir).unwrap()); + let cwd = options.working_dir.as_ref().map(|dir| canonicalize(dir).unwrap()); let cwd = cwd.as_ref().map(|dir| dir.to_str().unwrap()); // Create the client application, using startup info containing ConPTY info @@ -250,10 +247,7 @@ pub fn new<'a>( let conin = EventedAnonWrite::new(conin); let conout = EventedAnonRead::new(conout); - let agent = Conpty { - handle: pty_handle, - api, - }; + let agent = Conpty { handle: pty_handle, api }; Some(Pty { handle: super::PtyHandle::Conpty(ConptyHandle::new(agent)), @@ -279,10 +273,7 @@ fn coord_from_sizeinfo(sizeinfo: &SizeInfo) -> Option<COORD> { let lines = sizeinfo.lines().0; if cols <= i16::MAX as usize && lines <= i16::MAX as usize { - Some(COORD { - X: sizeinfo.cols().0 as i16, - Y: sizeinfo.lines().0 as i16, - }) + Some(COORD { X: sizeinfo.cols().0 as i16, Y: sizeinfo.lines().0 as i16 }) } else { None } diff --git a/src/tty/windows/mod.rs b/src/tty/windows/mod.rs index 2f5caa93..c87c5257 100644 --- a/src/tty/windows/mod.rs +++ b/src/tty/windows/mod.rs @@ -28,7 +28,7 @@ use crate::cli::Options; use crate::config::Config; use crate::display::OnResize; use crate::term::SizeInfo; -use crate::tty::{EventedReadWrite, EventedPty}; +use crate::tty::{EventedPty, EventedReadWrite}; mod conpty; mod winpty; @@ -44,14 +44,14 @@ pub fn process_should_exit() -> bool { WAIT_OBJECT_0 => { info!("wait_object_0"); true - } + }, // Reached timeout of 0, process has not exited WAIT_TIMEOUT => false, // Error checking process, winpty gave us a bad agent handle? _ => { info!("Bad exit: {}", ::std::io::Error::last_os_error()); true - } + }, } } } @@ -219,7 +219,7 @@ impl<'a> OnResize for PtyHandle<'a> { PtyHandle::Conpty(c) => { let mut handle = c.clone(); handle.on_resize(sizeinfo) - } + }, } } } @@ -240,34 +240,14 @@ impl<'a> EventedReadWrite for Pty<'a> { self.write_token = token.next().unwrap(); if interest.is_readable() { - poll.register( - &self.conout, - self.read_token, - mio::Ready::readable(), - poll_opts, - )? + poll.register(&self.conout, self.read_token, mio::Ready::readable(), poll_opts)? } else { - poll.register( - &self.conout, - self.read_token, - mio::Ready::empty(), - poll_opts, - )? + poll.register(&self.conout, self.read_token, mio::Ready::empty(), poll_opts)? } if interest.is_writable() { - poll.register( - &self.conin, - self.write_token, - mio::Ready::writable(), - poll_opts, - )? + poll.register(&self.conin, self.write_token, mio::Ready::writable(), poll_opts)? } else { - poll.register( - &self.conin, - self.write_token, - mio::Ready::empty(), - poll_opts, - )? + poll.register(&self.conin, self.write_token, mio::Ready::empty(), poll_opts)? } Ok(()) } @@ -280,34 +260,14 @@ impl<'a> EventedReadWrite for Pty<'a> { poll_opts: mio::PollOpt, ) -> io::Result<()> { if interest.is_readable() { - poll.reregister( - &self.conout, - self.read_token, - mio::Ready::readable(), - poll_opts, - )?; + poll.reregister(&self.conout, self.read_token, mio::Ready::readable(), poll_opts)?; } else { - poll.reregister( - &self.conout, - self.read_token, - mio::Ready::empty(), - poll_opts, - )?; + poll.reregister(&self.conout, self.read_token, mio::Ready::empty(), poll_opts)?; } if interest.is_writable() { - poll.reregister( - &self.conin, - self.write_token, - mio::Ready::writable(), - poll_opts, - )?; + poll.reregister(&self.conin, self.write_token, mio::Ready::writable(), poll_opts)?; } else { - poll.reregister( - &self.conin, - self.write_token, - mio::Ready::empty(), - poll_opts, - )?; + poll.reregister(&self.conin, self.write_token, mio::Ready::empty(), poll_opts)?; } Ok(()) } @@ -340,4 +300,4 @@ impl<'a> EventedReadWrite for Pty<'a> { } } -impl<'a> EventedPty for Pty<'a> { } +impl<'a> EventedPty for Pty<'a> {} diff --git a/src/tty/windows/winpty.rs b/src/tty/windows/winpty.rs index 26536eee..10bd9d01 100644 --- a/src/tty/windows/winpty.rs +++ b/src/tty/windows/winpty.rs @@ -14,29 +14,29 @@ use super::{Pty, HANDLE}; -use std::io; use std::fs::OpenOptions; -use std::os::windows::io::{FromRawHandle, IntoRawHandle}; +use std::io; use std::os::windows::fs::OpenOptionsExt; +use std::os::windows::io::{FromRawHandle, IntoRawHandle}; use std::sync::Arc; use std::u16; use dunce::canonicalize; use mio_named_pipes::NamedPipe; use winapi::um::winbase::FILE_FLAG_OVERLAPPED; -use winpty::{ConfigFlags, MouseMode, SpawnConfig, SpawnFlags, Winpty}; use winpty::Config as WinptyConfig; +use winpty::{ConfigFlags, MouseMode, SpawnConfig, SpawnFlags, Winpty}; +use crate::cli::Options; use crate::config::{Config, Shell}; use crate::display::OnResize; -use crate::cli::Options; use crate::term::SizeInfo; // We store a raw pointer because we need mutable access to call // on_resize from a separate thread. Winpty internally uses a mutex // so this is safe, despite outwards appearance. pub struct Agent<'a> { - winpty: *mut Winpty<'a> + winpty: *mut Winpty<'a>, } /// Handle can be cloned freely and moved between threads. @@ -48,9 +48,7 @@ unsafe impl<'a> Sync for Agent<'a> {} impl<'a> Agent<'a> { pub fn new(winpty: Winpty<'a>) -> Self { - Self { - winpty: Box::into_raw(Box::new(winpty)) - } + Self { winpty: Box::into_raw(Box::new(winpty)) } } /// Get immutable access to Winpty. @@ -68,11 +66,12 @@ impl<'a> Agent<'a> { impl<'a> Drop for Agent<'a> { fn drop(&mut self) { - unsafe { Box::from_raw(self.winpty); } + unsafe { + Box::from_raw(self.winpty); + } } } - /// How long the winpty agent should wait for any RPC request /// This is a placeholder value until we see how often long responses happen const AGENT_TIMEOUT: u32 = 10000; @@ -112,30 +111,19 @@ pub fn new<'a>( Some(&cmdline.join(" ")), cwd, None, // Env - ).unwrap(); + ) + .unwrap(); let default_opts = &mut OpenOptions::new(); - default_opts - .share_mode(0) - .custom_flags(FILE_FLAG_OVERLAPPED); + default_opts.share_mode(0).custom_flags(FILE_FLAG_OVERLAPPED); let (conout_pipe, conin_pipe); unsafe { conout_pipe = NamedPipe::from_raw_handle( - default_opts - .clone() - .read(true) - .open(conout) - .unwrap() - .into_raw_handle(), + default_opts.clone().read(true).open(conout).unwrap().into_raw_handle(), ); conin_pipe = NamedPipe::from_raw_handle( - default_opts - .clone() - .write(true) - .open(conin) - .unwrap() - .into_raw_handle(), + default_opts.clone().write(true).open(conin).unwrap().into_raw_handle(), ); }; @@ -166,7 +154,7 @@ pub fn new<'a>( conout: super::EventedReadablePipe::Named(conout_pipe), conin: super::EventedWritablePipe::Named(conin_pipe), read_token: 0.into(), - write_token: 0.into() + write_token: 0.into(), } } |