Struct TermInfo

Source
pub struct TermInfo {
    pub name: String,
    pub description: String,
    pub aliases: Vec<String>,
    /* private fields */
}
Expand description

Terminfo database information

Fields§

§name: String§description: String§aliases: Vec<String>

Implementations§

Source§

impl TermInfo

Source

pub fn parse<R: Read>(reader: R) -> Result<TermInfo, Error>

Create terminfo database by parse byte-array directly

Source§

impl TermInfo

Source

pub fn raw_string_cap(&self, cap: StringCapability) -> Option<&[u8]>

Returns the string value for the capability

§Arguments
  • cap - string capability
§Example
use termini::TermInfo;
use termini::StringCapability;

if let Ok(info) = TermInfo::from_env() {
    println!("{:?}", info.raw_string_cap(StringCapability::Bell));
}
Source

pub fn utf8_string_cap(&self, cap: StringCapability) -> Option<&str>

Returns the string value for the capability. If the capability is invalid UTF-8 (ASCII) or doesn’t exists None is returned

§Arguments
  • cap - string capability
§Example
use termini::TermInfo;
use termini::StringCapability;

if let Ok(info) = TermInfo::from_env() {
    println!("{:?}", info.utf8_string_cap(StringCapability::Bell));
}
Source

pub fn number_cap(&self, cap: NumberCapability) -> Option<i32>

Returns the number value for the capability

§Arguments
  • cap - number capability
§Example
use termini::TermInfo;
use termini::NumberCapability;

if let Ok(info) = TermInfo::from_env() {
    println!("{:?}", info.number_cap(NumberCapability::MaxColors));
}
Source

pub fn flag_cap(&self, cap: BoolCapability) -> bool

Returns the bool value for the capability, if the capability is not present, false is returned

§Arguments
  • cap - bool capability
§Example
use termini::TermInfo;
use termini::BoolCapability;

if let Ok(info) = TermInfo::from_env() {
    println!("{:?}", info.flag_cap(BoolCapability::AutoLeftMargin));
}
Source

pub fn extended_cap(&self, name: &str) -> Option<Value<'_>>

Source

pub fn from_env() -> Result<Self, Error>

Create TermInfo database, using TERM environment var.

Source

pub fn from_name(name: &str) -> Result<Self, Error>

Create TermInfo database for the given name

Source

pub fn from_path(file: impl AsRef<Path>) -> Result<TermInfo, Error>

Rad a TermInfo database from a given path

Trait Implementations§

Source§

impl Debug for TermInfo

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for TermInfo

Source§

fn default() -> TermInfo

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.