Merge branch 'master' into 'master'

Added AsRawFd impl for RawTerminal

See merge request redox-os/termion!170
This commit is contained in:
Jeremy Soller 2020-06-26 12:20:27 +00:00
commit 189222555e
1 changed files with 14 additions and 2 deletions

View File

@ -25,8 +25,8 @@
use std::io::{self, Write}; use std::io::{self, Write};
use std::ops; use std::ops;
use sys::Termios;
use sys::attr::{get_terminal_attr, raw_terminal_attr, set_terminal_attr}; use sys::attr::{get_terminal_attr, raw_terminal_attr, set_terminal_attr};
use sys::Termios;
/// The timeout of an escape code control sequence, in milliseconds. /// The timeout of an escape code control sequence, in milliseconds.
pub const CONTROL_SEQUENCE_TIMEOUT: u64 = 100; pub const CONTROL_SEQUENCE_TIMEOUT: u64 = 100;
@ -70,6 +70,18 @@ impl<W: Write> Write for RawTerminal<W> {
} }
} }
#[cfg(unix)]
mod unix_impl {
use super::*;
use std::os::unix::io::{AsRawFd, RawFd};
impl<W: Write + AsRawFd> AsRawFd for RawTerminal<W> {
fn as_raw_fd(&self) -> RawFd {
self.output.as_raw_fd()
}
}
}
/// Types which can be converted into "raw mode". /// Types which can be converted into "raw mode".
/// ///
/// # Why is this type defined on writers and not readers? /// # Why is this type defined on writers and not readers?
@ -120,7 +132,7 @@ impl<W: Write> RawTerminal<W> {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use super::*; use super::*;
use std::io::{Write, stdout}; use std::io::{stdout, Write};
#[test] #[test]
fn test_into_raw_mode() { fn test_into_raw_mode() {