diff options
author | Andrew Jeffery <dev@jeffas.io> | 2020-11-24 21:39:02 +0000 |
---|---|---|
committer | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2020-11-25 15:54:47 +0200 |
commit | daee4e46de0cdfe220cff11fdf686ab2afac2c9c (patch) | |
tree | a841954bbb9f6f23a57e9624390fc65fe814bd71 /src/components/contacts/contact_list.rs | |
parent | 92c12d3526d5fdf4a4eaaf49f91ecd718074cb06 (diff) |
Allow configuration of the sidebar divider
This adds the config option listing.sidebar_divider to set the character
used to show the divider (defaults to ' ') along with the corresponding
theme in mail.sidebar_divider which defaults to the default theme.
Diffstat (limited to 'src/components/contacts/contact_list.rs')
-rw-r--r-- | src/components/contacts/contact_list.rs | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/src/components/contacts/contact_list.rs b/src/components/contacts/contact_list.rs index e6e016a0..cdcb277d 100644 --- a/src/components/contacts/contact_list.rs +++ b/src/components/contacts/contact_list.rs @@ -54,7 +54,10 @@ pub struct ContactList { mode: ViewMode, dirty: bool, - show_divider: bool, + + sidebar_divider: char, + sidebar_divider_theme: ThemeAttribute, + menu_visibility: bool, movement: Option<PageMovement>, cmd_buf: String, @@ -98,7 +101,8 @@ impl ContactList { cmd_buf: String::with_capacity(8), view: None, ratio: 90, - show_divider: false, + sidebar_divider: context.settings.listing.sidebar_divider, + sidebar_divider_theme: conf::value(context, "mail.sidebar_divider"), menu_visibility: true, id: ComponentId::new_v4(), } @@ -239,13 +243,11 @@ impl ContactList { change_colors(grid, area, fg_color, bg_color); } - fn draw_menu(&mut self, grid: &mut CellBuffer, mut area: Area, context: &mut Context) { + fn draw_menu(&mut self, grid: &mut CellBuffer, area: Area, context: &mut Context) { if !self.is_dirty() { return; } clear_area(grid, area, self.theme_default); - /* visually divide menu and listing */ - area = (area.0, pos_dec(area.1, (1, 0))); let upper_left = upper_left!(area); let bottom_right = bottom_right!(area); self.dirty = false; @@ -580,19 +582,12 @@ impl Component for ContactList { }; let mid = get_x(bottom_right) - right_component_width; if self.dirty && mid != get_x(upper_left) { - if self.show_divider { - for i in get_y(upper_left)..=get_y(bottom_right) { - grid[(mid, i)] - .set_ch(VERT_BOUNDARY) - .set_fg(self.theme_default.fg) - .set_bg(self.theme_default.bg); - } - } else { - for i in get_y(upper_left)..=get_y(bottom_right) { - grid[(mid, i)] - .set_fg(self.theme_default.fg) - .set_bg(self.theme_default.bg); - } + for i in get_y(upper_left)..=get_y(bottom_right) { + grid[(mid, i)] + .set_ch(self.sidebar_divider) + .set_fg(self.sidebar_divider_theme.fg) + .set_bg(self.sidebar_divider_theme.bg) + .set_attrs(self.sidebar_divider_theme.attrs); } context .dirty_areas @@ -604,7 +599,11 @@ impl Component for ContactList { } else if right_component_width == 0 { self.draw_menu(grid, area, context); } else { - self.draw_menu(grid, (upper_left, (mid, get_y(bottom_right))), context); + self.draw_menu( + grid, + (upper_left, (mid.saturating_sub(1), get_y(bottom_right))), + context, + ); self.draw_list(grid, (set_x(upper_left, mid + 1), bottom_right), context); } self.dirty = false; |