Skip to content

Commit

Permalink
add(style): add trailing comma in match blocks (zellij-org#1483)
Browse files Browse the repository at this point in the history
This makes it easier to distinguish from normal blocks
  • Loading branch information
a-kenji authored Jun 10, 2022
1 parent bcaa6b8 commit 67d2673
Show file tree
Hide file tree
Showing 45 changed files with 627 additions and 626 deletions.
1 change: 1 addition & 0 deletions .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
match_block_trailing_comma = true
16 changes: 8 additions & 8 deletions default-plugins/compact-bar/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,23 +49,23 @@ impl ZellijPlugin for State {
} else {
eprintln!("Could not find active tab.");
}
}
},
Event::Mouse(me) => match me {
Mouse::LeftClick(_, col) => {
self.mouse_click_pos = col;
self.should_render = true;
}
},
Mouse::ScrollUp(_) => {
switch_tab_to(min(self.active_tab_idx + 1, self.tabs.len()) as u32);
}
},
Mouse::ScrollDown(_) => {
switch_tab_to(max(self.active_tab_idx.saturating_sub(1), 1) as u32);
}
_ => {}
},
_ => {},
},
_ => {
eprintln!("Got unrecognized event: {:?}", event);
}
},
}
}

Expand Down Expand Up @@ -130,10 +130,10 @@ impl ZellijPlugin for State {
match background {
PaletteColor::Rgb((r, g, b)) => {
println!("{}\u{1b}[48;2;{};{};{}m\u{1b}[0K", s, r, g, b);
}
},
PaletteColor::EightBit(color) => {
println!("{}\u{1b}[48;5;{}m\u{1b}[0K", s, color);
}
},
}
self.should_render = false;
}
Expand Down
8 changes: 4 additions & 4 deletions default-plugins/status-bar/src/first_line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,16 +261,16 @@ fn single_letter_ctrl_key(
match key.mode {
CtrlKeyMode::Unselected => {
unselected_mode_shortcut_single_letter(letter_shortcut, palette, separator)
}
},
CtrlKeyMode::UnselectedAlternate => {
unselected_alternate_mode_shortcut_single_letter(letter_shortcut, palette, separator)
}
},
CtrlKeyMode::Selected => {
selected_mode_shortcut_single_letter(letter_shortcut, palette, separator)
}
},
CtrlKeyMode::Disabled => {
disabled_mode_shortcut(&format!(" {}", letter_shortcut), palette, separator)
}
},
}
}

Expand Down
18 changes: 9 additions & 9 deletions default-plugins/status-bar/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,21 +237,21 @@ impl ZellijPlugin for State {
match event {
Event::ModeUpdate(mode_info) => {
self.mode_info = mode_info;
}
},
Event::TabUpdate(tabs) => {
self.tabs = tabs;
}
},
Event::CopyToClipboard(copy_destination) => {
self.text_copy_destination = Some(copy_destination);
}
},
Event::SystemClipboardFailure => {
self.display_system_clipboard_failure = true;
}
},
Event::InputReceived => {
self.text_copy_destination = None;
self.display_system_clipboard_failure = false;
}
_ => {}
},
_ => {},
}
}

Expand Down Expand Up @@ -284,10 +284,10 @@ impl ZellijPlugin for State {
match background {
PaletteColor::Rgb((r, g, b)) => {
println!("{}\u{1b}[48;2;{};{};{}m\u{1b}[0K", first_line, r, g, b);
}
},
PaletteColor::EightBit(color) => {
println!("{}\u{1b}[48;5;{}m\u{1b}[0K", first_line, color);
}
},
}
println!("\u{1b}[m{}\u{1b}[0K", second_line);
}
Expand Down Expand Up @@ -319,7 +319,7 @@ impl State {
InputMode::Normal => floating_panes_are_visible(&self.mode_info.style.colors),
InputMode::Locked => {
locked_floating_panes_are_visible(&self.mode_info.style.colors)
}
},
_ => keybinds(&self.mode_info, &self.tip_name, cols),
}
} else {
Expand Down
8 changes: 4 additions & 4 deletions default-plugins/status-bar/src/second_line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ fn shortened_shortcut_list(help: &ModeInfo, tip: TipFn) -> LinePart {
InputMode::Tmux => short_tmux_mode_indication(help),
InputMode::RenamePane => {
shortened_shortcut_list_nonstandard_mode(select_pane_shortcut)(help)
}
},
_ => shortened_shortcut_list_nonstandard_mode(confirm_pane_selection)(help),
}
}
Expand Down Expand Up @@ -279,19 +279,19 @@ fn best_effort_shortcut_list(help: &ModeInfo, tip: TipFn, max_len: usize) -> Lin
} else {
LinePart::default()
}
}
},
InputMode::Locked => {
let line_part = locked_interface_indication(help.style.colors);
if line_part.len <= max_len {
line_part
} else {
LinePart::default()
}
}
},
InputMode::Tmux => best_effort_tmux_shortcut_list(help, max_len),
InputMode::RenamePane => {
best_effort_shortcut_list_nonstandard_mode(select_pane_shortcut)(help, max_len)
}
},
_ => best_effort_shortcut_list_nonstandard_mode(confirm_pane_selection)(help, max_len),
}
}
Expand Down
6 changes: 3 additions & 3 deletions default-plugins/status-bar/src/tip/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl LocalCache {
});
}
Err(LocalCacheError::Serde(err))
}
},
}
}

