From cb27f5c74a2b712b18e4c4471106c2e5b0659ec1 Mon Sep 17 00:00:00 2001 From: greg Date: Thu, 17 Oct 2024 07:51:06 +0200 Subject: [PATCH] feat: remove support for show_scrollbar & show_separators --- yazi-config/preset/theme.toml | 2 -- yazi-config/src/theme/theme.rs | 2 -- yazi-fm/src/confirm/confirm.rs | 8 ++------ yazi-fm/src/confirm/content.rs | 5 +---- yazi-fm/src/confirm/list.rs | 25 +++++++++---------------- 5 files changed, 12 insertions(+), 30 deletions(-) diff --git a/yazi-config/preset/theme.toml b/yazi-config/preset/theme.toml index 74bf59c3..08a23594 100644 --- a/yazi-config/preset/theme.toml +++ b/yazi-config/preset/theme.toml @@ -101,8 +101,6 @@ selected = { reversed = true } # : Confirm {{{ [confirm] -show_separators = true -show_scrollbar = true button_yes = " [Y]es " button_no = " (N)o " border = { fg = "blue" } diff --git a/yazi-config/src/theme/theme.rs b/yazi-config/src/theme/theme.rs index 33831865..d56dfee0 100644 --- a/yazi-config/src/theme/theme.rs +++ b/yazi-config/src/theme/theme.rs @@ -117,8 +117,6 @@ pub struct Input { #[derive(Deserialize, Serialize)] pub struct Confirm { - pub show_separators: bool, - pub show_scrollbar: bool, pub button_yes: String, pub button_no: String, pub border: Style, diff --git a/yazi-fm/src/confirm/confirm.rs b/yazi-fm/src/confirm/confirm.rs index 9efb7d0d..543db08e 100644 --- a/yazi-fm/src/confirm/confirm.rs +++ b/yazi-fm/src/confirm/confirm.rs @@ -34,14 +34,10 @@ impl<'a> Widget for Confirm<'a> { .render(area, buf); let content = confirm.content.clone(); - let mut content_height = content.line_count(area.width) as u16; - - if THEME.confirm.show_separators && content_height > 0 { - content_height = content_height.saturating_add(1); - } + let content_height = content.line_count(area.width).saturating_add(1) as u16; let chunks = Layout::vertical([ - Constraint::Length(content_height), + Constraint::Length(if content_height == 1 { 0 } else { content_height }), Constraint::Fill(1), Constraint::Length(1), ]) diff --git a/yazi-fm/src/confirm/content.rs b/yazi-fm/src/confirm/content.rs index 2675f015..ab524632 100644 --- a/yazi-fm/src/confirm/content.rs +++ b/yazi-fm/src/confirm/content.rs @@ -22,10 +22,7 @@ impl<'a> Widget for Content<'a> { let inner = area.inner(Margin::new(1, 0)); // Bottom border - let mut block = Block::new(); - if THEME.confirm.show_separators { - block = block.borders(Borders::BOTTOM).border_style(THEME.confirm.border); - } + let block = Block::new().borders(Borders::BOTTOM).border_style(THEME.confirm.border); block.clone().render(area.inner(Margin::new(1, 0)), buf); self diff --git a/yazi-fm/src/confirm/list.rs b/yazi-fm/src/confirm/list.rs index 4f01796c..69b7c660 100644 --- a/yazi-fm/src/confirm/list.rs +++ b/yazi-fm/src/confirm/list.rs @@ -26,10 +26,7 @@ impl<'a> Widget for List<'a> { let inner = area.inner(Margin::new(2, 0)); // Bottom border - let mut block = Block::new(); - if THEME.confirm.show_separators { - block = block.borders(Borders::BOTTOM).border_style(THEME.confirm.border); - } + let block = Block::new().borders(Borders::BOTTOM).border_style(THEME.confirm.border); block.clone().render(area.inner(Margin::new(1, 0)), buf); let list = self @@ -43,18 +40,14 @@ impl<'a> Widget for List<'a> { .wrap(Wrap { trim: false }); // Vertical scrollbar - if THEME.confirm.show_scrollbar { - let lines = list.line_count(inner.width); - if lines >= inner.height as usize { - if THEME.confirm.show_separators { - area.height = area.height.saturating_sub(1); - } - Scrollbar::new(ScrollbarOrientation::VerticalRight).render( - area, - buf, - &mut ScrollbarState::new(lines).position(self.cx.confirm.offset), - ); - } + let lines = list.line_count(inner.width); + if lines >= inner.height as usize { + area.height = area.height.saturating_sub(1); + Scrollbar::new(ScrollbarOrientation::VerticalRight).render( + area, + buf, + &mut ScrollbarState::new(lines).position(self.cx.confirm.offset), + ); } list.render(inner, buf);