Merge branch 'raw' into 'master'

Use stdout to get and set terminal attributes

See merge request redox-os/termion!161
This commit is contained in:
Jeremy Soller 2019-06-12 22:59:41 +00:00
commit c70e6074f4
2 changed files with 4 additions and 4 deletions

View File

@ -5,7 +5,7 @@ use super::{cvt, syscall, Termios};
pub fn get_terminal_attr() -> io::Result<Termios> {
let mut termios = Termios::default();
let fd = cvt(syscall::dup(0, b"termios"))?;
let fd = cvt(syscall::dup(1, b"termios"))?;
let res = cvt(syscall::read(fd, &mut termios));
let _ = syscall::close(fd);
@ -17,7 +17,7 @@ pub fn get_terminal_attr() -> io::Result<Termios> {
}
pub fn set_terminal_attr(termios: &Termios) -> io::Result<()> {
let fd = cvt(syscall::dup(0, b"termios"))?;
let fd = cvt(syscall::dup(1, b"termios"))?;
let res = cvt(syscall::write(fd, termios));
let _ = syscall::close(fd);

View File

@ -9,7 +9,7 @@ pub fn get_terminal_attr() -> io::Result<Termios> {
}
unsafe {
let mut termios = mem::zeroed();
cvt(tcgetattr(0, &mut termios))?;
cvt(tcgetattr(1, &mut termios))?;
Ok(termios)
}
}
@ -18,7 +18,7 @@ pub fn set_terminal_attr(termios: &Termios) -> io::Result<()> {
extern "C" {
pub fn tcsetattr(fd: c_int, opt: c_int, termptr: *const Termios) -> c_int;
}
cvt(unsafe { tcsetattr(0, 0, termios) }).and(Ok(()))
cvt(unsafe { tcsetattr(1, 0, termios) }).and(Ok(()))
}
pub fn raw_terminal_attr(termios: &mut Termios) {