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::{BufReader, Error};
|
||||||
use std::io::prelude::*;
|
use std::io::prelude::*;
|
||||||
|
|
||||||
// For future reference
|
// Redefine the posix constants for rust land
|
||||||
// STDIN_FILENO = 0
|
const STDIN_FILENO: i32 = 0;
|
||||||
// STDOUT_FILENO = 1
|
const STDOUT_FILENO: i32 = 1;
|
||||||
// STDERR_FILENO = 2
|
const STDERR_FILENO: i32 = 2;
|
||||||
|
|
||||||
fn enable_raw_mode() -> Result<(), Error> {
|
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();
|
let mut raw = raw.unwrap();
|
||||||
raw.local_flags.remove(termios::LocalFlags::ECHO);
|
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(()),
|
Ok(()) => Ok(()),
|
||||||
_ => panic!("Failed to set raw mode"),
|
_ => panic!("Failed to set raw mode"),
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user