From c471ab68119538f4284ecc7a61095a8127e980ae Mon Sep 17 00:00:00 2001 From: zethra Date: Fri, 26 Jun 2020 03:31:48 -0400 Subject: [PATCH] Added AsRawFd impl for RawTerminal --- src/raw.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/raw.rs b/src/raw.rs index 3e91696..91d8b39 100644 --- a/src/raw.rs +++ b/src/raw.rs @@ -25,8 +25,8 @@ use std::io::{self, Write}; use std::ops; -use sys::Termios; 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. pub const CONTROL_SEQUENCE_TIMEOUT: u64 = 100; @@ -70,6 +70,18 @@ impl Write for RawTerminal { } } +#[cfg(unix)] +mod unix_impl { + use super::*; + use std::os::unix::io::{AsRawFd, RawFd}; + + impl AsRawFd for RawTerminal { + fn as_raw_fd(&self) -> RawFd { + self.output.as_raw_fd() + } + } +} + /// Types which can be converted into "raw mode". /// /// # Why is this type defined on writers and not readers? @@ -120,7 +132,7 @@ impl RawTerminal { #[cfg(test)] mod test { use super::*; - use std::io::{Write, stdout}; + use std::io::{stdout, Write}; #[test] fn test_into_raw_mode() {