mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
feat: show current dir name in tab
This commit is contained in:
parent
4823c0abc4
commit
6b65b7a62c
4 changed files with 20 additions and 7 deletions
|
|
@ -19,11 +19,18 @@ impl<'a> Widget for Tabs<'a> {
|
||||||
tabs
|
tabs
|
||||||
.iter()
|
.iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(i, _)| {
|
.map(|(i, tab)| {
|
||||||
|
let mut text = format!(" {} ", i + 1);
|
||||||
|
if THEME.tab.max_width > 0 {
|
||||||
|
text
|
||||||
|
.push_str(&tab.current_name().chars().take(THEME.tab.max_width).collect::<String>());
|
||||||
|
text.push(' ');
|
||||||
|
}
|
||||||
|
|
||||||
if i == tabs.idx() {
|
if i == tabs.idx() {
|
||||||
Span::styled(format!(" {} ", i + 1), THEME.tab.active.get())
|
Span::styled(text, THEME.tab.active.get())
|
||||||
} else {
|
} else {
|
||||||
Span::styled(format!(" {} ", i + 1), THEME.tab.inactive.get())
|
Span::styled(text, THEME.tab.inactive.get())
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>(),
|
.collect::<Vec<_>>(),
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
[tab]
|
[tab]
|
||||||
active = { fg = "#1E2031", bg = "#80AEFA" }
|
active = { fg = "#1E2031", bg = "#80AEFA" }
|
||||||
inactive = { fg = "#C8D3F8", bg = "#484D66" }
|
inactive = { fg = "#C8D3F8", bg = "#484D66" }
|
||||||
|
max_width = 0
|
||||||
|
|
||||||
[status]
|
[status]
|
||||||
primary = { normal = "#80AEFA", select = "#CD9EFC", unset = "#FFA577" }
|
primary = { normal = "#80AEFA", select = "#CD9EFC", unset = "#FFA577" }
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ use crate::MERGED_THEME;
|
||||||
pub struct Tab {
|
pub struct Tab {
|
||||||
pub active: Style,
|
pub active: Style,
|
||||||
pub inactive: Style,
|
pub inactive: Style,
|
||||||
|
pub max_width: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
|
|
|
||||||
|
|
@ -270,6 +270,10 @@ impl Tab {
|
||||||
};
|
};
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn current_name(&self) -> &str {
|
||||||
|
self.current.cwd.file_name().and_then(|name| name.to_str()).unwrap_or_default()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Tab {
|
impl Tab {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue