mirror of
https://github.com/uutils/coreutils
synced 2024-12-14 07:12:44 +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 = [
|
generic = [
|
||||||
"arch",
|
"arch",
|
||||||
"hostname",
|
"hostname",
|
||||||
"more",
|
|
||||||
"nproc",
|
"nproc",
|
||||||
"sync",
|
"sync",
|
||||||
"tail",
|
"tail",
|
||||||
|
@ -108,6 +107,7 @@ redox_generic = [
|
||||||
"ls",
|
"ls",
|
||||||
"mkdir",
|
"mkdir",
|
||||||
"mktemp",
|
"mktemp",
|
||||||
|
"more",
|
||||||
"mv",
|
"mv",
|
||||||
"nl",
|
"nl",
|
||||||
"od",
|
"od",
|
||||||
|
|
|
@ -12,6 +12,10 @@ path = "more.rs"
|
||||||
getopts = "0.2.14"
|
getopts = "0.2.14"
|
||||||
uucore = { path="../uucore" }
|
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]
|
[target.'cfg(all(unix, not(target_os = "fuchsia")))'.dependencies]
|
||||||
nix = "0.8.1"
|
nix = "0.8.1"
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,11 @@ extern crate nix;
|
||||||
#[cfg(all(unix, not(target_os = "fuchsia")))]
|
#[cfg(all(unix, not(target_os = "fuchsia")))]
|
||||||
use nix::sys::termios;
|
use nix::sys::termios;
|
||||||
|
|
||||||
|
#[cfg(target_os = "redox")]
|
||||||
|
extern crate redox_termios;
|
||||||
|
#[cfg(target_os = "redox")]
|
||||||
|
extern crate syscall;
|
||||||
|
|
||||||
#[derive(Clone, Eq, PartialEq)]
|
#[derive(Clone, Eq, PartialEq)]
|
||||||
pub enum Mode {
|
pub enum Mode {
|
||||||
More,
|
More,
|
||||||
|
@ -96,6 +101,18 @@ fn setup_term() -> usize {
|
||||||
0
|
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")))]
|
#[cfg(all(unix, not(target_os = "fuchsia")))]
|
||||||
fn reset_term(term: &mut termios::Termios) {
|
fn reset_term(term: &mut termios::Termios) {
|
||||||
term.c_lflag.insert(termios::ICANON);
|
term.c_lflag.insert(termios::ICANON);
|
||||||
|
@ -107,6 +124,16 @@ fn reset_term(term: &mut termios::Termios) {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn reset_term(_: &mut usize) {}
|
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) {
|
fn more(matches: getopts::Matches) {
|
||||||
let files = matches.free;
|
let files = matches.free;
|
||||||
let mut f = File::open(files.first().unwrap()).unwrap();
|
let mut f = File::open(files.first().unwrap()).unwrap();
|
||||||
|
|
Loading…
Reference in a new issue