Commit 45c75071 authored by Michael Bradshaw's avatar Michael Bradshaw

Use stdout to get and set terminal attriutes

parent a69af178
Pipeline #4157 passed with stages
in 3 minutes and 5 seconds
......@@ -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);
......
......@@ -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) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment