[][src]Struct tinf::Desc

pub struct Desc { /* fields omitted */ }

The names and capabilities that make up a terminal description.

Predefined capabilities are read by indexing a Desc object with a Boolean, Number, or String capability name. For example, desc[bw] returns a bool, desc[cols] returns a u16, and &desc[setaf] returns a &[u8]. User-defined capabilities are queried using the get_*_ext() methods.

An absent capability will be false, 0xffff, or an empty slice, for booleans, numbers, and strings respectively.

The desc! macro provides syntax for Desc literals.

Examples

Read the description for xterm-256color and look up the rs1 capability:

use tinf::Desc;
use tinf::cap::rs1;

let mut file = Desc::file("xterm-256color")?;
let desc = Desc::parse(&mut file)?;
assert_eq!(&desc[rs1], b"\x1bc\x1b]104\x07");

Implementations

impl Desc[src]

pub fn file(term_name: &str) -> Result<File, DescError>[src]

Finds and opens the compiled terminfo description for the terminal named by term_name.

This assumes that the local terminfo database uses a directory tree format for storing compiled descriptions, and it searches in these directories:

  1. The directory named by the TERMINFO environment variable.
  2. $HOME/.terminfo
  3. The list of directories named by the TERMINFO_DIRS environment variable (with empty entries replaced by /usr/share/terminfo).
  4. /etc/terminfo
  5. /lib/terminfo
  6. /usr/share/terminfo

For each directory, file checks for a description named term_name in a subdirectory named by the first letter of term_name as a character or hex representation, for example /x/xterm or /78/xterm. (Note that if term_name has more than one path component, only the last one is used).

#Errors

This returns an error if file could not find and open a description for term_name, or if term_name is invalid.

pub fn parse(r: &mut dyn Read) -> Result<Desc, DescError>[src]

Creates a Desc from a compiled terminfo description.

Errors

This returns an error if the input is not a valid terminfo description.

pub fn current() -> &'static Desc[src]

The description for the terminal type from the TERM environment variable, or the "dumb terminal" description if TERM is empty.

pub fn names(&self) -> &[String][src]

The terminal's names.

pub fn get_bool_ext(&self, name: &UserDef) -> bool[src]

Query a user-defined boolean capability.

If the capability is absent, returns false.

pub fn bool_exts(&self) -> Vec<&UserDef>[src]

List the names of any user-defined boolean capabilities.

pub fn get_num_ext(&self, name: &UserDef) -> u16[src]

Query a user-defined numeric capability.

If the capability is absent, returns 0xffff.

pub fn num_exts(&self) -> Vec<&UserDef>[src]

List the names of any user-defined numeric capabilities.

pub fn get_str_ext(&self, name: &UserDef) -> &[u8][src]

Query a user-defined string capability.

If the capability is absent, returns an empty slice.

pub fn str_exts(&self) -> Vec<&UserDef>[src]

List the names of any user-defined string capabilities.

Trait Implementations

impl Clone for Desc[src]

impl Debug for Desc[src]

impl Index<Boolean> for Desc[src]

type Output = bool

The returned type after indexing.

fn index(&self, idx: Boolean) -> &bool[src]

The value of the boolean capability named by index.

impl Index<Number> for Desc[src]

type Output = u16

The returned type after indexing.

fn index(&self, idx: Number) -> &u16[src]

The value of the numeric capability named by index.

impl Index<String> for Desc[src]

type Output = [u8]

The returned type after indexing.

fn index(&self, idx: String) -> &[u8][src]

The value of the string capability named by index.

Auto Trait Implementations

impl RefUnwindSafe for Desc

impl Send for Desc

impl Sync for Desc

impl Unpin for Desc

impl UnwindSafe for Desc

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.