shorthand next and prev and page number roll over
This commit is contained in:
parent
15fabbdb1a
commit
79fc190013
1 changed files with 18 additions and 11 deletions
|
|
@ -572,15 +572,14 @@ fn create_config(
|
||||||
print_flag_page(&pages[usize::from(page)], page).context("failed to print flag page")?;
|
print_flag_page(&pages[usize::from(page)], page).context("failed to print flag page")?;
|
||||||
|
|
||||||
let mut opts: Vec<&str> = <Preset as VariantNames>::VARIANTS.into();
|
let mut opts: Vec<&str> = <Preset as VariantNames>::VARIANTS.into();
|
||||||
if page < num_pages.checked_sub(1).unwrap() {
|
opts.push("next");
|
||||||
opts.push("next");
|
opts.push("n");
|
||||||
}
|
opts.push("prev");
|
||||||
if page > 0 {
|
opts.push("p");
|
||||||
opts.push("prev");
|
|
||||||
}
|
|
||||||
writeln!(
|
writeln!(
|
||||||
io::stdout(),
|
io::stdout(),
|
||||||
"Enter 'next' to go to the next page and 'prev' to go to the previous page."
|
"Enter '[n]ext' to go to the next page and '[p]rev' to go to the previous page."
|
||||||
)
|
)
|
||||||
.context("failed to write message to stdout")?;
|
.context("failed to write message to stdout")?;
|
||||||
let selection = literal_input(
|
let selection = literal_input(
|
||||||
|
|
@ -595,10 +594,18 @@ fn create_config(
|
||||||
)
|
)
|
||||||
.context("failed to ask for choice input")
|
.context("failed to ask for choice input")
|
||||||
.context("failed to select preset")?;
|
.context("failed to select preset")?;
|
||||||
if selection == "next" {
|
if selection == "next" || selection == "n" {
|
||||||
page = page.checked_add(1).unwrap();
|
if page == num_pages.checked_sub(1).unwrap() {
|
||||||
} else if selection == "prev" {
|
page = 0
|
||||||
page = page.checked_sub(1).unwrap();
|
} else {
|
||||||
|
page = page.checked_add(1).unwrap();
|
||||||
|
}
|
||||||
|
} else if selection == "prev" || selection == "p" {
|
||||||
|
if page == 0 {
|
||||||
|
page = num_pages.checked_sub(1).unwrap();
|
||||||
|
} else {
|
||||||
|
page = page.checked_sub(1).unwrap();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
preset = selection.parse().expect("selected preset should be valid");
|
preset = selection.parse().expect("selected preset should be valid");
|
||||||
debug!(?preset, "selected preset");
|
debug!(?preset, "selected preset");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue