pub fn add_tab(&mut self, name: u32, path: PathBuf) -> Result<()> {
        let mut tab = Tab::from(name, &path)?;
        self.siv.call_on_id("topbar/center", |view: &mut TextView| {
            let mut current_text: TextContent = view.get_shared_content();
            current_text.set_content(format!(" {}", path.to_str().unwrap()));
        });
        self.siv.call_on_id(
            "current",
            |event_view: &mut OnEventView<MultiSelectView<PathBuf>>| {
                let view = event_view.get_inner_mut();
                view.clear();
                for entry in App::get_path_iter(&tab.c_view)
                    .filter_entry(|e| e.path().is_dir() && !filter::is_hidden(e))
                {
                    let entry = entry.unwrap();
                    match entry.file_name().to_str() {
                        Some(c) => {
                            view.add_item(format!(r"  {}", c), PathBuf::from(entry.path()))
                        }
                        None => {}
                    }
                }
                for entry in App::get_path_iter(&tab.c_view)
                    .filter_entry(|e| e.path().is_file() && !filter::is_hidden(e))
                {
                    let entry = entry.unwrap();
                    match entry.file_name().to_str() {
                        Some(c) => {
                            view.add_item(format!(r"  {}", c), PathBuf::from(entry.path()))
                        }
                        None => {}
                    };
                }
                view.set_selection(0);
            },
        );

        let mut i: usize = 0;
        self.siv
            .call_on_id("parent", |view: &mut MultiSelectView<PathBuf>| {
                view.clear();
                debug!("siv call on id parent {:?}", tab.p_view.to_str());
                match tab.p_view.to_str() {
                    Some("root") => {
                        view.add_item("/", PathBuf::from("/"));
                        view.set_enabled(false);
                        view.set_selection(0);
                    }
                    Some(_) | None => {
                        for (index, entry) in App::get_path_iter(&tab.p_view)
                            .filter_entry(|e| e.path().is_dir() && !filter::is_hidden(e))
                            .enumerate()
                        {
                            let entry = entry.unwrap();
                            if entry.path() == &tab.c_view {
                                i = index;
                            }
                            match entry.file_name().to_str() {
                                Some(c) => view
                                    .add_item(format!("  {}", c), PathBuf::from(entry.path())),
                                None => {}
                            };
                        }
                        for entry in App::get_path_iter(&tab.p_view)
                            .filter_entry(|e| e.path().is_file() && !filter::is_hidden(e))
                        {
                            let entry = entry.unwrap();
                            match entry.file_name().to_str() {
                                Some(c) => view
                                    .add_item(format!("  {}", c), PathBuf::from(entry.path())),
                                None => {}
                            };
                        }
                        view.set_selection(i);
                        view.set_enabled(false);
                    } // None
                };
            });
        tab.focused.insert(PathBuf::from(&tab.p_view), i);
        // tab.p_focused = i;
        debug!("Value of tab: {:?}", tab);
        self.vec_tabs.borrow_mut().insert(1, tab);
        self.focused_entry = i;
        debug!("Value of arr: {:?}", self.vec_tabs.borrow());
        Ok(())
    }
/// [Experimental] Adds a new tab to the main view. Currently only single tab is supported
/// for the sake of simplicity. Multiple tabs support will land in near future.
[Experimental] Adds a new tab to the main view. Currently only single tab is supported
for the sake of simplicity. Multiple tabs support will land in near future.
[ Experimental ] Adds a new tab to the main view . Currently only single tab is supported for the sake of simplicity . Multiple tabs support will land in near future .
pub fn add_tab(&mut self, name: u32, path: PathBuf) -> Result<()> {
        let mut tab = Tab::from(name, &path)?;
        self.siv.call_on_id("topbar/center", |view: &mut TextView| {
            let mut current_text: TextContent = view.get_shared_content();
            current_text.set_content(format!(" {}", path.to_str().unwrap()));
        });
        self.siv.call_on_id(
            "current",
            |event_view: &mut OnEventView<MultiSelectView<PathBuf>>| {
                let view = event_view.get_inner_mut();
                view.clear();
                for entry in App::get_path_iter(&tab.c_view)
                    .filter_entry(|e| e.path().is_dir() && !filter::is_hidden(e))
                {
                    let entry = entry.unwrap();
                    match entry.file_name().to_str() {
                        Some(c) => {
                            view.add_item(format!(r"  {}", c), PathBuf::from(entry.path()))
                        }
                        None => {}
                    }
                }
                for entry in App::get_path_iter(&tab.c_view)
                    .filter_entry(|e| e.path().is_file() && !filter::is_hidden(e))
                {
                    let entry = entry.unwrap();
                    match entry.file_name().to_str() {
                        Some(c) => {
                            view.add_item(format!(r"  {}", c), PathBuf::from(entry.path()))
                        }
                        None => {}
                    };
                }
                view.set_selection(0);
            },
        );
        let mut i: usize = 0;
        self.siv
            .call_on_id("parent", |view: &mut MultiSelectView<PathBuf>| {
                view.clear();
                debug!("siv call on id parent {:?}", tab.p_view.to_str());
                match tab.p_view.to_str() {
                    Some("root") => {
                        view.add_item("/", PathBuf::from("/"));
                        view.set_enabled(false);
                        view.set_selection(0);
                    }
                    Some(_) | None => {
                        for (index, entry) in App::get_path_iter(&tab.p_view)
                            .filter_entry(|e| e.path().is_dir() && !filter::is_hidden(e))
                            .enumerate()
                        {
                            let entry = entry.unwrap();
                            if entry.path() == &tab.c_view {
                                i = index;
                            }
                            match entry.file_name().to_str() {
                                Some(c) => view
                                    .add_item(format!("  {}", c), PathBuf::from(entry.path())),
                                None => {}
                            };
                        }
                        for entry in App::get_path_iter(&tab.p_view)
                            .filter_entry(|e| e.path().is_file() && !filter::is_hidden(e))
                        {
                            let entry = entry.unwrap();
                            match entry.file_name().to_str() {
                                Some(c) => view
                                    .add_item(format!("  {}", c), PathBuf::from(entry.path())),
                                None => {}
                            };
                        }
                        view.set_selection(i);
                        view.set_enabled(false);
                    } // None
                };
            });
        tab.focused.insert(PathBuf::from(&tab.p_view), i);
        // tab.p_focused = i;
        debug!("Value of tab: {:?}", tab);
        self.vec_tabs.borrow_mut().insert(1, tab);
        self.focused_entry = i;
        debug!("Value of arr: {:?}", self.vec_tabs.borrow());
        Ok(())
    }
