Skip to main content

TermEntry

Struct TermEntry 

Source
pub struct TermEntry {
    pub names: Vec<String>,
    pub bools: Vec<i8>,
    pub nums: Vec<i32>,
    pub strs: Vec<Option<Vec<u8>>>,
    pub ext_bools: HashMap<String, bool>,
    pub ext_nums: HashMap<String, i32>,
    pub ext_strs: HashMap<String, Vec<u8>>,
    pub fix_sgr0: Option<Vec<u8>>,
}
Expand description

One compiled terminfo entry, held as the positional arrays the file stores plus ncurses’ extended-capability maps.

Fields§

§names: Vec<String>

|-separated names from the header, first is the primary name.

§bools: Vec<i8>

Booleans, indexed by position in BOOL_NAMES.

§nums: Vec<i32>

Numbers, indexed by position in NUM_NAMES; ABSENT/CANCELLED.

§strs: Vec<Option<Vec<u8>>>

Strings, indexed by position in STR_NAMES. None is absent.

§ext_bools: HashMap<String, bool>

ncurses extended booleans, by capability name.

§ext_nums: HashMap<String, i32>

ncurses extended numbers, by capability name.

§ext_strs: HashMap<String, Vec<u8>>

ncurses extended strings, by capability name.

§fix_sgr0: Option<Vec<u8>>

ncurses’ FIX_SGR0: the termcap-facing form of sgr0, computed by tgetent and substituted for it by tgetstr. None until tgetent runs, or when the trimmed form equals sgr0 itself.

Implementations§

Source§

impl TermEntry

Source

pub fn parse(b: &[u8]) -> Option<TermEntry>

Parse one compiled entry. Returns None when the bytes are not a terminfo file or are truncated — a corrupt entry is treated the same as a missing one, exactly as ncurses does.

Source

pub fn flag(&self, name: &str) -> i32

Boolean capability by terminfo long name (am, xenl, …), falling back to the extended map. ncurses returns -1 for a name that is not a boolean at all; that is the caller’s tigetflag contract.

Source

pub fn num(&self, name: &str) -> i32

Numeric capability by terminfo long name.

tigetnum(3): “-1 if capname is not a numeric capability, or -2 if it is canceled or absent”. A CANCELLED value stored in the entry (ncv@, colors@) is therefore reported as ABSENT — only an unknown-or-wrong-kind NAME yields CANCELLED. Returning the raw -2 here made $terminfo[ncv] read -2 where zsh reads -1 on 45 of the 394 entries in the reference database.

Source

pub fn string(&self, name: &str) -> Option<&[u8]>

String capability by terminfo long name. None is absent; the wrong-type case is reported separately by TermEntry::str_is_wrong_type so callers can reproduce ncurses’ (char *)-1.

Source

pub fn set_string(&mut self, name: &str, value: Option<Vec<u8>>)

Write (or clear) a string capability by terminfo long name, growing the positional array when the compiled entry was shorter than the slot. Only tgetent’s termcap fixups mutate a loaded entry.

Source

pub fn str_is_wrong_type(&self, name: &str) -> bool

True when name is not a string capability at all, which is what ncurses signals with a (char *)-1 return from tigetstr — for a capability of another kind and for an unknown name alike.

Source

pub fn tc_flag(&self, code: &str) -> i32

Boolean capability by two-letter TERMCAP code (am, xn, …).

Source

pub fn tc_num(&self, code: &str) -> i32

Numeric capability by two-letter TERMCAP code (li, co, Co, …). tgetnum reports a missing capability as -1.

Source

pub fn tc_string(&self, code: &str) -> Option<&[u8]>

String capability by two-letter TERMCAP code (cl, ce, up, …).

rposition, not position: ML is carried by two slots (smgl at 271 and smglr at 368) and ncurses’ _nc_find_type_entry resolves it to the later one, so a position lookup answered with smgl — absent on xterm — and dropped ML from $termcap entirely.

Trait Implementations§

Source§

impl Clone for TermEntry

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TermEntry

Source§

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

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

impl Default for TermEntry

Source§

fn default() -> Self

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> ArchivePointee for T

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<F, W, T, D> Deserialize<With<T, W>, D> for F
where W: DeserializeWith<F, T, D>, D: Fallible + ?Sized, F: ?Sized,

Source§

fn deserialize( &self, deserializer: &mut D, ) -> Result<With<T, W>, <D as Fallible>::Error>

Deserializes using the given deserializer
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> LayoutRaw for T

Source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Gets the layout of the type.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The type for metadata in pointers and references to Self.
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more