diff options
author | qkzk <qu3nt1n@gmail.com> | 2023-10-19 21:09:16 +0200 |
---|---|---|
committer | qkzk <qu3nt1n@gmail.com> | 2023-10-19 21:21:50 +0200 |
commit | 707b3067caa45ffb1b7c187fbfaa6c128c68c70d (patch) | |
tree | da74eb64a758ae6b50c4379fc8c798f2f23098c7 /src/tab.rs | |
parent | b74d60dfe8b54d5ee7a236fb8a8646dfac1fdba1 (diff) |
more args : dual pane, preview second, display full, show hidden. Refactor tab & status instanciation
Diffstat (limited to 'src/tab.rs')
-rw-r--r-- | src/tab.rs | 26 |
1 files changed, 19 insertions, 7 deletions
@@ -58,24 +58,36 @@ pub struct Tab { impl Tab { /// Creates a new tab from args and height. - pub fn new(args: Args, height: usize, users_cache: UsersCache) -> Result<Self> { + pub fn new( + args: &Args, + height: usize, + users_cache: UsersCache, + mount_points: &[&path::Path], + ) -> Result<Self> { let path = std::fs::canonicalize(path::Path::new(&args.path))?; - let directory = Directory::empty(&path, &users_cache)?; + let start_dir = if path.is_dir() { + &path + } else { + path.parent().context("")? + }; + let directory = Directory::empty(start_dir, &users_cache)?; let filter = FilterKind::All; - let show_hidden = false; - let path_content = PathContent::new(&path, users_cache, &filter, show_hidden)?; - let show_hidden = false; + let show_hidden = args.all; + let mut path_content = PathContent::new(start_dir, users_cache, &filter, show_hidden)?; let mode = Mode::Normal; let previous_mode = Mode::Normal; - let window = ContentWindow::new(path_content.content.len(), height); + let mut window = ContentWindow::new(path_content.content.len(), height); let input = Input::default(); let completion = Completion::default(); let must_quit = false; let preview = Preview::Empty; let mut history = History::default(); history.push(&path); - let shortcut = Shortcut::new(&path); + let mut shortcut = Shortcut::new(&path); + shortcut.extend_with_mount_points(mount_points); let searched = None; + let index = path_content.select_file(&path); + window.scroll_to(index); Ok(Self { mode, previous_mode, |