Use constants from libc instead of magic numbers.

This commit is contained in:
Luqman Aden 2021-09-27 07:43:32 -07:00
parent 234af89ffb
commit 4fafb44f89
1 changed files with 2 additions and 2 deletions

View File

@ -5,13 +5,13 @@ use super::{cvt, Termios};
pub fn get_terminal_attr() -> io::Result<Termios> { pub fn get_terminal_attr() -> io::Result<Termios> {
unsafe { unsafe {
let mut termios = mem::zeroed(); let mut termios = mem::zeroed();
cvt(libc::tcgetattr(1, &mut termios))?; cvt(libc::tcgetattr(libc::STDOUT_FILENO, &mut termios))?;
Ok(termios) Ok(termios)
} }
} }
pub fn set_terminal_attr(termios: &Termios) -> io::Result<()> { pub fn set_terminal_attr(termios: &Termios) -> io::Result<()> {
cvt(unsafe { libc::tcsetattr(1, 0, termios) }).and(Ok(())) cvt(unsafe { libc::tcsetattr(libc::STDOUT_FILENO, libc::TCSANOW, termios) }).and(Ok(()))
} }
pub fn raw_terminal_attr(termios: &mut Termios) { pub fn raw_terminal_attr(termios: &mut Termios) {