File descriptor constants
This commit is contained in:
parent
e3e187d442
commit
2d5db77ce4
12
src/main.rs
12
src/main.rs
@ -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"),
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user