[−][src]Struct tinf::Desc
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:
- 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.
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]
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,