Skip to content

Commit

Permalink
polish it even more
Browse files Browse the repository at this point in the history
  • Loading branch information
micielski committed Aug 26, 2024
1 parent b0dc4ee commit 413b0c6
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions rm-main/src/tui/global_popups/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,34 +207,34 @@ impl Component for HelpPopup {

let block = popup_block_with_close_highlight(" Help ");

let mut max_len = 0;
let mut to_pad = 0;
let mut max_line_len = 0;
let mut global_keys = Self::get_keybindings(
&CONFIG.keybindings.general.keybindings,
&mut max_len,
&mut to_pad,
&mut max_line_len,
);
let mut torrents_keys = Self::get_keybindings(
&CONFIG.keybindings.torrents_tab.keybindings,
&mut max_len,
&mut to_pad,
&mut max_line_len,
);
let mut search_keys = Self::get_keybindings(
&CONFIG.keybindings.search_tab.keybindings,
&mut max_len,
&mut to_pad,
&mut max_line_len,
);
debug_assert!(max_len > 0);
debug_assert!(to_pad > 0);
let to_pad_additionally = (text_rect
.width
.saturating_sub(max_line_len.try_into().unwrap())
/ 2)
.saturating_sub(6);
max_len += usize::from(to_pad_additionally);
to_pad += usize::from(to_pad_additionally);

let pad_keys = |keys: &mut Vec<(String, &'static str)>| {
for key in keys {
let mut how_much_to_pad = max_len.saturating_sub(key.0.chars().count());
let mut how_much_to_pad = to_pad.saturating_sub(key.0.chars().count());
while how_much_to_pad > 0 {
key.0.insert(0, ' ');
how_much_to_pad -= 1;
Expand All @@ -251,6 +251,7 @@ impl Component for HelpPopup {
for (keycode, desc) in keys {
add_line!(lines, keycode, desc);
}
lines.push(Line::default());
};

lines.push(
Expand Down

0 comments on commit 413b0c6

Please sign in to comment.