mirror of
https://github.com/zellij-org/zellij.git
synced 2024-11-23 19:10:09 +03:00
Fixing a load of clippy lints in status-bar
This commit is contained in:
parent
b6f945da35
commit
6316763b0e
@ -70,90 +70,64 @@ fn unselected_mode_shortcut(letter: char, text: &str) -> LinePart {
|
||||
.fg(BLACK)
|
||||
.on(BRIGHT_GRAY)
|
||||
.bold()
|
||||
.paint(format!(" <"));
|
||||
.paint(" <");
|
||||
let char_shortcut = Style::new()
|
||||
.bold()
|
||||
.fg(RED)
|
||||
.on(BRIGHT_GRAY)
|
||||
.bold()
|
||||
.paint(format!("{}", letter));
|
||||
.paint(letter.to_string());
|
||||
let char_right_separator = Style::new()
|
||||
.bold()
|
||||
.fg(BLACK)
|
||||
.on(BRIGHT_GRAY)
|
||||
.bold()
|
||||
.paint(format!(">"));
|
||||
let styled_text = Style::new()
|
||||
.fg(BLACK)
|
||||
.on(BRIGHT_GRAY)
|
||||
.bold()
|
||||
.paint(format!("{} ", text));
|
||||
.paint(">");
|
||||
let styled_text = Style::new().fg(BLACK).on(BRIGHT_GRAY).bold().paint(text);
|
||||
let suffix_separator = Style::new().fg(BRIGHT_GRAY).on(GRAY).paint(ARROW_SEPARATOR);
|
||||
LinePart {
|
||||
part: format!(
|
||||
"{}",
|
||||
ANSIStrings(&[
|
||||
part: ANSIStrings(&[
|
||||
prefix_separator,
|
||||
char_left_separator,
|
||||
char_shortcut,
|
||||
char_right_separator,
|
||||
styled_text,
|
||||
suffix_separator
|
||||
suffix_separator,
|
||||
])
|
||||
),
|
||||
.to_string(),
|
||||
len: text.chars().count() + 6, // 2 for the arrows, 3 for the char separators, 1 for the character
|
||||
}
|
||||
}
|
||||
|
||||
fn selected_mode_shortcut(letter: char, text: &str) -> LinePart {
|
||||
let prefix_separator = Style::new().fg(GRAY).on(GREEN).paint(ARROW_SEPARATOR);
|
||||
let char_left_separator = Style::new()
|
||||
.bold()
|
||||
.fg(BLACK)
|
||||
.on(GREEN)
|
||||
.bold()
|
||||
.paint(format!(" <"));
|
||||
let char_left_separator = Style::new().bold().fg(BLACK).on(GREEN).bold().paint(" <");
|
||||
let char_shortcut = Style::new()
|
||||
.bold()
|
||||
.fg(RED)
|
||||
.on(GREEN)
|
||||
.bold()
|
||||
.paint(format!("{}", letter));
|
||||
let char_right_separator = Style::new()
|
||||
.bold()
|
||||
.fg(BLACK)
|
||||
.on(GREEN)
|
||||
.bold()
|
||||
.paint(format!(">"));
|
||||
let styled_text = Style::new()
|
||||
.fg(BLACK)
|
||||
.on(GREEN)
|
||||
.bold()
|
||||
.paint(format!("{} ", text));
|
||||
.paint(letter.to_string());
|
||||
let char_right_separator = Style::new().bold().fg(BLACK).on(GREEN).bold().paint(">");
|
||||
let styled_text = Style::new().fg(BLACK).on(GREEN).bold().paint(text);
|
||||
let suffix_separator = Style::new().fg(GREEN).on(GRAY).paint(ARROW_SEPARATOR);
|
||||
LinePart {
|
||||
part: format!(
|
||||
"{}",
|
||||
ANSIStrings(&[
|
||||
part: ANSIStrings(&[
|
||||
prefix_separator,
|
||||
char_left_separator,
|
||||
char_shortcut,
|
||||
char_right_separator,
|
||||
styled_text,
|
||||
suffix_separator
|
||||
suffix_separator,
|
||||
])
|
||||
),
|
||||
.to_string(),
|
||||
len: text.chars().count() + 6, // 2 for the arrows, 3 for the char separators, 1 for the character
|
||||
}
|
||||
}
|
||||
|
||||
fn disabled_mode_shortcut(text: &str) -> LinePart {
|
||||
let prefix_separator = Style::new().fg(GRAY).on(BRIGHT_GRAY).paint(ARROW_SEPARATOR);
|
||||
let styled_text = Style::new()
|
||||
.fg(GRAY)
|
||||
.on(BRIGHT_GRAY)
|
||||
.dimmed()
|
||||
.paint(format!("{} ", text));
|
||||
let styled_text = Style::new().fg(GRAY).on(BRIGHT_GRAY).dimmed().paint(text);
|
||||
let suffix_separator = Style::new().fg(BRIGHT_GRAY).on(GRAY).paint(ARROW_SEPARATOR);
|
||||
LinePart {
|
||||
part: format!("{}{}{}", prefix_separator, styled_text, suffix_separator),
|
||||
@ -162,7 +136,7 @@ fn disabled_mode_shortcut(text: &str) -> LinePart {
|
||||
}
|
||||
|
||||
fn selected_mode_shortcut_single_letter(letter: char) -> LinePart {
|
||||
let char_shortcut_text = format!(" {} ", letter);
|
||||
let char_shortcut_text = letter.to_string();
|
||||
let len = char_shortcut_text.chars().count() + 4; // 2 for the arrows, 2 for the padding
|
||||
let prefix_separator = Style::new().fg(GRAY).on(GREEN).paint(ARROW_SEPARATOR);
|
||||
let char_shortcut = Style::new()
|
||||
@ -173,16 +147,13 @@ fn selected_mode_shortcut_single_letter(letter: char) -> LinePart {
|
||||
.paint(char_shortcut_text);
|
||||
let suffix_separator = Style::new().fg(GREEN).on(GRAY).paint(ARROW_SEPARATOR);
|
||||
LinePart {
|
||||
part: format!(
|
||||
"{}",
|
||||
ANSIStrings(&[prefix_separator, char_shortcut, suffix_separator])
|
||||
),
|
||||
part: ANSIStrings(&[prefix_separator, char_shortcut, suffix_separator]).to_string(),
|
||||
len,
|
||||
}
|
||||
}
|
||||
|
||||
fn unselected_mode_shortcut_single_letter(letter: char) -> LinePart {
|
||||
let char_shortcut_text = format!(" {} ", letter);
|
||||
let char_shortcut_text = letter.to_string();
|
||||
let len = char_shortcut_text.chars().count() + 4; // 2 for the arrows, 2 for the padding
|
||||
let prefix_separator = Style::new().fg(GRAY).on(BRIGHT_GRAY).paint(ARROW_SEPARATOR);
|
||||
let char_shortcut = Style::new()
|
||||
@ -193,10 +164,7 @@ fn unselected_mode_shortcut_single_letter(letter: char) -> LinePart {
|
||||
.paint(char_shortcut_text);
|
||||
let suffix_separator = Style::new().fg(BRIGHT_GRAY).on(GRAY).paint(ARROW_SEPARATOR);
|
||||
LinePart {
|
||||
part: format!(
|
||||
"{}",
|
||||
ANSIStrings(&[prefix_separator, char_shortcut, suffix_separator])
|
||||
),
|
||||
part: ANSIStrings(&[prefix_separator, char_shortcut, suffix_separator]).to_string(),
|
||||
len,
|
||||
}
|
||||
}
|
||||
@ -225,12 +193,8 @@ fn shortened_ctrl_key(key: &CtrlKeyShortcut) -> LinePart {
|
||||
_ => shortened_text,
|
||||
};
|
||||
match key.mode {
|
||||
CtrlKeyMode::Unselected => {
|
||||
unselected_mode_shortcut(letter_shortcut, &format!("{}", shortened_text))
|
||||
}
|
||||
CtrlKeyMode::Selected => {
|
||||
selected_mode_shortcut(letter_shortcut, &format!("{}", shortened_text))
|
||||
}
|
||||
CtrlKeyMode::Unselected => unselected_mode_shortcut(letter_shortcut, &shortened_text),
|
||||
CtrlKeyMode::Selected => selected_mode_shortcut(letter_shortcut, &shortened_text),
|
||||
CtrlKeyMode::Disabled => {
|
||||
disabled_mode_shortcut(&format!(" <{}>{}", letter_shortcut, shortened_text))
|
||||
}
|
||||
@ -282,7 +246,7 @@ pub fn superkey() -> LinePart {
|
||||
let prefix_text = " Ctrl + ";
|
||||
let prefix = Style::new().fg(WHITE).on(GRAY).bold().paint(prefix_text);
|
||||
LinePart {
|
||||
part: format!("{}", prefix),
|
||||
part: prefix.to_string(),
|
||||
len: prefix_text.chars().count(),
|
||||
}
|
||||
}
|
||||
@ -291,7 +255,7 @@ pub fn ctrl_keys(help: &ModeInfo, max_len: usize) -> LinePart {
|
||||
match &help.mode {
|
||||
InputMode::Locked => key_indicators(
|
||||
max_len,
|
||||
&vec![
|
||||
&[
|
||||
CtrlKeyShortcut::new(CtrlKeyMode::Selected, CtrlKeyAction::Lock),
|
||||
CtrlKeyShortcut::new(CtrlKeyMode::Disabled, CtrlKeyAction::Pane),
|
||||
CtrlKeyShortcut::new(CtrlKeyMode::Disabled, CtrlKeyAction::Tab),
|
||||
@ -302,7 +266,7 @@ pub fn ctrl_keys(help: &ModeInfo, max_len: usize) -> LinePart {
|
||||
),
|
||||
InputMode::Resize => key_indicators(
|
||||
max_len,
|
||||
&vec![
|
||||
&[
|
||||
CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Lock),
|
||||
CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Pane),
|
||||
CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Tab),
|
||||
@ -313,7 +277,7 @@ pub fn ctrl_keys(help: &ModeInfo, max_len: usize) -> LinePart {
|
||||
),
|
||||
InputMode::Pane => key_indicators(
|
||||
max_len,
|
||||
&vec![
|
||||
&[
|
||||
CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Lock),
|
||||
CtrlKeyShortcut::new(CtrlKeyMode::Selected, CtrlKeyAction::Pane),
|
||||
CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Tab),
|
||||
@ -324,7 +288,7 @@ pub fn ctrl_keys(help: &ModeInfo, max_len: usize) -> LinePart {
|
||||
),
|
||||
InputMode::Tab | InputMode::RenameTab => key_indicators(
|
||||
max_len,
|
||||
&vec![
|
||||
&[
|
||||
CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Lock),
|
||||
CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Pane),
|
||||
CtrlKeyShortcut::new(CtrlKeyMode::Selected, CtrlKeyAction::Tab),
|
||||
@ -335,7 +299,7 @@ pub fn ctrl_keys(help: &ModeInfo, max_len: usize) -> LinePart {
|
||||
),
|
||||
InputMode::Scroll => key_indicators(
|
||||
max_len,
|
||||
&vec![
|
||||
&[
|
||||
CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Lock),
|
||||
CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Pane),
|
||||
CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Tab),
|
||||
@ -346,7 +310,7 @@ pub fn ctrl_keys(help: &ModeInfo, max_len: usize) -> LinePart {
|
||||
),
|
||||
InputMode::Normal => key_indicators(
|
||||
max_len,
|
||||
&vec![
|
||||
&[
|
||||
CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Lock),
|
||||
CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Pane),
|
||||
CtrlKeyShortcut::new(CtrlKeyMode::Unselected, CtrlKeyAction::Tab),
|
||||
|
@ -108,7 +108,7 @@ fn full_shortcut_list(help: &ModeInfo) -> LinePart {
|
||||
line_part.len += shortcut.len;
|
||||
line_part.part = format!("{}{}", line_part.part, shortcut,);
|
||||
}
|
||||
let select_pane_shortcut = select_pane_shortcut(help.keybinds.len() == 0);
|
||||
let select_pane_shortcut = select_pane_shortcut(help.keybinds.is_empty());
|
||||
line_part.len += select_pane_shortcut.len;
|
||||
line_part.part = format!("{}{}", line_part.part, select_pane_shortcut,);
|
||||
line_part
|
||||
@ -127,7 +127,7 @@ fn shortened_shortcut_list(help: &ModeInfo) -> LinePart {
|
||||
line_part.len += shortcut.len;
|
||||
line_part.part = format!("{}{}", line_part.part, shortcut,);
|
||||
}
|
||||
let select_pane_shortcut = select_pane_shortcut(help.keybinds.len() == 0);
|
||||
let select_pane_shortcut = select_pane_shortcut(help.keybinds.is_empty());
|
||||
line_part.len += select_pane_shortcut.len;
|
||||
line_part.part = format!("{}{}", line_part.part, select_pane_shortcut,);
|
||||
line_part
|
||||
@ -159,7 +159,7 @@ fn best_effort_shortcut_list(help: &ModeInfo, max_len: usize) -> LinePart {
|
||||
line_part.len += shortcut.len;
|
||||
line_part.part = format!("{}{}", line_part.part, shortcut,);
|
||||
}
|
||||
let select_pane_shortcut = select_pane_shortcut(help.keybinds.len() == 0);
|
||||
let select_pane_shortcut = select_pane_shortcut(help.keybinds.is_empty());
|
||||
if line_part.len + select_pane_shortcut.len <= max_len {
|
||||
line_part.len += select_pane_shortcut.len;
|
||||
line_part.part = format!("{}{}", line_part.part, select_pane_shortcut,);
|
||||
@ -178,5 +178,5 @@ pub fn keybinds(help: &ModeInfo, max_width: usize) -> LinePart {
|
||||
if shortened_shortcut_list.len <= max_width {
|
||||
return shortened_shortcut_list;
|
||||
}
|
||||
return best_effort_shortcut_list(help, max_width);
|
||||
best_effort_shortcut_list(help, max_width)
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ fn add_next_tabs_msg(
|
||||
}
|
||||
|
||||
fn tab_line_prefix() -> LinePart {
|
||||
let prefix_text = format!(" Zellij ");
|
||||
let prefix_text = " Zellij ".to_string();
|
||||
let prefix_text_len = prefix_text.chars().count();
|
||||
let prefix_styled_text = Style::new().fg(WHITE).on(GRAY).bold().paint(prefix_text);
|
||||
LinePart {
|
||||
|
Loading…
Reference in New Issue
Block a user