### Example: Get MaxColors Capability Source: https://docs.rs/terminfo/0.9.0/src/terminfo/database.rs.html Demonstrates how to get the `MaxColors` capability from a `Database` loaded from the environment. ```rust use terminfo::{Database, capability as cap}; let info = Database::from_env().unwrap(); let colors: i32 = info.get::().unwrap().into(); ``` -------------------------------- ### Simple Terminal Capability Example Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.ExitAttributeMode.html This example shows how to retrieve and use various terminal capabilities, including setting foreground and background colors, and finally exiting attribute mode using ExitAttributeMode. ```rust fn main() { let info = Database::from_env().unwrap(); if let Some(cap::MaxColors(n)) = info.get::() { println!("The terminal supports {} colors.", n); } else { println!("The terminal does not support colors, what year is this?"); } if let Some(flash) = info.get::() { flash.expand().to(io::stdout()).unwrap(); } else { println!("FLASH GORDON!"); } info.get::().unwrap().expand().color(2).to(io::stdout()).unwrap(); info.get::().unwrap().expand().color(4).to(io::stdout()).unwrap(); println!("SUP"); info.get::().unwrap().expand().to(io::stdout()).unwrap(); } ``` -------------------------------- ### Example: Check for Truecolor Support Source: https://docs.rs/terminfo/0.9.0/src/terminfo/database.rs.html Demonstrates how to check for truecolor support by querying the raw capability 'Tc'. ```rust use terminfo::Database; let info = Database::from_env().unwrap(); let truecolor = info.raw("Tc").is_some(); ``` -------------------------------- ### Example Calling a Crate Function Source: https://docs.rs/terminfo/0.9.0/scrape-examples-help.html This example demonstrates how an external crate's function can be called within a Rust project's example file. Rustdoc uses such examples to document the called function. ```rust // examples/ex.rs fn main() { a_crate::a_func(); } ``` -------------------------------- ### Example: Move Cursor with expand! Source: https://docs.rs/terminfo/0.9.0/src/terminfo/expand.rs.html Demonstrates using the `expand!` macro to write a terminfo capability to stdout, specifically for moving the cursor to a given position. ```rust use terminfo::{Database, capability as cap, expand}; use std::io; # fn main() { let info = Database::from_env().unwrap(); // Move the cursor to X: 20, Y: 30 expand!(io::stdout(), info.get::().unwrap().as_ref(); 20, 30).unwrap(); # } ``` -------------------------------- ### Example: Set Foreground Color with expand! Source: https://docs.rs/terminfo/0.9.0/src/terminfo/expand.rs.html Shows how to use the `expand!` macro to capture terminfo capability expansions into a variable for later use, such as setting text colors. ```rust use terminfo::{Database, capability as cap, expand}; use std::io; # fn main() { let info = Database::from_env().unwrap(); // Set foreground color to red. let red = expand!(info.get::().unwrap().as_ref(); 1).unwrap(); let on_blue = expand!(info.get::().unwrap().as_ref(); 4).unwrap(); # } ``` -------------------------------- ### TryInto Implementation Example Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.OutputResLine.html Demonstrates the generic TryInto trait implementation, allowing conversion into other types that implement TryFrom. ```rust fn try_into(self) -> Result>::Error> where U: TryFrom, ``` -------------------------------- ### KeySCreate::expand Method Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.KeySCreate.html Begins the process of expanding a KeySCreate capability. This method is used to get an iterator over the expanded capability values. ```rust pub fn expand(&self) -> Expansion<'_, KeySCreate<'_>> ``` -------------------------------- ### Get Max Colors Capability Source: https://docs.rs/terminfo/0.9.0/terminfo/struct.Database.html Retrieves the maximum number of colors supported by the terminal. This example demonstrates how to use `get` with a specific capability type. ```rust use terminfo::{Database, capability as cap}; let info = Database::from_env().unwrap(); let colors: i32 = info.get::().unwrap().into(); ``` -------------------------------- ### StartBitImage::expand Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.StartBitImage.html Begins the expansion process for the capability, returning an Expansion object. ```APIDOC ## StartBitImage::expand ``` pub fn expand(&self) -> Expansion<'_, StartBitImage<'_>> ``` Begin expanding the capability. ``` -------------------------------- ### Expand and Apply Terminal Capabilities Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.Expansion.html This example demonstrates expanding various terminal capabilities, including screen flashing and setting foreground/background colors. It also shows how to exit attribute mode. Ensure the terminal supports the requested capabilities. ```rust 4fn main() { 5 let info = Database::from_env().unwrap(); 6 7 if let Some(cap::MaxColors(n)) = info.get::() { 8 println!("The terminal supports {} colors.", n); 9 } else { 10 println!("The terminal does not support colors, what year is this?"); 11 } 12 13 if let Some(flash) = info.get::() { 14 flash.expand().to(io::stdout()).unwrap(); 15 } else { 16 println!("FLASH GORDON!"); 17 } 18 19 info.get::().unwrap().expand().color(2).to(io::stdout()).unwrap(); 20 info.get::().unwrap().expand().color(4).to(io::stdout()).unwrap(); 21 println!("SUP"); 22 info.get::().unwrap().expand().to(io::stdout()).unwrap(); 23} ``` -------------------------------- ### Exit Attribute Mode Example Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.ExitAttributeMode.html This example demonstrates how to use ExitAttributeMode to clear attributes after setting them. It first sets bold and underline attributes and then uses ExitAttributeMode to reset them. ```rust fn main() { let info = Database::from_env().unwrap(); if let Some(set_attributes) = info.get::() { let clear = info.get::().unwrap(); set_attributes.expand().bold(true).underline(true).to(io::stdout()).unwrap(); println!("bold and underline"); clear.expand().to(io::stdout()).unwrap(); } else { println!("The terminal does not support mass-setting attributes"); } } ``` -------------------------------- ### Expand Capability - StartBitImage Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.StartBitImage.html Begins the expansion of the capability. This method is part of the StartBitImage struct's implementation. ```rust pub fn expand(&self) -> Expansion<'_, StartBitImage<'_>> ``` -------------------------------- ### Any::type_id Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.ExitSuperscriptMode.html Gets the TypeId of the ExitSuperscriptMode instance. ```APIDOC ## Any::type_id ### Description Gets the `TypeId` of `self`. ### Method `fn type_id(&self) -> TypeId` ``` -------------------------------- ### Parse Terminfo Database from Path Source: https://docs.rs/terminfo/0.9.0/src/parse/parse.rs.html This example shows how to load a terminfo database from a file path provided as a command-line argument. Ensure the file path is passed correctly when running the program. ```rust 1// DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 2// Version 2, December 2004 3// 4// Copyleft (ↄ) meh. | http://meh.schizofreni.co 5// 6// Everyone is permitted to copy and distribute verbatim or modified 7// copies of this license document, and changing it is allowed as long 8// as the name is changed. 9// 10// DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 11// TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 12// 13// 0. You just DO WHAT THE FUCK YOU WANT TO. 14 15use std::env; 16 17fn main() { 18 println!("{:?}", terminfo::Database::from_path(env::args().nth(1).expect("no file given"))); 19} ``` -------------------------------- ### Expand ParmUpCursor Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.ParmUpCursor.html Demonstrates how to begin expanding the ParmUpCursor capability to get its `Expansion` representation. ```APIDOC ## impl<'a> ParmUpCursor<'a> ### fn expand(&self) -> Expansion<'_, ParmUpCursor<'_>> Begin expanding the capability. #### Returns An `Expansion` object that allows for further processing of the capability. ``` -------------------------------- ### Capability Retrieval Source: https://docs.rs/terminfo/0.9.0/src/terminfo/database.rs.html Functions to get terminal capabilities, either typed or as raw values. ```APIDOC ## `get` ### Description Get a capability. ### Example ``` use terminfo::{Database, capability as cap}; let info = Database::from_env().unwrap(); let colors: i32 = info.get::().unwrap().into(); ``` ### Signature `pub fn get<'a, C: Capability<'a>>(&'a self) -> Option` ## `raw` ### Description Get a capability by name. ### Note This interface only makes sense for extended capabilities since they don't have standardized types. ### Example ``` use terminfo::Database; let info = Database::from_env().unwrap(); let truecolor = info.raw("Tc").is_some(); ``` ### Signature `pub fn raw>(&self, name: S) -> Option<&Value>` ``` -------------------------------- ### KeyCreate::expand Method Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.KeyCreate.html Begins the expansion of a capability. This method returns an `Expansion` object that can be used to further process the capability. ```rust pub fn expand(&self) -> Expansion<'_, KeyCreate<'_>> ``` -------------------------------- ### InitProg::expand Method Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.InitProg.html Begins the process of expanding the initialization program capability. Returns an `Expansion` object that can be further processed. ```APIDOC ## InitProg::expand ```rust pub fn expand(&self) -> Expansion<'_, InitProg<'_>> ``` ### Description Begin expanding the capability. ``` -------------------------------- ### Expand ChangeScrollRegion Capability Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.ChangeScrollRegion.html Begins expanding the ChangeScrollRegion capability. This is used to get a representation that can be further processed. ```rust pub fn expand(&self) -> Expansion<'_, ChangeScrollRegion<'_>> ``` -------------------------------- ### Init3String::expand Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.Init3String.html Begins expanding the capability. Returns an Expansion iterator. ```APIDOC ## Init3String::expand ### Description Begin expanding the capability. ### Method `pub fn expand(&self) -> Expansion<'_, Init3String<'_>>` ### Parameters * `&self`: A reference to the Init3String instance. ### Returns An `Expansion` iterator that yields the expanded string components. ``` -------------------------------- ### EraseChars::expand Method Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.EraseChars.html Begins the expansion of the EraseChars capability. This is used to get a structured representation of the capability. ```rust pub fn expand(&self) -> Expansion<'_, EraseChars<'_>> ``` -------------------------------- ### KeyCreate::expand Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.KeyCreate.html Begins the expansion of the capability. This method is part of the KeyCreate struct and returns an Expansion object. ```APIDOC ## KeyCreate::expand ### Description Begin expanding the capability. ### Method `pub fn expand(&self) -> Expansion<'_, KeyCreate<'_>>` ### Returns An `Expansion` object that allows for further processing of the capability. ``` -------------------------------- ### Any::type_id Implementation Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.AcsLLcorner.html Gets the TypeId of the AcsLLcorner instance. This is part of the Any trait, used for dynamic type checking. ```rust fn type_id(&self) -> TypeId ``` -------------------------------- ### expand Method Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.KeyF7.html Begins the expansion of the KeyF7 capability, returning an Expansion object. ```APIDOC ## expand ```rust pub fn expand(&self) -> Expansion<'_, KeyF7<'_>> ``` ### Description This method initiates the process of expanding the KeyF7 capability. It returns an `Expansion` object which can be used to further process or interpret the capability's expanded form. The `Expansion` object is generic over a lifetime and the `KeyF7` type itself. ``` -------------------------------- ### Error::cause() (Deprecated) Source: https://docs.rs/terminfo/0.9.0/terminfo/enum.Error.html Deprecated method for getting the underlying cause of the error. Use Error::source() instead. ```rust fn cause(&self) -> Option<&dyn Error> ``` -------------------------------- ### KeySHelp::expand Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.KeySHelp.html Begins the expansion process for the KeySHelp capability, returning an Expansion object. ```APIDOC ## KeySHelp::expand ```rust pub fn expand(&self) -> Expansion<'_, KeySHelp<'_>> ``` ### Description This method initiates the expansion of the KeySHelp capability. It returns an `Expansion` object that can be used to further process or retrieve the expanded capability data. ``` -------------------------------- ### Capability Trait Implementation for KeySMessage Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.KeySMessage.html Provides methods for interacting with KeySMessage as a capability, including getting its name and parsing/converting it. ```APIDOC ## impl<'a> Capability<'a> for KeySMessage<'a> ### Methods #### `name() -> &'static str` Returns the name of the capability in its long form. #### `from(value: Option<&'a Value>) -> Option>` Parse the capability from its raw value. #### `into(self) -> Option` Convert the capability into its raw value. ``` -------------------------------- ### KeySDl Equality and Cloning Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.KeySDl.html Details on how to compare KeySDl instances for equality and how to create copies of them. ```APIDOC ## Equality and Cloning for KeySDl ### `Clone` #### `clone(&self) -> KeySDl<'a>` Returns a duplicate of the value. #### `clone_from(&mut self, source: &Self)` Performs copy-assignment from `source`. ### `PartialEq` #### `eq(&self, other: &KeySDl<'a>) -> bool` Tests for `self` and `other` values to be equal, and is used by `==`. #### `ne(&self, other: &Rhs) -> bool` Tests for `!=`. ### `Eq` This trait indicates that equality is reflexive, symmetric, and transitive. ``` -------------------------------- ### KeyRight::expand Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.KeyRight.html Begins expanding the capability. Returns an Expansion struct which can be used to get the capability's value. ```APIDOC ### impl<'a> KeyRight<'a> #### pub fn expand(&self) -> Expansion<'_, KeyRight<'_>> Begin expanding the capability. ``` -------------------------------- ### KeyF62::expand Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.KeyF62.html Begins expanding the capability, returning an Expansion object. ```APIDOC ## impl<'a> KeyF62<'a> ### pub fn expand(&self) -> Expansion<'_, KeyF62<'_>> Begin expanding the capability. ``` -------------------------------- ### Capability Trait Implementation Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.Init1String.html Provides methods for interacting with the capability, such as getting its name, parsing from a value, and converting into a value. ```APIDOC ### impl<'a> Capability<'a> for Init1String<'a> #### fn name() -> &'static str Returns the name of the capability in its long form. #### fn from(value: Option<&'a Value>) -> Option> Parse the capability from its raw value. #### fn into(self) -> Option Convert the capability into its raw value. ``` -------------------------------- ### KeyHelp::expand Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.KeyHelp.html Begins the expansion process for the KeyHelp capability, returning an Expansion object. ```APIDOC ## KeyHelp::expand ### Description Begin expanding the capability. ### Method `pub fn expand(&self) -> Expansion<'_, KeyHelp<'_>>` ### Parameters - `&self`: A reference to the `KeyHelp` instance. ### Returns An `Expansion` object for the `KeyHelp` capability. ``` -------------------------------- ### CrtNoScrolling::name() - Get Capability Name Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.CrtNoScrolling.html Returns the long-form name of the CrtNoScrolling capability. This is useful for introspection and debugging. ```rust fn name() -> &'static str; ``` -------------------------------- ### Parse Disable Entry - Rust Source: https://docs.rs/terminfo/0.9.0/src/terminfo/parser/source.rs.html Parses a 'disable' entry, typically starting with '@'. It extracts the name of the capability to be disabled. ```rust fn disable(input: &[u8]) -> IResult<&[u8], Item> { let (input, _) = ws(input)?; let (input, _) = take_while(is_ws)(input)?; let (input, _) = tag("@")(input)?; let (input, name) = map(take_while(is_printable_no_control), |n| unsafe { str::from_utf8_unchecked(n) })( input, )?; let (input, _) = tag(",")(input)?; let (input, _) = take_while(is_ws)(input)?; let (input, _) = end(input)?; let (input, _) = opt(complete(take_while(is_eol)))(input)?; Ok((input, Item::Disable(name))) } ``` -------------------------------- ### PartialEq and Eq Implementations Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.KeyOpen.html Enables comparison of KeyOpen instances for equality. ```APIDOC ### impl<'a> PartialEq for KeyOpen<'a> #### fn eq(&self, other: &KeyOpen<'a>) -> bool Tests for `self` and `other` values to be equal, and is used by `==`. #### fn ne(&self, other: &Rhs) -> bool Tests for `!=`. ### impl<'a> Eq for KeyOpen<'a> ``` -------------------------------- ### KeySEnd::expand Method Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.KeySEnd.html Begins the expansion of the KeySEnd capability. This method returns an Expansion object. ```rust pub fn expand(&self) -> Expansion<'_, KeySEnd<'_>> ``` -------------------------------- ### Parse Comment - Rust Source: https://docs.rs/terminfo/0.9.0/src/terminfo/parser/source.rs.html Parses a comment line starting with '#'. It trims whitespace and handles potential trailing newlines. ```rust fn comment(input: &[u8]) -> IResult<&[u8], Item> { let (input, _) = tag("#")(input)?; let (input, content) = map_res(terminated(take_until("\n"), tag("\n")), str::from_utf8)(input)?; let (input, _) = opt(complete(take_while(is_eol)))(input)?; Ok((input, Item::Comment(content.trim()))) } ``` -------------------------------- ### KeyOpen::expand Method Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.KeyOpen.html Initiates the expansion of the capability. This method is used to begin processing the capability's definition. ```rust pub fn expand(&self) -> Expansion<'_, KeyOpen<'_>> ``` -------------------------------- ### Basic Function Definition for Scraping Source: https://docs.rs/terminfo/0.9.0/scrape-examples-help.html This is a simple public function definition in Rust. Rustdoc can scrape examples that call such functions. ```rust // src/lib.rs pub fn a_func() {} ``` -------------------------------- ### expand Method Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.KeyF24.html Begins the expansion of the KeyF24 capability, returning an Expansion object. ```APIDOC ## Method: expand ### Description Begin expanding the capability. ### Signature ```rust pub fn expand(&self) -> Expansion<'_, KeyF24<'_>> ``` ``` -------------------------------- ### Basic unwrap() usage Source: https://docs.rs/terminfo/0.9.0/terminfo/type.Result.html Demonstrates the basic usage of `unwrap()` to get the value from an `Ok` variant. Panics if the `Result` is an `Err`. ```rust let x: Result = Ok(2); assert_eq!(x.unwrap(), 2); ``` -------------------------------- ### Error::description() (Deprecated) Source: https://docs.rs/terminfo/0.9.0/terminfo/enum.Error.html Deprecated method for getting a string description of the error. Use the Display impl or to_string() instead. ```rust fn description(&self) -> &str ``` -------------------------------- ### Equality and Cloning Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.SetCursorStyle.html Documents the implementations for `PartialEq`, `Eq`, and `Clone` for `SetCursorStyle`, enabling comparison between instances and the creation of copies. ```APIDOC ### impl<'a> Clone for SetCursorStyle<'a> #### fn clone(&self) -> SetCursorStyle<'a> Returns a duplicate of the `SetCursorStyle` instance. ### impl<'a> PartialEq for SetCursorStyle<'a> #### fn eq(&self, other: &SetCursorStyle<'a>) -> bool Tests for equality between two `SetCursorStyle` instances. ``` -------------------------------- ### Capability Trait Implementation for SetLrMargin Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.SetLrMargin.html Provides methods for interacting with SetLrMargin as a terminfo capability, including getting its name and parsing/converting it. ```rust fn name() -> &'static str ``` ```rust fn from(value: Option<&'a Value>) -> Option> ``` ```rust fn into(self) -> Option ``` -------------------------------- ### Build a new terminfo database Source: https://docs.rs/terminfo/0.9.0/src/terminfo/database.rs.html Use the `Database::new()` function to get a builder, then chain methods to set name, aliases, description, and capabilities before calling `build()`. ```rust use terminfo::{Database, capability as cap}; let mut info = Database::new(); info.name("foo"); info.description("foo terminal"); // Set the amount of available colors. info.set(cap::MaxColors(16)); info.build().unwrap(); ``` -------------------------------- ### PKeyLocal::expand Method Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.PKeyLocal.html Begins the expansion of a capability. This method returns an Expansion object that can be used to iterate over the expanded capability. ```rust pub fn expand(&self) -> Expansion<'_, PKeyLocal<'_>> ``` -------------------------------- ### Capability Trait Implementation for SelectCharSet Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.SelectCharSet.html Provides core functionality for SelectCharSet as a terminfo capability, including getting its name and parsing/converting it. ```rust fn name() -> &'static str ``` ```rust fn from(value: Option<&'a Value>) -> Option> ``` ```rust fn into(self) -> Option ``` -------------------------------- ### From Implementation Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.KeyPrevious.html Allows KeyPrevious to be created from types that can be referenced as byte slices. ```APIDOC ### impl<'a, T: AsRef<&'a [u8]>> From for KeyPrevious<'a> #### fn from(value: T) -> Self Converts to this type from the input type. ``` -------------------------------- ### Test Variable Parsing Source: https://docs.rs/terminfo/0.9.0/src/terminfo/parser/expansion.rs.html Tests parsing of various variable-related sequences, including length, push, set, and get operations. ```Rust test!(b"%l" => Variable(Variable::Length)); test!(b"%p1" => Variable(Variable::Push(0))); test!(b"%Pa" => Variable(Variable::Set(true, 0))); test!(b"%PA" => Variable(Variable::Set(false, 0))); test!(b"%ga" => Variable(Variable::Get(true, 0))); test!(b"%gA" => Variable(Variable::Get(false, 0))); ``` -------------------------------- ### fn report(self) -> ExitCode Source: https://docs.rs/terminfo/0.9.0/terminfo/type.Result.html Is called to get the representation of the value as status code. This status code is returned to the operating system. ```APIDOC ## fn report(self) -> ExitCode ### Description Is called to get the representation of the value as status code. This status code is returned to the operating system. ### Returns - `ExitCode`: The exit code representing the `Result`. ``` -------------------------------- ### KeySHome::expand Method Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.KeySHome.html Begins the expansion of the KeySHome capability. This method is part of the Capability trait implementation. ```rust pub fn expand(&self) -> Expansion<'_, KeySHome<'_>> ``` -------------------------------- ### StartCharSetDef::expand Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.StartCharSetDef.html Begins the process of expanding the capability. This method is part of the `StartCharSetDef` struct's public API. ```APIDOC ## impl<'a> StartCharSetDef<'a> ### pub fn expand(&self) -> Expansion<'_, StartCharSetDef<'_>> Begin expanding the capability. ``` -------------------------------- ### Database::from_env Source: https://docs.rs/terminfo/0.9.0/terminfo/struct.Database.html Loads a terminfo database from the current environment. This is often the most convenient way to get the database for the terminal you are currently running in. ```APIDOC ## Database::from_env ### Description Load a database from the current environment. ### Method `pub fn from_env() -> Result` ### Example ```rust use terminfo::Database; let info = Database::from_env().unwrap(); ``` ``` -------------------------------- ### KeyF20::expand Method Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.KeyF20.html Begins the expansion of the KeyF20 capability, returning an Expansion object. ```rust pub fn expand(&self) -> Expansion<'_, KeyF20<'_>> ``` -------------------------------- ### Capability Trait Implementation Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.ParmDownMicro.html Implementation of the `Capability` trait, providing methods for getting the capability name, parsing from a value, and converting into a value. ```APIDOC ### impl<'a> Capability<'a> for ParmDownMicro<'a> #### fn name() -> &'static str Returns the name of the capability in its long form. #### fn from(value: Option<&'a Value>) -> Option> Parse the capability from its raw value. #### fn into(self) -> Option Convert the capability into its raw value. ``` -------------------------------- ### Capability Trait Implementation for LinefeedIfNotLf Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.LinefeedIfNotLf.html Provides methods for interacting with the LinefeedIfNotLf capability, including getting its name and parsing/converting it from raw values. ```rust fn name() -> &'static str ``` ```rust fn from(value: Option<&'a Value>) -> Option> ``` ```rust fn into(self) -> Option ``` -------------------------------- ### KeyLl::expand Method Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.KeyLl.html Begins the expansion of the terminal capability. This method returns an `Expansion` object that can be used to further process the capability. ```rust pub fn expand(&self) -> Expansion<'_, KeyLl<'_>> ``` -------------------------------- ### Handling file metadata with Result Source: https://docs.rs/terminfo/0.9.0/terminfo/type.Result.html This example demonstrates using `Result` to handle potential errors when accessing file metadata, such as checking if a path exists or if it can be modified. ```rust use std::{io::ErrorKind, path::Path}; // Note: on Windows "/" maps to "C:\\" let root_modified_time = Path::new("/").metadata().and_then(|md| md.modified()); assert!(root_modified_time.is_ok()); let should_fail = Path::new("/bad/path").metadata().and_then(|md| md.modified()); assert!(should_fail.is_err()); assert_eq!(should_fail.unwrap_err().kind(), ErrorKind::NotFound); ``` -------------------------------- ### From Implementation Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.KeyOpen.html Allows KeyOpen to be created from other types that can be referenced as byte slices. ```APIDOC ### impl<'a, T: AsRef<&'a [u8]>> From for KeyOpen<'a> #### fn from(value: T) -> Self Converts to this type from the input type. ``` -------------------------------- ### PartialEq and Eq Implementation for PKeyKey Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.PKeyKey.html These implementations allow PKeyKey instances to be compared for equality. ```APIDOC ### impl<'a> PartialEq for PKeyKey<'a> #### fn eq(&self, other: &PKeyKey<'a>) -> bool Tests for `self` and `other` values to be equal, and is used by `==`. #### fn ne(&self, other: &Rhs) -> bool Tests for `!=`. ### impl<'a> Eq for PKeyKey<'a> ``` -------------------------------- ### Capability for KeyLeft Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.KeyLeft.html Implementation of the Capability trait for KeyLeft, providing methods to get the capability name and convert to/from raw values. ```APIDOC ### impl<'a> Capability<'a> for KeyLeft<'a> #### fn name() -> &'static str Returns the name of the capability in its long form. #### fn from(value: Option<&'a Value>) -> Option> Parse the capability from its raw value. #### fn into(self) -> Option Convert the capability into its raw value. ``` -------------------------------- ### Capability Trait Implementation for KeyF18 Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.KeyF18.html Provides essential methods for the KeyF18 capability, such as getting its name and converting to/from raw values. ```APIDOC ## impl<'a> Capability<'a> for KeyF18<'a> ### Methods #### `name()` Returns the name of the capability in its long form. ```rust fn name() -> &'static str; ``` #### `from(value: Option<&'a Value>)` Parse the capability from its raw value. ```rust fn from(value: Option<&'a Value>) -> Option>; ``` #### `into()` Convert the capability into its raw value. ```rust fn into(self) -> Option; ``` ``` -------------------------------- ### expand Method Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.KeyF2.html Begins the expansion of the KeyF2 capability. ```APIDOC ## impl<'a> KeyF2<'a> ### pub fn expand(&self) -> Expansion<'_, KeyF2<'_>> #### Description Begin expanding the capability. #### Returns A new `Expansion` instance for the `KeyF2` capability. ``` -------------------------------- ### Capability Trait Implementation for InitFile Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.InitFile.html Implements the Capability trait for InitFile, providing methods to get the capability name and to parse or convert it. ```rust fn name() -> &'static str ``` ```rust fn from(value: Option<&'a Value>) -> Option> ``` ```rust fn into(self) -> Option ``` -------------------------------- ### expand Method Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.EnterMicroMode.html Begins the expansion of the EnterMicroMode capability, returning an `Expansion` object. ```APIDOC ## pub fn expand(&self) -> Expansion<'_, EnterMicroMode<'_>> Begin expanding the capability. ``` -------------------------------- ### Capability Trait Implementation Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.EnterSubscriptMode.html Provides core functionality for terminfo capabilities, including getting the name, parsing from a value, and converting into a value. ```APIDOC ### impl<'a> Capability<'a> for EnterSubscriptMode<'a> #### fn name() -> &'static str ### Description Returns the name of the capability in its long form. #### fn from(value: Option<&'a Value>) -> Option> ### Description Parse the capability from its raw value. #### fn into(self) -> Option ### Description Convert the capability into its raw value. ``` -------------------------------- ### KeyC3::expand Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.KeyC3.html Begins the expansion process for the KeyC3 capability, returning an `Expansion` object. ```APIDOC ## KeyC3::expand ```rust pub fn expand(&self) -> Expansion<'_, KeyC3<'_>> ``` ### Description This method initiates the expansion of the `KeyC3` capability. It returns an `Expansion` object that can be used to further process or retrieve the expanded capability data. ``` -------------------------------- ### KeyF43::expand Method Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.KeyF43.html Begins the expansion of the KeyF43 capability. This is used to interpret the raw capability data. ```rust pub fn expand(&self) -> Expansion<'_, KeyF43<'_>> ``` -------------------------------- ### Capability Trait Implementation for DeleteCharacter Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.DeleteCharacter.html Provides methods for interacting with the DeleteCharacter capability, including getting its name and parsing/converting it from raw values. ```rust fn name() -> &'static str ``` ```rust fn from(value: Option<&'a Value>) -> Option> ``` ```rust fn into(self) -> Option ``` -------------------------------- ### KeyC1::expand Method Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.KeyC1.html Initiates the expansion of the KeyC1 capability, returning an Expansion object. ```APIDOC ## impl<'a> KeyC1<'a> ### pub fn expand(&self) -> Expansion<'_, KeyC1<'_>> Begin expanding the capability. ``` -------------------------------- ### Load Database from Environment Source: https://docs.rs/terminfo/0.9.0/terminfo/struct.Database.html Loads a terminal capability database from the current environment. This is a common starting point for using terminfo functionalities. ```rust 4fn main() { 5 let info = Database::from_env().unwrap(); 6 7 if let Some(set_attributes) = info.get::() { 8 let clear = info.get::().unwrap(); 9 10 set_attributes.expand().bold(true).underline(true).to(io::stdout()).unwrap(); 11 12 println!("bold and underline"); 13 14 clear.expand().to(io::stdout()).unwrap(); 15 } else { 16 println!("The terminal does not support mass-setting attributes"); 17 } 18} ``` ```rust 4fn main() { 5 let info = Database::from_env().unwrap(); 6 7 if let Some(cap::MaxColors(n)) = info.get::() { 8 println!("The terminal supports {} colors.", n); 9 } else { 10 println!("The terminal does not support colors, what year is this?"); 11 } 12 13 if let Some(flash) = info.get::() { 14 flash.expand().to(io::stdout()).unwrap(); 15 } else { 16 println!("FLASH GORDON!"); 17 } 18 19 info.get::().unwrap().expand().color(2).to(io::stdout()).unwrap(); 20 info.get::().unwrap().expand().color(4).to(io::stdout()).unwrap(); 21 println!("SUP"); 22 info.get::().unwrap().expand().to(io::stdout()).unwrap(); 23} ``` -------------------------------- ### KeyEnd::expand Method Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.KeyEnd.html Begins the expansion of the KeyEnd capability. This method returns an Expansion object that can be used to further process the capability. ```rust pub fn expand(&self) -> Expansion<'_, KeyEnd<'_>> ``` -------------------------------- ### Getting references with as_ref() Source: https://docs.rs/terminfo/0.9.0/terminfo/type.Result.html Use `as_ref()` to convert a `&Result` into a `Result<&T, &E>`. This allows inspecting the contents of a `Result` without consuming it. ```rust let x: Result = Ok(2); assert_eq!(x.as_ref(), Ok(&2)); let x: Result = Err("Error"); assert_eq!(x.as_ref(), Err(&"Error")); ``` -------------------------------- ### KeyIl::expand Method Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.KeyIl.html Begins the expansion of a terminal capability represented by the KeyIl struct. Returns an Expansion object. ```rust pub fn expand(&self) -> Expansion<'_, KeyIl<'_>> ``` -------------------------------- ### Capability Trait Implementation for XonCharacter Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.XonCharacter.html Implements the Capability trait for XonCharacter, providing methods to get the capability name and parse/convert it from raw values. ```rust fn name() -> &'static str ``` ```rust fn from(value: Option<&'a Value>) -> Option> ``` ```rust fn into(self) -> Option ``` -------------------------------- ### KeyF3::expand Method Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.KeyF3.html Begins the process of expanding the KeyF3 capability, returning an Expansion object. ```APIDOC ### impl<'a> KeyF3<'a> #### pub fn expand(&self) -> Expansion<'_, KeyF3<'_>> Begin expanding the capability. ``` -------------------------------- ### Capability Trait Implementation for TermcapInit2 Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.TermcapInit2.html Provides methods for interacting with TermcapInit2 as a capability, including getting its name, parsing from a value, and converting into a value. ```APIDOC ### impl<'a> Capability<'a> for TermcapInit2<'a> #### fn name() -> &'static str Returns the name of the capability in its long form. #### fn from(value: Option<&'a Value>) -> Option> Parse the capability from its raw value. #### fn into(self) -> Option Convert the capability into its raw value. ``` -------------------------------- ### Capability Trait Implementation Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.TransparentUnderline.html Implementation of the Capability trait for TransparentUnderline, providing methods to get the capability name and convert to/from raw values. ```APIDOC ### impl<'a> Capability<'a> for TransparentUnderline #### fn name() -> &'static str Returns the name of the capability in its long form. #### fn from(value: Option<&Value>) -> Option Parse the capability from its raw value. #### fn into(self) -> Option Convert the capability into its raw value. ``` -------------------------------- ### KeyF5::expand Method Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.KeyF5.html Begins the process of expanding the KeyF5 capability. This method returns an Expansion object, which likely allows for further processing or interpretation of the capability's value. ```rust pub fn expand(&self) -> Expansion<'_, KeyF5<'_>> ``` -------------------------------- ### PartialEq and Eq Implementations Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.MemoryBelow.html Illustrates the equality comparison implementations for MemoryBelow. ```APIDOC ### impl PartialEq for MemoryBelow #### fn eq(&self, other: &MemoryBelow) -> bool Tests for `self` and `other` values to be equal, and is used by `==`. #### fn ne(&self, other: &MemoryBelow) -> bool Tests for `!=`. ### impl Eq for MemoryBelow ``` -------------------------------- ### Capability Trait Implementation for StartBitImage Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.StartBitImage.html Implements the Capability trait for StartBitImage, providing methods to get the capability name, and to convert from and into raw values. ```APIDOC ## impl<'a> Capability<'a> for StartBitImage<'a> ### fn name() -> &'static str Returns the name of the capability in its long form. ### fn from(value: Option<&'a Value>) -> Option> Parse the capability from its raw value. ### fn into(self) -> Option Convert the capability into its raw value. ``` -------------------------------- ### Capability Trait Implementation Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.SubscriptCharacters.html Implements the `Capability` trait for `SubscriptCharacters`, providing methods to get the capability name, parse from a value, and convert into a value. ```APIDOC ### impl<'a> Capability<'a> for SubscriptCharacters<'a> #### fn name() -> &'static str Returns the name of the capability in its long form. #### fn from(value: Option<&'a Value>) -> Option> Parse the capability from its raw value. #### fn into(self) -> Option Convert the capability into its raw value. ``` -------------------------------- ### KeyF40::expand Method Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.KeyF40.html Begins the expansion of the terminal capability represented by KeyF40. This method returns an Expansion object. ```rust pub fn expand(&self) -> Expansion<'_, KeyF40<'_>> ``` -------------------------------- ### Capability Trait Implementation Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.SetLrMargin.html Implementation of the Capability trait for SetLrMargin, providing methods to get the capability name and convert from/to raw values. ```APIDOC ### impl<'a> Capability<'a> for SetLrMargin<'a> #### `name()` ```rust fn name() -> &'static str ``` Returns the name of the capability in its long form. #### `from(value: Option<&'a Value>)` ```rust fn from(value: Option<&'a Value>) -> Option> ``` Parses the capability from its raw value. #### `into()` ```rust fn into(self) -> Option ``` Converts the capability into its raw value. ``` -------------------------------- ### KeyEnter::expand Method Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.KeyEnter.html Begins the process of expanding the terminal capability. This is useful for interpreting the raw capability data into a usable format. ```rust pub fn expand(&self) -> Expansion<'_, KeyEnter<'_>> ``` -------------------------------- ### KeyNext::expand Method Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.KeyNext.html Initiates the expansion of the KeyNext capability. This method is used to begin processing the capability's value. ```rust pub fn expand(&self) -> Expansion<'_, KeyNext<'_>> ``` -------------------------------- ### Capability Trait Implementation for ParmRightMicro Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.ParmRightMicro.html Implements the `Capability` trait for ParmRightMicro, providing methods to get the capability name and parse/convert it from raw values. ```rust fn name() -> &'static str ``` ```rust fn from(value: Option<&'a Value>) -> Option> ``` ```rust fn into(self) -> Option ``` -------------------------------- ### ParmUpCursor Capability Trait Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.ParmUpCursor.html Details the implementations of the `Capability` trait for `ParmUpCursor`, including methods for getting the capability name and parsing from raw values. ```APIDOC ### impl<'a> Capability<'a> for ParmUpCursor<'a> #### fn name() -> &'static str Returns the name of the capability in its long form. #### fn from(value: Option<&'a Value>) -> Option> Parse the capability from its raw value. #### fn into(self) -> Option Convert the capability into its raw value. ``` -------------------------------- ### KeyEos::expand Method Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.KeyEos.html Begins the expansion of the KeyEos capability. This method returns an `Expansion` object that can be used to further process the capability. ```rust pub fn expand(&self) -> Expansion<'_, KeyEos<'_>> ``` -------------------------------- ### KeySOptions::fmt Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.KeySOptions.html Formats the KeySOptions instance for debugging. ```APIDOC ## KeySOptions::fmt ### Description Formats the value using the given formatter. ### Method `fn fmt(&self, f: &mut Formatter<'_>) -> Result` ### Parameters - `f` (&mut Formatter<'_>) - The formatter to use. ### Returns A `Result` indicating success or failure of the formatting operation. ``` -------------------------------- ### Capability Trait Implementation Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.OutputResLine.html Implementation of the Capability trait for OutputResLine, providing methods to get the capability name and convert to/from raw values. ```APIDOC ### impl<'a> Capability<'a> for OutputResLine * `fn name() -> &'static str` - Returns the name of the capability in its long form. * `fn from(value: Option<&Value>) -> Option` - Parse the capability from its raw value. * `fn into(self) -> Option` - Convert the capability into its raw value. ``` -------------------------------- ### Capability Trait Implementation Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.OrigColors.html Implementation of the Capability trait for OrigColors, providing methods to get the capability name and convert to/from raw values. ```APIDOC ### impl<'a> Capability<'a> for OrigColors<'a> #### fn name() -> &'static str Returns the name of the capability in its long form. #### fn from(value: Option<&'a Value>) -> Option> Parse the capability from its raw value. #### fn into(self) -> Option Convert the capability into its raw value. ``` -------------------------------- ### InitFile::expand Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.InitFile.html Begins the expansion of a capability. Returns an Expansion object that can be used to iterate over the expanded capability. ```APIDOC ## InitFile::expand ### Description Begin expanding the capability. ### Method `pub fn expand(&self) -> Expansion<'_, InitFile<'_>>` ### Returns An `Expansion` object that allows iteration over the expanded capability. ``` -------------------------------- ### Database::new Source: https://docs.rs/terminfo/0.9.0/src/terminfo/database.rs.html Creates a new `Builder` instance for constructing a `Database`. ```APIDOC ## Database::new ### Description Creates a new `Builder` instance for constructing a `Database`. ### Method `new() -> Builder` ### Parameters None ### Response - `Builder`: A new `Builder` instance. ``` -------------------------------- ### Capability Trait Implementation Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.MagicCookieGlitchUl.html Implements the Capability trait for MagicCookieGlitchUl, providing methods to get the capability name and convert to/from raw values. ```APIDOC ### impl<'a> Capability<'a> for MagicCookieGlitchUl #### fn name() -> &'static str Returns the name of the capability in its long form. #### fn from(value: Option<&Value>) -> Option Parse the capability from its raw value. #### fn into(self) -> Option Convert the capability into its raw value. ``` -------------------------------- ### Capability Trait Implementation Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.LabF8.html Implements the Capability trait for LabF8, providing methods to get the capability name, parse from a value, and convert into a value. ```APIDOC ### impl<'a> Capability<'a> for LabF8<'a> #### fn name() -> &'static str Returns the name of the capability in its long form. #### fn from(value: Option<&'a Value>) -> Option> Parse the capability from its raw value. #### fn into(self) -> Option Convert the capability into its raw value. ``` -------------------------------- ### KeyHelp::ne Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.KeyHelp.html Compares two KeyHelp capabilities for inequality. ```APIDOC ## KeyHelp::ne ### Description Tests for `!=`. ### Method `fn ne(&self, other: &Rhs) -> bool` ### Parameters - `&self`: A reference to the first `KeyHelp` instance. - `other`: A reference to the second `KeyHelp` instance. ### Returns `true` if the capabilities are not equal, `false` otherwise. ``` -------------------------------- ### impl Capability for KeySTab Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.KeySTab.html Implementation of the `Capability` trait for `KeySTab`, providing methods to get the capability name and convert to/from raw values. ```APIDOC ## impl<'a> Capability<'a> for KeySTab<'a> ### fn name() -> &'static str Returns the name of the capability in its long form. ### fn from(value: Option<&'a Value>) -> Option> Parse the capability from its raw value. ### fn into(self) -> Option Convert the capability into its raw value. ``` -------------------------------- ### KeyC3::expand Method Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.KeyC3.html Initiates the expansion of the capability. This method returns an `Expansion` object that can be used to further process the capability. ```rust pub fn expand(&self) -> Expansion<'_, KeyC3<'_>> ``` -------------------------------- ### Capability Trait Implementation for KeyMove Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.KeyMove.html Provides methods for interacting with KeyMove as a terminfo capability, including getting its name and parsing from raw values. ```APIDOC ### impl<'a> Capability<'a> for KeyMove<'a> #### `name()` ```rust fn name() -> &'static str ``` Returns the name of the capability in its long form. #### `from()` ```rust fn from(value: Option<&'a Value>) -> Option> ``` Parse the capability from its raw value. #### `into()` ```rust fn into(self) -> Option ``` Convert the capability into its raw value. ``` -------------------------------- ### KeyF63::expand Method Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.KeyF63.html Initiates the expansion of the KeyF63 capability, returning an Expansion object. ```rust pub fn expand(&self) -> Expansion<'_, KeyF63<'_>> ``` -------------------------------- ### Init2String::expand Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.Init2String.html Begins the process of expanding the capability associated with the Init2String. ```APIDOC ### pub fn expand(&self) -> Expansion<'_, Init2String<'_>> Begin expanding the capability. ``` -------------------------------- ### Capability Trait Implementation for KeyF17 Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.KeyF17.html Provides methods for interacting with KeyF17 as a terminfo capability, including getting its name and parsing/converting it from raw values. ```APIDOC ## impl<'a> Capability<'a> for KeyF17<'a> ### name ```rust fn name() -> &'static str ``` Returns the name of the capability in its long form. ### from ```rust fn from(value: Option<&'a Value>) -> Option> ``` Parse the capability from its raw value. ### into ```rust fn into(self) -> Option ``` Convert the capability into its raw value. ``` -------------------------------- ### Capability Trait Implementation for HueLightnessSaturation Source: https://docs.rs/terminfo/0.9.0/terminfo/capability/struct.HueLightnessSaturation.html Provides methods to interact with the HueLightnessSaturation capability, such as getting its name, parsing it from a value, and converting it back to a value. ```APIDOC ### impl<'a> Capability<'a> for HueLightnessSaturation #### fn name() -> &'static str Returns the name of the capability in its long form. #### fn from(value: Option<&Value>) -> Option Parse the capability from its raw value. #### fn into(self) -> Option Convert the capability into its raw value. ```