Struct tinf::Desc
[−]
[src]
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");
Methods
impl Desc
[src]
fn file(term_name: &str) -> Result<File, DescError>
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:
- The directory named by the
TERMINFO
environment variable. $HOME/.terminfo
- The list of directories named by the
TERMINFO_DIRS
environment variable (with empty entries replaced by/usr/share/terminfo
). /etc/terminfo
/lib/terminfo
/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.
fn parse(r: &mut Read) -> Result<Desc, DescError>
Creates a Desc
from a compiled terminfo description.
Errors
This returns an error if the input is not a valid terminfo description.
fn current() -> &'static Desc
The description for the terminal type from the TERM
environment variable, or the "dumb terminal" description if
TERM
is empty.
fn names(&self) -> &[String]
The terminal's names.
fn get_bool_ext(&self, name: &UserDef) -> bool
Query a user-defined boolean capability.
If the capability is absent, returns false
.
fn bool_exts(&self) -> Vec<&UserDef>
List the names of any user-defined boolean capabilities.
fn get_num_ext(&self, name: &UserDef) -> u16
Query a user-defined numeric capability.
If the capability is absent, returns 0xffff
.
fn num_exts(&self) -> Vec<&UserDef>
List the names of any user-defined numeric capabilities.
fn get_str_ext(&self, name: &UserDef) -> &[u8]
Query a user-defined string capability.
If the capability is absent, returns an empty slice.
fn str_exts(&self) -> Vec<&UserDef>
List the names of any user-defined string capabilities.
Trait Implementations
impl Index<Boolean> for Desc
[src]
type Output = bool
The returned type after indexing
fn index(&self, idx: Boolean) -> &bool
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
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]
The value of the string capability named by index
.
impl Clone for Desc
[src]
fn clone(&self) -> Desc
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more