Macro terminfo::expand

source ·
macro_rules! expand {
    ($value:expr) => { ... };
    ($value:expr => $context:expr) => { ... };
    ($value:expr; $($item:expr),*) => { ... };
    ($value:expr => $context:expr; $($item:expr),*) => { ... };
    ($output:expr, $value:expr) => { ... };
    ($output:expr, $value:expr => $context:expr) => { ... };
    ($output:expr, $value:expr; $($item:expr),*) => { ... };
    ($output:expr, $value:expr => $context:expr; $($item:expr),*) => { ... };
}
Expand description

Expand a parametrized string.

Examples

Write the expansion to stdout.


use terminfo::{Database, capability as cap};
use std::io;


let info = Database::from_env().unwrap();

// Move the cursor to X: 20, Y: 30
expand!(io::stdout(), info.get::<cap::CursorAddress>().unwrap().as_ref(); 20, 30).unwrap();

Load the expansion for later usage.


use terminfo::{Database, capability as cap};
use std::io;


let info = Database::from_env().unwrap();

// Set foreground color to red.
let red     = expand!(info.get::<cap::SetAForeground>().unwrap().as_ref(); 1).unwrap();
let on_blue = expand!(info.get::<cap::SetABackground>().unwrap().as_ref(); 4).unwrap();