pub fn add_tab ( & mut self , name : u32 , path : PathBuf ) -> Result < ( ) > { let mut tab = Tab :: from ( name , & path ) ? ; self . siv . call_on_id ( " " , | view : & mut TextView | { let mut current_text : TextContent = view . get_shared_content ( ) ; current_text . set_content ( format ! ( " " path to_str ( ) unwrap ( ) ) ) ; } ) ; self . siv . call_on_id ( " " , | event_view : & mut OnEventView < MultiSelectView < PathBuf > > | { let view = event_view . get_inner_mut ( ) ; view . clear ( ) ; for entry in App :: get_path_iter ( & tab . c_view ) . filter_entry ( | e | e . path ( ) . is_dir ( ) && ! filter :: is_hidden ( e ) ) { let entry = entry . unwrap ( ) ; match entry . file_name ( ) . to_str ( ) { Some ( c ) => { view . add_item ( format ! ( r"  {}",  , P thBuf:: fr om(e n try.p a th() ) ) } None => { } } } for entry in App :: get_path_iter ( & tab . c_view ) . filter_entry ( | e | e . path ( ) . is_file ( ) && ! filter :: is_hidden ( e ) ) { let entry = entry . unwrap ( ) ; match entry . file_name ( ) . to_str ( ) { Some ( c ) => { view . add_item ( format ! ( r"  {}",  , P thBuf:: fr om(e n try.p a th() ) ) } None => { } } ; } view . set_selection ( 0 ) ; } , ) ; let mut i : usize = 0 ; self . siv . call_on_id ( " " , | view : & mut MultiSelectView < PathBuf > | { view . clear ( ) ; debug ! ( " " tab p_view to_str ( ) ) ; match tab . p_view . to_str ( ) { Some ( " " ) => { view . add_item ( " " , PathBuf :: from ( " " ) ) ; view . set_enabled ( false ) ; view . set_selection ( 0 ) ; } Some ( _ ) | None => { for ( index , entry ) in App :: get_path_iter ( & tab . p_view ) . filter_entry ( | e | e . path ( ) . is_dir ( ) && ! filter :: is_hidden ( e ) ) . enumerate ( ) { let entry = entry . unwrap ( ) ; if entry . path ( ) == & tab . c_view { i = index ; } match entry . file_name ( ) . to_str ( ) { Some ( c ) => view . add_item ( format ! ( " , P thBuf:: fr om(e n try.p a th() ) ) , None => { } } ; } for entry in App :: get_path_iter ( & tab . p_view ) . filter_entry ( | e | e . path ( ) . is_file ( ) && ! filter :: is_hidden ( e ) ) { let entry = entry . unwrap ( ) ; match entry . file_name ( ) . to_str ( ) { Some ( c ) => view . add_item ( format ! ( " , P thBuf:: fr om(e n try.p a th() ) ) , None => { } } ; } view . set_selection ( i ) ; view . set_enabled ( false ) ; } // None } ; } ) ; tab . focused . insert ( PathBuf :: from ( & tab . p_view ) , i ) ; // tab.p_focused = i; debug ! ( " " tab ) ; self . vec_tabs . borrow_mut ( ) . insert ( 1 , tab ) ; self . focused_entry = i ; debug ! ( " " self vec_tabs borrow ( ) ) ; Ok ( ( ) ) }
[Experimental] Adds a new tab to the main view.
[ Experimental ] Adds a new tab to the main view .
&mut self
name
u32
path
PathBuf
&mut self
name
u32
path
PathBuf