Expand All @@ -64,7 +64,7 @@ impl LocalCache {

let metadata = LocalCache::from_json(&json_cache)?;
Ok(LocalCache { path, metadata })
}
},
Err(e) => Err(LocalCacheError::IoPath(e, path)),
}
}
Expand All @@ -77,7 +77,7 @@ impl LocalCache {
file.write_all(json_cache.as_bytes())
.map_err(LocalCacheError::Io)?;
Ok(())
}
},
Err(e) => Err(LocalCacheError::Serde(e)),
}
}
Expand Down
20 changes: 10 additions & 10 deletions default-plugins/strider/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ impl ZellijPlugin for State {
Event::Key(key) => match key {
Key::Up | Key::Char('k') => {
*self.selected_mut() = self.selected().saturating_sub(1);
}
},
Key::Down | Key::Char('j') => {
let next = self.selected().saturating_add(1);
*self.selected_mut() = min(self.files.len().saturating_sub(1), next);
}
},
Key::Right | Key::Char('\n') | Key::Char('l') if !self.files.is_empty() => {
self.traverse_dir_or_open_file();
self.ev_history.clear();
}
},
Key::Left | Key::Char('h') => {
if self.path.components().count() > 2 {
// don't descend into /host
Expand All @@ -42,22 +42,22 @@ impl ZellijPlugin for State {
self.path.pop();
refresh_directory(self);
}
}
},
Key::Char('.') => {
self.toggle_hidden_files();
refresh_directory(self);
}
},

_ => (),
},
Event::Mouse(mouse_event) => match mouse_event {
Mouse::ScrollDown(_) => {
let next = self.selected().saturating_add(1);
*self.selected_mut() = min(self.files.len().saturating_sub(1), next);
}
},
Mouse::ScrollUp(_) => {
*self.selected_mut() = self.selected().saturating_sub(1);
}
},
Mouse::Release(line, _) => {
if line < 0 {
return;
Expand All @@ -75,12 +75,12 @@ impl ZellijPlugin for State {
if should_select && self.scroll() + (line as usize) < self.files.len() {
*self.selected_mut() = self.scroll() + (line as usize);
}
}
_ => {}
},
_ => {},
},
_ => {
dbg!("Unknown event {:?}", event);
}
},
}
}

Expand Down
2 changes: 1 addition & 1 deletion default-plugins/strider/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ impl State {
FsEntry::Dir(p, _) => {
self.path = p;
refresh_directory(self);
}
},
FsEntry::File(p, _) => open_file(p.strip_prefix(ROOT).unwrap()),
}
}
Expand Down
16 changes: 8 additions & 8 deletions default-plugins/tab-bar/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,23 +49,23 @@ impl ZellijPlugin for State {
} else {
eprintln!("Could not find active tab.");
}
}
},
Event::Mouse(me) => match me {
Mouse::LeftClick(_, col) => {
self.mouse_click_pos = col;
self.should_render = true;
}
},
Mouse::ScrollUp(_) => {
switch_tab_to(min(self.active_tab_idx + 1, self.tabs.len()) as u32);
}
},
Mouse::ScrollDown(_) => {
switch_tab_to(max(self.active_tab_idx.saturating_sub(1), 1) as u32);
}
_ => {}
},
_ => {},
},
_ => {
eprintln!("Got unrecognized event: {:?}", event);
}
},
}
}

Expand Down Expand Up @@ -129,10 +129,10 @@ impl ZellijPlugin for State {
match background {
PaletteColor::Rgb((r, g, b)) => {
println!("{}\u{1b}[48;2;{};{};{}m\u{1b}[0K", s, r, g, b);
}
},
PaletteColor::EightBit(color) => {
println!("{}\u{1b}[48;5;{}m\u{1b}[0K", s, color);
}
},
}
self.should_render = false;
}
Expand Down
Loading

0 comments on commit 67d2673

Please sign in to comment.