/// Create a new instance of cursive with default global callbacks.
/// `q` is used to quit the cursive instance.
///
/// TODO `:` is used to open the command box
Create a new instance of cursive with default global callbacks.
`q` is used to quit the cursive instance.


Create a new instance of cursive with default global callbacks . ` q ` is used to quit the cursive instance .
pub fn new() -> Result<Self> {
        let data_path: PathBuf = dirs::config_dir().ok_or(ErrorKind::DirNotFound {
            dirname: String::from("CONFIG_DIR"),
        })?;
        let data_path = data_path.join("marcos");
        if !data_path.exists() {
            stdfs::create_dir_all(&data_path).expect("Cannot create data_dir");
        }
        let asset_file = data_path.join("style.toml");
        debug!("Loading theme from file: {:?}", asset_file);
        if !asset_file.is_file() {
            stdfs::File::create(&asset_file).expect("Failed to create asset file");
        }
        let mut siv = Cursive::default();
        // Create empty views
        let p_widget = MultiSelectView::<PathBuf>::new().with_id("parent");
        let c_widget = MultiSelectView::<PathBuf>::new().on_select(update_info);
        let c_widget = OnEventView::new(c_widget).with_id("current");
        let preview_widget = TextView::new("").with_id("preview");
        let top_widget = LinearLayout::horizontal()
            .child(TextView::new(info::user_info())
                   .h_align(HAlign::Left)
                   .with_id("topbar/left"))
            .child(TextView::new(info::user_info())
                   .h_align(HAlign::Left)
                   .with_id("topbar/center").full_width())
            .child(TextView::new(info::disk_info("/"))
                   .h_align(HAlign::Right)
                   .with_id("topbar/right").full_width());
        // let top_bar = TextView::new(format!("{} {}", info::user_info(), info::disk_info("/")))
        //     .with_id("topbar");
        let mut status_bar = HideableView::new(TextView::new("Status").with_id("status"));
        status_bar.unhide();
        // let console = EditView::new().filler(">").with_id("console");
        // let console = HideableView::new(console);
        // let console = console.with_id("console/vis");
        let status_bar = status_bar.with_id("status/vis");
        // Horizontal panes
        let mut panes = LinearLayout::horizontal();
        panes.add_child(
            Panel::new(p_widget)
                .full_width()
                .max_width(30)
                .full_height(),
        );
        panes.add_child(
            Panel::new(c_widget)
                .full_width()
                .max_width(40)
                .full_height(),
        );
        panes.add_child(Panel::new(preview_widget).full_width().full_height());
        let h_panes = LinearLayout::vertical()
            .child(top_widget.full_width())
            .child(panes)
            // .child(console)
            .child(status_bar);
        siv.add_layer(h_panes);
        siv.add_global_callback(Event::CtrlChar('w'), |s| s.quit());
        siv.add_global_callback('q', |s| s.quit());
        let vec_tabs = Rc::new(RefCell::new(HashMap::<u32, Tab>::new()));
        debug!("Loading theme resource file");
        siv.load_theme_file(asset_file).expect("Cannot find file!");
        Ok(Self {
            siv,
            vec_tabs,
            focused_entry: 0,
            focused_tab: 0,
        })
    }
pub fn new ( ) -> Result < Self > { let data_path : PathBuf = dirs :: config_dir ( ) . ok_or ( ErrorKind :: DirNotFound { dirname : String :: from ( " " ) , } ) ? ; let data_path = data_path . join ( " " ) ; if ! data_path . exists ( ) { stdfs :: create_dir_all ( & data_path ) . expect ( " " ) ; } let asset_file = data_path . join ( " " ) ; debug ! ( " " asset_file ) ; if ! asset_file . is_file ( ) { stdfs :: File :: create ( & asset_file ) . expect ( " " ) ; } let mut siv = Cursive :: default ( ) ; // Create empty views let p_widget = MultiSelectView :: < PathBuf > :: new ( ) . with_id ( " " ) ; let c_widget = MultiSelectView :: < PathBuf > :: new ( ) . on_select ( update_info ) ; let c_widget = OnEventView :: new ( c_widget ) . with_id ( " " ) ; let preview_widget = TextView :: new ( " " ) . with_id ( " " ) ; let top_widget = LinearLayout :: horizontal ( ) . child ( TextView :: new ( info :: user_info ( ) ) . h_align ( HAlign :: Left ) . with_id ( " " ) ) . child ( TextView :: new ( info :: user_info ( ) ) . h_align ( HAlign :: Left ) . with_id ( " " ) . full_width ( ) ) . child ( TextView :: new ( info :: disk_info ( " " ) ) . h_align ( HAlign :: Right ) . with_id ( " " ) . full_width ( ) ) ; // let top_bar = TextView::new(format!("{} {}", info::user_info(), info::disk_info("/"))) //     .with_id("topbar"); let mut status_bar = HideableView :: new ( TextView :: new ( " " ) . with_id ( " " ) ) ; status_bar . unhide ( ) ; // let console = EditView::new().filler(">").with_id("console"); // let console = HideableView::new(console); // let console = console.with_id("console/vis"); let status_bar = status_bar . with_id ( " " ) ; // Horizontal panes let mut panes = LinearLayout :: horizontal ( ) ; panes . add_child ( Panel :: new ( p_widget ) . full_width ( ) . max_width ( 30 ) . full_height ( ) , ) ; panes . add_child ( Panel :: new ( c_widget ) . full_width ( ) . max_width ( 40 ) . full_height ( ) , ) ; panes . add_child ( Panel :: new ( preview_widget ) . full_width ( ) . full_height ( ) ) ; let h_panes = LinearLayout :: vertical ( ) . child ( top_widget . full_width ( ) ) . child ( panes ) // .child(console) . child ( status_bar ) ; siv . add_layer ( h_panes ) ; siv . add_global_callback ( Event :: CtrlChar ( 'w' ) , | s | s . quit ( ) ) ; siv . add_global_callback ( 'q' , | s | s . quit ( ) ) ; let vec_tabs = Rc :: new ( RefCell :: new ( HashMap :: < u32 , Tab > :: new ( ) ) ) ; debug ! ( " " ) ; siv . load_theme_file ( asset_file ) . expect ( " " ) ; Ok ( Self { siv , vec_tabs , focused_entry : 0 , focused_tab : 0 , } ) }
Create a new instance of cursive with default global callbacks.
Create a new instance of cursive with default global callbacks .