mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-08-04 06:57:47 +00:00
refactor/more ~ polish spelling (comments, names, and exceptions)
This commit is contained in:
parent
57e342d2b2
commit
00c02505a1
1 changed files with 16 additions and 20 deletions
|
@ -5,7 +5,7 @@
|
||||||
// * For the full copyright and license information, please view the LICENSE file
|
// * For the full copyright and license information, please view the LICENSE file
|
||||||
// * that was distributed with this source code.
|
// * that was distributed with this source code.
|
||||||
|
|
||||||
// spell-checker:ignore (ToDO) lflag ICANON tcgetattr tcsetattr TCSADRAIN
|
// spell-checker:ignore (methods) isnt
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate uucore;
|
extern crate uucore;
|
||||||
|
@ -100,7 +100,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
.long(options::LINES)
|
.long(options::LINES)
|
||||||
.value_name("number")
|
.value_name("number")
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.help("The number of lines per screenful"),
|
.help("The number of lines per screen full"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name(options::NUMBER)
|
Arg::with_name(options::NUMBER)
|
||||||
|
@ -137,28 +137,25 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
.get_matches_from(args);
|
.get_matches_from(args);
|
||||||
|
|
||||||
let mut buff = String::new();
|
let mut buff = String::new();
|
||||||
if let Some(filenames) = matches.values_of(options::FILES) {
|
if let Some(files) = matches.values_of(options::FILES) {
|
||||||
let mut stdout = setup_term();
|
let mut stdout = setup_term();
|
||||||
let length = filenames.len();
|
let length = files.len();
|
||||||
for (idx, fname) in filenames.enumerate() {
|
for (idx, file) in files.enumerate() {
|
||||||
let fname = Path::new(fname);
|
let file = Path::new(file);
|
||||||
if fname.is_dir() {
|
if file.is_dir() {
|
||||||
terminal::disable_raw_mode().unwrap();
|
terminal::disable_raw_mode().unwrap();
|
||||||
show_usage_error!("'{}' is a directory.", fname.display());
|
show_usage_error!("'{}' is a directory.", file.display());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if !fname.exists() {
|
if !file.exists() {
|
||||||
terminal::disable_raw_mode().unwrap();
|
terminal::disable_raw_mode().unwrap();
|
||||||
show_error!(
|
show_error!("cannot open {}: No such file or directory", file.display());
|
||||||
"cannot open {}: No such file or directory",
|
|
||||||
fname.display()
|
|
||||||
);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if length > 1 {
|
if length > 1 {
|
||||||
buff.push_str(&MULTI_FILE_TOP_PROMPT.replace("{}", fname.to_str().unwrap()));
|
buff.push_str(&MULTI_FILE_TOP_PROMPT.replace("{}", file.to_str().unwrap()));
|
||||||
}
|
}
|
||||||
let mut reader = BufReader::new(File::open(fname).unwrap());
|
let mut reader = BufReader::new(File::open(file).unwrap());
|
||||||
reader.read_to_string(&mut buff).unwrap();
|
reader.read_to_string(&mut buff).unwrap();
|
||||||
let is_last = idx + 1 == length;
|
let is_last = idx + 1 == length;
|
||||||
more(&buff, &mut stdout, is_last);
|
more(&buff, &mut stdout, is_last);
|
||||||
|
@ -254,7 +251,6 @@ fn more(buff: &str, mut stdout: &mut Stdout, is_last: bool) {
|
||||||
modifiers: KeyModifiers::NONE,
|
modifiers: KeyModifiers::NONE,
|
||||||
}) => {
|
}) => {
|
||||||
upper_mark = upper_mark.saturating_add(rows.saturating_sub(1));
|
upper_mark = upper_mark.saturating_add(rows.saturating_sub(1));
|
||||||
|
|
||||||
}
|
}
|
||||||
Event::Key(KeyEvent {
|
Event::Key(KeyEvent {
|
||||||
code: KeyCode::Up,
|
code: KeyCode::Up,
|
||||||
|
@ -275,7 +271,7 @@ fn more(buff: &str, mut stdout: &mut Stdout, is_last: bool) {
|
||||||
|
|
||||||
if lines_left == 0 {
|
if lines_left == 0 {
|
||||||
if to_be_done || is_last {
|
if to_be_done || is_last {
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
to_be_done = true;
|
to_be_done = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue