Struct nixterm::terminfo::TermInfo [−][src]
pub struct TermInfo<'a> { /* fields omitted */ }
TermInfo is immutable terminfo data.
To mutate TermInfo
use TermInfo::into<TermInfoBuf>()
to get a TermInfoBuf
struct.
Generally, the TermInfo
struct is good for quickly peeking at terminfo file. It is fast,
and makes no allocations, however it cannot be modified, and is difficult to use over a long period of time,
since the buffer it parsed has to live along side it.
Methods
impl<'a> TermInfo<'a>
[src]
impl<'a> TermInfo<'a>
pub fn parse(bytes: &'a [u8]) -> Result<TermInfo<'a>>
[src]
pub fn parse(bytes: &'a [u8]) -> Result<TermInfo<'a>>
Parse a terminfo file from a buffer.
Example
use std::io; use std::io::prelude::*; use std::fs::File; use nixterm::terminfo; fn main() { let mut data = Vec::new(); File::open("/usr/share/terminfo/x/xterm") .unwrap() .read_to_end(&mut data); let info = terminfo::TermInfo::parse(&data).unwrap(); assert_eq!(info.boolean(terminfo::AutoLeftMargin), false); }
pub fn names(
&self
) -> impl Iterator<Item = &str>
[src]
pub fn names(
&self
) -> impl Iterator<Item = &str>
Get an iterator over the terminal's name(s)
The first name is generally the primary one, for example XTerm's first name is "xterm". The following names will usually be longer. Sometimes they will describe this terminal (e.g. linux-16color's second name is "linux console with 16 colors"). Other names may expand on the first name if it is an acronym (e.g. kitty's second name is "KovIdTTY").
pub fn number(&self, field: NumericField) -> Option<u16>
[src]
pub fn number(&self, field: NumericField) -> Option<u16>
Get a numeric field.
Not all terminals will include a value for every field enumerated in NumericField
.
pub fn boolean(&self, field: BooleanField) -> bool
[src]
pub fn boolean(&self, field: BooleanField) -> bool
Get a boolean field.
Not all terminals will include a value for every field enumerated in BooleanField
. boolean
will return false if a value is missing.
pub fn string(&self, field: StringField) -> Option<&str>
[src]
pub fn string(&self, field: StringField) -> Option<&str>
Get a string field.
Not all terminals will include a value for every field enumerated in StringField
.
pub fn has_ext(&self) -> bool
[src]
pub fn has_ext(&self) -> bool
Check if the the terminfo file has an extensions section
If this method returns false then the TermInfo::ext_*
methods won't fail. However TermInfo::ext_boolean
will always return false, and TermInfo::ext_number
and TermInfo::ext_string
will always return None.
pub fn ext_boolean<T: AsRef<str>>(&self, field: T) -> bool
[src]
pub fn ext_boolean<T: AsRef<str>>(&self, field: T) -> bool
This method is identical to TermInfo::boolean
, except the boolean is identified with a string.
pub fn ext_number<T: AsRef<str>>(&self, field: T) -> Option<u16>
[src]
pub fn ext_number<T: AsRef<str>>(&self, field: T) -> Option<u16>
This method is identified to Terminfo::number
, except the number is identified by a string.
pub fn ext_string<T: AsRef<str>>(&self, field: T) -> Option<&str>
[src]
pub fn ext_string<T: AsRef<str>>(&self, field: T) -> Option<&str>
This method is identified to Terminfo::string
, except the string is identified by a string.
Trait Implementations
impl<'a> Debug for TermInfo<'a>
[src]
impl<'a> Debug for TermInfo<'a>
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl<'a> Clone for TermInfo<'a>
[src]
impl<'a> Clone for TermInfo<'a>
fn clone(&self) -> TermInfo<'a>
[src]
fn clone(&self) -> TermInfo<'a>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl<'a> From<TermInfo<'a>> for TermInfoBuf
[src]
impl<'a> From<TermInfo<'a>> for TermInfoBuf
fn from(src: TermInfo<'a>) -> TermInfoBuf
[src]
fn from(src: TermInfo<'a>) -> TermInfoBuf
Performs the conversion.
impl<'a> From<&'a TermInfo<'a>> for TermInfoBuf
[src]
impl<'a> From<&'a TermInfo<'a>> for TermInfoBuf
fn from(src: &'a TermInfo<'a>) -> TermInfoBuf
[src]
fn from(src: &'a TermInfo<'a>) -> TermInfoBuf
Performs the conversion.