Add home button, canonicalize paths
This commit is contained in:
parent
b0d7898cdd
commit
eec07d9631
2 changed files with 31 additions and 20 deletions
14
src/tab.rs
14
src/tab.rs
|
|
@ -49,6 +49,7 @@ pub fn open_command(path: &PathBuf) -> process::Command {
|
|||
#[derive(Clone, Copy, Debug)]
|
||||
pub enum Message {
|
||||
Click(usize),
|
||||
Home,
|
||||
Parent,
|
||||
}
|
||||
|
||||
|
|
@ -69,9 +70,15 @@ pub struct Tab {
|
|||
|
||||
impl Tab {
|
||||
pub fn new<P: Into<PathBuf>>(path: P) -> Self {
|
||||
//TODO: store absolute path
|
||||
let path = path.into();
|
||||
let mut tab = Self {
|
||||
path: path.into(),
|
||||
path: match fs::canonicalize(&path) {
|
||||
Ok(absolute) => absolute,
|
||||
Err(err) => {
|
||||
log::warn!("failed to canonicalize {:?}: {}", path, err);
|
||||
path
|
||||
}
|
||||
},
|
||||
context_menu: None,
|
||||
items: Vec::new(),
|
||||
};
|
||||
|
|
@ -167,6 +174,9 @@ impl Tab {
|
|||
}
|
||||
}
|
||||
}
|
||||
Message::Home => {
|
||||
cd = Some(crate::home_dir());
|
||||
}
|
||||
Message::Parent => {
|
||||
if let Some(parent) = self.path.parent() {
|
||||
cd = Some(parent.to_owned());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue