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> {
unsafe {
let mut termios = mem::zeroed();
cvt(libc::tcgetattr(1, &mut termios))?;
cvt(libc::tcgetattr(libc::STDOUT_FILENO, &mut termios))?;
Ok(termios)
}
}
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) {