mirror of
https://github.com/uutils/coreutils
synced 2024-12-13 14:52:41 +00:00
Port 'more' to Redox
This commit is contained in:
parent
ec6321a31e
commit
f76b23e3df
3 changed files with 32 additions and 1 deletions
|
@ -66,7 +66,6 @@ fuchsia = [
|
|||
generic = [
|
||||
"arch",
|
||||
"hostname",
|
||||
"more",
|
||||
"nproc",
|
||||
"sync",
|
||||
"tail",
|
||||
|
@ -108,6 +107,7 @@ redox_generic = [
|
|||
"ls",
|
||||
"mkdir",
|
||||
"mktemp",
|
||||
"more",
|
||||
"mv",
|
||||
"nl",
|
||||
"od",
|
||||
|
|
|
@ -12,6 +12,10 @@ path = "more.rs"
|
|||
getopts = "0.2.14"
|
||||
uucore = { path="../uucore" }
|
||||
|
||||
[target.'cfg(target_os = "redox")'.dependencies]
|
||||
redox_termios = "0.1"
|
||||
redox_syscall = "0.1"
|
||||
|
||||
[target.'cfg(all(unix, not(target_os = "fuchsia")))'.dependencies]
|
||||
nix = "0.8.1"
|
||||
|
||||
|
|
|
@ -23,6 +23,11 @@ extern crate nix;
|
|||
#[cfg(all(unix, not(target_os = "fuchsia")))]
|
||||
use nix::sys::termios;
|
||||
|
||||
#[cfg(target_os = "redox")]
|
||||
extern crate redox_termios;
|
||||
#[cfg(target_os = "redox")]
|
||||
extern crate syscall;
|
||||
|
||||
#[derive(Clone, Eq, PartialEq)]
|
||||
pub enum Mode {
|
||||
More,
|
||||
|
@ -96,6 +101,18 @@ fn setup_term() -> usize {
|
|||
0
|
||||
}
|
||||
|
||||
#[cfg(target_os = "redox")]
|
||||
fn setup_term() -> redox_termios::Termios {
|
||||
let mut term = redox_termios::Termios::default();
|
||||
let fd = syscall::dup(0, b"termios").unwrap();
|
||||
syscall::read(fd, &mut term).unwrap();
|
||||
term.c_lflag &= !redox_termios::ICANON;
|
||||
term.c_lflag &= !redox_termios::ECHO;
|
||||
syscall::write(fd, &term).unwrap();
|
||||
let _ = syscall::close(fd);
|
||||
term
|
||||
}
|
||||
|
||||
#[cfg(all(unix, not(target_os = "fuchsia")))]
|
||||
fn reset_term(term: &mut termios::Termios) {
|
||||
term.c_lflag.insert(termios::ICANON);
|
||||
|
@ -107,6 +124,16 @@ fn reset_term(term: &mut termios::Termios) {
|
|||
#[inline(always)]
|
||||
fn reset_term(_: &mut usize) {}
|
||||
|
||||
#[cfg(any(target_os = "redox"))]
|
||||
fn reset_term(term: &mut redox_termios::Termios) {
|
||||
let fd = syscall::dup(0, b"termios").unwrap();
|
||||
syscall::read(fd, term).unwrap();
|
||||
term.c_lflag |= redox_termios::ICANON;
|
||||
term.c_lflag |= redox_termios::ECHO;
|
||||
syscall::write(fd, &term).unwrap();
|
||||
let _ = syscall::close(fd);
|
||||
}
|
||||
|
||||
fn more(matches: getopts::Matches) {
|
||||
let files = matches.free;
|
||||
let mut f = File::open(files.first().unwrap()).unwrap();
|
||||
|
|
Loading…
Reference in a new issue