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 {{{
|
||||||
|
|
||||||
[confirm]
|
[confirm]
|
||||||
show_separators = true
|
|
||||||
show_scrollbar = true
|
|
||||||
button_yes = " [Y]es "
|
button_yes = " [Y]es "
|
||||||
button_no = " (N)o "
|
button_no = " (N)o "
|
||||||
border = { fg = "blue" }
|
border = { fg = "blue" }
|
||||||
|
|
|
||||||
|
|
@ -117,8 +117,6 @@ pub struct Input {
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize)]
|
#[derive(Deserialize, Serialize)]
|
||||||
pub struct Confirm {
|
pub struct Confirm {
|
||||||
pub show_separators: bool,
|
|
||||||
pub show_scrollbar: bool,
|
|
||||||
pub button_yes: String,
|
pub button_yes: String,
|
||||||
pub button_no: String,
|
pub button_no: String,
|
||||||
pub border: Style,
|
pub border: Style,
|
||||||
|
|
|
||||||
|
|
@ -34,14 +34,10 @@ impl<'a> Widget for Confirm<'a> {
|
||||||
.render(area, buf);
|
.render(area, buf);
|
||||||
|
|
||||||
let content = confirm.content.clone();
|
let content = confirm.content.clone();
|
||||||
let mut content_height = content.line_count(area.width) as u16;
|
let content_height = content.line_count(area.width).saturating_add(1) as u16;
|
||||||
|
|
||||||
if THEME.confirm.show_separators && content_height > 0 {
|
|
||||||
content_height = content_height.saturating_add(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
let chunks = Layout::vertical([
|
let chunks = Layout::vertical([
|
||||||
Constraint::Length(content_height),
|
Constraint::Length(if content_height == 1 { 0 } else { content_height }),
|
||||||
Constraint::Fill(1),
|
Constraint::Fill(1),
|
||||||
Constraint::Length(1),
|
Constraint::Length(1),
|
||||||
])
|
])
|
||||||
|
|
|
||||||
|
|
@ -22,10 +22,7 @@ impl<'a> Widget for Content<'a> {
|
||||||
let inner = area.inner(Margin::new(1, 0));
|
let inner = area.inner(Margin::new(1, 0));
|
||||||
|
|
||||||
// Bottom border
|
// Bottom border
|
||||||
let mut block = Block::new();
|
let block = Block::new().borders(Borders::BOTTOM).border_style(THEME.confirm.border);
|
||||||
if THEME.confirm.show_separators {
|
|
||||||
block = block.borders(Borders::BOTTOM).border_style(THEME.confirm.border);
|
|
||||||
}
|
|
||||||
block.clone().render(area.inner(Margin::new(1, 0)), buf);
|
block.clone().render(area.inner(Margin::new(1, 0)), buf);
|
||||||
|
|
||||||
self
|
self
|
||||||
|
|
|
||||||
|
|
@ -26,10 +26,7 @@ impl<'a> Widget for List<'a> {
|
||||||
let inner = area.inner(Margin::new(2, 0));
|
let inner = area.inner(Margin::new(2, 0));
|
||||||
|
|
||||||
// Bottom border
|
// Bottom border
|
||||||
let mut block = Block::new();
|
let block = Block::new().borders(Borders::BOTTOM).border_style(THEME.confirm.border);
|
||||||
if THEME.confirm.show_separators {
|
|
||||||
block = block.borders(Borders::BOTTOM).border_style(THEME.confirm.border);
|
|
||||||
}
|
|
||||||
block.clone().render(area.inner(Margin::new(1, 0)), buf);
|
block.clone().render(area.inner(Margin::new(1, 0)), buf);
|
||||||
|
|
||||||
let list = self
|
let list = self
|
||||||
|
|
@ -43,18 +40,14 @@ impl<'a> Widget for List<'a> {
|
||||||
.wrap(Wrap { trim: false });
|
.wrap(Wrap { trim: false });
|
||||||
|
|
||||||
// Vertical scrollbar
|
// Vertical scrollbar
|
||||||
if THEME.confirm.show_scrollbar {
|
let lines = list.line_count(inner.width);
|
||||||
let lines = list.line_count(inner.width);
|
if lines >= inner.height as usize {
|
||||||
if lines >= inner.height as usize {
|
area.height = area.height.saturating_sub(1);
|
||||||
if THEME.confirm.show_separators {
|
Scrollbar::new(ScrollbarOrientation::VerticalRight).render(
|
||||||
area.height = area.height.saturating_sub(1);
|
area,
|
||||||
}
|
buf,
|
||||||
Scrollbar::new(ScrollbarOrientation::VerticalRight).render(
|
&mut ScrollbarState::new(lines).position(self.cx.confirm.offset),
|
||||||
area,
|
);
|
||||||
buf,
|
|
||||||
&mut ScrollbarState::new(lines).position(self.cx.confirm.offset),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
list.render(inner, buf);
|
list.render(inner, buf);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue