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
|
||||
.iter()
|
||||
.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() {
|
||||
Span::styled(format!(" {} ", i + 1), THEME.tab.active.get())
|
||||
Span::styled(text, THEME.tab.active.get())
|
||||
} else {
|
||||
Span::styled(format!(" {} ", i + 1), THEME.tab.inactive.get())
|
||||
Span::styled(text, THEME.tab.inactive.get())
|
||||
}
|
||||
})
|
||||
.collect::<Vec<_>>(),
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
[tab]
|
||||
active = { fg = "#1E2031", bg = "#80AEFA" }
|
||||
inactive = { fg = "#C8D3F8", bg = "#484D66" }
|
||||
active = { fg = "#1E2031", bg = "#80AEFA" }
|
||||
inactive = { fg = "#C8D3F8", bg = "#484D66" }
|
||||
max_width = 0
|
||||
|
||||
[status]
|
||||
primary = { normal = "#80AEFA", select = "#CD9EFC", unset = "#FFA577" }
|
||||
|
|
|
|||
|
|
@ -8,8 +8,9 @@ use crate::MERGED_THEME;
|
|||
|
||||
#[derive(Deserialize)]
|
||||
pub struct Tab {
|
||||
pub active: Style,
|
||||
pub inactive: Style,
|
||||
pub active: Style,
|
||||
pub inactive: Style,
|
||||
pub max_width: usize,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
|
|
|
|||
|
|
@ -270,6 +270,10 @@ impl Tab {
|
|||
};
|
||||
true
|
||||
}
|
||||
|
||||
pub fn current_name(&self) -> &str {
|
||||
self.current.cwd.file_name().and_then(|name| name.to_str()).unwrap_or_default()
|
||||
}
|
||||
}
|
||||
|
||||
impl Tab {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue