[][src]Macro tmux_plugin::format_plugin

macro_rules! format_plugin {
    ($name:expr, |$ft:ident| $body:block) => { ... };
}

Defines a new format variable.

This macro takes two arguments: The name of the variable (as a null-terminated byte string), and a function to calculate that variable's value. This function will be passed a tmux format_tree object, and should return a type that implements AsRef<CStr>, such as CStr or CString.

For example:

// This plugin does the same thing as the builtin "window_width".
use tmux_plugin::format_plugin;
use std::ffi::CString;

format_plugin!(b"my_window_width\0", |format_tree| {
    CString::new(
        format!("{}", unsafe { *(*format_tree).w }.sx)
    ).unwrap()
});