pub fn for_term(term: &str, db: Option<&str>) -> Result<Self, Error> {
        match db {
            None => {
                // Search directories as described in
                // https://invisible-island.net/ncurses/man/terminfo.5.html
                if let Ok(dir) = std::env::var("TERMINFO") {
                    if let Ok(info) = Self::for_term(term, Some(&dir)) {
                        return Ok(info);
                    }
                } else {
                    if let Ok(home) = std::env::var("HOME") {
                        if let Ok(info) = Self::for_term(term, Some(&format!("{}/.terminfo", home)))
                        {
                            return Ok(info);
                        }
                    }
                }
                if let Ok(dirs) = std::env::var("TERMINFO_DIRS") {
                    let mut i = 0;
                    let mut j = 0;
                    while j <= dirs.len() {
                        if j == dirs.len() || dirs.as_bytes()[j] == b':' {
                            if let Ok(info) = Self::for_term(term, Some(&dirs[i..j])) {
                                return Ok(info);
                            }
                            i = j + 1;
                        }
                        j += 1;
                    }
                }
                if let Ok(info) = Self::for_term(
                    term,
                    Some(&format!(
                        "{}/usr/share/terminfo",
                        std::env::var("PREFIX").unwrap_or(String::from(""))
                    )),
                ) {
                    return Ok(info);
                }
                Err(NotFound.into())
            }
            Some(db) => {
                let t = term.chars().next().ok_or(Error::from(InvalidInput))?;
                Self::from_file(
                    File::open(format!("{}/{}/{}", db, t, term))
                        .or_else(|_| File::open(format!("{}/{:2x}/{}", db, t as u8, term)))?,
                )
            }
        }
    }
/// Load the terminfo for a specific terminal named `term`.
/// `db` gives the name of a specific directory to use for the terminfo
/// database.
///
/// If `db` is `None`, then the following directories are searched:
///     1) either `$TERMINFO` or `$HOME/.terminfo`
///     2) the colon separated directories `$TERMINFO_DIRS` (in order).
///     3) `$PREFIX/usr/share/terminfo`
Load the terminfo for a specific terminal named `term`.
`db` gives the name of a specific directory to use for the terminfo
database.


Load the terminfo for a specific terminal named ` term ` . ` db ` gives the name of a specific directory to use for the terminfo database .
pub fn for_term(term: &str, db: Option<&str>) -> Result<Self, Error> {
        match db {
            None => {
                // Search directories as described in
                // https://invisible-island.net/ncurses/man/terminfo.5.html
                if let Ok(dir) = std::env::var("TERMINFO") {
                    if let Ok(info) = Self::for_term(term, Some(&dir)) {
                        return Ok(info);
                    }
                } else {
                    if let Ok(home) = std::env::var("HOME") {
                        if let Ok(info) = Self::for_term(term, Some(&format!("{}/.terminfo", home)))
                        {
                            return Ok(info);
                        }
                    }
                }
                if let Ok(dirs) = std::env::var("TERMINFO_DIRS") {
                    let mut i = 0;
                    let mut j = 0;
                    while j <= dirs.len() {
                        if j == dirs.len() || dirs.as_bytes()[j] == b':' {
                            if let Ok(info) = Self::for_term(term, Some(&dirs[i..j])) {
                                return Ok(info);
                            }
                            i = j + 1;
                        }
                        j += 1;
                    }
                }
                if let Ok(info) = Self::for_term(
                    term,
                    Some(&format!(
                        "{}/usr/share/terminfo",
                        std::env::var("PREFIX").unwrap_or(String::from(""))
                    )),
                ) {
                    return Ok(info);
                }
                Err(NotFound.into())
            }
            Some(db) => {
                let t = term.chars().next().ok_or(Error::from(InvalidInput))?;
                Self::from_file(
                    File::open(format!("{}/{}/{}", db, t, term))
                        .or_else(|_| File::open(format!("{}/{:2x}/{}", db, t as u8, term)))?,
                )
            }
        }
    }
pub fn for_term ( term : & str , db : Option < & str > ) -> Result < Self , Error > { match db { None => { // Search directories as described in // https://invisible-island.net/ncurses/man/terminfo.5.html if let Ok ( dir ) = std :: env :: var ( " " ) { if let Ok ( info ) = Self :: for_term ( term , Some ( & dir ) ) { return Ok ( info ) ; } } else { if let Ok ( home ) = std :: env :: var ( " " ) { if let Ok ( info ) = Self :: for_term ( term , Some ( & format ! ( " " home ) ) ) { return Ok ( info ) ; } } } if let Ok ( dirs ) = std :: env :: var ( " " ) { let mut i = 0 ; let mut j = 0 ; while j <= dirs . len ( ) { if j == dirs . len ( ) || dirs . as_bytes ( ) [ j ] == b':' { if let Ok ( info ) = Self :: for_term ( term , Some ( & dirs [ i .. j ] ) ) { return Ok ( info ) ; } i = j + 1 ; } j += 1 ; } } if let Ok ( info ) = Self :: for_term ( term , Some ( & format ! ( " " std env var ( " " ) unwrap_or ( String from ( " " ) ) ) ) , ) { return Ok ( info ) ; } Err ( NotFound . into ( ) ) } Some ( db ) => { let t = term . chars ( ) . next ( ) . ok_or ( Error :: from ( InvalidInput ) ) ? ; Self :: from_file ( File :: open ( format ! ( " " db t term ) ) . or_else ( | _ | File :: open ( format ! ( " " db t as u8 term ) ) ) ? , ) } } }
Load the terminfo for a specific terminal named `term`.
Load the terminfo for a specific terminal named ` term ` .
term
&str
db
Option<&str>
term
&str
db
Option<&str>