summaryrefslogtreecommitdiffstats
path: root/default-plugins
diff options
context:
space:
mode:
authorMarcin Puc <5671049+tranzystorek-io@users.noreply.github.com>2021-12-07 11:24:42 +0100
committerGitHub <noreply@github.com>2021-12-07 10:24:42 +0000
commit56e85f87d6c365816cca71c496aa7e49709e0b11 (patch)
tree1dbc6db878e8da9544df9445d77d1cd665b9126b /default-plugins
parentd34e6240101d246f02921cbc909dcd04f648203e (diff)
fix(style): various internal refactorings
Diffstat (limited to 'default-plugins')
-rw-r--r--default-plugins/status-bar/src/first_line.rs2
-rw-r--r--default-plugins/status-bar/src/main.rs2
-rw-r--r--default-plugins/status-bar/src/second_line.rs58
-rw-r--r--default-plugins/tab-bar/src/line.rs16
-rw-r--r--default-plugins/tab-bar/src/main.rs4
-rw-r--r--default-plugins/tab-bar/src/tab.rs12
6 files changed, 40 insertions, 54 deletions
diff --git a/default-plugins/status-bar/src/first_line.rs b/default-plugins/status-bar/src/first_line.rs
index b3dea2783..5bc510868 100644
--- a/default-plugins/status-bar/src/first_line.rs
+++ b/default-plugins/status-bar/src/first_line.rs
@@ -93,7 +93,7 @@ fn selected_mode_shortcut(
) -> LinePart {
let prefix_separator = palette.selected_prefix_separator.paint(separator);
let char_left_separator = palette.selected_char_left_separator.paint(" <".to_string());
- let char_shortcut = palette.selected_char_shortcut.paint(format!("{}", letter));
+ let char_shortcut = palette.selected_char_shortcut.paint(letter.to_string());
let char_right_separator = palette.selected_char_right_separator.paint(">".to_string());
let styled_text = palette.selected_styled_text.paint(format!("{} ", text));
let suffix_separator = palette.selected_suffix_separator.paint(separator);
diff --git a/default-plugins/status-bar/src/main.rs b/default-plugins/status-bar/src/main.rs
index 1ecd87ab1..ce80dab14 100644
--- a/default-plugins/status-bar/src/main.rs
+++ b/default-plugins/status-bar/src/main.rs
@@ -176,7 +176,7 @@ impl ZellijPlugin for State {
let first_line = format!("{}{}", superkey, ctrl_keys);
let mut second_line = LinePart::default();
- for t in self.tabs.iter_mut() {
+ for t in &mut self.tabs {
if t.active {
match self.mode_info.mode {
InputMode::Normal => {
diff --git a/default-plugins/status-bar/src/second_line.rs b/default-plugins/status-bar/src/second_line.rs
index 1b90443c0..9cc978a61 100644
--- a/default-plugins/status-bar/src/second_line.rs
+++ b/default-plugins/status-bar/src/second_line.rs
@@ -31,16 +31,14 @@ fn full_length_shortcut(
let description = Style::new().fg(white_color).bold().paint(description);
let len = shortcut_len + description_len + separator.chars().count();
LinePart {
- part: format!(
- "{}",
- ANSIStrings(&[
- separator,
- shortcut_left_separator,
- shortcut,
- shortcut_right_separator,
- description
- ])
- ),
+ part: ANSIStrings(&[
+ separator,
+ shortcut_left_separator,
+ shortcut,
+ shortcut_right_separator,
+ description,
+ ])
+ .to_string(),
len,
}
}
@@ -73,16 +71,14 @@ fn first_word_shortcut(
.paint(description_first_word);
let len = shortcut_len + description_first_word_length + separator.chars().count();
LinePart {
- part: format!(
- "{}",
- ANSIStrings(&[
- separator,
- shortcut_left_separator,
- shortcut,
- shortcut_right_separator,
- description_first_word,
- ])
- ),
+ part: ANSIStrings(&[
+ separator,
+ shortcut_left_separator,
+ shortcut,
+ shortcut_right_separator,
+ description_first_word,
+ ])
+ .to_string(),
len,
}
}
@@ -284,7 +280,7 @@ fn locked_interface_indication(palette: Palette) -> LinePart {
};
let locked_styled_text = Style::new().fg(white_color).bold().paint(locked_text);
LinePart {
- part: format!("{}", locked_styled_text),
+ part: locked_styled_text.to_string(),
len: locked_text_len,
}
}
@@ -310,16 +306,14 @@ fn select_pane_shortcut(is_first_shortcut: bool, palette: Palette) -> LinePart {
let description = Style::new().fg(white_color).bold().paint(description);
let len = shortcut_len + description_len + separator.chars().count();
LinePart {
- part: format!(
- "{}",
- ANSIStrings(&[
- separator,
- shortcut_left_separator,
- shortcut,
- shortcut_right_separator,
- description
- ])
- ),
+ part: ANSIStrings(&[
+ separator,
+ shortcut_left_separator,
+ shortcut,
+ shortcut_right_separator,
+ description,
+ ])
+ .to_string(),
len,
}
}
@@ -422,7 +416,7 @@ pub fn text_copied_hint(palette: &Palette) -> LinePart {
PaletteColor::EightBit(color) => Fixed(color),
};
LinePart {
- part: format!("{}", Style::new().fg(green_color).bold().paint(hint)),
+ part: Style::new().fg(green_color).bold().paint(hint).to_string(),
len: hint.len(),
}
}
diff --git a/default-plugins/tab-bar/src/line.rs b/default-plugins/tab-bar/src/line.rs
index 2e180845b..b8c58854d 100644
--- a/default-plugins/tab-bar/src/line.rs
+++ b/default-plugins/tab-bar/src/line.rs
@@ -107,10 +107,8 @@ fn left_more_message(tab_count_to_the_left: usize, palette: Palette, separator:
.bold()
.paint(more_text);
let right_separator = style!(palette.orange, palette.gray).paint(separator);
- let more_styled_text = format!(
- "{}",
- ANSIStrings(&[left_separator, more_styled_text, right_separator,])
- );
+ let more_styled_text =
+ ANSIStrings(&[left_separator, more_styled_text, right_separator]).to_string();
LinePart {
part: more_styled_text,
len: more_text_len,
@@ -137,10 +135,8 @@ fn right_more_message(
.bold()
.paint(more_text);
let right_separator = style!(palette.orange, palette.gray).paint(separator);
- let more_styled_text = format!(
- "{}",
- ANSIStrings(&[left_separator, more_styled_text, right_separator,])
- );
+ let more_styled_text =
+ ANSIStrings(&[left_separator, more_styled_text, right_separator]).to_string();
LinePart {
part: more_styled_text,
len: more_text_len,
@@ -155,7 +151,7 @@ fn tab_line_prefix(session_name: Option<&str>, palette: Palette, cols: usize) ->
.bold()
.paint(prefix_text);
let mut parts = vec![LinePart {
- part: format!("{}", prefix_styled_text),
+ part: prefix_styled_text.to_string(),
len: prefix_text_len,
}];
if let Some(name) = session_name {
@@ -164,7 +160,7 @@ fn tab_line_prefix(session_name: Option<&str>, palette: Palette, cols: usize) ->
let name_part_styled_text = style!(palette.white, palette.gray).bold().paint(name_part);
if cols.saturating_sub(prefix_text_len) >= name_part_len {
parts.push(LinePart {
- part: format!("{}", name_part_styled_text),
+ part: name_part_styled_text.to_string(),
len: name_part_len,
})
}
diff --git a/default-plugins/tab-bar/src/main.rs b/default-plugins/tab-bar/src/main.rs
index 5902050ae..31b2f2d37 100644
--- a/default-plugins/tab-bar/src/main.rs
+++ b/default-plugins/tab-bar/src/main.rs
@@ -43,7 +43,7 @@ impl ZellijPlugin for State {
Event::ModeUpdate(mode_info) => self.mode_info = mode_info,
Event::TabUpdate(tabs) => {
// tabs are indexed starting from 1 so we need to add 1
- self.active_tab_idx = (&tabs).iter().position(|t| t.active).unwrap() + 1;
+ self.active_tab_idx = tabs.iter().position(|t| t.active).unwrap() + 1;
self.tabs = tabs;
}
Event::Mouse(me) => match me {
@@ -69,7 +69,7 @@ impl ZellijPlugin for State {
}
let mut all_tabs: Vec<LinePart> = vec![];
let mut active_tab_index = 0;
- for t in self.tabs.iter_mut() {
+ for t in &mut self.tabs {
let mut tabname = t.name.clone();
if t.active && self.mode_info.mode == InputMode::RenameTab {
if tabname.is_empty() {
diff --git a/default-plugins/tab-bar/src/tab.rs b/default-plugins/tab-bar/src/tab.rs
index fc34b6c36..db960fd52 100644
--- a/default-plugins/tab-bar/src/tab.rs
+++ b/default-plugins/tab-bar/src/tab.rs
@@ -11,10 +11,8 @@ pub fn active_tab(text: String, palette: Palette, separator: &str) -> LinePart {
.bold()
.paint(format!(" {} ", text));
let right_separator = style!(palette.green, palette.gray).paint(separator);
- let tab_styled_text = format!(
- "{}",
- ANSIStrings(&[left_separator, tab_styled_text, right_separator,])
- );
+ let tab_styled_text =
+ ANSIStrings(&[left_separator, tab_styled_text, right_separator]).to_string();
LinePart {
part: tab_styled_text,
len: tab_text_len,
@@ -28,10 +26,8 @@ pub fn non_active_tab(text: String, palette: Palette, separator: &str) -> LinePa
.bold()
.paint(format!(" {} ", text));
let right_separator = style!(palette.fg, palette.gray).paint(separator);
- let tab_styled_text = format!(
- "{}",
- ANSIStrings(&[left_separator, tab_styled_text, right_separator,])
- );
+ let tab_styled_text =
+ ANSIStrings(&[left_separator, tab_styled_text, right_separator]).to_string();
LinePart {
part: tab_styled_text,
len: tab_text_len,