mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
feat: remove support for show_scrollbar & show_separators
This commit is contained in:
parent
a7b0e56b67
commit
cb27f5c74a
5 changed files with 12 additions and 30 deletions
|
|
@ -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" }
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
])
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue