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>§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
impl TermEntry
Sourcepub fn parse(b: &[u8]) -> Option<TermEntry>
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.
Sourcepub fn flag(&self, name: &str) -> i32
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.
Sourcepub fn num(&self, name: &str) -> i32
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.
Sourcepub fn string(&self, name: &str) -> Option<&[u8]>
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.
Sourcepub fn set_string(&mut self, name: &str, value: Option<Vec<u8>>)
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.
Sourcepub fn str_is_wrong_type(&self, name: &str) -> bool
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.
Sourcepub fn tc_flag(&self, code: &str) -> i32
pub fn tc_flag(&self, code: &str) -> i32
Boolean capability by two-letter TERMCAP code (am, xn, …).
Sourcepub fn tc_num(&self, code: &str) -> i32
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.
Sourcepub fn tc_string(&self, code: &str) -> Option<&[u8]>
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§
Auto Trait Implementations§
impl Freeze for TermEntry
impl RefUnwindSafe for TermEntry
impl Send for TermEntry
impl Sync for TermEntry
impl Unpin for TermEntry
impl UnsafeUnpin for TermEntry
impl UnwindSafe for TermEntry
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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