diff options
Diffstat (limited to 'src/ui/widgets/tui_view.rs')
-rw-r--r-- | src/ui/widgets/tui_view.rs | 54 |
1 files changed, 44 insertions, 10 deletions
diff --git a/src/ui/widgets/tui_view.rs b/src/ui/widgets/tui_view.rs index 0f2d64d..46af0b3 100644 --- a/src/ui/widgets/tui_view.rs +++ b/src/ui/widgets/tui_view.rs @@ -2,11 +2,12 @@ use tui::buffer::Buffer; use tui::layout::{Direction, Layout, Rect}; use tui::style::{Color, Modifier, Style}; use tui::widgets::{Paragraph, Text, Widget}; -use unicode_width::UnicodeWidthStr; -use super::{TuiDirList, TuiDirListDetailed, TuiFooter, TuiTopBar}; +use super::{TuiDirList, TuiDirListDetailed, TuiFooter, TuiTabBar, TuiTopBar}; use crate::context::JoshutoContext; +const TAB_VIEW_WIDTH: u16 = 15; + pub struct TuiView<'a> { pub context: &'a JoshutoContext, pub show_bottom_status: bool, @@ -44,14 +45,47 @@ impl<'a> Widget for TuiView<'a> { .split(f_size); { - let rect = Rect { - x: 0, - y: 0, - width: f_size.width, - height: 1, - }; - - TuiTopBar::new(curr_tab.curr_path.as_path()).draw(rect, buf); + let curr_path = curr_tab.curr_path.as_path(); + + if self.context.tabs.len() > 1 { + let topbar_width = if f_size.width > TAB_VIEW_WIDTH { + f_size.width - TAB_VIEW_WIDTH + } else { + 0 + }; + + let rect = Rect { + x: 0, + y: 0, + width: topbar_width, + height: 1, + }; + TuiTopBar::new(curr_path).draw(rect, buf); + + let rect = Rect { + x: topbar_width, + y: 0, + width: TAB_VIEW_WIDTH, + height: 1, + }; + let name = if let Some(ostr) = curr_path.file_name() { + ostr.to_str().unwrap_or("") + } else { + "" + }; + TuiTabBar::new(name, self.context.curr_tab_index, self.context.tabs.len()) + .draw(rect, buf); + } else { + let topbar_width = f_size.width; + + let rect = Rect { + x: 0, + y: 0, + width: topbar_width, + height: 1, + }; + TuiTopBar::new(curr_path).draw(rect, buf); + } } if let Some(curr_list) = parent_list.as_ref() { |