File descriptor constants

This commit is contained in:
Timothy Warren 2019-08-21 16:51:45 -04:00
parent e3e187d442
commit 2d5db77ce4

View File

@ -6,17 +6,17 @@ use std::io;
use std::io::{BufReader, Error};
use std::io::prelude::*;
// For future reference
// STDIN_FILENO = 0
// STDOUT_FILENO = 1
// STDERR_FILENO = 2
// Redefine the posix constants for rust land
const STDIN_FILENO: i32 = 0;
const STDOUT_FILENO: i32 = 1;
const STDERR_FILENO: i32 = 2;
fn enable_raw_mode() -> Result<(), Error> {
let raw: Result<Termios, NixError> = termios::tcgetattr(0);
let raw: Result<Termios, NixError> = termios::tcgetattr(STDIN_FILENO);
let mut raw = raw.unwrap();
raw.local_flags.remove(termios::LocalFlags::ECHO);
match termios::tcsetattr(0, termios::SetArg::TCSAFLUSH, &raw) {
match termios::tcsetattr(STDIN_FILENO, termios::SetArg::TCSAFLUSH, &raw) {
Ok(()) => Ok(()),
_ => panic!("Failed to set raw mode"),
}