[][src]Macro tinf::desc

macro_rules! desc {
    (@acc [$($ns:expr),*] [$($ps:expr),*]) => { ... };
    (@acc [$($ns:expr),*] [$($ps:expr),*] $n:expr) => { ... };
    (@acc [$($ns:expr),*] [$($ps:expr),*] $n:expr, $($xs:tt)*) => { ... };
    (@acc [$($ns:expr),*] [$($ps:expr),*] $k:expr => $v:expr) => { ... };
    (@acc [$($ns:expr),*] [$($ps:expr),*] $k:expr => $v:expr, $($xs:tt)*) => { ... };
    ($n:expr) => { ... };
    ($n:expr, $($xs:tt)*) => { ... };
    ($k:expr => $v:expr) => { ... };
    ($k:expr => $v:expr, $($xs:tt)*) => { ... };
}

A syntax for Desc literals.

Examples

A description for a "dumb terminal":

#[macro_use]
extern crate tinf;
use tinf::cap::*;

let desc = desc![
    "dumb", "80-column dumb terminal",
    am => true,
    cols => 80,
    bel => "\x07",
    cr => "\r",
    cud1 => "\n",
    ind => "\n",
];

A terminal with user-defined capabilities:

#[macro_use]
use tinf::cap::UserDef;
let desc = desc![
    // tmux can use this to indicate TrueColor support
    UserDef::named("Tc") => true,

    // emacs can use these for TrueColor
    UserDef::named("setb24") => "\x1b[48;2;\
                                 %p1%{65536}%/%d;\
                                 %p1%{256}%/%{255}%&%d;\
                                 %p1%{255}%&%dm",
    UserDef::named("setf24") => "\x1b[38;2;\
                                 %p1%{65536}%/%d;\
                                 %p1%{256}%/%{255}%&%d;\
                                 %p1%{255}%&%dm"
];

Terminal names are specified by strings; predefined capabilities are specified by name => val pairs, where name is a Boolean, Number, or String capability name, and val is a bool, u16, or AsRef<[u8]> respectively; for user-defined capabilities, name must be Borrow<str> and val can be a bool, a u16, or a &'static str.