/// Redraws the plist on the screen
/// Draws the Footer first, in case it needs to be overwritten
/// Draws the plist next with current selection expanded
/// This allows the currently highlighted item info to be obtained
/// so any special comments can be included in the Header
/// which is drawn last
Redraws the plist on the screen
Draws the Footer first, in case it needs to be overwritten
Draws the plist next with current selection expanded
This allows the currently highlighted item info to be obtained
so any special comments can be included in the Header
which is drawn last
Redraws the plist on the screen Draws the Footer first in case it needs to be overwritten Draws the plist next with current selection expanded This allows the currently highlighted item info to be obtained so any special comments can be included in the Header which is drawn last
pub fn update_screen(
    settings: &mut Settings,
    resources: &Resources,
    stdout: &mut Stdout,
) -> Result<(), Box<dyn Error>> {
    let plist = &resources.config_plist;
    let rows: i32 = size().unwrap().1.into();
    settings.can_expand = false;
    //    let bgc = &settings.bg_col.clone();
    let bgc = "\x1b[0m";
    write!(stdout, "\x1B[{}H", rows - 1)?; // show footer first, in case we need to write over it
    write!(
        stdout,
        " {inv}D{res}/{inv}^x{res}cut {inv}^c{res}op{inv}y{res} {inv}^v{res}/{inv}p{res}aste   {inv}f{res}ind {inv}n{res}ext   \
        {inv}a{res}dd {inv}d{res}el   {inv}M{res}/{inv}m{res}erge {inv}P{res}urge {inv}r{res}eset   {inv}K{res}ey\x1B[0K\r\n {inv}s{res}ave\
        +validate {inv}q{res}uit   {inv}G{res}o build EFI  {inv}{red} {grn} {res}boolean {inv}{mag} {res}data {inv}{blu} \
        {res}integer {inv} {res}string\x1B[0K",
        inv = "\x1b[7m",
//        res = &settings.bg_col,
        res = "\x1b[0m",
        grn = "\x1b[32m",
        red = "\x1b[31m",
        mag = "\x1b[35m",
        blu = "\x1b[34m",
    )?;
    write!(stdout, "\x1B[3H")?; // jump under header
    let mut row = 4;
    let list = plist.as_dictionary().unwrap();
    let keys: Vec<String> = list.keys().map(|s| s.to_string()).collect();
    for (i, k) in keys.iter().enumerate() {
        if row < rows {
            row += display_value(
                k,
                None,
                settings,
                resources,
                list.get(k).unwrap(),
                stdout,
                i,
                0,
            )
            .unwrap();
        }
    }
    #[cfg(debug_assertions)]
    write!(
        stdout,
        "debug-> {:?} {} {:?}",
        settings.sec_length, settings.depth, settings.sec_num
    )?;
    let mut blanks = rows - row - 1;
    if blanks < 0 {
        blanks = 0;
    }
    write!(stdout, "{}", "\r\n\x1B[0K".repeat(blanks as usize))?; // clear rows up to footer
                                                                  // lastly draw the header
    let mut info = String::new();
    settings.res_name(&mut info);
    if info.len() > 20 {
        info = info[0..17].to_string();
        info.push_str("...");
    }
    write!(
        stdout,
        "\x1b[1;{}H\x1b[2KOC \x1b[7mV{}ersion {}",
        (size().unwrap().0 - 16).to_string(),
        //        &settings.bg_col,
        "\x1b[0m",
        settings.oc_build_version,
    )
    .unwrap();
    write!(
        stdout,
        "\x1B[H{}{}   \x1B[0;7mi{}nfo for {}{}{}\r\n\x1B[0K",
        "\x1b[32m", &settings.config_file_name, bgc, "\x1b[4m", &info, bgc,
    )
    .unwrap();
    if settings.depth > 0 {
        write!(stdout, "  \x1B[7mleft{} collapse", bgc).unwrap();
    }
    write!(stdout, "{}", settings.item_instructions,).unwrap();
    if settings.depth == 2 {
        if settings.is_resource() {
            write!(stdout, "  \x1B[7mspace{} toggle", bgc).unwrap();
        }
    }
    if settings.find_string.len() > 0 {
        write!(
            stdout,
            "  \x1B[7mn{} jump to next {}{}{}",
            bgc, "\x1b[4m", settings.find_string, bgc,
        )
        .unwrap();
    }
    if settings.held_key.len() > 0 {
        write!(
            stdout,
            "  {}p{}aste {}{}{}",
            "\x1b[7m", bgc, "\x1b[4m", settings.held_key, bgc,
        )
        .unwrap();
    }
    write!(stdout, "\r\n\x1B[2K\x1B8",).unwrap();
    Ok(())
}
pub fn update_screen ( settings : & mut Settings , resources : & Resources , stdout : & mut Stdout , ) -> Result < ( ) , Box < dyn Error > > { let plist = & resources . config_plist ; let rows : i32 = size ( ) . unwrap ( ) . 1 . into ( ) ; settings . can_expand = false ; //    let bgc = &settings.bg_col.clone(); let bgc = " \x1b " ; write ! ( stdout " \x1B " rows 1 ) ? ; // show footer first, in case we need to write over it write ! ( stdout " \
 \x1B \r \n \
 \
 \x1B " inv " \x1b " //        res = &settings.bg_col, res " \x1b " grn " \x1b " red " \x1b " mag " \x1b " blu " \x1b " ) ? ; write ! ( stdout " \x1B " ) ? ; // jump under header let mut row = 4 ; let list = plist . as_dictionary ( ) . unwrap ( ) ; let keys : Vec < String > = list . keys ( ) . map ( | s | s . to_string ( ) ) . collect ( ) ; for ( i , k ) in keys . iter ( ) . enumerate ( ) { if row < rows { row += display_value ( k , None , settings , resources , list . get ( k ) . unwrap ( ) , stdout , i , 0 , ) . unwrap ( ) ; } } # [ cfg ( debug_assertions ) ] write ! ( stdout " " settings sec_length settings depth settings sec_num ) ? ; let mut blanks = rows - row - 1 ; if blanks < 0 { blanks = 0 ; } write ! ( stdout " " " \r \n \x1B " repeat ( blanks as usize ) ) ? ; // clear rows up to footer // lastly draw the header let mut info = String :: new ( ) ; settings . res_name ( & mut info ) ; if info . len ( ) > 20 { info = info [ 0 .. 17 ] . to_string ( ) ; info . push_str ( " " ) ; } write ! ( stdout " \x1b \x1b \x1b " ( size ( ) unwrap ( ) 0 16 ) to_string ( ) //        &settings.bg_col, " \x1b " settings oc_build_version ) . unwrap ( ) ; write ! ( stdout " \x1B \x1B \r \n \x1B " " \x1b " settings config_file_name bgc " \x1b " info bgc ) . unwrap ( ) ; if settings . depth > 0 { write ! ( stdout " \x1B " bgc ) . unwrap ( ) ; } write ! ( stdout " " settings item_instructions ) . unwrap ( ) ; if settings . depth == 2 { if settings . is_resource ( ) { write ! ( stdout " \x1B " bgc ) . unwrap ( ) ; } } if settings . find_string . len ( ) > 0 { write ! ( stdout " \x1B " bgc " \x1b " settings find_string bgc ) . unwrap ( ) ; } if settings . held_key . len ( ) > 0 { write ! ( stdout " " " \x1b " bgc " \x1b " settings held_key bgc ) . unwrap ( ) ; } write ! ( stdout " \r \n \x1B \x1B " ) . unwrap ( ) ; Ok ( ( ) ) }
Redraws the plist on the screen
Draws the Footer first, in case it needs to be overwritten
Draws the plist next with current selection expanded
This allows the currently highlighted item info to be obtained
so any special comments can be included in the Header
which is drawn last
Redraws the plist on the screen Draws the Footer first in case it needs to be overwritten Draws the plist next with current selection expanded This allows the currently highlighted item info to be obtained so any special comments can be included in the Header which is drawn last
settings
&mut Settings
resources
&Resources
stdout
&mut Stdout