summaryrefslogtreecommitdiffstats
path: root/src/ui/widgets/tui_topbar.rs
diff options
context:
space:
mode:
authorLzzzzzt <101313294+Lzzzzzt@users.noreply.github.com>2023-08-12 20:50:20 +0800
committerGitHub <noreply@github.com>2023-08-12 08:50:20 -0400
commit0eec61eb82d10b8b9f76c8b5c9e2a0fae0514a1e (patch)
tree7195f1d89bc046597feb76b7d8d875b116b61071 /src/ui/widgets/tui_topbar.rs
parentfc2fdf3ca79cbfba18350dd5faaf548d7a98f96f (diff)
feat: tab bar can show current dir name (#390)
* add user & group on footer * linemode have more options * linemode have more options * linemode have more options * make tarbar title not hardcoded * topbar width with modified tab width * change the ellipsis
Diffstat (limited to 'src/ui/widgets/tui_topbar.rs')
-rw-r--r--src/ui/widgets/tui_topbar.rs34
1 files changed, 14 insertions, 20 deletions
diff --git a/src/ui/widgets/tui_topbar.rs b/src/ui/widgets/tui_topbar.rs
index 700f318..10ed131 100644
--- a/src/ui/widgets/tui_topbar.rs
+++ b/src/ui/widgets/tui_topbar.rs
@@ -32,8 +32,7 @@ impl<'a> Widget for TuiTopBar<'a> {
let mut ellipses = None;
let mut curr_path_str = self.path.to_string_lossy().into_owned();
- let num_tabs = self.context.tab_context_ref().len();
- let tab_width = num_tabs * 8;
+ let tab_width = self.context.tab_context_ref().tab_area_width();
let name_width = USERNAME.as_str().len() + HOSTNAME.as_str().len() + 2;
if tab_width + name_width > area.width as usize {
@@ -79,24 +78,19 @@ impl<'a> Widget for TuiTopBar<'a> {
.add_modifier(Modifier::BOLD)
};
- let text = match ellipses {
- Some(s) => Line::from(vec![
- Span::styled(USERNAME.as_str(), username_style),
- Span::styled("@", username_style),
- Span::styled(HOSTNAME.as_str(), username_style),
- Span::styled(" ", username_style),
- s,
- Span::styled(curr_path_str, path_style),
- ]),
- None => Line::from(vec![
- Span::styled(USERNAME.as_str(), username_style),
- Span::styled("@", username_style),
- Span::styled(HOSTNAME.as_str(), username_style),
- Span::styled(" ", username_style),
- Span::styled(curr_path_str, path_style),
- ]),
- };
+ let mut text = vec![
+ Span::styled(USERNAME.as_str(), username_style),
+ Span::styled("@", username_style),
+ Span::styled(HOSTNAME.as_str(), username_style),
+ Span::styled(" ", username_style),
+ ];
+
+ if let Some(s) = ellipses {
+ text.push(s);
+ }
+
+ text.extend([Span::styled(curr_path_str, path_style)]);
- Paragraph::new(text).render(area, buf);
+ Paragraph::new(Line::from(text)).render(area, buf);
}
}