diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/file_browser.rs | 8 | ||||
-rw-r--r-- | src/term.rs | 4 |
2 files changed, 12 insertions, 0 deletions
diff --git a/src/file_browser.rs b/src/file_browser.rs index 34ddd32..d1c597c 100644 --- a/src/file_browser.rs +++ b/src/file_browser.rs @@ -18,6 +18,7 @@ use crate::fail::{HResult, HError, ErrorLog}; use crate::widget::{Events, WidgetCore}; use crate::proclist::ProcView; use crate::bookmarks::BMPopup; +use crate::term::ScreenExt; #[derive(PartialEq)] pub enum FileBrowserWidgets { @@ -339,6 +340,12 @@ impl FileBrowser { Ok(()) } + pub fn set_title(&self) -> HResult<()> { + let cwd = &self.cwd.path.to_string_lossy(); + self.core.screen.lock()?.set_title(cwd)?; + Ok(()) + } + pub fn update_preview(&mut self) -> HResult<()> { if !self.main_widget()?.ready() { return Ok(()) } let file = self.selected_file()?.clone(); @@ -680,6 +687,7 @@ impl Widget for FileBrowser { } fn refresh(&mut self) -> HResult<()> { //self.proc_view.lock()?.set_coordinates(self.get_coordinates()?); + self.set_title().ok(); self.handle_dir_events().ok(); self.columns.refresh().ok(); self.set_left_selection().log(); diff --git a/src/term.rs b/src/term.rs index d92baa3..641b4b1 100644 --- a/src/term.rs +++ b/src/term.rs @@ -40,6 +40,10 @@ pub trait ScreenExt: Write { let (_, ysize) = termion::terminal_size()?; Ok((ysize - 1) as usize) } + fn set_title(&mut self, title: &str) -> HResult<()> { + write!(self, "\x1b]2;{}", title)?; + Ok(()) + } } impl ScreenExt for AlternateScreen<Box<Stdout>> {} |