Added AsRawFd impl for RawTerminal
This commit is contained in:
parent
a448f510f0
commit
c471ab6811
16
src/raw.rs
16
src/raw.rs
|
@ -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() {
|
||||||
|
|
Loading…
Reference in New Issue