1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-29 12:07:46 +00:00

fix behavior of -c and -p commands

This commit is contained in:
Ideflop 2023-05-20 08:56:50 +02:00
parent 1a12ffaa79
commit 2d1a9f6709
2 changed files with 12 additions and 7 deletions

View file

@ -333,9 +333,14 @@ fn more(
_ => continue, _ => continue,
} }
if options.clean_print { if options.print_over {
execute!(std::io::stdout(), Clear(ClearType::Purge), MoveTo(0, 0)).unwrap(); execute!(
} else if options.print_over { std::io::stdout(),
MoveTo(0, 0),
Clear(ClearType::FromCursorDown)
)
.unwrap();
} else if options.clean_print {
execute!(std::io::stdout(), Clear(ClearType::All), MoveTo(0, 0)).unwrap(); execute!(std::io::stdout(), Clear(ClearType::All), MoveTo(0, 0)).unwrap();
} }
pager.draw(stdout, wrong_key); pager.draw(stdout, wrong_key);

View file

@ -13,11 +13,11 @@ fn test_more_no_arg() {
#[test] #[test]
fn test_valid_arg() { fn test_valid_arg() {
if std::io::stdout().is_terminal() { if std::io::stdout().is_terminal() {
new_ucmd!().arg("-c").succeeds().code_is(0); new_ucmd!().arg("-c").succeeds();
new_ucmd!().arg("--print-over").succeeds().code_is(0); new_ucmd!().arg("--print-over").succeeds();
new_ucmd!().arg("-p").succeeds().code_is(0); new_ucmd!().arg("-p").succeeds();
new_ucmd!().arg("--clean-print").succeeds().code_is(0); new_ucmd!().arg("--clean-print").succeeds();
} else { } else {
} }
} }