Skip to content
Snippets Groups Projects
Commit 4fafb44f authored by Luqman Aden's avatar Luqman Aden
Browse files

Use constants from libc instead of magic numbers.

parent 234af89f
No related branches found
No related tags found
1 merge request!181Use libc to be more resilient and compatible.
......@@ -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) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment