mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
feat: exclude padding
This commit is contained in:
parent
c0bf888247
commit
6e175cfd7d
2 changed files with 7 additions and 9 deletions
|
|
@ -23,12 +23,13 @@ impl<'a> Widget for Tabs<'a> {
|
|||
.iter()
|
||||
.enumerate()
|
||||
.map(|(i, tab)| {
|
||||
let mut text = format!(" {} ", i + 1);
|
||||
let mut text = format!("{}", i + 1);
|
||||
if let Some(dir_name) = tab.current_name() {
|
||||
text.push(' ');
|
||||
text.push_str(dir_name);
|
||||
}
|
||||
|
||||
let threshold = THEME.tab.max_width.max(3) - 1;
|
||||
let threshold = THEME.tab.max_width.max(1);
|
||||
let truncated = text.chars().try_fold(String::with_capacity(threshold), |mut text, c| {
|
||||
if text.width() > threshold {
|
||||
ControlFlow::Break(text)
|
||||
|
|
@ -37,18 +38,15 @@ impl<'a> Widget for Tabs<'a> {
|
|||
ControlFlow::Continue(text)
|
||||
}
|
||||
});
|
||||
let mut text = match truncated {
|
||||
let text = match truncated {
|
||||
ControlFlow::Break(text) => text,
|
||||
ControlFlow::Continue(text) => text,
|
||||
};
|
||||
if !text.ends_with(' ') {
|
||||
text.push(' ');
|
||||
}
|
||||
|
||||
if i == tabs.idx() {
|
||||
Span::styled(text, THEME.tab.active.get())
|
||||
Span::styled(format!(" {text} "), THEME.tab.active.get())
|
||||
} else {
|
||||
Span::styled(text, THEME.tab.inactive.get())
|
||||
Span::styled(format!(" {text} "), THEME.tab.inactive.get())
|
||||
}
|
||||
})
|
||||
.collect::<Vec<_>>(),
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
[tab]
|
||||
active = { fg = "#1E2031", bg = "#80AEFA" }
|
||||
inactive = { fg = "#C8D3F8", bg = "#484D66" }
|
||||
max_width = 3
|
||||
max_width = 1
|
||||
|
||||
[status]
|
||||
primary = { normal = "#80AEFA", select = "#CD9EFC", unset = "#FFA577" }
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue