mirror of
https://github.com/TECHNOFAB11/pay-respects.git
synced 2025-12-13 15:00:15 +01:00
fix: style
This commit is contained in:
parent
1ddfbef7e7
commit
838eac5852
2 changed files with 23 additions and 8 deletions
|
|
@ -8,7 +8,6 @@ pub fn highlight_difference(
|
|||
shell: &str,
|
||||
suggested_command: &str,
|
||||
last_command: &str,
|
||||
difference_only: bool,
|
||||
) -> Option<String> {
|
||||
// let replaced_newline = suggested_command.replace('\n', r" {{newline}} ");
|
||||
let mut split_suggested_command = split_command(suggested_command);
|
||||
|
|
@ -43,9 +42,7 @@ pub fn highlight_difference(
|
|||
}
|
||||
for old in &old_entries {
|
||||
if old == entry {
|
||||
if !difference_only {
|
||||
*entry = entry.blue().to_string();
|
||||
}
|
||||
continue 'next;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ pub fn select_candidate(data: &mut Data) {
|
|||
let candidates = &data.candidates;
|
||||
if candidates.len() == 1 {
|
||||
let suggestion = candidates[0].to_string();
|
||||
let highlighted = highlight_difference(&data.shell, &suggestion, &data.command, false).unwrap();
|
||||
let highlighted = highlight_difference(&data.shell, &suggestion, &data.command).unwrap();
|
||||
eprintln!("{}\n", highlighted);
|
||||
let confirm = format!("[{}]", t!("confirm-yes")).green();
|
||||
eprintln!("{}: {} {}", t!("confirm"), confirm, "[Ctrl+C]".red());
|
||||
|
|
@ -70,7 +70,7 @@ pub fn select_candidate(data: &mut Data) {
|
|||
} else {
|
||||
let mut highlight_candidates = candidates
|
||||
.iter()
|
||||
.map(|candidate| highlight_difference(&data.shell, candidate, &data.command, true).unwrap())
|
||||
.map(|candidate| highlight_difference(&data.shell, candidate, &data.command).unwrap())
|
||||
.collect::<Vec<String>>();
|
||||
|
||||
for candidate in highlight_candidates.iter_mut() {
|
||||
|
|
@ -86,7 +86,25 @@ pub fn select_candidate(data: &mut Data) {
|
|||
*candidate = formated;
|
||||
}
|
||||
|
||||
let ans = Select::new("Select a suggestion:", highlight_candidates.clone())
|
||||
let style = ui::Styled::default();
|
||||
let render_config = ui::RenderConfig::default()
|
||||
.with_prompt_prefix(style)
|
||||
.with_answered_prompt_prefix(style)
|
||||
.with_highlighted_option_prefix(style);
|
||||
|
||||
let msg = format!("{} suggestions found:", candidates.len()).bold().blue();
|
||||
let hint = format!("{} {} {}",
|
||||
"[↑/↓]".blue(),
|
||||
t!("confirm-yes").green(),
|
||||
"[Ctrl+C]".red());
|
||||
eprintln!("{}", msg);
|
||||
eprintln!("{}", hint);
|
||||
|
||||
let ans = Select::new("\n", highlight_candidates.clone())
|
||||
.with_page_size(1)
|
||||
.without_filtering()
|
||||
.without_help_message()
|
||||
.with_render_config(render_config)
|
||||
.prompt()
|
||||
.unwrap();
|
||||
let pos = highlight_candidates.iter().position(|x| x == &ans).unwrap();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue